all repos — archive/dotfiles @ ed18ff39c95c842e8ea465610f5d06e3c5f700be

Superseded by nixfiles

Emacs: Extend kill-this-buffer-dwim to delete file

Deletes current-buffer's file if called with universal prefix argument.
Alan Pearce alan@alanpearce.co.uk
Thu, 10 Jul 2014 20:38:57 +0100
commit

ed18ff39c95c842e8ea465610f5d06e3c5f700be

parent

1c79164ecdab46c284def04ad374fcae94116b0d

1 files changed, 11 insertions(+), 7 deletions(-)

jump to
M tag-emacs/emacs.d/init.eltag-emacs/emacs.d/init.el
@@ -126,12 +126,6 @@ backup-by-copying-when-mismatch t)) 
 ;;;; Buffers
 
-(defun kill-this-buffer-dwim ()
-  (interactive)
-  (if server-buffer-clients
-      (server-edit)
-    (kill-this-buffer)))
-
 (req-package ibuffer
   :bind (("C-x C-b" . ibuffer))
   :config (progn
@@ -327,6 +321,16 @@ (delete-file filename)         (kill-this-buffer)
         (message "File '%s' successfully removed" filename)))))
 
+(defun kill-or-delete-this-buffer-dwim (&optional arg)
+  "Kills current buffer. With prefix arg, delete it."
+  (interactive "P")
+  (message "%s" arg)
+  (if (equal arg '(4))
+      (delete-current-buffer-file)
+    (if server-buffer-clients
+        (server-edit)
+      (kill-this-buffer))))
+
 (req-package ws-butler
   :if window-system
   :config (ws-butler-global-mode 1))
@@ -444,7 +448,7 @@ (unbind-key "s-h") (unbind-key "s-n")
 (unbind-key "s-p")
 (unbind-key "s-w")
-(bind-key "s-k" #'kill-this-buffer-dwim)
+(bind-key "s-k" #'kill-or-delete-this-buffer-dwim)
 
 (bind-key "s-x" (define-prefix-command 'super-x-map))