From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: make pred customable in auto-save-visited-mode Date: Sat, 31 Mar 2018 10:23:13 +0000 Message-ID: References: <83a7uo8wk5.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000026de130568b2bf18" X-Trace: blaine.gmane.org 1522491733 9486 195.159.176.226 (31 Mar 2018 10:22:13 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 31 Mar 2018 10:22:13 +0000 (UTC) Cc: =?UTF-8?B?57qq56eA5bOw?= , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 31 12:22:09 2018 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 1f2DeC-0002KK-O7 for ged-emacs-devel@m.gmane.org; Sat, 31 Mar 2018 12:22:08 +0200 Original-Received: from localhost ([::1]:36103 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2DgF-0002p0-Df for ged-emacs-devel@m.gmane.org; Sat, 31 Mar 2018 06:24:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59933) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f2DfW-0002o0-Rm for emacs-devel@gnu.org; Sat, 31 Mar 2018 06:23:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f2DfV-0002Xz-OH for emacs-devel@gnu.org; Sat, 31 Mar 2018 06:23:30 -0400 Original-Received: from mail-lf0-x22e.google.com ([2a00:1450:4010:c07::22e]:38122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f2DfR-0002T2-Ob; Sat, 31 Mar 2018 06:23:26 -0400 Original-Received: by mail-lf0-x22e.google.com with SMTP id u3-v6so15142442lff.5; Sat, 31 Mar 2018 03:23:25 -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 :cc; bh=9TlGNbRuJq21yDzEdLarWz9zvt64Ld3Qzsbw4C26zbw=; b=KcVqpAA5IAFhlJcR6s024Yh5Y/HfdH8WNiRrmP5Ck17jgH4WuGV/D3IInIB451BToz vuS2n0vE8LLRBAOEzCPtM1tiWnRfa3EjM9P7Nlv9vD1VvgV/Gvcq2fqoD7EVsMbNSj58 KeanQ71apYDO9tiafNTf+4i/2hDbgywrFR7T3WfK9uwlVlVg4QsXfgAaG5Vp9waCbeei fXqcLhskFR/a4P4rVjbNZczQ4H0sLNTO7hHf2NW6LI/nYOtXIVcGC7VWJD/x6XlHKmOc OA12FNPECvNj4mMRkO6hF9xD5dQGlv3iwqJawL1asmyyjSQJ2LsvL+XAwnzgJQiYj62L lHEQ== 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:cc; bh=9TlGNbRuJq21yDzEdLarWz9zvt64Ld3Qzsbw4C26zbw=; b=O6TUZPHoFqZpCg/V28ayHNL2yokwc+EriB81jEfyKI/4ADpe8vMzDlqgT9jV9xs5vi G0F/IdvkREQ2sCVoa0xV9cg2nsySql2lKrWCf6Lhvf1IYiax0J/Wso14vLnJejPuxL/v ILZ7xvKqEd+Vbr5Ism0PbvbV1oHsIKYhAc2AF56oD+9mujKwqmALb4MtE1Z7QZcyxCKD Skrg6vIYpXs3zLAXhj5SmDX3s4JV0NkTChUfu+qw3OyMaIr+zxKyctuUAfK/elThNNfb 0owjbCNaqWuCTyxjTT31Wl+pa/HkhaRcDguockYrKSJVFrqnp8qZ16Gwy+DXwC/CQRhy ivuA== X-Gm-Message-State: ALQs6tCY4s8JadQMq2PMylqM2xFRadY30QjWbyBzxxB4MBGjusoCdTq5 KPgIy8FcSYKlsvIfYWr4s5PH3A3VpxOag4nxLoFYpg== X-Google-Smtp-Source: AIpwx4+DB3ZmPIv0fwUacvyJPJ7834jn66n18B0lO/cIeOy9mifzL4C2qUCO9AfkWYMDN5HJ2Ku2BV7t+ZkIYm0OZ8I= X-Received: by 2002:a19:136a:: with SMTP id j103-v6mr1405252lfi.19.1522491804014; Sat, 31 Mar 2018 03:23:24 -0700 (PDT) In-Reply-To: <83a7uo8wk5.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::22e 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:224199 Archived-At: --00000000000026de130568b2bf18 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Eli Zaretskii schrieb am Sa., 31. M=C3=A4rz 2018 um 10:44 Uh= r: > > From: =E7=BA=AA=E7=A7=80=E5=B3=B0 > > Date: Sat, 31 Mar 2018 00:59:19 +0800 > > Feedback-ID: esmtp:qq.com:bgforeign:bgforeign1 > > > > When I enable auto-save-visited-mode and start an ediff merge session > > It always prompt me save "*ediff-merge*=E2=80=9D to a file. > > Why is that a problem? *ediff-merge* is a buffer where you prepare > the merge, and that merge will eventually be saved to some file, > right? So it doesn't sound wrong to offer to save it. > However, auto-saving should probably not prompt for filenames. That's at least the intention of the :noprompt argument here. > > > (setq auto-save--timer > > (when auto-save-visited-mode > > (run-with-idle-timer > > auto-save-visited-interval :repeat > > #'save-some-buffers :no-prompt > > (lambda () ;;<=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94how about ma= ke this customable > > (not (and buffer-auto-save-file-name > > auto-save-visited-file-name))))))) > > Letting users customize a non-trivial function is not the best way of > affecting this behavior. I think you can have what you want by adding > a function to ediff-startup-hook, and in that function set > buffer-auto-save-file-name of the *ediff-merge* buffer to nil. > > I agree that customization isn't the best solution here. However, I'm suprised that `save-some-buffers' still prompts even if :noprompt is passed= . The issue might be in `save-some-buffers': Its docstring says "If PRED is t, then certain non-file buffers will also be considered.", but later it only checks whether PRED is non-nil: (or (buffer-file-name buffer) (with-current-buffer buffer (or (eq buffer-offer-save 'always) (and pred buffer-offer-save (> (buffer-size) 0))))) Maybe instead of `pred' here we should say (eq pred t). Alternative, the predicate lambda should check whether `buffer-file-name' is non-nil. --00000000000026de130568b2bf18 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Eli Za= retskii <eliz@gnu.org> schrieb am= Sa., 31. M=C3=A4rz 2018 um 10:44=C2=A0Uhr:
> From: =E7=BA=AA=E7=A7=80=E5=B3=B0 <jixiuf@qq.com>
> Date: Sat, 31 Mar 2018 00:59:19 +0800
> Feedback-ID: esmtp:qq.com:bgforeign:bgforeign1
>
> When I enable=C2=A0 auto-save-visited-mode and start an ediff merge se= ssion
> It always prompt me save "*ediff-merge*=E2=80=9D to a file.

Why is that a problem?=C2=A0 *ediff-merge* is a buffer where you prepare the merge, and that merge will eventually be saved to some file,
right?=C2=A0 So it doesn't sound wrong to offer to save it.

However, auto-saving should probably not prompt fo= r filenames. That's at least the intention of the :noprompt argument he= re.
=C2=A0

>=C2=A0 =C2=A0(setq auto-save--timer
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(when auto-save-visited-mode
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(run-with-idle-timer
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 auto-save-visited-interval :r= epeat
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #'save-some-buffers :no-p= rompt
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (lambda ()=C2=A0 ;;<=E2=80= =94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94=E2=80=94= =E2=80=94=E2=80=94=E2=80=94how about make this customable
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (not (and buffer-auto-= save-file-name
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 auto-save-visited-file-name)))))))

Letting users customize a non-trivial function is not the best way of
affecting this behavior.=C2=A0 I think you can have what you want by adding=
a function to ediff-startup-hook, and in that function set
buffer-auto-save-file-name of the *ediff-merge* buffer to nil.


I agree that customization isn't t= he best solution here. However, I'm suprised that `save-some-buffers= 9; still prompts even if :noprompt is passed.
The issue might be = in `save-some-buffers': Its docstring says "If PRED is t, then cer= tain non-file buffers will also be considered.", but later it only che= cks whether PRED is non-nil:

=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(b= uffer-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(with-current-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(or (eq buffer-offer-save 'always)
=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 pred buffer-offer-save (> (buffer-size) 0)))))

Maybe instead of `pred' here we should say (eq pre= d t). Alternative, the predicate lambda should check whether `buffer-file-n= ame' is non-nil.
--00000000000026de130568b2bf18--