unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Looking up and CALLING a key binding
@ 2009-01-05 14:00 TheLonelyStar
  2009-01-06 14:22 ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: TheLonelyStar @ 2009-01-05 14:00 UTC (permalink / raw)
  To: Help-gnu-emacs


Hi,

I know very little elisp have basicly no practical expirience with it.

I know I can lookup a keybinding with lookup-key and similiar.
But how do I look it up and call it (execute it)?

Thanks!
nathan
-- 
View this message in context: http://www.nabble.com/Looking-up-and-CALLING-a-key-binding-tp21291485p21291485.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
       [not found] <mailman.4013.1231164018.26697.help-gnu-emacs@gnu.org>
@ 2009-01-06  1:13 ` Xah Lee
  2009-01-06 15:14   ` TheLonelyStar
       [not found]   ` <mailman.4126.1231254888.26697.help-gnu-emacs@gnu.org>
  2009-01-06 14:56 ` OtherMichael
  1 sibling, 2 replies; 8+ messages in thread
From: Xah Lee @ 2009-01-06  1:13 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 5, 6:00 am, TheLonelyStar <nabb...@lonely-star.org> wrote:
> Hi,
>
> I know very little elisp have basicly no practical expirience with it.
>
> I know I can lookup a keybinding with lookup-key and similiar.
> But how do I look it up and call it (execute it)?
>
> Thanks!
> nathan

what exactly you want to do?

are you writing a elisp program? ... or you trying to do something in
emacs?

once you know what command the binding is associated with, you can
just call the command by typing Alt+x commandName.

if you are writing elisp... once you get the command name, say it is
forward-word, then you can run it by just (forward-word) ... some
example of your case would be good to clarify.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
  2009-01-05 14:00 TheLonelyStar
@ 2009-01-06 14:22 ` Kevin Rodgers
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2009-01-06 14:22 UTC (permalink / raw)
  To: help-gnu-emacs

TheLonelyStar wrote:
> I know very little elisp have basicly no practical expirience with it.
> 
> I know I can lookup a keybinding with lookup-key and similiar.
> But how do I look it up and call it (execute it)?

C-h f call-interactively

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
       [not found] <mailman.4013.1231164018.26697.help-gnu-emacs@gnu.org>
  2009-01-06  1:13 ` Looking up and CALLING a key binding Xah Lee
@ 2009-01-06 14:56 ` OtherMichael
  1 sibling, 0 replies; 8+ messages in thread
From: OtherMichael @ 2009-01-06 14:56 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 5, 9:00 am, TheLonelyStar <nabb...@lonely-star.org> wrote:
> Hi,
>
> I know very little elisp have basicly no practical expirience with it.
>
> I know I can lookup a keybinding with lookup-key and similiar.
> But how do I look it up and call it (execute it)?
>
> Thanks!
> nathan
> --
> View this message in context:http://www.nabble.com/Looking-up-and-CALLING-a-key-binding-tp21291485...
> Sent from the Emacs - Help mailing list archive at Nabble.com.

If you are trying to find WHERE a command is mapped, C-h w <command-
name> runs where-is and gives you the keystroke-sequence

If you are trying to find the NAME of a command, C-h k <keystroke-
sequence> runs describe-key and gives you the command-name mapped to
the keystroke-sequence.


Once you know the name, then you can execute it via M-x as Xah said.

--the Other michael


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
  2009-01-06  1:13 ` Looking up and CALLING a key binding Xah Lee
@ 2009-01-06 15:14   ` TheLonelyStar
  2009-01-06 15:20     ` Lennart Borgman
       [not found]   ` <mailman.4126.1231254888.26697.help-gnu-emacs@gnu.org>
  1 sibling, 1 reply; 8+ messages in thread
From: TheLonelyStar @ 2009-01-06 15:14 UTC (permalink / raw)
  To: Help-gnu-emacs


Hi,

I need this for the following two things:

1. I want to bind a key (the tab key) to a special function which can fail.
If the function fails, I want to call the original  binding of the key
(which is differerent depending on which mode I am in).

2. I want to bind a key to the insertion of a little code snippet.
i.E. { -> to
{
  |
}
But since in many modes the "{" and "}" keys are bound to some special
function, I want to call these keybindings for the insertions of the "{" and
"}".


Xah Lee-2 wrote:
> 
> On Jan 5, 6:00 am, TheLonelyStar <nabb...@lonely-star.org> wrote:
>> Hi,
>>
>> I know very little elisp have basicly no practical expirience with it.
>>
>> I know I can lookup a keybinding with lookup-key and similiar.
>> But how do I look it up and call it (execute it)?
>>
>> Thanks!
>> nathan
> 
> what exactly you want to do?
> 
> are you writing a elisp program? ... or you trying to do something in
> emacs?
> 
> once you know what command the binding is associated with, you can
> just call the command by typing Alt+x commandName.
> 
> if you are writing elisp... once you get the command name, say it is
> forward-word, then you can run it by just (forward-word) ... some
> example of your case would be good to clarify.
> 
>   Xah
> ∑ http://xahlee.org/
> 
> ☄
> 
> 

-- 
View this message in context: http://www.nabble.com/Looking-up-and-CALLING-a-key-binding-tp21291485p21312291.html
Sent from the Emacs - Help mailing list archive at Nabble.com.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
  2009-01-06 15:14   ` TheLonelyStar
