unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Frank Fischer <frank-fischer@shadow-soft.de>
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: Tue, 26 Feb 2013 13:12:01 -0500	[thread overview]
Message-ID: <jwvtxoz7z1r.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20130226145608.GC31613@bayes.mathematik.tu-chemnitz.de> (Frank Fischer's message of "Tue, 26 Feb 2013 15:56:08 +0100")

>> Maybe "enable evil-esc-mode in post-command-hook and disable it in
>> pre-command-hook" might work?
> I'm a little bit afraid of situations where a new binding is defined
> but pre-command-hook has not been called (to restore the original
> definition of `input-decode-map`). For example if a new binding is
> established in a hook or when Emacs starts. If evil is loaded before
> that binding is defined, i.e. input-decode-map is already 'patched',
> then it may fail. Of course one could start with an unpatched
> input-decode-map and wait for the first post-command-hook.

Agreed, using post/pre-command-hook is messy.  Other problems come up
with recursive edits (and minibuffers), where the pre-command-hook can
end up run twice without intervening post-command-hook and
post-command-hook can similarly be run twice without an intervening
pre-command-hook.

> So the question is: is it guaranteed that a post-command-hook will be
> called when Emacs starts and before any user input, and that a call to
> `define-key` will always be preceded by a pre-command-hook and
> followed by a post-command-hook, no matter how it is called?

No, basically with pre/post-command-hook, nothing is guaranteed.

> This includes any possibility to call `define-key` from a hook or
> so.  I just do not have the overview to give a reliable judgement on
> this.  IMO using an advice is more direct and simpler in this
> particular situation, although I really don't like it.

I think what we really care about is to detect "called from
read-key-sequence".  How 'bout:

(defvar evil-normal-esc-map (lookup-key input-decode-map [?\e]))
(define-key input-decode-map
  [?\e] `(menu-item "" ,evil-normal-esc-map
          :filter ,(λ (map)
                     (if (and (not evil-inhibit-escape)
                              (equal (this-single-command-keys) [?\e])
                              (sit-for 0.1))
                         [escape] map))))

So the special ESC=>escape mapping only takes place if the whole
last key-sequence so far is just [?\e], i.e. either we're still in
read-key-sequence, or the last read-key-sequence only read [?\e], which
should ideally never happen because it should have been mapped to [escape].


        Stefan





  reply	other threads:[~2013-02-26 18:12 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   ` bug#13709: " Frank Fischer
2013-02-25 21:35     ` 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             ` Stefan Monnier [this message]
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

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvtxoz7z1r.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=13709@debbugs.gnu.org \
    --cc=13793@debbugs.gnu.org \
    --cc=frank-fischer@shadow-soft.de \
    --cc=kifer@cs.stonybrook.edu \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).