commit b661efd90d9bd57430761b0e87fcc8723ec24814 (HEAD, refs/remotes/origin/master) Author: Philipp Stephani Date: Tue Sep 27 20:47:23 2016 +0200 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. 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 @@ 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}. 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 @@ 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 diff --git a/etc/NEWS b/etc/NEWS index bc36d8a..bd94c94 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 @@ 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 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 @@ 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 commit e1c5422e7bc2fbe0ecf5ab501b39d32fac61e747 Author: Glenn Morris Date: Sat Oct 1 06:22:45 2016 -0400 ; Auto-commit of loaddefs files. diff --git a/lisp/ldefs-boot.el b/lisp/ldefs-boot.el index 920ea30..25a9c4f 100644 --- a/lisp/ldefs-boot.el +++ b/lisp/ldefs-boot.el @@ -11323,8 +11323,6 @@ Third arg DELIMITED (prefix arg) means replace only word-delimited matches. If you exit (\\[keyboard-quit], RET or q), you can resume the query replace with the command \\[tags-loop-continue]. Fourth arg FILE-LIST-FORM non-nil means initialize the replacement loop. -Fifth and sixth arguments START and END are accepted, for compatibility -with `query-replace-regexp', and ignored. If FILE-LIST-FORM is non-nil, it is a form to evaluate to produce the list of files to search. @@ -15153,7 +15151,7 @@ The return value is the last VAL in the list. Return a reference to PLACE. This is like the `&' operator of the C language. Note: this only works reliably with lexical binding mode, except for very -simple PLACEs such as (function-symbol \\='foo) which will also work in dynamic +simple PLACEs such as (symbol-function \\='foo) which will also work in dynamic binding mode. \(fn PLACE)" nil t) @@ -26789,18 +26787,44 @@ This enforces rescanning the buffer on next use. (autoload 'regexp-opt "regexp-opt" "\ Return a regexp to match a string in the list STRINGS. -Each string should be unique in STRINGS and should not contain any regexps, -quoted or not. If optional PAREN is non-nil, ensure that the returned regexp -is enclosed by at least one regexp grouping construct. -The returned regexp is typically more efficient than the equivalent regexp: +Each string should be unique in STRINGS and should not contain +any regexps, quoted or not. Optional PAREN specifies how the +returned regexp is surrounded by grouping constructs. - (let ((open (if PAREN \"\\\\(\" \"\")) (close (if PAREN \"\\\\)\" \"\"))) - (concat open (mapconcat \\='regexp-quote STRINGS \"\\\\|\") close)) +The optional argument PAREN can be any of the following: -If PAREN is `words', then the resulting regexp is additionally surrounded -by \\=\\< and \\>. -If PAREN is `symbols', then the resulting regexp is additionally surrounded -by \\=\\_< and \\_>. +a string + the resulting regexp is preceded by PAREN and followed by + \\), e.g. use \"\\\\(?1:\" to produce an explicitly numbered + group. + +`words' + the resulting regexp is surrounded by \\=\\<\\( and \\)\\>. + +`symbols' + the resulting regexp is surrounded by \\_<\\( and \\)\\_>. + +non-nil + the resulting regexp is surrounded by \\( and \\). + +nil + the resulting regexp is surrounded by \\(?: and \\), if it is + necessary to ensure that a postfix operator appended to it will + apply to the whole expression. + +The resulting regexp is equivalent to but usually more efficient +than that of a simplified version: + + (defun simplified-regexp-opt (strings &optional paren) + (let ((parens + (cond ((stringp paren) (cons paren \"\\\\)\")) + ((eq paren 'words) '(\"\\\\\\=<\\\\(\" . \"\\\\)\\\\>\")) + ((eq paren 'symbols) '(\"\\\\_<\\\\(\" . \"\\\\)\\\\_>\")) + ((null paren) '(\"\\\\(?:\" . \"\\\\)\")) + (t '(\"\\\\(\" . \"\\\\)\"))))) + (concat (car paren) + (mapconcat 'regexp-quote strings \"\\\\|\") + (cdr paren)))) \(fn STRINGS &optional PAREN)" nil nil) @@ -34990,6 +35014,11 @@ in any way you like. \(fn FILE OPPONENT)" nil nil) +(autoload 'userlock--ask-user-about-supersession-threat "userlock" "\ + + +\(fn FN)" nil nil) + (autoload 'ask-user-about-supersession-threat "userlock" "\ Ask a user who is about to modify an obsolete buffer what to do. This function has two choices: it can return, in which case the modification @@ -35001,7 +35030,7 @@ The buffer in question is current when this function is called. \(fn FN)" nil nil) -(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "userlock" '("ask-user-about-" "file-"))) +(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "userlock" '("ask-user-about-" "userlock--check-content-unchanged" "file-"))) ;;;*** @@ -36981,8 +37010,10 @@ in certain major modes. (autoload 'whitespace-mode "whitespace" "\ Toggle whitespace visualization (Whitespace mode). With a prefix argument ARG, enable Whitespace mode if ARG is -positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil. +positive, and disable it otherwise. + +If called from Lisp, also enables the mode if ARG is omitted or nil, +and toggles it if ARG is `toggle'. See also `whitespace-style', `whitespace-newline' and `whitespace-display-mappings'. @@ -36992,8 +37023,10 @@ See also `whitespace-style', `whitespace-newline' and (autoload 'whitespace-newline-mode "whitespace" "\ Toggle newline visualization (Whitespace Newline mode). With a prefix argument ARG, enable Whitespace Newline mode if ARG -is positive, and disable it otherwise. If called from Lisp, -enable the mode if ARG is omitted or nil. +is positive, and disable it otherwise. + +If called from Lisp, also enables the mode if ARG is omitted or nil, +and toggles it if ARG is `toggle'. Use `whitespace-newline-mode' only for NEWLINE visualization exclusively. For other visualizations, including NEWLINE @@ -37017,8 +37050,10 @@ or call the function `global-whitespace-mode'.") (autoload 'global-whitespace-mode "whitespace" "\ Toggle whitespace visualization globally (Global Whitespace mode). With a prefix argument ARG, enable Global Whitespace mode if ARG -is positive, and disable it otherwise. If called from Lisp, -enable it if ARG is omitted or nil. +is positive, and disable it otherwise. + +If called from Lisp, also enables the mode if ARG is omitted or nil, +and toggles it if ARG is `toggle'. See also `whitespace-style', `whitespace-newline' and `whitespace-display-mappings'. @@ -37038,8 +37073,10 @@ or call the function `global-whitespace-newline-mode'.") (autoload 'global-whitespace-newline-mode "whitespace" "\ Toggle global newline visualization (Global Whitespace Newline mode). With a prefix argument ARG, enable Global Whitespace Newline mode -if ARG is positive, and disable it otherwise. If called from -Lisp, enable it if ARG is omitted or nil. +if ARG is positive, and disable it otherwise. + +If called from Lisp, also enables the mode if ARG is omitted or nil, +and toggles it if ARG is `toggle'. Use `global-whitespace-newline-mode' only for NEWLINE visualization exclusively. For other visualizations, including