* RE: How to simulate pressing a key
2008-09-19 15:12 How to simulate pressing a key netawater
@ 2008-09-19 15:05 ` Drew Adams
[not found] ` <mailman.19555.1221836708.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Drew Adams @ 2008-09-19 15:05 UTC (permalink / raw)
To: 'netawater', help-gnu-emacs
> 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'.
^ permalink raw reply [flat|nested] 11+ messages in thread
* How to simulate pressing a key
@ 2008-09-19 15:12 netawater
2008-09-19 15:05 ` Drew Adams
[not found] ` <mailman.19555.1221836708.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: netawater @ 2008-09-19 15:12 UTC (permalink / raw)
To: help-gnu-emacs
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.
Thank you very much!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
[not found] ` <mailman.19555.1221836708.18990.help-gnu-emacs@gnu.org>
@ 2008-09-20 2:50 ` netawater
2008-09-20 6:19 ` Drew Adams
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: netawater @ 2008-09-20 2:50 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <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.
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.
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.
(defun my-indent-or-complete ()
"if cursor is at
the end of word then call M-TAB's function, else call TAB's function."
(interactive)
;; ^C^t is binding to tab key's function in mode-hook.
(let ((TAB-func (key-binding "^C^t"))
(M-TAB-func (key-binding "\M-\t"))
)
(if (looking-at "\\>")
(apply M-TAB-func '())
(apply TAB-func '())
))
)
my way is only suitable for lisp-indent-line but not forward-button.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: How to simulate pressing a key
2008-09-20 2:50 ` netawater
@ 2008-09-20 6:19 ` Drew Adams
2008-09-20 6:55 ` Drew Adams
2008-09-20 10:59 ` Nikolaj Schumacher
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2008-09-20 6:19 UTC (permalink / raw)
To: 'netawater', help-gnu-emacs
> >> 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.
Sorry, I'm unable to follow you. Hopefully someone else will understand and
answer you.
> 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.
>
> (defun my-indent-or-complete ()
> "if cursor is at
> the end of word then call M-TAB's function, else call
> TAB's function."
> (interactive)
> ;; ^C^t is binding to tab key's function in mode-hook.
> (let ((TAB-func (key-binding "^C^t"))
> (M-TAB-func (key-binding "\M-\t")))
> (if (looking-at "\\>")
> (apply M-TAB-func '())
> (apply TAB-func '()))))
>
> my way is only suitable for lisp-indent-line but not forward-button.
As you said, `forward-button' expects at least one argument, and you are
applying it to zero arguments. Above, you say "it get parameter by itself". It's
unclear to me what you mean by that.
Calling the command interactively (call-interactively #'button) will provide the
needed arguments (by default, N=1, WRAP=(point), DISPLAY-MESSAGE=(point), which
I think will do just what you want - but you say you don't want that.
Again, perhaps someone else can help you better.
Also, it sounds like you are trying to do something that several others have
already done. Take a look here and see if you don't find what you're looking for
already made: http://www.emacswiki.org/cgi-bin/wiki/TabCompletion
[BTW, you don't need to quote nil: '(). () evaluates to itself.]
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: How to simulate pressing a key
2008-09-20 6:19 ` Drew Adams
@ 2008-09-20 6:55 ` Drew Adams
2008-09-20 7:08 ` Thierry Volpiatto
0 siblings, 1 reply; 11+ messages in thread
From: Drew Adams @ 2008-09-20 6:55 UTC (permalink / raw)
To: 'netawater', help-gnu-emacs
> Calling the command interactively
> (call-interactively #'button)...
Sorry, I meant (call-interactively #'forward-button).
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
2008-09-20 6:55 ` Drew Adams
@ 2008-09-20 7:08 ` Thierry Volpiatto
0 siblings, 0 replies; 11+ messages in thread
From: Thierry Volpiatto @ 2008-09-20 7:08 UTC (permalink / raw)
To: Drew Adams; +Cc: help-gnu-emacs, 'netawater'
"Drew Adams" <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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
2008-09-20 2:50 ` netawater
2008-09-20 6:19 ` Drew Adams
@ 2008-09-20 10:59 ` Nikolaj Schumacher
[not found] ` <mailman.19594.1221891580.18990.help-gnu-emacs@gnu.org>
[not found] ` <mailman.19605.1221908356.18990.help-gnu-emacs@gnu.org>
3 siblings, 0 replies; 11+ messages in thread
From: Nikolaj Schumacher @ 2008-09-20 10:59 UTC (permalink / raw)
To: netawater; +Cc: help-gnu-emacs
netawater <netstandin-003@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
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
[not found] ` <mailman.19594.1221891580.18990.help-gnu-emacs@gnu.org>
@ 2008-09-20 14:37 ` netawater
2008-09-20 16:00 ` Drew Adams
[not found] ` <mailman.19618.1221926415.18990.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 11+ messages in thread
From: netawater @ 2008-09-20 14:37 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <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.
>>
>> 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.
>
> Sorry, I'm unable to follow you. Hopefully someone else will understand and
> answer you.
>
>> 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.
>>
>> (defun my-indent-or-complete ()
>> "if cursor is at
>> the end of word then call M-TAB's function, else call
>> TAB's function."
>> (interactive)
>> ;; ^C^t is binding to tab key's function in mode-hook.
>> (let ((TAB-func (key-binding "^C^t"))
>> (M-TAB-func (key-binding "\M-\t")))
>> (if (looking-at "\\>")
>> (apply M-TAB-func '())
>> (apply TAB-func '()))))
>>
>> my way is only suitable for lisp-indent-line but not forward-button.
>
> As you said, `forward-button' expects at least one argument, and you are
> applying it to zero arguments. Above, you say "it get parameter by
> itself". It's
> unclear to me what you mean by that.
>
> Calling the command interactively (call-interactively #'button) will provide
> the
> needed arguments (by default, N=1, WRAP=(point), DISPLAY-MESSAGE=(point), which
> I think will do just what you want - but you say you don't want that.
>
> Again, perhaps someone else can help you better.
>
> Also, it sounds like you are trying to do something that several others have
> already done. Take a look here and see if you don't find what you're looking
> for
> already made: http://www.emacswiki.org/cgi-bin/wiki/TabCompletion
>
> [BTW, you don't need to quote nil: '(). () evaluates to itself.]
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!
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
[not found] ` <mailman.19605.1221908356.18990.help-gnu-emacs@gnu.org>
@ 2008-09-20 14:43 ` netawater
0 siblings, 0 replies; 11+ messages in thread
From: netawater @ 2008-09-20 14:43 UTC (permalink / raw)
To: help-gnu-emacs
Nikolaj Schumacher <me@nschum.de> writes:
> netawater <netstandin-003@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
Thank you for pointing my error, :)
I have bind tab's function to ^C^t before bind this function to TAB.
Thanks.
^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: How to simulate pressing a key
2008-09-20 14:37 ` netawater
@ 2008-09-20 16:00 ` Drew Adams
[not found] ` <mailman.19618.1221926415.18990.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 11+ messages in thread
From: Drew Adams @ 2008-09-20 16:00 UTC (permalink / raw)
To: 'netawater', help-gnu-emacs
> 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.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: How to simulate pressing a key
[not found] ` <mailman.19618.1221926415.18990.help-gnu-emacs@gnu.org>
@ 2008-09-26 13:18 ` netawater
0 siblings, 0 replies; 11+ messages in thread
From: netawater @ 2008-09-26 13:18 UTC (permalink / raw)
To: help-gnu-emacs
"Drew Adams" <drew.adams@oracle.com> writes:
>> 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.
>
Thank you for your couragement, :)
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-09-26 13:18 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-19 15:12 How to simulate pressing a key netawater
2008-09-19 15:05 ` Drew Adams
[not found] ` <mailman.19555.1221836708.18990.help-gnu-emacs@gnu.org>
2008-09-20 2:50 ` netawater
2008-09-20 6:19 ` Drew Adams
2008-09-20 6:55 ` Drew Adams
2008-09-20 7:08 ` Thierry Volpiatto
2008-09-20 10:59 ` Nikolaj Schumacher
[not found] ` <mailman.19594.1221891580.18990.help-gnu-emacs@gnu.org>
2008-09-20 14:37 ` netawater
2008-09-20 16:00 ` Drew Adams
[not found] ` <mailman.19618.1221926415.18990.help-gnu-emacs@gnu.org>
2008-09-26 13:18 ` netawater
[not found] ` <mailman.19605.1221908356.18990.help-gnu-emacs@gnu.org>
2008-09-20 14:43 ` netawater
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).