all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 纪秀峰 <jixiuf@qq.com>, emacs-devel@gnu.org
Subject: Re: make pred customable in auto-save-visited-mode
Date: Sat, 31 Mar 2018 10:28:58 +0000	[thread overview]
Message-ID: <CAArVCkQForXTEChFY1WeBTe76bbBYDijqu3cugX-0e636grX8Q@mail.gmail.com> (raw)
In-Reply-To: <CAArVCkTmCuEumgqg3fR-r_Xsu8sWtFK89g489SYWV+JGMbV-qQ@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1822 bytes --]

Philipp Stephani <p.stephani2@gmail.com> schrieb am Sa., 31. März 2018 um
12:23 Uhr:

> Eli Zaretskii <eliz@gnu.org> schrieb am Sa., 31. März 2018 um 10:44 Uhr:
>
>>
>>
>> >   (setq auto-save--timer
>> >         (when auto-save-visited-mode
>> >           (run-with-idle-timer
>> >            auto-save-visited-interval :repeat
>> >            #'save-some-buffers :no-prompt
>> >            (lambda ()  ;;<————————————how about make 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.
>

Probably the second option is better because the first option would prevent
PRED from running for non-file-visiting buffers. Patch attached.

[-- Attachment #1.2: Type: text/html, Size: 2835 bytes --]

[-- Attachment #2: 0001-files.el-auto-save-visited-mode-Don-t-prompt-for-filen.txt --]
[-- Type: text/plain, Size: 1010 bytes --]

From 65efc1bfcfa8a9b14f325df0987bd233ec25edb3 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Sat, 31 Mar 2018 12:26:30 +0200
Subject: [PATCH] * files.el (auto-save-visited-mode): Don't prompt for
 filenames.

---
 lisp/files.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/files.el b/lisp/files.el
index 6a13a9d71a..83cba24336 100644
--- a/lisp/files.el
+++ b/lisp/files.el
@@ -436,8 +436,9 @@ auto-save-visited-mode
            auto-save-visited-interval :repeat
            #'save-some-buffers :no-prompt
            (lambda ()
-             (not (and buffer-auto-save-file-name
-                       auto-save-visited-file-name)))))))
+             (and buffer-file-name
+                  (not (and buffer-auto-save-file-name
+                            auto-save-visited-file-name))))))))
 
 ;; The 'set' part is so we don't get a warning for using this variable
 ;; above, while still catching code that _sets_ the variable to get
-- 
2.16.1


  reply	other threads:[~2018-03-31 10:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-30 16:59 make pred customable in auto-save-visited-mode 纪秀峰
2018-03-31  8:43 ` Eli Zaretskii
2018-03-31 10:23   ` Philipp Stephani
2018-03-31 10:28     ` Philipp Stephani [this message]
2018-03-31 10:45       ` Eli Zaretskii
2018-04-01 17:19         ` Philipp Stephani
2018-04-01 17:35           ` Eli Zaretskii
2018-04-01 19:51             ` Philipp Stephani
2018-04-02  4:44               ` Eli Zaretskii
2018-04-02 10:20                 ` Philipp Stephani
2018-03-31 10:42     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAArVCkQForXTEChFY1WeBTe76bbBYDijqu3cugX-0e636grX8Q@mail.gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=eliz@gnu.org \
    --cc=emacs-devel@gnu.org \
    --cc=jixiuf@qq.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.