From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Kaushal Modi Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] emacs-26 ee512e9: Ignore buffers whose name begins with a space in save-some-buffers Date: Wed, 20 Sep 2017 02:10:11 +0000 Message-ID: References: <20170918202953.21378.63492@vcs0.savannah.gnu.org> <20170918202955.5043420AC4@vcs0.savannah.gnu.org> <87inge8skl.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a114d725c70cacf0559957a68" X-Trace: blaine.gmane.org 1505873476 10763 195.159.176.226 (20 Sep 2017 02:11:16 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 20 Sep 2017 02:11:16 +0000 (UTC) To: Eric Abrahamsen , Emacs developers , Stefan Monnier , Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Sep 20 04:11:11 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1duUTi-0002Pw-UU for ged-emacs-devel@m.gmane.org; Wed, 20 Sep 2017 04:11:07 +0200 Original-Received: from localhost ([::1]:46255 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duUTq-0001qz-5y for ged-emacs-devel@m.gmane.org; Tue, 19 Sep 2017 22:11:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57975) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duUT3-0001ly-Ej for emacs-devel@gnu.org; Tue, 19 Sep 2017 22:10:26 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duUT1-0003wA-Th for emacs-devel@gnu.org; Tue, 19 Sep 2017 22:10:25 -0400 Original-Received: from mail-yw0-x234.google.com ([2607:f8b0:4002:c05::234]:44196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duUT1-0003vo-Ng; Tue, 19 Sep 2017 22:10:23 -0400 Original-Received: by mail-yw0-x234.google.com with SMTP id r85so992371ywg.1; Tue, 19 Sep 2017 19:10:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=0GTKu/4OpB4oOSC0D29L3rViFjMJpGmYf4IoxRrpSPo=; b=dTRvSS2L+iaZEDQhzuK+UvdcnQoMbOqJKZFYwyptzgsLPci48rqJ9cul5WmLLrnocQ 0qzn+7vd+DVqqZD9vRRDYhUP20vKo6ZYiCxlDY8dFjKcx19e+/jpjcwmwi/7CbeSG5Jc Vf446NGvQNf0g+v4fc5RrpGy2jCGltXPpgS576U+xk6MMAWneLrUKtv6NMRhDRGCcv3A kH4EelMY1SL658EfeBl+KD2KJXMAevUFrBuk8qFa3BNevt4JmiOVrCFJrbqEloTfU1CR 5i6TimALeMdv+wIp2hXgGYpWFvh4n7BgFYu+bliWaI19PCT3TCTNGjZMxYOb7k098sG6 JZvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=0GTKu/4OpB4oOSC0D29L3rViFjMJpGmYf4IoxRrpSPo=; b=jmmiLqw6CbdM/5QCwCJMXE7QHc+oLuBEsWtKVO/gpWWLe5QedBKcDW2agT3JGp18E3 BAauRjo5LXM+59PgR0HoOscln9kW0r2I96yQuCegxbIbofNfN7LyYfVAawLkgZnB5yTk 2sblLMzQ5B/mfZiAevD9psFG3q3yOONzByr2LDYKTuw9Wq04X/c2ICjGMHemGkiyrJt/ pzs0GmymKZ57aZ/bDsT4xqDOmOMpCnBsQy1h54HsLHwVAyEOe92cvHHiHGqyUqq8ZcPE Umrbj2ra7gW6f85q3IsTnefzZg5+fhBT7AlGQKxxPbtiejxFZdvd8IzQHGu1m/p8OtVD DDPw== X-Gm-Message-State: AHPjjUhAAwf9BbKtlWQlESyietuvj+K7EsBvLZDU4+2xjkfSa7DGawTI 6xDVlj2Xh4dkHWl+Bv3GbE4VfyWioqslPXksXmE= X-Google-Smtp-Source: AOwi7QArZH700JLT5S86VIUMYzw9xCKQN645NylBBhYfvHHK7Wtx3f+WUGg0nj0IlmEqgObboRWy96DeWSjBt3fhJgw= X-Received: by 10.129.70.135 with SMTP id t129mr2595624ywa.41.1505873422762; Tue, 19 Sep 2017 19:10:22 -0700 (PDT) In-Reply-To: <87inge8skl.fsf@ericabrahamsen.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4002:c05::234 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:218558 Archived-At: --001a114d725c70cacf0559957a68 Content-Type: text/plain; charset="UTF-8" On Tue, Sep 19, 2017 at 2:14 PM Eric Abrahamsen wrote: > > I've played with this a bit, and am getting hung up on the (and pred... > part above. "pred" is nil unless someone's customized > `save-some-buffers-default-predicate', so in the majority of cases the > check won't even reach `buffer-offer-save'. > Wow! That (and pred.. ) section has been there since the genesis of files.el in 1991 by Roland McGrath: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=b4da00e92a09a2ee2cfb5df2ec111636c66e1597 (Thanks to vc-region-history.) It was named exiting.. and at some point got renamed to pred. So it looks like, by design buffer-offer-save was checked only at the time of exiting emacs i.e. during the call to save-some-buffers within save-buffer-kill-emacs. > I don't really know why that (and pred... is in there, and don't feel comfortable just yanking it out. Yes, given that it had always been there. The pred will be true automatically at the time of quitting emacs (aptly because earlier that var was called 'exiting').. but not when you call C-x s. So looks like along with setting buffer-offer-save to t, you would also need to set save-some-buffers-default-predicate to t locally for the special buffers you need saving. How about this as a solution? With this, you only need to set buffer-over-save. diff --git a/lisp/files.el b/lisp/files.el index 0c30d40c13..5c05e3168b 100644 --- a/lisp/files.el +++ b/lisp/files.el @@ -5188,15 +5188,15 @@ save-some-buffers (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)) + (and buffer-offer-save + (buffer-local-value + 'write-contents-functions buffer))) (or (not (functionp pred)) (with-current-buffer buffer (funcall pred))) (if arg Stefan? Eli? -- Kaushal Modi --001a114d725c70cacf0559957a68 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Tue, Sep 19= , 2017 at 2:14 PM Eric Abrahamsen <eric@ericabrahamsen.net> wrote:

