From 558d23085fab11e8f49ae583c71f203279c4e8bc Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 13 May 2024 21:50:56 +0200 Subject: emacs: don't stop me deleting files which have changes in git --- user/emacs/init.el | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/user/emacs/init.el b/user/emacs/init.el index 2f338b9a..117b2bda 100644 --- a/user/emacs/init.el +++ b/user/emacs/init.el @@ -632,6 +632,16 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve (setq delete-by-moving-to-trash t) +(defun my/delete-file-and-buffer () + "Kill the current buffer and deletes the file it is visiting." + (interactive) + (let ((filename (buffer-file-name))) + (when filename + (when (y-or-n-p (format "Are you sure you want to delete %s? " filename)) + (delete-file filename delete-by-moving-to-trash) + (message "Deleted file %s" filename) + (kill-buffer))))) + (use-package goto-chg :defer 1) @@ -1143,7 +1153,7 @@ _C-k_: prev _u_pper _=_: upper/lower _s_mart resolve "fs" #'save-buffer "ff" #'find-file "fw" #'write-file - "fd" #'crux-delete-file-and-buffer + "fd" #'my/delete-file-and-buffer "fr" #'crux-rename-file-and-buffer "gs" #'magit-status "gm" #'vc-msg-show -- cgit 1.4.1