I am trying to have a cleaning up function going on, where I basically want it to just delete all the files in the folder when emacs ends. I already settled for writing the individual file names, however, when the file does not exist Emacs errors (and actually does not allow me to exit).
(defun delete-Navi-empty-files ()
(delete-file "/emacs-24.1/.emacs.d/Navi-empty/empty_flymake.tex" nil)
(delete-file "/emacs-24.1/.emacs.d/Navi-empty/empty_flymake.log" nil)
)
(add-hook 'kill-emacs-hook 'delete-Navi-empty-files)
Any idea how to get rid of the “no such file exists”, or how to just clean up a folder?
Thanks.
The easiest thing to do would be to check if the file exists before trying to delete it:
Since it looks like you’re going to be using this repeatedly, it might make sense to wrap this up in a function: