* Creating a "shortcut" key for "C-c C-"
@ 2003-04-22 1:55 Bill Clementson
2003-04-22 6:15 ` Kai Großjohann
0 siblings, 1 reply; 6+ messages in thread
From: Bill Clementson @ 2003-04-22 1:55 UTC (permalink / raw)
Does anyone know how to map a key to a specific portion of a pre-defined
mapping? For example, if a standard major mode binding is "C-c C-n", how
would you define a particular key to represent the "C-c C-" portion of
the binding so that it is possible to substitute <key>-n for the "C-c
C-n" command? I can't see how this would be possible with either
Super/Hyper keys or other keymap alternatives, but it would be useful to
be able to do this.
I don't want to create a new keybinding for a command, I just want to be
able to indicate that a specific key will "globally" replace the "C-c
C-" portion of already defined major mode commands.
--
Bill Clementson
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Creating a "shortcut" key for "C-c C-"
2003-04-22 1:55 Creating a "shortcut" key for "C-c C-" Bill Clementson
@ 2003-04-22 6:15 ` Kai Großjohann
2003-04-22 14:38 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Kai Großjohann @ 2003-04-22 6:15 UTC (permalink / raw)
Bill Clementson <bc19191@attbi.com> writes:
> I don't want to create a new keybinding for a command, I just want to be
> able to indicate that a specific key will "globally" replace the "C-c
> C-" portion of already defined major mode commands.
Whee. It's easy to replace the "C-c" portion, but there is no easy
way to replace the "C-c C-" portion. A modifier is quite closely
connected with the corresponding key.
Maybe it works to do
(global-set-key (kbd "<f4>") (kbd "C-c C-x @ c"))
The C-x @ c portion is event-apply-control-modifier. But I've never
tried this. I wonder if this approach does anything at all.
It would, however, be kinda cool. When I use viper mode, I use
bindings starting with z that are similar to the standard C-x
bindings. Now, many C-x bindings are of the form C-x a through C-x z
rather than C-x C-a through C-x C-z. But if I wanted to do the same
for C-c bindings (for a major mode), then I'm in trouble -- most C-c
bindings are of the form C-c C-a through C-c C-z rather than C-c a
through C-c z.
--
file-error; Data: (Opening input file no such file or directory ~/.signature)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Creating a "shortcut" key for "C-c C-"
2003-04-22 6:15 ` Kai Großjohann
@ 2003-04-22 14:38 ` Stefan Monnier
2003-04-23 3:45 ` Bill Clementson
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-04-22 14:38 UTC (permalink / raw)
> Maybe it works to do
> (global-set-key (kbd "<f4>") (kbd "C-c C-x @ c"))
That won't work: the C-x @ c thingy works in function-key-map,
i.e. before almost all keymaps.
Furthermore, (define-key function-key-map [f8] "\C-c\C-x@c") won't work
either because the output of function-key-map is not fed back to
function-key-map.
And I can't think of any map that applies before function-key-map and
that can do such mapping.
But you can do:
(defun C-cC- (prompt)
(vconcat "\C-c" (event-apply-control-modifier prompt)))
(define-key function-key-map [f8] 'C-cC-)
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Creating a "shortcut" key for "C-c C-"
2003-04-22 14:38 ` Stefan Monnier
@ 2003-04-23 3:45 ` Bill Clementson
2003-04-23 13:27 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Bill Clementson @ 2003-04-23 3:45 UTC (permalink / raw)
"Stefan Monnier" <monnier+gnu.emacs.help/news/@flint.cs.yale.edu> writes:
> > Maybe it works to do
> > (global-set-key (kbd "<f4>") (kbd "C-c C-x @ c"))
>
> That won't work: the C-x @ c thingy works in function-key-map,
> i.e. before almost all keymaps.
> Furthermore, (define-key function-key-map [f8] "\C-c\C-x@c") won't work
> either because the output of function-key-map is not fed back to
> function-key-map.
> And I can't think of any map that applies before function-key-map and
> that can do such mapping.
>
> But you can do:
>
> (defun C-cC- (prompt)
(vconcat "\C-c" (event-apply-control-modifier prompt)))
> (define-key function-key-map [f8] 'C-cC-)
Sounds great; unfortunately, it doesn't work for me :-(
When I evaluate the above forms, I tried pressing "f8-n" in a buffer
that has a keybinding to "C-c C-n". I thought that the "f8-n" keybinding
would result in the execution of the same command that was bound to "C-c
C-n". Unfortunately, the only thing that happened was that an "n" was
inserted into the buffer. When I run the command "describe-key" on
"f8-n", it says that "n runs the command self-insert-command
(self-insert-command N)". Am I missing some step?
Thanks for your help.
--
Bill Clementson
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Creating a "shortcut" key for "C-c C-"
2003-04-23 3:45 ` Bill Clementson
@ 2003-04-23 13:27 ` Stefan Monnier
2003-04-23 15:37 ` Reiner Steib
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2003-04-23 13:27 UTC (permalink / raw)
>> (defun C-cC- (prompt)
> (vconcat "\C-c" (event-apply-control-modifier prompt)))
>> (define-key function-key-map [f8] 'C-cC-)
> Sounds great; unfortunately, it doesn't work for me :-(
No idea here. It works with the Emacs code on the CVS trunk.
Try something like
(defun C-cC- (prompt)
(message "Entering C-cC-...")
(let ((key (event-apply-control-modifier prompt)))
(message "e-a-c-m returned %s" key)
(vconcat "\C-c" key)))
and look at the *Messages* buffer to see what e-a-c-m returned.
It should look like [14] or "\^N" if you pressed `n' after f8
(because the ascii code of C-n is 14).
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Creating a "shortcut" key for "C-c C-"
2003-04-23 13:27 ` Stefan Monnier
@ 2003-04-23 15:37 ` Reiner Steib
0 siblings, 0 replies; 6+ messages in thread
From: Reiner Steib @ 2003-04-23 15:37 UTC (permalink / raw)
On Wed, Apr 23 2003, Stefan Monnier wrote:
> No idea here. It works with the Emacs code on the CVS trunk.
It works in Emacs 21.3 too. But I had to eval (global-unset-key [f8])
before the (define-key ...), because I already had a global binding
for F8.
> It should look like [14] or "\^N" if you pressed `n' after f8
> (because the ascii code of C-n is 14).
,----
| Entering C-cC-...
| e-a-c-m returned [14]
`----
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- PGP key available via WWW http://rsteib.home.pages.de/
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2003-04-23 15:37 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-22 1:55 Creating a "shortcut" key for "C-c C-" Bill Clementson
2003-04-22 6:15 ` Kai Großjohann
2003-04-22 14:38 ` Stefan Monnier
2003-04-23 3:45 ` Bill Clementson
2003-04-23 13:27 ` Stefan Monnier
2003-04-23 15:37 ` Reiner Steib
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.