I've played with this a bit, and am getting hung up on the (and pred...=
part above. "pred" is nil unless someone's customized
`save-some-buffers-default-predicate', so in the majority of cases the<= br> check won't even reach `buffer-offer-save'.
Wow! That (and pred.. ) section has been there since the genes= is of files.el in 1991 by Roland McGrath: http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=3Db4da00e92a09a2ee2c= fb5df2ec111636c66e1597

(Thanks to vc-region-hi= story.)

It was named exiting.. and at some point g= ot renamed to pred. So it looks like, by design buffer-offer-save was check= ed only at the time of exiting emacs i.e. during the call to save-some-buff= ers within save-buffer-kill-emacs.

> =C2=A0I do= n't really know why that (and pred... is in there, and don't feel c= omfortable just yanking it out.

Yes, given that it= had always been there.

The pred will be true auto= matically at the time of quitting emacs (aptly because earlier that var was= called 'exiting').. but not when you call C-x s.

So looks like along with setting buffer-offer-save to t, you would = also need to set save-some-buffers-default-predicate to t locally for the s= pecial buffers you need saving.

How about this as = a solution? With this, you only need to set buffer-over-save.
diff --git a/lisp/files.el b/lisp/files.el
index= 0c30d40c13..5c05e3168b 100644
--- a/lisp/files.el
+++ = b/lisp/files.el
@@ -5188,15 +5188,15 @@ save-some-buffers
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (and= (buffer-live-p buffer)
=C2=A0 <= /span> =C2=A0 =C2=A0(buffer-modified-p buffer)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(not (buffer-bas= e-buffer buffer))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(not (eq (aref (buffer-name buffer) 0) ?\s))
<= div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0(or
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 (buffer-file-name buffer)
=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and pred
=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(progn
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(s= et-buffer buffer)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(and buffer-offe= r-save (> (buffer-size) 0))))
- =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (buffer-local-value
- = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0'write-contents-functions buffer))
+ =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (and buffer-offer-save
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(buffer-local-value
+ =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &= #39;write-contents-functions buffer)))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(or (not (functionp pre= d))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(with-current-buffer buffer (funcall pred)))=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0(if arg

Stefan? Eli?
--

Kaushal Modi

--001a114d725c70cacf0559957a68--