* New customization option for killing processes without asking @ 2016-09-27 18:53 Philipp Stephani 2016-09-27 19:17 ` Eli Zaretskii ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Philipp Stephani @ 2016-09-27 18:53 UTC (permalink / raw) To: Emacs developers [-- Attachment #1.1: Type: text/plain, Size: 340 bytes --] Hi, there seem to be sufficiently many people annoyed by the "Active processes exist; kill them and exit anyway" prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I created a new customization option to make prompting optional. I've attached a patch, which I can push to master unless there are complaints. Thanks, Philipp [-- Attachment #1.2: Type: text/html, Size: 484 bytes --] [-- Attachment #2: 0001-Make-querying-to-kill-processes-customizable.txt --] [-- Type: text/plain, Size: 3398 bytes --] From b7adb3930de7cc422b2beee61cb20285a3916571 Mon Sep 17 00:00:00 2001 From: Philipp Stephani <phst@google.com> Date: Tue, 27 Sep 2016 20:47:23 +0200 Subject: [PATCH] Make querying to kill processes customizable Introduce a new customization option, `confirm-kill-processes', that users can set to nil if they don't want Emacs to nag them about killing processes. * lisp/files.el (confirm-kill-processes): New customization option. (save-buffers-kill-emacs): Use customization option. * test/lisp/files-tests.el (files-test--save-buffers-kill-emacs--confirm-kill-processes): Add test for new customization option. --- lisp/files.el | 14 +++++++++++++- test/lisp/files-tests.el | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lisp/files.el b/lisp/files.el index 4bd708d..f481b99 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6757,11 +6757,22 @@ confirm-kill-emacs :group 'convenience :version "21.1") +(defcustom confirm-kill-processes t + "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." + :type 'boolean + :group 'convenience + :version "26.1") + (defun save-buffers-kill-emacs (&optional arg) "Offer to save each buffer, then kill this Emacs process. With prefix ARG, silently save all file-visiting buffers without asking. If there are active processes where `process-query-on-exit-flag' -returns non-nil, asks whether processes should be killed. +returns non-nil and `confirm-kill-processes' is non-nil, +asks whether processes should be killed. Runs the members of `kill-emacs-query-functions' in turn and stops if any returns nil. If `confirm-kill-emacs' is non-nil, calls it." (interactive "P") @@ -6776,6 +6787,7 @@ save-buffers-kill-emacs (yes-or-no-p "Modified buffers exist; exit anyway? "))) (or (not (fboundp 'process-list)) ;; process-list is not defined on MSDOS. + (not confirm-kill-processes) (let ((processes (process-list)) active) (while processes diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 479848a..581c8bf 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -197,5 +197,24 @@ files-test-bug-18141-file (setenv "FOO" foo-env) (setenv "BAR" bar-env)))) +(ert-deftest files-test--save-buffers-kill-emacs--confirm-kill-processes () + "Test that `save-buffers-kill-emacs' honors +`confirm-kill-processes'." + (cl-letf* ((yes-or-no-p-prompts nil) + ((symbol-function #'yes-or-no-p) + (lambda (prompt) + (push prompt yes-or-no-p-prompts) + nil)) + (kill-emacs-args nil) + ((symbol-function #'kill-emacs) + (lambda (&optional arg) (push arg kill-emacs-args))) + (process (make-process :name "sleep" + :command '("/bin/sleep" "1000"))) + (confirm-kill-processes nil)) + (save-buffers-kill-emacs) + (kill-process process) + (should-not yes-or-no-p-prompts) + (should (equal kill-emacs-args '(nil))))) + (provide 'files-tests) ;;; files-tests.el ends here -- 2.10.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-09-27 18:53 New customization option for killing processes without asking Philipp Stephani @ 2016-09-27 19:17 ` Eli Zaretskii 2016-09-28 11:41 ` Philipp Stephani 2016-09-27 19:49 ` Clément Pit--Claudel 2016-10-21 2:07 ` Daniel Colascione 2 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2016-09-27 19:17 UTC (permalink / raw) To: Philipp Stephani; +Cc: emacs-devel > From: Philipp Stephani <p.stephani2@gmail.com> > Date: Tue, 27 Sep 2016 18:53:40 +0000 > > there seem to be sufficiently many people annoyed by the "Active processes exist; kill them and exit anyway" > prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I created a new customization option to > make prompting optional. I've attached a patch, which I can push to master unless there are complaints. Fine with me, but I have 2 comments: . Please add a NEWS entry and mention this in the 2 manuals. . Please modify the test so that it doesn't invoke programs which might not exist on non-Posix platforms; my obvious suggestion would be to invoke a subordinate Emacs. Thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-09-27 19:17 ` Eli Zaretskii @ 2016-09-28 11:41 ` Philipp Stephani 2016-10-01 8:00 ` Eli Zaretskii 0 siblings, 1 reply; 7+ messages in thread From: Philipp Stephani @ 2016-09-28 11:41 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1.1: Type: text/plain, Size: 836 bytes --] Eli Zaretskii <eliz@gnu.org> schrieb am Di., 27. Sep. 2016 um 21:17 Uhr: > > From: Philipp Stephani <p.stephani2@gmail.com> > > Date: Tue, 27 Sep 2016 18:53:40 +0000 > > > > there seem to be sufficiently many people annoyed by the "Active > processes exist; kill them and exit anyway" > > prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I > created a new customization option to > > make prompting optional. I've attached a patch, which I can push to > master unless there are complaints. > > Fine with me, but I have 2 comments: > > . Please add a NEWS entry and mention this in the 2 manuals. > . Please modify the test so that it doesn't invoke programs which > might not exist on non-Posix platforms; my obvious suggestion > would be to invoke a subordinate Emacs. > > Done. I've attached a new patch. [-- Attachment #1.2: Type: text/html, Size: 1627 bytes --] [-- Attachment #2: 0001-Make-querying-to-kill-processes-customizable.txt --] [-- Type: text/plain, Size: 5877 bytes --] From c72742869b79f71b6a2fcc68641c785b0194fa0b Mon Sep 17 00:00:00 2001 From: Philipp Stephani <phst@google.com> Date: Tue, 27 Sep 2016 20:47:23 +0200 Subject: [PATCH] Make querying to kill processes customizable Introduce a new customization option, `confirm-kill-processes', that users can set to nil if they don't want Emacs to nag them about killing processes. * lisp/files.el (confirm-kill-processes): New customization option. (save-buffers-kill-emacs): Use customization option. * test/lisp/files-tests.el (files-test--save-buffers-kill-emacs--confirm-kill-processes): Add test for new customization option. * doc/emacs/entering.texi (Exiting): Document new user option. * doc/lispref/processes.texi (Query Before Exit): Document new user option. * etc/NEWS: Document new user option. --- doc/emacs/entering.texi | 5 +++++ doc/lispref/processes.texi | 7 +++++++ etc/NEWS | 7 +++++++ lisp/files.el | 14 +++++++++++++- test/lisp/files-tests.el | 23 +++++++++++++++++++++++ 5 files changed, 55 insertions(+), 1 deletion(-) diff --git a/doc/emacs/entering.texi b/doc/emacs/entering.texi index 66817e3..09331e8 100644 --- a/doc/emacs/entering.texi +++ b/doc/emacs/entering.texi @@ -133,6 +133,11 @@ Exiting @code{confirm-kill-emacs} is the function @code{yes-or-no-p}. The default value of @code{confirm-kill-emacs} is @code{nil}. +@vindex confirm-kill-processes + If the value of the variable @code{confirm-kill-processes} is +@code{nil}, @kbd{C-x C-c} does not ask for confirmation before killing +subprocesses started by Emacs. The value is @code{t} by default. + To further customize what happens when Emacs is exiting, see @ref{Killing Emacs,,, elisp, The GNU Emacs Lisp Reference Manual}. diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index f9d5096..87c0b5c 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -1970,6 +1970,13 @@ Query Before Exit @end smallexample @end defun +@defopt confirm-kill-processes +If this user option is set to @code{t} (the default), then Emacs asks +for confirmation before killing processes on exit. If it is +@code{nil}, Emacs kills processes without confirmation, i.e., the +query flag of all processes is ignored. +@end defopt + @node System Processes @section Accessing Other Processes @cindex system processes diff --git a/etc/NEWS b/etc/NEWS index c3f4cf0..13814be 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -82,6 +82,13 @@ of a parenthetical grouping or string-delimiter: the default value nil keeps point at the end of the region, setting it to non-nil moves point to the beginning of the region. ++++ +** The new user option 'confirm-kill-processes' allows the user to +skip a confirmation prompt for killing subprocesses when exiting +Emacs. When set to t (the default), Emacs will prompt for +confirmation before killing subprocesses on exit, which is the same +behavior as before. + --- ** 'find-library-name' will now fall back on looking at 'load-history' to try to locate libraries that have been loaded with an explicit path diff --git a/lisp/files.el b/lisp/files.el index 4bd708d..f481b99 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -6757,11 +6757,22 @@ confirm-kill-emacs :group 'convenience :version "21.1") +(defcustom confirm-kill-processes t + "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." + :type 'boolean + :group 'convenience + :version "26.1") + (defun save-buffers-kill-emacs (&optional arg) "Offer to save each buffer, then kill this Emacs process. With prefix ARG, silently save all file-visiting buffers without asking. If there are active processes where `process-query-on-exit-flag' -returns non-nil, asks whether processes should be killed. +returns non-nil and `confirm-kill-processes' is non-nil, +asks whether processes should be killed. Runs the members of `kill-emacs-query-functions' in turn and stops if any returns nil. If `confirm-kill-emacs' is non-nil, calls it." (interactive "P") @@ -6776,6 +6787,7 @@ save-buffers-kill-emacs (yes-or-no-p "Modified buffers exist; exit anyway? "))) (or (not (fboundp 'process-list)) ;; process-list is not defined on MSDOS. + (not confirm-kill-processes) (let ((processes (process-list)) active) (while processes diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 479848a..80d5e5b 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el @@ -197,5 +197,28 @@ files-test-bug-18141-file (setenv "FOO" foo-env) (setenv "BAR" bar-env)))) +(ert-deftest files-test--save-buffers-kill-emacs--confirm-kill-processes () + "Test that `save-buffers-kill-emacs' honors +`confirm-kill-processes'." + (cl-letf* ((yes-or-no-p-prompts nil) + ((symbol-function #'yes-or-no-p) + (lambda (prompt) + (push prompt yes-or-no-p-prompts) + nil)) + (kill-emacs-args nil) + ((symbol-function #'kill-emacs) + (lambda (&optional arg) (push arg kill-emacs-args))) + (process + (make-process + :name "sleep" + :command (list + (expand-file-name invocation-name invocation-directory) + "-batch" "-Q" "-eval" "(sleep-for 1000)"))) + (confirm-kill-processes nil)) + (save-buffers-kill-emacs) + (kill-process process) + (should-not yes-or-no-p-prompts) + (should (equal kill-emacs-args '(nil))))) + (provide 'files-tests) ;;; files-tests.el ends here -- 2.10.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-09-28 11:41 ` Philipp Stephani @ 2016-10-01 8:00 ` Eli Zaretskii 2016-10-01 12:26 ` Philipp Stephani 0 siblings, 1 reply; 7+ messages in thread From: Eli Zaretskii @ 2016-10-01 8:00 UTC (permalink / raw) To: Philipp Stephani; +Cc: emacs-devel > From: Philipp Stephani <p.stephani2@gmail.com> > Date: Wed, 28 Sep 2016 11:41:41 +0000 > Cc: emacs-devel@gnu.org > > Eli Zaretskii <eliz@gnu.org> schrieb am Di., 27. Sep. 2016 um 21:17 Uhr: > > > From: Philipp Stephani <p.stephani2@gmail.com> > > Date: Tue, 27 Sep 2016 18:53:40 +0000 > > > > there seem to be sufficiently many people annoyed by the "Active processes exist; kill them and exit > anyway" > > prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I created a new customization > option to > > make prompting optional. I've attached a patch, which I can push to master unless there are > complaints. > > Fine with me, but I have 2 comments: > > . Please add a NEWS entry and mention this in the 2 manuals. > . Please modify the test so that it doesn't invoke programs which > might not exist on non-Posix platforms; my obvious suggestion > would be to invoke a subordinate Emacs. > > Done. I've attached a new patch. LGTM, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-10-01 8:00 ` Eli Zaretskii @ 2016-10-01 12:26 ` Philipp Stephani 0 siblings, 0 replies; 7+ messages in thread From: Philipp Stephani @ 2016-10-01 12:26 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel [-- Attachment #1: Type: text/plain, Size: 1122 bytes --] Eli Zaretskii <eliz@gnu.org> schrieb am Sa., 1. Okt. 2016 um 10:00 Uhr: > > From: Philipp Stephani <p.stephani2@gmail.com> > > Date: Wed, 28 Sep 2016 11:41:41 +0000 > > Cc: emacs-devel@gnu.org > > > > Eli Zaretskii <eliz@gnu.org> schrieb am Di., 27. Sep. 2016 um 21:17 Uhr: > > > > > From: Philipp Stephani <p.stephani2@gmail.com> > > > Date: Tue, 27 Sep 2016 18:53:40 +0000 > > > > > > there seem to be sufficiently many people annoyed by the "Active > processes exist; kill them and exit > > anyway" > > > prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I > created a new customization > > option to > > > make prompting optional. I've attached a patch, which I can push to > master unless there are > > complaints. > > > > Fine with me, but I have 2 comments: > > > > . Please add a NEWS entry and mention this in the 2 manuals. > > . Please modify the test so that it doesn't invoke programs which > > might not exist on non-Posix platforms; my obvious suggestion > > would be to invoke a subordinate Emacs. > > > > Done. I've attached a new patch. > > LGTM, thanks. > Thanks, pushed. [-- Attachment #2: Type: text/html, Size: 2474 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-09-27 18:53 New customization option for killing processes without asking Philipp Stephani 2016-09-27 19:17 ` Eli Zaretskii @ 2016-09-27 19:49 ` Clément Pit--Claudel 2016-10-21 2:07 ` Daniel Colascione 2 siblings, 0 replies; 7+ messages in thread From: Clément Pit--Claudel @ 2016-09-27 19:49 UTC (permalink / raw) To: emacs-devel [-- Attachment #1.1: Type: text/plain, Size: 429 bytes --] This looks great :) On 2016-09-27 14:53, Philipp Stephani wrote: > Hi, > > there seem to be sufficiently many people annoyed by the "Active processes exist; kill them and exit anyway" prompt (see e.g. http://stackoverflow.com/q/2706527/178761) that I created a new customization option to make prompting optional. I've attached a patch, which I can push to master unless there are complaints. > > Thanks, > Philipp [-- Attachment #2: OpenPGP digital signature --] [-- Type: application/pgp-signature, Size: 819 bytes --] ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: New customization option for killing processes without asking 2016-09-27 18:53 New customization option for killing processes without asking Philipp Stephani 2016-09-27 19:17 ` Eli Zaretskii 2016-09-27 19:49 ` Clément Pit--Claudel @ 2016-10-21 2:07 ` Daniel Colascione 2 siblings, 0 replies; 7+ messages in thread From: Daniel Colascione @ 2016-10-21 2:07 UTC (permalink / raw) To: Philipp Stephani, Emacs developers On 09/27/2016 11:53 AM, Philipp Stephani wrote: > Hi, > > there seem to be sufficiently many people annoyed by the "Active > processes exist; kill them and exit anyway" prompt (see > e.g. http://stackoverflow.com/q/2706527/178761) that I created a new > customization option to make prompting optional. I've attached a patch, > which I can push to master unless there are complaints. > On a related note, I think I have a patch somewhere (maybe I even sent it to emacs-devel?) that makes comint behave like common terminal emulators with respect to killing subprocesses: kill without prompting if the foreground process is the shell, and prompt otherwise. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-10-21 2:07 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-09-27 18:53 New customization option for killing processes without asking Philipp Stephani 2016-09-27 19:17 ` Eli Zaretskii 2016-09-28 11:41 ` Philipp Stephani 2016-10-01 8:00 ` Eli Zaretskii 2016-10-01 12:26 ` Philipp Stephani 2016-09-27 19:49 ` Clément Pit--Claudel 2016-10-21 2:07 ` Daniel Colascione
Code repositories for project(s) associated with this external index https://git.savannah.gnu.org/cgit/emacs.git https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.