read-char-from-minibuffer ends keyboard macro recording

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

read-char-from-minibuffer ends keyboard macro recording

Filipp Gunbin
Hi, there's a problem with recent changes to read-char-from-minibuffer
(commit 04ab67470706f1c66bdf08e4078ea3dffd79b41e): this function invokes
(discard-input) at the very beginning, thus making it impossible to use
it as part of the keyboard macro (through zap-to-char or otherwise).

Filipp

Reply | Threaded
Open this post in threaded view
|

Re: read-char-from-minibuffer ends keyboard macro recording

Juri Linkov-2
> Hi, there's a problem with recent changes to read-char-from-minibuffer
> (commit 04ab67470706f1c66bdf08e4078ea3dffd79b41e): this function invokes
> (discard-input) at the very beginning, thus making it impossible to use
> it as part of the keyboard macro (through zap-to-char or otherwise).

'(discard-input)' was added to swallow some initial events.
Without it, 'sit-for' in 'minibuffer-message' doesn't wait
2 seconds to display the message.  Such events occur only
at Emacs startup, and they need to be discarded to display
the message for 2 seconds when the minibuffer is activated
to ask a question about loading the desktop or visiting
a file with local variables loaded from the desktop.

We need first to solve the problem with initial events
before removing '(discard-input)'.

Reply | Threaded
Open this post in threaded view
|

Re: read-char-from-minibuffer ends keyboard macro recording

Juri Linkov-2
>> Hi, there's a problem with recent changes to read-char-from-minibuffer
>> (commit 04ab67470706f1c66bdf08e4078ea3dffd79b41e): this function invokes
>> (discard-input) at the very beginning, thus making it impossible to use
>> it as part of the keyboard macro (through zap-to-char or otherwise).
>
> '(discard-input)' was added to swallow some initial events.
> Without it, 'sit-for' in 'minibuffer-message' doesn't wait
> 2 seconds to display the message.  Such events occur only
> at Emacs startup, and they need to be discarded to display
> the message for 2 seconds when the minibuffer is activated
> to ask a question about loading the desktop or visiting
> a file with local variables loaded from the desktop.
>
> We need first to solve the problem with initial events
> before removing '(discard-input)'.

Startup emits various events such as CONFIG_CHANGED_EVENT,
FOCUS_IN_EVENT, MOVE_FRAME_EVENT, ICONIFY_EVENT.

I don't know why run-with-timer doesn't allow handling these events,
but run-with-idle-timer does.  So here's the fix:

diff --git a/lisp/subr.el b/lisp/subr.el
index eaec223585..20daed623f 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2707,7 +2707,6 @@ read-char-from-minibuffer
 When HISTORY is a symbol, then allows navigating in a history.
 The navigation commands are `M-p' and `M-n', with `RET' to select
 a character from history."
-  (discard-input)
   (let* ((empty-history '())
          (map (if (consp chars)
                   (or (gethash chars read-char-from-minibuffer-map-hash)
@@ -2847,7 +2846,6 @@ y-or-n-p
     answer (x-popup-dialog t `(,prompt ("Yes" . act) ("No" . skip)))))
      (t
       (setq prompt (funcall padded prompt))
-      (discard-input)
       (let* ((empty-history '())
              (str (read-from-minibuffer
                    prompt nil
@@ -4622,7 +4620,7 @@ do-after-load-evaluation
   byte-compile-current-file
   byte-compile-root-dir)))
       (byte-compile-warn "%s" msg))
-  (run-with-timer 0 nil
+  (run-with-idle-timer 0 nil
   (lambda (msg)
     (minibuffer-message "%s" msg))
   msg)))))

Reply | Threaded
Open this post in threaded view
|

Re: read-char-from-minibuffer ends keyboard macro recording

Filipp Gunbin
Thanks, this looks like a good fix.

Filipp