More than once I’ve lost work by accidentally killing a temporary buffer in Emacs. Can I set up Emacs to give me a warning when I kill a buffer not associated with a file?
More than once I’ve lost work by accidentally killing a temporary buffer in Emacs.
Share
Make a function that will ask you whether you’re sure when the buffer has been edited and is not associated with a file. Then add that function to the list
kill-buffer-query-functions.Looking at the documentation for Buffer File Name you understand:
buffer-file-nameis nilUse that insight to write the function:
And then add the function to the hook like so: