From 3d3778d82a87139ef50a24146f5bad2a57a82094 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Sun, 24 Sep 2017 14:01:21 -0700 Subject: Accept new `always' value for option `buffer-offer-save' Also revert ee512e9a82 * lisp/files.el (buffer-offer-save): In addition to nil and t, now allows a third symbol value, `always'. A buffer where this option is set to `always' will always be offered for save by `save-some-buffers'. (save-some-buffers): Check the exact value of this buffer-local variable. No longer check the buffer name, or the value of `write-contents-functions'. * doc/lispref/buffers.texi (Killing Buffers): Note change in manual. * doc/lispref/files.texi (Saving Buffers): Remove note about buffer names. * etc/NEWS: Mention in NEWS. --- lisp/files.el | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'lisp/files.el') diff --git a/lisp/files.el b/lisp/files.el index f0a1f2380d9..211457ac7d7 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -150,8 +150,13 @@ Called with an absolute file name as argument, it returns t to enable backup.") (defcustom buffer-offer-save nil "Non-nil in a buffer means always offer to save buffer on exit. Do so even if the buffer is not visiting a file. -Automatically local in all buffers." - :type 'boolean +Automatically local in all buffers. + +Set to the symbol `always' to offer to save buffer whenever +`save-some-buffers' is called." + :type '(choice (const :tag "Never" nil) + (const :tag "On Emacs exit" t) + (const :tag "Whenever save-some-buffers is called" always)) :group 'backup) (make-variable-buffer-local 'buffer-offer-save) (put 'buffer-offer-save 'permanent-local t) @@ -5188,15 +5193,11 @@ change the additional actions you can take on files." (and (buffer-live-p buffer) (buffer-modified-p buffer) (not (buffer-base-buffer buffer)) - (not (eq (aref (buffer-name buffer) 0) ?\s)) (or (buffer-file-name buffer) - (and pred - (progn - (set-buffer buffer) - (and buffer-offer-save (> (buffer-size) 0)))) - (buffer-local-value - 'write-contents-functions buffer)) + (with-current-buffer buffer + (or (eq buffer-offer-save 'always) + (and pred buffer-offer-save (> (buffer-size) 0))))) (or (not (functionp pred)) (with-current-buffer buffer (funcall pred))) (if arg -- cgit v1.2.3