* interactive and &optional arguments
@ 2013-02-26 2:09 Thorsten Jolitz
2013-02-26 3:15 ` Stefan Monnier
0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Jolitz @ 2013-02-26 2:09 UTC (permalink / raw)
To: help-gnu-emacs
Hi List,
sometimes I want a function with &optional args to be interactive, and I
wonder if there is a way to, as default action, interactively call the
function via M-x without args, except the user does something special -
e.g. C-u M-x - and only then ask the user for input?
That is
,-----------------------------------------
| (defun foo (&optional arg1 arg2 arg3)
| (interactive "???")
| ...)
|
| M-x foo ; call foo without args
| C-u M-x foo ; ask the user for input
`-----------------------------------------
or something similar?
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: interactive and &optional arguments
2013-02-26 2:09 interactive and &optional arguments Thorsten Jolitz
@ 2013-02-26 3:15 ` Stefan Monnier
2013-02-26 4:18 ` Thorsten Jolitz
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2013-02-26 3:15 UTC (permalink / raw)
To: help-gnu-emacs
> sometimes I want a function with &optional args to be interactive, and I
> wonder if there is a way to, as default action, interactively call the
> function via M-x without args, except the user does something special -
> e.g. C-u M-x - and only then ask the user for input?
Just use a (interactive <spec>) where <spec> is not a string but some
Elisp expression that computes the arguments you want to provide to
the function.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: interactive and &optional arguments
2013-02-26 3:15 ` Stefan Monnier
@ 2013-02-26 4:18 ` Thorsten Jolitz
0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Jolitz @ 2013-02-26 4:18 UTC (permalink / raw)
To: help-gnu-emacs
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> sometimes I want a function with &optional args to be interactive, and I
>> wonder if there is a way to, as default action, interactively call the
>> function via M-x without args, except the user does something special -
>> e.g. C-u M-x - and only then ask the user for input?
>
> Just use a (interactive <spec>) where <spec> is not a string but some
> Elisp expression that computes the arguments you want to provide to
> the function.
I see, thanks, its even described in the manual, but somehow I couldn't
relate the dense paragraph to my problem without some external hint.
--
cheers,
Thorsten
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-02-26 4:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-26 2:09 interactive and &optional arguments Thorsten Jolitz
2013-02-26 3:15 ` Stefan Monnier
2013-02-26 4:18 ` Thorsten Jolitz
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.