all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@linkov.net>
To: HaiJun Zhang <netjune@outlook.com>
Cc: "34614@debbugs.gnu.org" <34614@debbugs.gnu.org>,
	Zhang Haijun <ccsmile2008@outlook.com>
Subject: bug#34614: 26.1.92; When reading input in mini-buffer, message to each area overide the input prompt
Date: Sun, 10 Nov 2019 01:05:08 +0200	[thread overview]
Message-ID: <87k188abx7.fsf@mail.linkov.net> (raw)
In-Reply-To: <SG2PR03MB3611693E41A7228711B8A8A0B77B0@SG2PR03MB3611.apcprd03.prod.outlook.com> (HaiJun Zhang's message of "Fri, 8 Nov 2019 01:46:45 +0000")

> I got it. Thanks for your explaination.
>
> It is strange that minibuffer-message-timeout is defined in C.
> But the timeout is processed in lisp (in the function minibuffer-message).
>
> 在 2019年11月8日 +0800 AM6:58,Juri Linkov <juri@linkov.net>,写道:
>
>         The prompt is replaced with the message from autorevert. And after
>         about 2~3 seconds (not fixed), the prompt comes back. What controls
>         the delay(2~3 seconds)? It is not the value of
>         minibuffer-message-timeout, which is 0.6. Is this expected?
>
>     The problem is that when auto-revert-handler calls minibuffer-message,
>     the current buffer is not the minibuffer, because functions that call
>     auto-revert-handler (auto-revert-notify-handler, auto-revert--end-lockout,
>     or auto-revert-buffers) change the current buffer using with-current-buffer.
>    
>     When the current buffer is not the minibuffer then minibuffer-message
>     just calls (message "%s" message) and then does
>     (sit-for (or minibuffer-message-timeout 1000000))
>
>         And it behaves differently with the following test code:
>        
>         (progn (run-with-idle-timer 3 nil
>         (lambda ()
>         (minibuffer-message "Reverting buffer `%s'." (buffer-name))))
>         (call-interactively 'find-file))
>        
>         This works well. The prompt is NOT replaced. The message is appended
>         to the end of the prompt and disappears after 0.6 second.
>
>     To work well like this, minibuffer-message should be called outside
>     of with-current-buffer code block. Yesterday I fixed Man-bgproc-sentinel
>     in bug#19064 to call minibuffer-message outside of with-current-buffer.
>    
>     But auto-revert functions require complete rewrite. I don't see
>     how this could be fixed with a simple change.

Actually I found a solution with two alternatives, and both works well,
and I can't decide which is less error-prone.  This patch shows both:

diff --git a/lisp/autorevert.el b/lisp/autorevert.el
index 9275513c8d..17678010f1 100644
--- a/lisp/autorevert.el
+++ b/lisp/autorevert.el
@@ -815,7 +815,13 @@ auto-revert-handler
     (when revert
       (when (and auto-revert-verbose
                  (not (eq revert 'fast)))
-        (message "Reverting buffer `%s'." (buffer-name)))
+        ;; 1.
+        (with-selected-window (old-selected-window)
+          (minibuffer-message "Reverting buffer `%s'." (buffer-name)))
+        ;; 2.
+        ;; (with-current-buffer (window-buffer (old-selected-window))
+        ;;   (minibuffer-message "Reverting buffer `%s'." (buffer-name)))
+        )
       ;; If point (or a window point) is at the end of the buffer, we
       ;; want to keep it at the end after reverting.  This allows one
       ;; to tail a file.






  reply	other threads:[~2019-11-09 23:05 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-22 12:17 bug#34614: 26.1.92; When reading input in mini-buffer, message to each area overide the input prompt Zhang Haijun
2019-02-22 13:20 ` Eli Zaretskii
2019-02-22 13:35   ` Zhang Haijun
2019-02-22 15:07 ` martin rudalics
2019-02-22 15:40   ` Zhang Haijun
2019-02-22 21:38     ` martin rudalics
2019-02-23  7:26       ` Eli Zaretskii
2019-02-23  7:54         ` martin rudalics
2019-02-23  8:25           ` Eli Zaretskii
2019-02-23  8:29             ` martin rudalics
2019-02-23  9:31               ` Eli Zaretskii
2019-02-23  9:57                 ` martin rudalics
2019-02-23 10:35                   ` Eli Zaretskii
2019-02-23 14:02                     ` martin rudalics
2019-02-23 16:51                       ` Eli Zaretskii
2019-02-24  8:44                         ` martin rudalics
2019-02-24 16:11                           ` Eli Zaretskii
2019-02-24 18:31                             ` martin rudalics
2019-02-24 19:02                               ` Eli Zaretskii
2019-02-25 10:11                                 ` martin rudalics
     [not found]     ` <5C7043C9.2090809@gmx.at>
2019-02-23  2:01       ` Zhang Haijun
2019-02-23  2:33         ` Zhang Haijun
2019-02-23  7:53           ` martin rudalics
2019-02-23  8:05             ` Zhang Haijun
2019-02-23  8:29               ` martin rudalics
2019-02-23  8:01           ` Eli Zaretskii
2019-02-23  8:29             ` Zhang Haijun
2019-11-06 22:02     ` Juri Linkov
2019-11-07 14:52       ` HaiJun Zhang
2019-11-07 22:12         ` Juri Linkov
2019-11-08  1:46           ` HaiJun Zhang
2019-11-09 23:05             ` Juri Linkov [this message]
2019-11-09 23:38               ` HaiJun Zhang
2019-11-10 21:22                 ` Juri Linkov
2019-11-12  0:49                   ` HaiJun Zhang
2019-11-12  8:10                     ` martin rudalics
2019-11-14  0:44                       ` Zhang Haijun
2019-11-12  1:15                   ` HaiJun Zhang
2019-11-12 20:53                     ` Juri Linkov
2019-11-14  0:46                       ` Zhang Haijun

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=87k188abx7.fsf@mail.linkov.net \
    --to=juri@linkov.net \
    --cc=34614@debbugs.gnu.org \
    --cc=ccsmile2008@outlook.com \
    --cc=netjune@outlook.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.