* Executing the command bound to a key-stroke
@ 2004-01-26 7:33 Arjan Bos
2004-01-27 7:56 ` Joakim Hove
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Arjan Bos @ 2004-01-26 7:33 UTC (permalink / raw)
How do I execute the command bound to \C-j ?
I've written my own major mode (netrexx-mode.el) and one of the pieces
of elisp I have in there worry me. I feel that there should be a more
consise way of doing it.
(if (eq (local-key-binding "\C-j")
'netrexx-indent-newline-indent-with-end-comment)
(netrexx-indent-newline-indent-with-end-comment)
;; else
(netrexx-indent-newline-indent)))
The problem with this is that \C-j might be bound to some other command
and that isn't handled by my code. What I would like is to execute the
command bound to \C-j directly. I've tried several things, but they all
failed me, hence this kludge.
TIA,
Arjan
--
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, ICU.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing the command bound to a key-stroke
2004-01-26 7:33 Executing the command bound to a key-stroke Arjan Bos
@ 2004-01-27 7:56 ` Joakim Hove
2004-01-28 19:57 ` Arjan Bos
2004-01-27 9:26 ` Eli Zaretskii
2004-01-27 14:08 ` Stefan Monnier
2 siblings, 1 reply; 6+ messages in thread
From: Joakim Hove @ 2004-01-27 7:56 UTC (permalink / raw)
Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl> writes:
> What I would like is to execute the command bound to \C-j
> directly. I've tried several things, but they all failed me, hence
> this kludge.
M-x apropos bind <return>:
(key-binding KEY &optional ACCEPT-DEFAULT NO-REMAP)
Return the binding for command KEY in current keymaps.
KEY is a string or vector, a sequence of keystrokes.
The binding is probably a symbol with a function definition.
[....]
i.e M-x apropos is a *really good* friend!
I.e. I guess something like
(funcall (key-binding "\C-j"))
should do the trick.
HTH - Joakim
--
/--------------------------------------------------------------------\
/ Joakim Hove / hove@bccs.no / (55 5) 84076 | \
| Unifob AS, Avdeling for Beregningsvitenskap (BCCS) | Stabburveien 18 |
| CMU | 5231 Paradis |
\ Thormøhlensgt.55, 5020 Bergen. | 55 91 28 18 /
\--------------------------------------------------------------------/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing the command bound to a key-stroke
2004-01-26 7:33 Executing the command bound to a key-stroke Arjan Bos
2004-01-27 7:56 ` Joakim Hove
@ 2004-01-27 9:26 ` Eli Zaretskii
2004-01-27 14:08 ` Stefan Monnier
2 siblings, 0 replies; 6+ messages in thread
From: Eli Zaretskii @ 2004-01-27 9:26 UTC (permalink / raw)
> Date: Mon, 26 Jan 2004 08:33:13 +0100
> From: Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl>
> Newsgroups: gnu.emacs.help
>
> (if (eq (local-key-binding "\C-j")
> 'netrexx-indent-newline-indent-with-end-comment)
> (netrexx-indent-newline-indent-with-end-comment)
> ;; else
> (netrexx-indent-newline-indent)))
>
> The problem with this is that \C-j might be bound to some other command
> and that isn't handled by my code. What I would like is to execute the
> command bound to \C-j directly. I've tried several things, but they all
> failed me, hence this kludge.
I think you want this, or some variant thereof:
(call-interactively (key-binding "\C-j"))
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing the command bound to a key-stroke
2004-01-26 7:33 Executing the command bound to a key-stroke Arjan Bos
2004-01-27 7:56 ` Joakim Hove
2004-01-27 9:26 ` Eli Zaretskii
@ 2004-01-27 14:08 ` Stefan Monnier
2004-01-28 19:56 ` Arjan Bos
2 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2004-01-27 14:08 UTC (permalink / raw)
> How do I execute the command bound to \C-j ?
Normally you never need to do that. Could you explain why you feel
like doing such a thing? Is it for a command bound to M-C-j or some such
binding cognitively linked to C-j ?
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing the command bound to a key-stroke
2004-01-27 14:08 ` Stefan Monnier
@ 2004-01-28 19:56 ` Arjan Bos
0 siblings, 0 replies; 6+ messages in thread
From: Arjan Bos @ 2004-01-28 19:56 UTC (permalink / raw)
Stefan Monnier wrote:
>>How do I execute the command bound to \C-j ?
>
>
> Normally you never need to do that. Could you explain why you feel
> like doing such a thing? Is it for a command bound to M-C-j or some such
> binding cognitively linked to C-j ?
>
>
I thought to override the global function of C-j with my own version of
it. Namely one that inserts comments at the closing of a block. The
comments tell me which block-starter command matches the end.
If there is a better way of doing this, or a more appropriate
key-binding to use, then please tell me.
--
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, ICU.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Executing the command bound to a key-stroke
2004-01-27 7:56 ` Joakim Hove
@ 2004-01-28 19:57 ` Arjan Bos
0 siblings, 0 replies; 6+ messages in thread
From: Arjan Bos @ 2004-01-28 19:57 UTC (permalink / raw)
Joakim Hove wrote:
> Arjan Bos <Arjan.Bos@nospam.ISeeYou.nl> writes:
>
>
>>What I would like is to execute the command bound to \C-j
>>directly. I've tried several things, but they all failed me, hence
>>this kludge.
>
>
> M-x apropos bind <return>:
>
> (key-binding KEY &optional ACCEPT-DEFAULT NO-REMAP)
>
> Return the binding for command KEY in current keymaps.
> KEY is a string or vector, a sequence of keystrokes.
> The binding is probably a symbol with a function definition.
>
> [....]
>
> i.e M-x apropos is a *really good* friend!
>
>
> I.e. I guess something like
>
> (funcall (key-binding "\C-j"))
>
> should do the trick.
And indeed it does!
Thanks!
Arjan
--
If you really want to contact me, then replace the "I see you" text by
its three letter accronym, ICU.
Fabricate Diem PVNC, Motto of the Night Watch -- Terry Pratchett
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-01-28 19:57 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-01-26 7:33 Executing the command bound to a key-stroke Arjan Bos
2004-01-27 7:56 ` Joakim Hove
2004-01-28 19:57 ` Arjan Bos
2004-01-27 9:26 ` Eli Zaretskii
2004-01-27 14:08 ` Stefan Monnier
2004-01-28 19:56 ` Arjan Bos
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).