From 6db5582479bdf6b7b090c5b450534999ef284aa8 Mon Sep 17 00:00:00 2001 From: Richard Stallman Date: Sat, 4 Feb 2017 11:16:55 +0200 Subject: [PATCH] New defcustom 'save-some-buffers-default-predicate' * lisp/files.el (save-some-buffers-default-predicate): New defcustom. (save-some-buffers): Use it when PRED is nil or omitted. --- etc/NEWS | 5 +++++ lisp/files.el | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/etc/NEWS b/etc/NEWS index 930e1c893b4..25e1d6e8369 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -758,6 +758,11 @@ instead. * Lisp Changes in Emacs 26.1 +** 'save-some-buffers' now uses 'save-some-buffers-default-predicate' +to decide which buffers to ask about, if the PRED argument is nil. +The default value of 'save-some-buffers-default-predicate' is nil, +which means ask about all file-visiting buffers. + ** string-(to|as|make)-(uni|multi)byte are now declared obsolete. ** New variable 'while-no-input-ignore-events' which allow setting which special events 'while-no-input' should ignore. diff --git a/lisp/files.el b/lisp/files.el index 25392fdcc71..2833ec5c124 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5134,6 +5134,13 @@ Before and after saving the buffer, this function runs "Non-nil means `save-some-buffers' should save this buffer without asking.") (make-variable-buffer-local 'buffer-save-without-query) +(defcustom save-some-buffers-default-predicate nil + "Default predicate for `save-some-buffers'. +This allows you to stop `save-some-buffers' from asking +about certain files that you'd usually rather not save." + :group 'auto-save + :type 'function) + (defun save-some-buffers (&optional arg pred) "Save some modified file-visiting buffers. Asks user about each one. You can answer `y' to save, `n' not to save, `C-r' to look at the @@ -5149,10 +5156,13 @@ If PRED is nil, all the file-visiting buffers are considered. If PRED is t, then certain non-file buffers will also be considered. If PRED is a zero-argument function, it indicates for each buffer whether to consider it or not when called with that buffer current. +PRED defaults to the value of `save-some-buffers-default-predicate'. See `save-some-buffers-action-alist' if you want to change the additional actions you can take on files." (interactive "P") + (unless pred + (setq pred save-some-buffers-default-predicate)) (save-window-excursion (let* (queried autosaved-buffers files-done abbrevs-done) @@ -6812,6 +6822,8 @@ 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") + ;; Don't use save-some-buffers-default-predicate, because we want + ;; to ask about all the buffers before killing Emacs. (save-some-buffers arg t) (let ((confirm confirm-kill-emacs)) (and -- 2.39.5