emacs-devel
[Top][All Lists]
Advanced

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

Re: substitute-key-definition vs. define-key MAP [remap ...]


From: Stefan Monnier
Subject: Re: substitute-key-definition vs. define-key MAP [remap ...]
Date: Fri, 23 Jul 2010 11:26:47 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

> If I understand you correctly, that won't get into XEmacs any time
> soon.  Do you really mean that `define-key' is allowed to effectively
> change the command binding of a symbol globally, so that its function
> definition is ignored in the context of interpreting keystrokes?  Ie,
> `define-key' now turns Emacs into what is effectively a LISP-3?

I don't know what "ignored in the context of interpreting keystrokes"
means, nor what LISP-3 means.

The `remap' thingy operates at the level of `key-binding'.  I.e. after
the command loop reads a key-sequence, it looks it up in the keymaps to
turn the key-sequence into a command, and then it looks this up in the
`remap' sub-keymap(s) to see if it got remapped.

So if you want to bind the original command to a key, you have to trick
the remapping by using another command name, e.g.:

  (defalias 'new-name-for-old-command 'old-remapped-command)
  (define-key MAP [KEYS] 'new-name-for-old-command)

since the remapping will apply to `old-remapped-command' but not to
`new-name-for-old-command'.  There are other ways, of course, such as:

  (define-key MAP [KEYS]
    (lambda () (interactive) (call-interactively 'old-remapped-command)))


-- Stefan



reply via email to

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