I try to run crux-delete-file-and-buffer, but it gives me:

vc-delete-file: Please commit or undo your changes before deleting

Why can't it just delete it?;)

1 Answer 1


Just delete the stupid crux* thing and use this;)

;; based on http://emacsredux.com/blog/2013/04/03/delete-file-and-buffer/
(defun delete-file-and-buffer ()
  "Kill the current buffer and deletes the file it is visiting."
  (let ((filename (buffer-file-name)))
    (if filename
        (if (y-or-n-p (concat "Do you really want to delete file " filename " ?"))
              (delete-file filename)
              (message "Deleted file %s." filename)
      (message "Not a file visiting buffer!"))))

Found here: Github

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.