@ 2009-01-06 15:20     ` Lennart Borgman
  0 siblings, 0 replies; 8+ messages in thread
From: Lennart Borgman @ 2009-01-06 15:20 UTC (permalink / raw)
  To: TheLonelyStar; +Cc: Help-gnu-emacs

On Tue, Jan 6, 2009 at 4:14 PM, TheLonelyStar <nabble2@lonely-star.org> wrote:
>
> Hi,
>
> I need this for the following two things:
>
> 1. I want to bind a key (the tab key) to a special function which can fail.
> If the function fails, I want to call the original  binding of the key
> (which is differerent depending on which mode I am in).

This is what tabkey2 mode (and its predecessor) tries to do. Please
see EmacsWiki.

> 2. I want to bind a key to the insertion of a little code snippet.
> i.E. { -> to
> {
>  |
> }
> But since in many modes the "{" and "}" keys are bound to some special
> function, I want to call these keybindings for the insertions of the "{" and
> "}".

You can use a minor mode for this. Minor mode key bindings comes
before major mode.




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
       [not found]   ` <mailman.4126.1231254888.26697.help-gnu-emacs@gnu.org>
@ 2009-01-07 18:08     ` Xah Lee
  2009-01-08 15:31       ` Kevin Rodgers
  0 siblings, 1 reply; 8+ messages in thread
From: Xah Lee @ 2009-01-07 18:08 UTC (permalink / raw)
  To: help-gnu-emacs

On Jan 6, 7:14 am, TheLonelyStar <nabb...@lonely-star.org> wrote:
> Hi,
>
> I need this for the following two things:
>
> 1. I want to bind a key (the tab key) to a special function which can fail.
> If the function fails, I want to call the original  binding of the key
> (which is differerent depending on which mode I am in).
>
> 2. I want to bind a key to the insertion of a little code snippet.
> i.E. { -> to
> {
>   |}
>
> But since in many modes the "{" and "}" keys are bound to some special
> function, I want to call these keybindings for the insertions of the "{" and
> "}".

do it like this:

(funcall (lookup-key (current-global-map) (kbd "M-r")))

this will find out the function assigned to the key “Alt+r”, then call
the function.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Looking up and CALLING a key binding
  2009-01-07 18:08     ` Xah Lee
@ 2009-01-08 15:31       ` Kevin Rodgers
  0 siblings, 0 replies; 8+ messages in thread
From: Kevin Rodgers @ 2009-01-08 15:31 UTC (permalink / raw)
  To: help-gnu-emacs

Xah Lee wrote:
> On Jan 6, 7:14 am, TheLonelyStar <nabb...@lonely-star.org> wrote:
> do it like this:
> 
> (funcall (lookup-key (current-global-map) (kbd "M-r")))
> 
> this will find out the function assigned to the key “Alt+r”, then call
> the function.

It will call the function with no arguments, so if it has required
arguments it will fail.  Use call-interactively instead of funcall
to provide any required arguments.

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-01-08 15:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <mailman.4013.1231164018.26697.help-gnu-emacs@gnu.org>
2009-01-06  1:13 ` Looking up and CALLING a key binding Xah Lee
2009-01-06 15:14   ` TheLonelyStar
2009-01-06 15:20     ` Lennart Borgman
     [not found]   ` <mailman.4126.1231254888.26697.help-gnu-emacs@gnu.org>
2009-01-07 18:08     ` Xah Lee
2009-01-08 15:31       ` Kevin Rodgers
2009-01-06 14:56 ` OtherMichael
2009-01-05 14:00 TheLonelyStar
2009-01-06 14:22 ` Kevin Rodgers

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).