Setjmp
Setjmp

Reputation: 28372

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.

Upvotes: 3

Views: 1748

Answers (2)

Setjmp
Setjmp

Reputation: 28372

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.

Upvotes: 3

sds
sds

Reputation: 60004

If you want to save all buffers when exiting without any questions at all, do C-u C-x C-c:

C-x C-c runs the command save-buffers-kill-terminal...

...With prefix ARG, silently save all file-visiting buffers, then kill.

If you want Emacs to think that the buffer should not be saved at all, all you need to do is to mark it as unmodified: M-~.

Upvotes: 1

Related Questions