emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] emacs-26 3d3778d: Accept new `always' value for option `bu


From: Eric Abrahamsen
Subject: [Emacs-diffs] emacs-26 3d3778d: Accept new `always' value for option `buffer-offer-save'
Date: Sun, 24 Sep 2017 17:57:54 -0400 (EDT)

branch: emacs-26
commit 3d3778d82a87139ef50a24146f5bad2a57a82094
Author: Eric Abrahamsen <address@hidden>
Commit: Eric Abrahamsen <address@hidden>

    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.
---
 doc/lispref/buffers.texi | 15 +++++++++------
 doc/lispref/files.texi   |  3 +--
 etc/NEWS                 |  8 ++++++--
 lisp/files.el            | 19 ++++++++++---------
 4 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/doc/lispref/buffers.texi b/doc/lispref/buffers.texi
index cf24a73..0d02cb3 100644
--- a/doc/lispref/buffers.texi
+++ b/doc/lispref/buffers.texi
@@ -1089,12 +1089,15 @@ is not cleared by changing major modes.
 
 @defopt buffer-offer-save
 This variable, if address@hidden in a particular buffer, tells
address@hidden and @code{save-some-buffers} (if the
-second optional argument to that function is @code{t}) to offer to
-save that buffer, just as they offer to save file-visiting buffers.
address@hidden of save-some-buffers}.  The variable
address@hidden automatically becomes buffer-local when set
-for any reason.  @xref{Buffer-Local Variables}.
address@hidden to offer to save that buffer, just as
+it offers to save file-visiting buffers.  If @code{save-some-buffers}
+is called with the second optional argument set to @code{t}, it will
+also offer to save the buffer.  Lastly, if this variable is set to the
+symbol @code{always}, both @code{save-buffers-kill-emacs} and
address@hidden will always offer to save.  @xref{Definition
+of save-some-buffers}.  The variable @code{buffer-offer-save}
+automatically becomes buffer-local when set for any reason.
address@hidden Variables}.
 @end defopt
 
 @defvar buffer-save-without-query
diff --git a/doc/lispref/files.texi b/doc/lispref/files.texi
index b1b858a..f49b02d 100644
--- a/doc/lispref/files.texi
+++ b/doc/lispref/files.texi
@@ -368,8 +368,7 @@ With an argument of 0, unconditionally do @emph{not} make 
any backup file.
 This command saves some modified file-visiting buffers.  Normally it
 asks the user about each buffer.  But if @var{save-silently-p} is
 address@hidden, it saves all the file-visiting buffers without
-querying the user.  Additionally, buffers whose name begins with a
-space (``internal'' buffers) will not be offered for save.
+querying the user.
 
 @vindex save-some-buffers-default-predicate
 The optional @var{pred} argument provides a predicate that controls
diff --git a/etc/NEWS b/etc/NEWS
index 19a6893..040d265 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -117,6 +117,11 @@ The effect is similar to that of "toolBar" resource on the 
tool bar.
 
 * Changes in Emacs 26.1
 
++++
+** Option 'buffer-offer-save' can be set to new value, 'always'.  When
+   set to 'always', the command `save-some-buffers' will always offer
+   this buffer for saving.
+
 ** Security vulnerability related to Enriched Text mode is removed.
 
 +++
@@ -144,8 +149,7 @@ init file:
 'save-buffer' process.  Previously, saving a buffer that was not
 visiting a file would always prompt for a file name.  Now it only does
 so if 'write-contents-functions' is nil (or all its functions return
-nil).  A non-nil buffer-local value for this variable is sufficient
-for 'save-some-buffers' to consider the buffer for saving.
+nil).
 
 ---
 ** New variable 'executable-prefix-env' for inserting magic signatures.
diff --git a/lisp/files.el b/lisp/files.el
index f0a1f23..211457a 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]