RE: How to simulate pressing a key
  Home FAQ Contact Sign in
gnu.emacs.help only
 
Advanced search
POPULAR GROUPS

more...

gnu.emacs.help Profile…
 Up
RE: How to simulate pressing a key         


Author: Drew Adams
Date: Sep 19, 2008 08:05

> I can not just call the function which key is binding for it may
> have uncertainty parameter, like tab's function forward-button has
> parameter, but lisp-indent-line does not.
>
> although execute-extended-command works perfect, but I can not use
> it in my elisp function.

I'm not sure I understand your question, but if I do, have a look at function
`call-interactively'. It lets you call an interactive function (command) in such
a way that the function's `interactive' spec is used to obtain the argument
values.

See the Elisp manual, node `Interactive Call'.
7 Comments
Re: How to simulate pressing a key         


Author: netawater
Date: Sep 19, 2008 19:50

"Drew Adams" oracle.com> writes:
>> I can not just call the function which key is binding for it may
>> have uncertainty parameter, like tab's function forward-button has
>> parameter, but lisp-indent-line does not.
>>
>> although execute-extended-command works perfect, but I can not use
>> it in my elisp function.
>
> I'm not sure I understand your question, but if I do, have a look at function
> `call-interactively'. It lets you call an interactive function (command) in
> such
> a way that the function's `interactive' spec is used to obtain the argument
> values.
>
> See the Elisp manual, node `Interactive Call'.

Thanks for your reply.
Show full article (1.51Kb)
1 Comment
RE: How to simulate pressing a key         


Author: Drew Adams
Date: Sep 19, 2008 23:19

>>> I can not just call the function which key is binding for it may
>>> have uncertainty parameter, like tab's function forward-button has
>>> parameter, but lisp-indent-line does not.
>>>
>>> although execute-extended-command works perfect, but I can not use
>>> it in my elisp function.
>>
>> I'm not sure I understand your question, but if I do, have
>> a look at function `call-interactively'. It lets you call an
>> interactive function (command) in such a way that the function's
>> `interactive' spec is used to obtain the argument values.
>>
>> See the Elisp manual, node `Interactive Call'.
>
> Thanks for your reply.
>
> I do not want to interactive call a function but call it like
> pressing a key. for example, press tab in help-mode will cause
> forward-button function which has a parameter, however I do
> not need give it parameter and it get parameter by itself. ...
Show full article (2.38Kb)
no comments
Re: How to simulate pressing a key         


Author: Thierry Volpiatto
Date: Sep 20, 2008 00:08

"Drew Adams" oracle.com> writes:
>> Calling the command interactively
>> (call-interactively #'button)...
>
> Sorry, I meant (call-interactively #'forward-button).

(forward-button +or-arg) go to the next/prec arg button
and
(push-button) active the button
--
A + Thierry Volpiatto
Location: Saint-Cyr-Sur-Mer - France
no comments
Re: How to simulate pressing a key         


Author: Nikolaj Schumacher
Date: Sep 20, 2008 03:59

netawater yahoo.com.cn> wrote:
> I do not want to interactive call a function but call it like pressing
> a key.

I think you do, you just don't know it yet. :)

You want to do something like thas

(defun do-what-backspace-does ()
(interactive)
(call-interactively (key-binding "\C-?")))
> my aim is to binding a funtion to tab key in every mode: if cursor is at
> the end of word then call M-TAB's function, else call TAB's function.

This, however, might not work. Because if you bind your function to
tab, you might be unable to retrieve the original binding.

regards,
Nikolaj Schumacher
no comments
Re: How to simulate pressing a key         


Author: netawater
Date: Sep 20, 2008 07:37

"Drew Adams" oracle.com> writes:
>>>> I can not just call the function which key is binding for it may
>>>> have uncertainty parameter, like tab's function forward-button has
>>>> parameter, but lisp-indent-line does not.
>>>>
>...
Show full article (2.72Kb)
1 Comment
Re: How to simulate pressing a key         


Author: netawater
Date: Sep 20, 2008 07:43

Nikolaj Schumacher writes:
Show full article (0.82Kb)
no comments
RE: How to simulate pressing a key         


Author: Drew Adams
Date: Sep 20, 2008 09:00

> Sorry, I misunderstanded your call interactively's mean, I
> thought it need me input parameter interactively, sorry for
> my poor english level, call-interactively is a perfect method
> for my function. Thank you very much!

No problem. I sympathize with the language difficulties.

BTW, I've filed an Emacs bug (#1010) suggesting a slight change in the doc for
`call-interactively', to try to prevent the confusion you had.

`call-interactively' just provides the args needed by a command automatically,
according to its `interactive' spec. In some cases that does entail reading user
input, but not in all cases. I suggested that the language be changed from
"reading args" to "providing args" and that how the argument values are
determined be explained explicitly.

Don't be intimidated by difficulty with English. Using short sentences helps.
There's always room for improvement in the doc, especially as concerns its
accessibility by people whose mother tongue is not English.
no comments