From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel Subject: Re: [Emacs-diffs] emacs-26 ee512e9: Ignore buffers whose name begins with a space in save-some-buffers Date: Fri, 22 Sep 2017 09:54:37 -0700 Message-ID: <874lruishe.fsf@ericabrahamsen.net> References: <20170918202953.21378.63492@vcs0.savannah.gnu.org> <20170918202955.5043420AC4@vcs0.savannah.gnu.org> <87inge8skl.fsf@ericabrahamsen.net> <878th9z40r.fsf@ericabrahamsen.net> <831sn0fpk9.fsf@gnu.org> <87o9q3lt8s.fsf@ericabrahamsen.net> <83zi9ncjg2.fsf@gnu.org> <87d16iivcx.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1506099301 9617 195.159.176.226 (22 Sep 2017 16:55:01 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 22 Sep 2017 16:55:01 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 22 18:54:54 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 1dvRE5-000203-Mz for ged-emacs-devel@m.gmane.org; Fri, 22 Sep 2017 18:54:53 +0200 Original-Received: from localhost ([::1]:60180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvREC-0003T6-WF for ged-emacs-devel@m.gmane.org; Fri, 22 Sep 2017 12:55:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50197) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dvRE5-0003Sp-Cf for emacs-devel@gnu.org; Fri, 22 Sep 2017 12:54:54 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dvRE1-0006yY-Cu for emacs-devel@gnu.org; Fri, 22 Sep 2017 12:54:53 -0400 Original-Received: from [195.159.176.226] (port=51123 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dvRE1-0006y7-5E for emacs-devel@gnu.org; Fri, 22 Sep 2017 12:54:49 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dvRDr-0001Ht-HT for emacs-devel@gnu.org; Fri, 22 Sep 2017 18:54:39 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 49 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:5lmc0+9fSXND2w2md5hcJCi5WSs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 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:218690 Archived-At: Stefan Monnier writes: >> (and pred >> (progn >> (set-buffer buffer) >> (and buffer-offer-save (> (buffer-size) 0)))) > >> Unless a user has customized `save-some-buffers-default-predicate', PRED >> is only t when Emacs is exiting. > > But it's also non-nil in some other cases (e.g. it was non-nil when > the function was called as a part of running a command in PCL-CVS, and > presumably the VC-Dir interface should do the same, where the pred` is > used to only prompt saving of buffers within the relevant directory). Hence my reluctance to go trampling on the logic! All kinds of packages must make use of this behavior. >> If we can come to a consensus about those two questions, it shouldn't be >> hard to come up with a clean solution. > > How 'bout turning buffer-offer-save into a 3-value variable (instead of > a boolean): > - nil = as before (i.e. never) > - t = as before (i.e. only when pred is non-nil and the buffer is not empty) > - `always` = regardless of pred and buffer's size (i.e. always) So like this? (or (buffer-file-name buffer) (eq buffer-offer-save 'always) (and pred (progn (set-buffer buffer) (and buffer-offer-save (> (buffer-size) 0))))) But think about it from the point of view of documentation: how do you explain the interaction between `buffer-offer-save' and PRED? "If b-o-s is t and PRED is t the buffer will be saved, unless b-o-s is 'always in which case it doesn't matter what PRED is, unless PRED is a function in which case the only thing that matters is what that function returns, so long as buffer has a file name." I'm exaggerating for effect, but still. I still don't quite understand the use of passing a boolean in for PRED. Maybe we should start by writing the docs, then the code.