5

It turned out not to be the same problem as Kill process buffer without confirmation?: emacs asks for different kind of confirmations when exiting and when just killing a buffer.

How to specify for all or specific processes (e.g. one launched with run-scheme) to be killed without confirmation on exiting emacs?

  • A side question is : why isn't that question asked from kill-emacs-query-functions ? I have no idea. Hysterical reasons ? A work around would be to use kill-emacs directly (or write an analogue to sbke which bypasses the question). Another workaround would be advice sbke with a :before advice that will kill the processes you don't want to be warned about. – YoungFrog Aug 25 '16 at 11:04
  • Yet another workaround would be to follow my answer at emacs.stackexchange.com/questions/14669/… and code the improvement I suggested in a comment, then use all of that around sbke... ok maybe I should stop now :) – YoungFrog Aug 25 '16 at 11:07
3

Following my own suggestion (second comment on the question), here's an answer which avoids the prompting altogether:

(require 'auto-answer)    
(let ((auto-answer '(("\\`Active processes exist; kill them and exit anyway\\? \\'" t))))
  (save-buffers-kill-emacs))

This uses auto-answer.el, available at https://github.com/YoungFrog/auto-answer/blob/master/auto-answer.el (it requires dash.el from your favourite package store, and nadvice.el which is available at least in 24.4).

Edit: If you only want to avoid the prompt for some (specific) processes, the documented way to do it is to set its query-on-exit flag to nil using set-process-query-on-exit-flag when creating the process.

  • Thanks, just a few problems: first, please note that it also requires dash.el. Then: am I supposed to put it in .emacs? Doing so closes emacs right after startup. Finally, for selectively disabling asking for some processes this approach doesn't seem appropriate, as it only looks for that message (which is common to all processes being killed). – user905686 Sep 2 '16 at 17:46
  • The dependency on dash is mentionned at the top of that file. The idea behind this code is that you create your own my-kill-emacs function and bind that to C-x C-c instead of save-buffers-kill-emacs. If you want to selectively disable asking for some processes, the obvious answer is to use set-process-query-on-exit-flag (set the flag to nil) on those processes when they are created. – YoungFrog Sep 2 '16 at 22:14
  • 2
    Thank you, this was even more what I was looking for. With (set-process-query-on-exit-flag (get-process "scheme") nil) (doc) right after (run-scheme "petite") the query is disabled directly after starting the process (which in my happens in .emacs). Could you add this to your answer? Then I'll accept it . – user905686 Sep 3 '16 at 19:37
3

Emacs 26.1 added the confirm-kill-processes variable. To disable conformation to kill processes on Emacs exit, add to your init file:

(setq confirm-kill-processes nil)

Documentation:

Non-nil if Emacs should confirm killing processes on exit. If this variable is nil, the value of process-query-on-exit-flag is ignored. Otherwise, if there are processes with a non-nil process-query-on-exit-flag, Emacs will prompt the user before killing them.

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.