From: Mihai Bazon <mihai@bazon.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 4093@emacsbugs.donarmstrong.com
Subject: bug#4093: Overlay keymap and timers
Date: Tue, 11 Aug 2009 19:49:39 +0300 [thread overview]
Message-ID: <3db84103d8c5db51b3dd6bba4c267a84@bazon.net> (raw)
In-Reply-To: <jwv8whr1wxp.fsf-monnier+emacsbugreports@gnu.org>
Indeed, that function looks frightening.
It's worth noting that XEmacs doesn't have this problem.
But the code differs drastically.. Hard to figure out a simple fix.
-M
Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> >> > Yes, this is a really bad thing - sometimes, ie when you need to do
> >> > just that.
> >> The code in keyboard.c reads the set of active keymaps before reading
> >> the next event. That's most likely the explanation for this behavior.
> > What you are saying does actually make sense. If it set the keymap
> > *before* serving an event, it should work fine. But I think what
> > happens is that it sets the keymap *after* executing an event...
>
> > I looked at the code but couldn't figure out where is the keymap
> > computed. Could you point it out?
>
> The relevant code is in .... read_key_sequence! (only those who've had
> to deal with this function understand the "....").
>
> You'll see that it first collects all the active keyamps (see where it
> calls current_minor_maps), and later on calls read_char (which can do
> redisplay, run timers, run process filters, etc...).
>
> Basically the problem in the case of changing the keymap from a timer
> comes down to:
>
> what happens if the use presses C-c, then your code runs then the user
> presses C-d: should the C-c C-d be looked up in the original keymaps
> or in the new keymaps?
>
> you worry about the case where the timer is run before the C-c, but from
> Emacs's current point of view, it's no different whether the timer is
> run after 1 key-press, or after 2 key-presses, or after 0 key-presses.
>
> We can probably change the code to collect the list of active keymaps
> later (e.g. right after the first key-press).
> But maybe an alternative is to provide some way for your Elisp code to
> cause a jump back to `replay_sequence' so that you can force the C-c C-d
> to be interpreted in the new keymaps even if the C-c had already been
> pressed when your code was run.
>
> In any case, this function is a monster, so I'll only consider changes
> to it if it makes it simpler (typically by moving code out of it into
> some new function). Maybe the idea of a new "need-to-replay-sequence"
> variable could be a good way to simplify the code: we could maybe
> arrange for most other "goto replay_sequence" to use this new var
> (i.e. replace the current code that checks some relevant condition, by
> some piece of code elsewhere (where that condition is created) which
> sets the var).
>
>
> Stefan
next prev parent reply other threads:[~2009-08-11 16:49 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-09 13:49 bug#4093: Overlay keymap and timers Mihai Bazon
2009-08-09 20:56 ` Lennart Borgman
2009-08-09 21:23 ` Mihai Bazon
2009-08-10 4:06 ` Stefan Monnier
2009-08-10 6:55 ` Mihai Bazon
2009-08-10 16:25 ` Stefan Monnier
2009-08-10 16:30 ` Lennart Borgman
2009-08-10 17:38 ` Stefan Monnier
2009-08-10 17:42 ` Lennart Borgman
2009-08-10 18:17 ` Stefan Monnier
2009-08-10 18:32 ` Lennart Borgman
2009-08-10 18:26 ` Mihai Bazon
2009-08-11 16:49 ` Mihai Bazon [this message]
2009-08-13 17:33 ` Stefan Monnier
2009-08-13 17:49 ` Mihai Bazon
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=3db84103d8c5db51b3dd6bba4c267a84@bazon.net \
--to=mihai@bazon.net \
--cc=4093@emacsbugs.donarmstrong.com \
--cc=monnier@iro.umontreal.ca \
/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.