summary refs log tree commit diff stats
path: root/tag-emacs
diff options
context:
space:
mode:
authorAlan Pearce2014-07-10 20:38:57 +0100
committerAlan Pearce2014-07-10 20:38:57 +0100
commited18ff39c95c842e8ea465610f5d06e3c5f700be (patch)
tree6fbf2f8bd07ac4781c66db38f65af5385d630773 /tag-emacs
parent1c79164ecdab46c284def04ad374fcae94116b0d (diff)
downloaddotfiles-ed18ff39c95c842e8ea465610f5d06e3c5f700be.tar.lz
dotfiles-ed18ff39c95c842e8ea465610f5d06e3c5f700be.tar.zst
dotfiles-ed18ff39c95c842e8ea465610f5d06e3c5f700be.zip
Emacs: Extend kill-this-buffer-dwim to delete file
Deletes current-buffer's file if called with universal prefix argument.
Diffstat (limited to 'tag-emacs')
-rw-r--r--tag-emacs/emacs.d/init.el18
1 files changed, 11 insertions, 7 deletions
diff --git a/tag-emacs/emacs.d/init.el b/tag-emacs/emacs.d/init.el
index 3b36f8a..a5649fb 100644
--- a/tag-emacs/emacs.d/init.el
+++ b/tag-emacs/emacs.d/init.el
@@ -126,12 +126,6 @@
 
 ;;;; 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 @@
         (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-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))