help-gnu-emacs
[Top][All Lists]
Advanced

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

How do I "duplicate" a keybinding?


From: Alan Mackenzie
Subject: How do I "duplicate" a keybinding?
Date: Fri, 17 Aug 2007 09:35:13 +0000
User-agent: Mutt/1.5.9i

I would like to "duplicate" a key-binding.  By this I mean I want to make
a new binding do the same thing as an existing one.

In particular, I find the commands in hideshow minor mode, such as

    C-c @ C-c (hs-toggle-hiding)

too cumbersome to type; each keystroke requires a modifier different
from the previous one - <ctrl>, <shift>, <ctrl>.

So I want to use an unused binding C-S-' in place of C-c @, so that I
could do the above command with the more convenient

    C-S-' C-c

.  I know that I could bind C-S-' to hs-minor-mode-map, but this wouldn't
be right, since C-S-' would continue to point to this keymap even when
hideshow mode was disabled.

I could write a command starting like this:

    (defun C-c@ ()
      (interactive)
      (let ((kmap (key-binding "\C-c@")))
        (if key-binding
            ....

where I then proceed to read further keystrokes until I get a complete
key sequence.  But do I really have to go through all this?

I've tried to find something useful in the chapter "Keymaps" in the Elisp
manual, but didn't find anything.  Am I missing something obvious here?

-- 
Alan Mackenzie (Ittersbach, Germany).




reply via email to

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