[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: M-x mystery

From: Drew Adams
Subject: RE: M-x mystery
Date: Mon, 2 Jan 2012 08:34:33 -0800

> in trying to debug some bad interactions between vip.el (VI emulation)
> and icicles, I've come against an obstable I can't surmount: M-x
> sometimes ceases to be M-x and becomes instead ESC-x.  
> Minimal example: I run "emacs -q -l foo.el" where foo.el 
> contains this code:
> (defun doit ()
>   "run test"
>   (interactive)
>   (defvar vip-mode-map (make-keymap))
>   (define-key vip-mode-map "\e" 'kill-line)
>   (use-local-map vip-mode-map))
> Then I into a scratch buffer and type M-x doit<RET> -- so far so good.
> After that, when I type M-x the behavior, it is as if I had typed ESC
> and x: the current line is killed and an x is inserted.
> Any ideas about what I'm doing wrong?

`M-x' is typically the same as `ESC x' (it is translated from `ESC x').  If you
redefine `ESC' as a command (`kill-line') then it can no longer continue to act
as a prefix key.  So both `M-x' and `ESC x' are then undefined.

(Also, why are you doing `make-keymap' here?  Why is that necessary?  Why not
just invoke `doit' after you have loaded Vip, so the keymap will be already

FYI: You can customize the key that Icicles uses to invoke
`icicle-execute-extended-command' (by default it is `M-x').  Just customize
option `icicle-top-level-key-bindings', changing the entry for that command.

Anyway, I tried to follow your recipe.  It seems incomplete.  You start with
`emacs -q`, which is good, but you do not show where/when you load vip.el[c] or
Icicles, and you do not show where/when you turn on Vip mode or Icicles mode.
Sometimes the load or mode-invocation order can matter (but it should not).

When I do `emacs -Q', then load vip.el, then evaluate the code above and do `M-x
doit', then load Icicles and turn on Icicle mode, I do not see the behavior you
describe.  If I then turn on Vip mode (using `M-x vip-mode' and answering `n' to
inhibiting startup msg), I still do not see that behavior.  If I toggle Icicle
mode off then on again I still do not see that behavior.  And I don't see any
difference if I turn on vip-mode before Icicle mode, etc.  The order does not
seem to matter.

`C-h k' says `M-x' and `ESC x' are undefined.  But they both seem to work
normally, invoking `icicle-execute-extended-command' in Icicle mode and
`execute-extended-command' when I turn off Icicle mode!  Yet looking at
`vip-mode-map' I see that it has `ESC' defined as `kill-line'.  But `C-h w
kill-line' does not list `ESC' as one of the bindings.  I get the impression
that I am not really in Vip mode (?).  And yet I see `Vi:' in the mode line.
But `C-h m' does not mention Vip at all (?).

I tried toggling Vip mode using `M-x vip-mode', but I still see `Vi:' in the
mode line. I know nothing about Vip, so I'm probably not turning it off and on
correctly.  I took a quick look at the Vip doc, but it wasn't very helpful,

Please send me a more complete recipe, mentioning also your Emacs version. We
can take this off list. But if someone else familiar with Vip can help, please

reply via email to

[Prev in Thread] Current Thread [Next in Thread]