aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2016-09-27 20:47:23 +0200
committerPhilipp Stephani2016-10-01 14:25:27 +0200
commitb661efd90d9bd57430761b0e87fcc8723ec24814 (patch)
tree2808dd470064a2ac929dd28804359886a650f9ad
parente1c5422e7bc2fbe0ecf5ab501b39d32fac61e747 (diff)
downloademacs-b661efd90d9bd57430761b0e87fcc8723ec24814.tar.gz
emacs-b661efd90d9bd57430761b0e87fcc8723ec24814.zip
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.
-rw-r--r--doc/emacs/entering.texi5
-rw-r--r--doc/lispref/processes.texi7
-rw-r--r--etc/NEWS7
-rw-r--r--lisp/files.el14
-rw-r--r--test/lisp/files-tests.el23
5 files changed, 55 insertions, 1 deletions
diff --git a/doc/emacs/entering.texi b/doc/emacs/entering.texi
index 66817e3067f..09331e80fb1 100644
--- a/doc/emacs/entering.texi
+++ b/doc/emacs/entering.texi
@@ -133,6 +133,11 @@ run. One convenient function to use as the value of
133@code{confirm-kill-emacs} is the function @code{yes-or-no-p}. The 133@code{confirm-kill-emacs} is the function @code{yes-or-no-p}. The
134default value of @code{confirm-kill-emacs} is @code{nil}. 134default value of @code{confirm-kill-emacs} is @code{nil}.
135 135
136@vindex confirm-kill-processes
137 If the value of the variable @code{confirm-kill-processes} is
138@code{nil}, @kbd{C-x C-c} does not ask for confirmation before killing
139subprocesses started by Emacs. The value is @code{t} by default.
140
136 To further customize what happens when Emacs is exiting, see 141 To further customize what happens when Emacs is exiting, see
137@ref{Killing Emacs,,, elisp, The GNU Emacs Lisp Reference Manual}. 142@ref{Killing Emacs,,, elisp, The GNU Emacs Lisp Reference Manual}.
138 143
diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi
index f9d5096dbea..87c0b5c7687 100644
--- a/doc/lispref/processes.texi
+++ b/doc/lispref/processes.texi
@@ -1970,6 +1970,13 @@ shell process to avoid querying:
1970@end smallexample 1970@end smallexample
1971@end defun 1971@end defun
1972 1972
1973@defopt confirm-kill-processes
1974If this user option is set to @code{t} (the default), then Emacs asks
1975for confirmation before killing processes on exit. If it is
1976@code{nil}, Emacs kills processes without confirmation, i.e., the
1977query flag of all processes is ignored.
1978@end defopt
1979
1973@node System Processes 1980@node System Processes
1974@section Accessing Other Processes 1981@section Accessing Other Processes
1975@cindex system processes 1982@cindex system processes
diff --git a/etc/NEWS b/etc/NEWS
index bc36d8ad3b9..bd94c943311 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -82,6 +82,13 @@ of a parenthetical grouping or string-delimiter: the default value nil
82keeps point at the end of the region, setting it to non-nil moves 82keeps point at the end of the region, setting it to non-nil moves
83point to the beginning of the region. 83point to the beginning of the region.
84 84
85+++
86** The new user option 'confirm-kill-processes' allows the user to
87skip a confirmation prompt for killing subprocesses when exiting
88Emacs. When set to t (the default), Emacs will prompt for
89confirmation before killing subprocesses on exit, which is the same
90behavior as before.
91
85--- 92---
86** 'find-library-name' will now fall back on looking at 'load-history' 93** 'find-library-name' will now fall back on looking at 'load-history'
87to try to locate libraries that have been loaded with an explicit path 94to try to locate libraries that have been loaded with an explicit path
diff --git a/lisp/files.el b/lisp/files.el
index 4bd708deed8..f481b9967c4 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -6757,11 +6757,22 @@ be a predicate function; for example `yes-or-no-p'."
6757 :group 'convenience 6757 :group 'convenience
6758 :version "21.1") 6758 :version "21.1")
6759 6759
6760(defcustom confirm-kill-processes t
6761 "Non-nil if Emacs should confirm killing processes on exit.
6762If this variable is nil, the value of
6763`process-query-on-exit-flag' is ignored. Otherwise, if there are
6764processes with a non-nil `process-query-on-exit-flag', Emacs will
6765prompt the user before killing them."
6766 :type 'boolean
6767 :group 'convenience
6768 :version "26.1")
6769
6760(defun save-buffers-kill-emacs (&optional arg) 6770(defun save-buffers-kill-emacs (&optional arg)
6761 "Offer to save each buffer, then kill this Emacs process. 6771 "Offer to save each buffer, then kill this Emacs process.
6762With prefix ARG, silently save all file-visiting buffers without asking. 6772With prefix ARG, silently save all file-visiting buffers without asking.
6763If there are active processes where `process-query-on-exit-flag' 6773If there are active processes where `process-query-on-exit-flag'
6764returns non-nil, asks whether processes should be killed. 6774returns non-nil and `confirm-kill-processes' is non-nil,
6775asks whether processes should be killed.
6765Runs the members of `kill-emacs-query-functions' in turn and stops 6776Runs the members of `kill-emacs-query-functions' in turn and stops
6766if any returns nil. If `confirm-kill-emacs' is non-nil, calls it." 6777if any returns nil. If `confirm-kill-emacs' is non-nil, calls it."
6767 (interactive "P") 6778 (interactive "P")
@@ -6776,6 +6787,7 @@ if any returns nil. If `confirm-kill-emacs' is non-nil, calls it."
6776 (yes-or-no-p "Modified buffers exist; exit anyway? "))) 6787 (yes-or-no-p "Modified buffers exist; exit anyway? ")))
6777 (or (not (fboundp 'process-list)) 6788 (or (not (fboundp 'process-list))
6778 ;; process-list is not defined on MSDOS. 6789 ;; process-list is not defined on MSDOS.
6790 (not confirm-kill-processes)
6779 (let ((processes (process-list)) 6791 (let ((processes (process-list))
6780 active) 6792 active)
6781 (while processes 6793 (while processes
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index 479848abb23..80d5e5befbc 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -197,5 +197,28 @@ form.")
197 (setenv "FOO" foo-env) 197 (setenv "FOO" foo-env)
198 (setenv "BAR" bar-env)))) 198 (setenv "BAR" bar-env))))
199 199
200(ert-deftest files-test--save-buffers-kill-emacs--confirm-kill-processes ()
201 "Test that `save-buffers-kill-emacs' honors
202`confirm-kill-processes'."
203 (cl-letf* ((yes-or-no-p-prompts nil)
204 ((symbol-function #'yes-or-no-p)
205 (lambda (prompt)
206 (push prompt yes-or-no-p-prompts)
207 nil))
208 (kill-emacs-args nil)
209 ((symbol-function #'kill-emacs)
210 (lambda (&optional arg) (push arg kill-emacs-args)))
211 (process
212 (make-process
213 :name "sleep"
214 :command (list
215 (expand-file-name invocation-name invocation-directory)
216 "-batch" "-Q" "-eval" "(sleep-for 1000)")))
217 (confirm-kill-processes nil))
218 (save-buffers-kill-emacs)
219 (kill-process process)
220 (should-not yes-or-no-p-prompts)
221 (should (equal kill-emacs-args '(nil)))))
222
200(provide 'files-tests) 223(provide 'files-tests)
201;;; files-tests.el ends here 224;;; files-tests.el ends here