From ed18ff39c95c842e8ea465610f5d06e3c5f700be Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 10 Jul 2014 20:38:57 +0100 Subject: Emacs: Extend kill-this-buffer-dwim to delete file Deletes current-buffer's file if called with universal prefix argument. --- tag-emacs/emacs.d/init.el | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'tag-emacs') 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)) -- cgit 1.4.1