From: Tassilo Horn <tsdh@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 21747@debbugs.gnu.org
Subject: bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook
Date: Sat, 24 Oct 2015 10:53:12 +0200 [thread overview]
Message-ID: <877fmcejgn.fsf@gnu.org> (raw)
In-Reply-To: <838u6sy9s1.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 24 Oct 2015 11:02:06 +0300")
Eli Zaretskii <eliz@gnu.org> writes:
>> With emacs -Q, evaluate the following in *stratch*:
>>
>> --8<---------------cut here---------------start------------->8---
>> (defun th/loop-on-no-input ()
>> (while-no-input (while t t)))
>>
>> (add-hook 'post-command-hook #'th/loop-on-no-input)
>> --8<---------------cut here---------------end--------------->8---
>>
>> After having done that, the effect of pressing any key is deferred
>> until you press the next key. E.g., typing "foo" just inserts "fo",
>> but after an additional C-b (the exact key doesn't matter) you'll see
>> "foo".
>
> I think what's deferred is redisplay, not the effect of pressing a
> key. IOW, the key does its thing, the character is inserted into the
> current buffer, but redisplay doesn't run, and so you don't see that
> inserted character, and think it was not inserted in the first place.
Yes, you are right.
> 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'.
> If I change the hook function to this:
>
> (defun th/loop-on-no-input ()
> (while-no-input (while t (sit-for 0))))
>
> then the "delay" goes away
Indeed, that works.
> (although I still don't recommend such virulent post-command hooks, as
> they make an otherwise idle Emacs suck all the juice out of a single
> execution unit).
>
> Am I missing something here?
Obviously, `aggressive-indent-mode's `post-command-hook' is no infinite
loop but just a reasonably costly operation which should have the
ability to be aborted when the user keeps on typing:
https://github.com/Malabarba/aggressive-indent-mode/blob/master/aggressive-indent.el#L357
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).
Bye,
Tassilo
next prev parent reply other threads:[~2015-10-24 8:53 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-24 7:42 bug#21747: 25.0.50; while-no-input breaks kbd event handling when called from post-command-hook Tassilo Horn
2015-10-24 8:02 ` Eli Zaretskii
2015-10-24 8:53 ` Tassilo Horn [this message]
2015-10-24 9:14 ` Eli Zaretskii
2015-10-24 9:49 ` Tassilo Horn
2015-10-24 10:30 ` Artur Malabarba
2015-10-24 10:52 ` Eli Zaretskii
2015-10-24 12:13 ` Tassilo Horn
2015-10-24 12:45 ` Eli Zaretskii
2015-10-24 13:30 ` Tassilo Horn
2015-10-24 13:57 ` Artur Malabarba
2015-10-24 14:06 ` Eli Zaretskii
2015-10-24 14:05 ` Eli Zaretskii
2015-10-25 7:19 ` Tassilo Horn
2015-10-25 8:10 ` Tassilo Horn
2015-10-25 9:25 ` Tassilo Horn
2015-10-25 18:45 ` Eli Zaretskii
2015-10-25 18:49 ` Tassilo Horn
2015-10-25 20:10 ` Stefan Monnier
2015-10-26 6:57 ` Tassilo Horn
2015-10-25 18:43 ` Eli Zaretskii
2015-10-24 12:46 ` Tassilo Horn
2015-10-25 14:43 ` Artur Malabarba
2015-10-25 18:50 ` Eli Zaretskii
2015-10-26 0:27 ` Artur Malabarba
2015-10-26 3:32 ` Eli Zaretskii
2015-10-26 13:43 ` Tassilo Horn
2015-10-24 10:35 ` 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=877fmcejgn.fsf@gnu.org \
--to=tsdh@gnu.org \
--cc=21747@debbugs.gnu.org \
--cc=eliz@gnu.org \
/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.