config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit e738420419beed2e0997d274777270104c22aa95
parent 528281d8dd4cbdd35c4cb89ba2eebe6b5f2ba533
Author: dwrz <dwrz@dwrz.net>
Date:   Sun,  9 Jul 2023 00:43:07 +0000

Add emacs copy file name and path functions

Diffstat:
Memacs/init.el | 15++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/emacs/init.el b/emacs/init.el @@ -35,13 +35,22 @@ ;; FUNCTIONS -(defun dwrz-copy-filename () - "Copy the current buffer file name to the clipboard." +(defun dwrz-copy-filepath () + "Copy the current buffer file path to the clipboard." (interactive) (let ((filename (if (equal major-mode 'dired-mode) default-directory (buffer-file-name)))) (when filename (kill-new filename) - (message "Copied buffer file name '%s' to the clipboard." filename)))) + (message "Copied buffer path '%s' to the clipboard." filename)))) + +(defun dwrz-copy-filename () + "Get the filename of the current buffer without the directory." + (interactive) + (when buffer-file-name + (let ((filename (file-name-nondirectory buffer-file-name))) + (when filename (kill-new filename) + (message "Copied buffer name '%s' to the clipboard." filename))))) + (defun shell-in-current-directory () "Create or switch to a shell buffer for the current directory."