Emacs: Delete the file that is associated with the current buffer

A little function that moves the file that is associated with the current buffer to the system’s trash bin.

1:  (defun delete-this-file ()
2:    "Delete (move to trash) the file that is associated with the
3:  current buffer."
4:    (interactive)
5:    (let ((filename (buffer-file-name)))
6:      (delete-file filename t)
7:      (kill-buffer)))

eval it and then you could press M-x delete-this-file to trigger it.

Happy Hacking!


Date: 2013-08-17

Author: 任文山 (Ren Wenshan)

Org version 7.9.3d with Emacs version 24

Validate XHTML 1.0

One thought on “Emacs: Delete the file that is associated with the current buffer

  1. Pingback: Starred Links — August 2013 | 肉山博客 (Wenshan's Blog)

Leave a Reply