From a4c54f239fce51ccdffd394cfab373a24dc4759f Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 26 Jan 2014 02:23:00 -0500 Subject: Add function to delete current buffer's file Taken from https://github.com/purcell/emacs.d/blob/master/lisp/init-utils.el. --- lisp/init-buffile.el | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lisp/init-buffile.el b/lisp/init-buffile.el index 865e629..09da103 100644 --- a/lisp/init-buffile.el +++ b/lisp/init-buffile.el @@ -19,6 +19,16 @@ (global-set-key (kbd "C-x C-r") 'km/rename-current-buffer-file) +;; https://github.com/purcell/emacs.d/blob/master/lisp/init-utils.el +(defun km/delete-this-file () + "Delete the current file, and kill the buffer." + (interactive) + (or (buffer-file-name) (error "No file is currently being edited")) + (when (yes-or-no-p (format "Really delete '%s'?" + (file-name-nondirectory buffer-file-name))) + (delete-file (buffer-file-name)) + (kill-this-buffer))) + ;; http://emacs-fu.blogspot.com/2013/03/editing-with-root-privileges-once-more.html (defun km/find-file-as-root () "`ido-find-file` that automatically edits the file with -- cgit v1.2.3