[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21747: 25.0.50; while-no-input breaks kbd event handling when called
From: |
Tassilo Horn |
Subject: |
bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook |
Date: |
Sat, 24 Oct 2015 11:49:01 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Eli Zaretskii <eliz@gnu.org> writes:
>> From: Tassilo Horn <tsdh@gnu.org>
>> Cc: 21747@debbugs.gnu.org
>> Date: Sat, 24 Oct 2015 10:53:12 +0200
>>
>> > Given that, maybe I'm missing something, but what did you expect? The
>> > above literally says that Emacs shall loop indefinitely after
>> > performing each command until there's more input. And that's what you
>> > get. Right?
>>
>> Correct, but when the input eventually arrives, I expect to see its
>> effects as if it had arrived outside of the `while-no-input'.
>
> That effect was not yet produced, because the arriving input was not
> yet consumed by the time while-no-input returns, that input is still
> "pending". For it to be consumed and acted upon, you need another
> crank of the Emacs main loop and another redisplay cycle (which is
> again delayed by the while-no-input loop). So the one-character delay
> goes on forever.
Ah, ok. I changed `while-no-input' locally to
(defmacro while-no-input (&rest body)
"Execute BODY only as long as there's no pending input.
If input arrives, that ends the execution of BODY,
and `while-no-input' returns t. Quitting makes it return nil.
If BODY finishes, `while-no-input' returns whatever value BODY produced."
(declare (debug t) (indent 0))
(let ((catch-sym (make-symbol "input")))
`(with-local-quit
(catch ',catch-sym
(let ((throw-on-input ',catch-sym))
(or (input-pending-p)
(progn
(sit-for 0) ;; <== just inserted that
,@body)))))))
which seems to fix the issue somehow. With your description, what I
think it does is that it forces the display of the effects of the
command which has interrupted the `while-no-input' in the previous
cycle.
>> So the question is: should `while-no-input' call (sit-for 0) as the
>> first statement in the `progn' or should functions using
>> `while-no-input' do that on their own? I'd prefer the former because
>> the current behavior is not really obvious (at least not to me nor
>> Artur).
>
> I don't have enough experience in using while-no-input to answer that.
> Perhaps others could chime in and voice their opinions. Maybe we
> should have a discussion on emacs-devel about this (because many
> people who read emacs-devel don't read the bug list).
Yes, I think that would be a good idea. Originally, `while-no-input'
used (not (sit-for 0 0 t)) instead of (input-pending-p) which I think is
pretty equivalent except that the former forces a redisplay. I've added
Kim to the Cc, so maybe he can speak up.
--8<---------------cut here---------------start------------->8---
commit 790e0ef78e306edc0664b8fa5a584c62ec01b444
Author: Kim F. Storm <storm@cua.dk>
Date: Mon Sep 11 22:21:55 2006 +0000
(sit-for): Rework to use input-pending-p and cond.
Return nil input is pending on entry also for SECONDS <= 0.
(while-no-input): Use input-pending-p instead of sit-for.
diff --git a/lisp/subr.el b/lisp/subr.el
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -2391,13 +2394,13 @@
(defmacro while-no-input (&rest body)
"Execute BODY only as long as there's no pending input.
If input arrives, that ends the execution of BODY,
and `while-no-input' returns t. Quitting makes it return nil.
If BODY finishes, `while-no-input' returns whatever value BODY produced."
(declare (debug t) (indent 0))
(let ((catch-sym (make-symbol "input")))
`(with-local-quit
(catch ',catch-sym
(let ((throw-on-input ',catch-sym))
- (or (not (sit-for 0 0 t))
- ,@body))))))
+ (or (input-pending-p)
+ ,@body))))))
--8<---------------cut here---------------end--------------->8---
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook,
Tassilo Horn <=
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Artur Malabarba, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Artur Malabarba, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Eli Zaretskii, 2015/10/24
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/25
- bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook, Tassilo Horn, 2015/10/25