Fix delete-file implementation

This commit is contained in:
Jeremy Dormitzer 2024-06-18 12:35:05 -04:00
parent 68955452a5
commit f3c529781c

View File

@ -2,15 +2,16 @@
;; File-related configuration ;; File-related configuration
(defun jdormit-delete-file (file) (defun my/delete-file (file)
(interactive (list (read-file-name "Delete file: " (interactive (list (read-file-name "Delete file: "
nil nil
nil nil
t t
(buffer-file-name)))) (file-name-nondirectory (buffer-file-name)))))
(let ((file (expand-file-name file)))
(delete-file file) (delete-file file)
(when (string-equal (buffer-file-name) file) (when (string-equal (buffer-file-name) file)
(quit-window))) (quit-window))))
(defun rename-this-file (new-name) (defun rename-this-file (new-name)
(interactive (list (read-file-name "Rename file: " (interactive (list (read-file-name "Rename file: "
@ -35,7 +36,7 @@
"f" '(nil :which-key "file") "f" '(nil :which-key "file")
"ff" #'find-file "ff" #'find-file
"fs" #'save-buffer "fs" #'save-buffer
"fD" '(jdormit-delete-file :which-key "delete") "fD" '(my/delete-file :which-key "delete")
"fr" '(rename-this-file :which-key "rename") "fr" '(rename-this-file :which-key "rename")
"fd" #'dired) "fd" #'dired)