]> git.eshelyaron.com Git - emacs.git/commitdiff
Make querying to kill processes customizable
authorPhilipp Stephani <phst@google.com>
Tue, 27 Sep 2016 18:47:23 +0000 (20:47 +0200)
committerPhilipp Stephani <phst@google.com>
Sat, 1 Oct 2016 12:25:27 +0000 (14:25 +0200)
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
doc/lispref/processes.texi
etc/NEWS
lisp/files.el
test/lisp/files-tests.el

index 66817e3067f3b581aef709ceeac8f14bcefde7e1..09331e80fb1420577ae607b08989758f500f5ffd 100644 (file)
@@ -133,6 +133,11 @@ run.  One convenient function to use as the value of
 @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}.
 
index f9d5096dbea3ed2768386055a8e5ab08420595ba..87c0b5c7687246fb5a038a9990af4c050ea5908e 100644 (file)
@@ -1970,6 +1970,13 @@ shell process to avoid querying:
 @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
index bc36d8ad3b930086a015f4886f7afefb9ab3c442..bd94c9433119b226e6f26e5d60a0afc70541f315 100644 (file)
--- 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
index 4bd708deed873fab77dea58f227b1edfa2967a7c..f481b9967c48f6a3751419a147bc8a51d917784e 100644 (file)
@@ -6757,11 +6757,22 @@ be a predicate function; for example `yes-or-no-p'."
   :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 @@ if any returns nil.  If `confirm-kill-emacs' is non-nil, calls it."
                 (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
index 479848abb23d700cf4deffc62f413b7eb0de97e0..80d5e5befbc006551fba9a845d326817c9fb3620 100644 (file)
@@ -197,5 +197,28 @@ form.")
       (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