summary refs log tree commit diff stats
path: root/user/emacs
diff options
context:
space:
mode:
authorAlan Pearce2024-05-13 21:50:56 +0200
committerAlan Pearce2024-05-13 21:53:43 +0200
commit558d23085fab11e8f49ae583c71f203279c4e8bc (patch)
tree068c0743cc46699161e0932f2de1e74ff9864f13 /user/emacs
parent9525dddaa025a9a779730f029fe39091804bbf83 (diff)
downloadnixfiles-558d23085fab11e8f49ae583c71f203279c4e8bc.tar.lz
nixfiles-558d23085fab11e8f49ae583c71f203279c4e8bc.tar.zst
nixfiles-558d23085fab11e8f49ae583c71f203279c4e8bc.zip
emacs: don't stop me deleting files which have changes in git
Diffstat (limited to 'user/emacs')
-rw-r--r--user/emacs/init.el12
1 files changed, 11 insertions, 1 deletions
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