Search code examples
emacssaveelisp

GNU Emacs: How to disable prompt to save modified buffer on exit


In GNU Emacs I have a particular buffer *my-special-buffer* which I create as the output of running a sub-process and storing the output. I mark this buffer as read only after filling the contents. Occasionally when I try to exit Emacs I notice that I am prompted to save this buffer:

Save file /foo/bar/.../*my-special-buffer*? (y, n, !, ...

Is there a buffer local variable I can set as part of the initialization of this buffer to prevent the save prompt from interrupting my attempt to shut down Emacs? Just to be clear, I don't want to save this buffer; the buffer's purpose is only to show read-only data from the sub-process.


Solution

  • It looks like this is what I should set after filling in the buffer.

    (set-buffer-modified-p nil)
    

    More details here. After that, I make the buffer read only.