From f3c529781c3c16e607cc796391f7fae05b891473 Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Tue, 18 Jun 2024 12:35:05 -0400 Subject: [PATCH] Fix delete-file implementation --- emacs/.emacs.d/config/init-files.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/emacs/.emacs.d/config/init-files.el b/emacs/.emacs.d/config/init-files.el index dd40c5b..732603d 100644 --- a/emacs/.emacs.d/config/init-files.el +++ b/emacs/.emacs.d/config/init-files.el @@ -2,15 +2,16 @@ ;; File-related configuration -(defun jdormit-delete-file (file) +(defun my/delete-file (file) (interactive (list (read-file-name "Delete file: " nil nil t - (buffer-file-name)))) - (delete-file file) - (when (string-equal (buffer-file-name) file) - (quit-window))) + (file-name-nondirectory (buffer-file-name))))) + (let ((file (expand-file-name file))) + (delete-file file) + (when (string-equal (buffer-file-name) file) + (quit-window)))) (defun rename-this-file (new-name) (interactive (list (read-file-name "Rename file: " @@ -35,7 +36,7 @@ "f" '(nil :which-key "file") "ff" #'find-file "fs" #'save-buffer - "fD" '(jdormit-delete-file :which-key "delete") + "fD" '(my/delete-file :which-key "delete") "fr" '(rename-this-file :which-key "rename") "fd" #'dired)