I never want to answer a prompt that asks me to save changes.

Whenever I close Emacs, I'm bombarded with dialog boxes and prompts. How can I avoid them and make Emacs automatically save all unsaved changes?

Also, how can I avoid the prompt when I close a single buffer with C-k and make Emacs automatically save the changes?


To avoid the prompts for saving files when quitting Emacs, you may pass a prefix argument to C-x C-c, i.e., quit with C-u C-x C-c.

Alternatively, add the following code to your .emacs file:

(global-set-key (kbd "C-x C-c")
                #'(lambda ()
                    (save-buffers-kill-terminal t)))

to quit without prompts using the usual C-x C-c keybinding.

Don't forget that at these prompts you may press ! to save all files.


I think this is what you are asking for:

(defun kill-buffer-no-query (&optional buffer)
  "Kill BUFFER without querying."
  (unless buffer (setq buffer  (current-buffer)))
  (let ((kill-buffer-query-functions ())
        (buffer-save-without-query   t)
        (buffer-modified-p           (buffer-modified-p)))
        (progn (set-buffer-modified-p nil)
               (kill-buffer buffer))
      (when (get-buffer buffer)
        (set-buffer-modified-p buffer-modified-p)))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.