From: Frank Fischer <frank-fischer@shadow-soft.de>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 13793@debbugs.gnu.org, 13709@debbugs.gnu.org,
Michael Kifer <kifer@cs.stonybrook.edu>
Subject: bug#13709: bug#13793: 24.3.50; M-x broken in viper and X
Date: Mon, 25 Feb 2013 21:16:57 +0100 [thread overview]
Message-ID: <20130225201657.GA10969@susi> (raw)
In-Reply-To: <jwvtxp1awak.fsf-monnier+emacs@gnu.org>
On 02/24, Stefan Monnier wrote:
> The same commit caused a problem in Evil as well (see bug#13709), and
> I hope the problem is the same and can be fixed in the same way, but I'm
> also having trouble figuring out what's happening in that case.
>
> If someone familiar with Evil or Viper's keymap tricks could investigate
> a bit more to try and see where the behavior changes, I can then
> hopefully see how it relates to my read-key-sequence changes.
Coincidentally, I'm involved with Evil, but I've never tried to debug
Emacs' C code. But I think I succeeded and can explain what's going
on. I will restrict to Evil, because I know it better than viper. I
start with a description of what Evil does and afterwards describe the
problem with the new code.
The problem, as I said, is that Evil needs to differentiate between a
plain ESC key and a meta key sequence. Evil does the following. It has
a special minor mode `evil-esc-mode` along with its keymap
`evil-esc-map`. This keymap has only one binding, (kbd "ESC") is bound
to a function `evil-esc`. This function is very simple (I removed some
code, but they main idea should become clear)
(defun evil-esc (arg)
"Wait for further keys within `evil-esc-delay'.
Otherwise send [escape]."
(interactive "P")
(if (sit-for evil-esc-delay t)
(push 'escape unread-command-events)
(push last-command-event unread-command-events)
;; preserve prefix argument
(setq prefix-arg arg))
;; disable interception for the next key sequence
(evil-esc-mode -1)
(setq this-command last-command)
(add-hook 'pre-command-hook #'evil-turn-on-esc-mode nil t))
The function waits for the next event. If it arrives, the (kbd "ESC")
event is unread, and evil-esc-mode is disabled so that it does not
call again `evil-esc`. If no next event arrives the event 'escape is
unread so whatever command is bound to 'escape will be called.
`evil-esc-mode` will be reenabled after the next command completed.
Note that an event like M-x (in the terminal) generates two events in
quick succession, namely (kbd "ESC") and "x", so the first case
happens. In GUI mode the function `evil-esc` is never called because
here M-x generates another event (some large integer). This event is
transformed to an ESC sequence, too, but not using `evil-esc` but
within the function `access_keymap_1` in file `keymap.c`.
If this function detects that the event is a meta event, it looks for
the prefix map of (kbd "ESC") in the keymap that has been passed to
the function in the "map" argument. Here comes the problem.
The function `follow_key` has been changed by the problematic commit.
Formerly severall keymaps have been passed in an array. Each keymap
has been checked in turn for a binding. One of the keymaps is
`evil-esc-map`. If this keymap is checked no binding is found. So the
next keymap is checked an it may contain a binding for M-x so this
binding is used.
After the commit all keymaps are collected in one single "super"
keymap, that contains all keymaps as "parents" (is this correct?). Now
`access_keymap_1` gets only called once for this super keymap. Again
this function tries to find (kbd "ESC") in this keymap. This will
return the binding of `evil-esc`, which is not a prefix keymap so no
binding will be found. Because of how keymaps work only the first
binding of (kbd "ESC") in one of the parent keymaps will be returned,
and this is `evil-esc`.
The get the old behaviour, `access_keymap_1` would have to check all
parent keymaps in turn. For each keymap that bind (kbd "ESC") to
another keymap it would have to check the second key.
I hope this helps. Sorry that I do not provide a patch, but currently
my "Emacs-C" is too bad for this.
Anyhow, the real problem is to "multiplex" the (kbd "ESC") event in
the terminal. Any solution that sends 'escape instead of (kbd "ESC")
if another event arrives within a short period should solve the
problem.
If my explanations are unclear, please tell ;)
Best regards,
Frank
next prev parent reply other threads:[~2013-02-25 20:16 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-23 11:35 bug#13793: 24.3.50; M-x broken in viper and X Frank Fischer
2013-02-25 3:55 ` Stefan Monnier
2013-02-25 20:16 ` Frank Fischer [this message]
2013-02-25 21:35 ` bug#13709: " Stefan Monnier
2013-02-26 8:57 ` Frank Fischer
2013-02-26 14:10 ` Stefan Monnier
2013-02-26 14:56 ` Frank Fischer
2013-02-26 18:12 ` bug#13709: " Stefan Monnier
2013-02-26 20:17 ` Frank Fischer
2013-02-27 17:59 ` bug#13709: " Frank Fischer
2013-02-27 19:08 ` Stefan Monnier
[not found] ` <76c7b8b296b248bf915de72349cfc0c9@HUBCAS2.cs.stonybrook.edu>
2013-02-26 7:17 ` bug#13709: " Michael Kifer
2013-06-15 12:25 ` Stefano Zacchiroli
2013-06-22 21:56 ` Stefan Monnier
2013-06-24 14:37 ` Stefano Zacchiroli
2013-06-25 16:17 ` Stefan Monnier
2013-07-01 16:32 ` Stefano Zacchiroli
2013-07-01 23:27 ` Stefan Monnier
[not found] ` <5fc5643667924a7eb32800ba7465bd7e@HUBCAS1.cs.stonybrook.edu>
2013-07-02 3:56 ` Michael Kifer
2013-07-02 7:55 ` Michael Kifer
2013-07-02 8:44 ` Stefano Zacchiroli
2013-07-02 14:41 ` Michael Kifer
2013-07-02 15:47 ` Glenn Morris
2013-07-02 16:39 ` Michael Kifer
2013-07-02 18:35 ` Glenn Morris
2013-07-02 18:18 ` Stefan Monnier
[not found] ` <435158c2008843bb9bd4a75345251bbe@HUBCAS1.cs.stonybrook.edu>
2013-06-22 23:49 ` Michael Kifer
2013-06-23 2:28 ` Stefan Monnier
2013-06-23 3:26 ` Michael Kifer
2013-07-04 21:13 ` Michael Kifer
2013-07-05 22:54 ` Michael Kifer
2013-07-06 19:12 ` Glenn Morris
2013-07-06 20:33 ` Michael Kifer
2013-07-06 21:01 ` Glenn Morris
2013-07-06 21:16 ` Michael Kifer
2013-07-06 21:27 ` Stephen Berman
2013-07-06 21:39 ` Stephen Berman
2013-07-07 19:41 ` Michael Kifer
2013-07-10 8:29 ` Stefan Monnier
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=20130225201657.GA10969@susi \
--to=frank-fischer@shadow-soft.de \
--cc=13709@debbugs.gnu.org \
--cc=13793@debbugs.gnu.org \
--cc=kifer@cs.stonybrook.edu \
--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.