From 79b15d7822e03ef529c77f163984bd96e98eb2e8 Mon Sep 17 00:00:00 2001 From: Daniel Weschke Date: Sun, 15 Jun 2025 22:55:25 +0200 Subject: [PATCH] add function to get filename of buffer --- lisp/my/my.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lisp/my/my.el b/lisp/my/my.el index 3435293c..343a92a7 100644 --- a/lisp/my/my.el +++ b/lisp/my/my.el @@ -282,6 +282,22 @@ Examples: (my-interpolate (nth 2 (car rgbsteps)) (nth 2 (cadr rgbsteps)) position (caar rgbsteps) (caadr rgbsteps)) (my-interpolate (nth 3 (car rgbsteps)) (nth 3 (cadr rgbsteps)) position (caar rgbsteps) (caadr rgbsteps)))))) +(defun my-filename () + "Copy the full path of the current buffer into the `kill-ring' and +print it in the message buffer." + (interactive) + (let ((fn (buffer-file-name (window-buffer (minibuffer-selected-window))))) + (kill-new fn) + (message fn))) + +(defun my-filename-basename () + "Copy the basename of the current buffer into the `kill-ring' and +print it in the message buffer." + (interactive) + (let ((fn (file-name-nondirectory (my-filename)))) + (kill-new fn) + (message fn))) + (defun my-gui-elements-toggle () "Function to toggle gui elements on/off." (interactive)