Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!shelby!agate!helios.ee.lbl.gov!nosc!humu!uhccux!julian From: julian@uhccux.uhcc.hawaii.edu (Julian Cowley) Newsgroups: gnu.emacs.bug Subject: Re: quitting a file Message-ID: <4105@uhccux.uhcc.hawaii.edu> Date: 14 Jun 89 04:43:47 GMT References: <8906071411.AA24255@osf.osf.org> <8906071607.AA02152@xx.bu.edu> Distribution: gnu Organization: University of Hawaii at Manoa Lines: 35 This is slightly passe, but someone asked about how to abandon a file after changes have been made to it. Normally C-x k (kill-buffer) will do the trick, but if there is an auto-save file associated with the buffer, the auto-save file stays around after the buffer has been killed. Here is an Elisp function that will delete the auto-save file at the time that you abandon a buffer: (defun kill-buffer-undo-auto-save (buf) "One arg, a string or a buffer. Get rid of the specified buffer. If the buffer is associated with a file and an auto-save file exists, the auto-save file is deleted." (interactive "bKill buffer: ") (save-excursion (set-buffer buf) (let ((auto-save-file buffer-auto-save-file-name)) (kill-buffer buf) (and (not (get-buffer buf)) auto-save-file delete-auto-save-files (condition-case () (delete-file auto-save-file) (file-error nil)))))) Minor gripe dept: the return value from kill-buffer does not indicate whether the buffer has actually been killed or not. If kill-buffer returned t if the buffer has actually killed, the above code could have been written by moving (kill-buffer buf) into the `and' form, replacing the test for whether the buffer still exists. julian@uhccux.uhcc.hawaii.edu | "Hawaii has always been a very pivotal role uunet!ucsd!nosc!uhccux!julian | in the Pacific. It is in the Pacific. julian@uhccux.bitnet | It is part of the United States that is an University of Hawaii at Manoa | island that is right here." - Quayle