1

I use the well known key-binding C-x C-c to quit emacs. However this command asks y/n confirmation to save modified buffers and if there are process buffers (eg. Shell) it also asks for yes/no confirmation before to exit.

I'd like a command that save all modified buffers, then kill emacs. Is there any function that does do this?

7

From the docstring of C-x C-c:

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

So you want to use C-u C-x C-c

EDIT: If you also want that the above silently kills all running processes, then you can set the variable confirm-kill-processes to nil.

  • This is no really what I need, because It still asks yes/no confirmation for "active processes", like shell, R or whatever. – PinkCollins May 24 at 6:05
  • Ok emacs asks you "Active processes exist; kill them and exit anyway?" Pressing 'y' should kill the active proceses altogether. Is it not the case for you or is it this one additional key that you want to avoid? – andrej May 24 at 18:04
  • 2
    If you wish to always kill active processes without prompting, then customize the user option confirm-kill-processes. – phils May 28 at 7:49
  • Thanks @phils I have included your hint in the answer – andrej May 28 at 15:56
1

I think I solved this with the following

;; [M-x  my-quit] and [C-c q] 
;; save all buffers then shuts down  emacs stopping all current processes 
(defun my-quit ()
  (interactive)
  (save-some-buffers t)
  (kill-emacs))
(global-set-key (kbd "C-c q")  'my-quit)                         

I bind the function to C-c q which I don't use, but you can bind the command to whatever you like.

  • 1
    I strongly recommend against rebinding C-q. quoted-insert is fairly crucial in situations where there's no easy way of typing certain characters (a classic example being C-q C-j to type a newline at a prompt where RET would just submit the input). – phils May 28 at 7:41
  • 1
    Every C-c <letter> sequence (for both upper- and lower-case letters) is reserved for end-users to bind, so you can safely use C-c q – phils May 28 at 7:42
  • thanks for the suggestions, I edited the solution above and I set <kbd>C-c q<kbd> in my .emacs file. Thanks a lot! – PinkCollins May 28 at 11:44

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.