Subject: bug#4093: Overlay keymap and timers

From: Mihai Bazon <[email-masked]>
Date: Mon, 10 Aug 2009 21:26:23 +0300

Stefan Monnier <[email-masked]> wrote:
> 
> 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?

That's a good question.  As an user, if I start typing a combined key
binding then I would expect it to work regardless of whatever happened
in a timer in between.  So indeed, it can be a problem to allow a timer
to set a new keymap in this case.

But if there's no prefix key already typed, it would be great if
use-local-map actually did what it's supposed to do, even when ran with
a timer.

Perhaps the proper solution would involve saving the current keymap when
a prefix key has been pressed, and use that keymap until it results in a
command or it's canceled.  If a timer changes the keymap in between, the
new keymap should apply only after any pending key binding has been
finished.  Not sure if this is doable...

I'm sorry I don't have any knowledge of Emacs internals, and only
limited Lisp knowledge anyway, but I'd love to see a decent work-around
for this...

Cheers,
-Mihai