From: "Drew Adams" <drew.adams@oracle.com>
Subject: Question on remapping keys
Date: Sun, 15 Jan 2006 17:19:51 -0800 [thread overview]
Message-ID: <MEEKKIABFKKDFJMPIOEBCEHNCOAA.drew.adams@oracle.com> (raw)
I have a minor mode that redefines some of the minibuffer keymaps (e.g.
minibuffer-local-completion-map). I want turning on the mode to implement
the new minibuffer bindings, and turning it off to restore the minibuffer
bindings of vanilla Emacs.
In some cases, I reuse key sequences that are bound in the global map,
binding them to other commands in minibuffer maps. Those are the bindings
that I have a question about.
In Emacs 20, I simply do this:
(substitute-key-definition from to
minibuffer-local-completion-map global-map)
For example, to bind `C-h' in the minibuffer to command `my-help':
(substitute-key-definition 'help-command 'my-help
minibuffer-local-completion-map global-map)
I do the same for `self-insert-command', replacing it with `my-self-insert'
for minibuffer maps.
This is very fast in Emacs 20, but in Emacs 22 it is unbearably slow. It
takes about 5 seconds for 10 such key-definition substitutions! I think that
the slowness might be due, in particular, to dealing with the case of
`self-insert-command'.
Someone suggested that I could use `define-key' with [remap...] instead of
`substitute-key-definition'. I'm not sure how to do that, since I use the
OLDMAP arg to `substitute-key-definition'. I tried using the following when
my minor mode is turned on:
(defun my-remap (from to map)
"Remap command FROM to command TO in keymap MAP."
(if (boundp 'this-original-command)
(define-key map [remap `,from] to) ; Emacs 22
(substitute-key-definition from to map global-map))) ; Emacs 20
And similarly when it is turned off, using nil for TO, to remove the binding
from MAP (a minibuffer map).
However, as you can guess, that doesn't work. I haven't expressed that I
want to pick up the `global-map' binding (equivalent of OLDMAP arg to
`substitute-key-definition').
Anyone have a suggestion on how to proceed? What I'm looking for is a fast
way to do more or less what (substitute-key-definition from to map
global-map) does. The performance penalty for using
`substitute-key-definition' is just too big - I need to find something
faster. Any advice would be appreciated.
next reply other threads:[~2006-01-16 1:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-16 1:19 Drew Adams [this message]
[not found] <mailman.1249.1137374555.26925.help-gnu-emacs@gnu.org>
2006-01-16 2:07 ` Question on remapping keys Johan Bockgård
2006-01-16 17:46 ` Drew Adams
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=MEEKKIABFKKDFJMPIOEBCEHNCOAA.drew.adams@oracle.com \
--to=drew.adams@oracle.com \
/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.
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).