Add delete-current-buffer-file and bind it

This commit is contained in:
Gergely Polonkai 2016-09-26 15:59:32 +02:00
parent 93ed071cee
commit b5c9d12e6b

18
init.el
View File

@ -493,3 +493,21 @@ Version 2016-02-16"
name (file-name-nondirectory new-name)))))))
(global-set-key (kbd "C-x C-r") 'rename-current-buffer-file)
; Copied from http://whattheemacsd.com/file-defuns.el-02.html
(defun delet-current-buffer-file ()
"Removes file connected to current buffer and kills the
buffer."
(interactive)
(let ((filename (buffer-file-name))
(name (buffer-name))
(buffer (current-buffer)))
(if (not (and filename (file-exists-p filename)))
(kill-buffer buffer)
(when (yes-or-no-p "Are you sure you want to remove this file? ")
(delete-file filename)
(kill-buffer buffer)
(message "File '%s' successfully removed" filename)))))
(global-set-key (kbd "C-x C-d") 'delete-current-buffer-file)