Here's a emacs lisp command that deletes the current file.
(defun xah-delete-current-file (&optional φno-backup-p)
"Delete the file associated with the current buffer.
Also close the current buffer. If no file is associated, just close buffer.
A backup file is created with filename appended “~‹date time stamp›~”. Existing file of the same name is overwritten. If the file is not associated with buffer, the backup file name starts with “xx_”.
When called with `universal-argument', don't create backup."
(bufferIsFile-p (if (null fName) nil t ))
(backupName (concat fName "~" (format-time-string "%Y%m%d_%H%M%S") "~")))
(copy-file fName backupName t))
(message "deleted and backup created at 「%s」." backupName))
(write-region (point-min) (point-max) (concat "xx_~" (format-time-string "%Y%m%d_%H%M%S") "~")))))
perm url http://ergoemacs.org/emacs/elisp_delete-current-file.html