* Passing arguments to functions
@ 2011-02-20 13:11 jkb0932
2011-02-22 13:44 ` Oleksandr Gavenko
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: jkb0932 @ 2011-02-20 13:11 UTC (permalink / raw)
To: Help-gnu-emacs
This answer to this question should be obvious, but no one seems to address
it explcitly:
How do I pass arguments to a function call? i.e. if I do "M-x some-function"
and "some-function" takes optional arguments, how do I pass those arguments
to the function call?
--
View this message in context: http://old.nabble.com/Passing-arguments-to-functions-tp30970549p30970549.html
Sent from the Emacs - Help mailing list archive at Nabble.com.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing arguments to functions
2011-02-20 13:11 Passing arguments to functions jkb0932
@ 2011-02-22 13:44 ` Oleksandr Gavenko
2011-02-22 14:13 ` Drew Adams
2011-02-23 4:28 ` Kevin Rodgers
2 siblings, 0 replies; 5+ messages in thread
From: Oleksandr Gavenko @ 2011-02-22 13:44 UTC (permalink / raw)
To: help-gnu-emacs
On 20.02.2011 15:11, jkb0932 wrote:
>
> This answer to this question should be obvious, but no one seems to address
> it explcitly:
>
> How do I pass arguments to a function call? i.e. if I do "M-x some-function"
> and "some-function" takes optional arguments, how do I pass those arguments
> to the function call?
^ permalink raw reply [flat|nested] 5+ messages in thread
* RE: Passing arguments to functions
2011-02-20 13:11 Passing arguments to functions jkb0932
2011-02-22 13:44 ` Oleksandr Gavenko
@ 2011-02-22 14:13 ` Drew Adams
2011-02-22 15:55 ` Perry Smith
2011-02-23 4:28 ` Kevin Rodgers
2 siblings, 1 reply; 5+ messages in thread
From: Drew Adams @ 2011-02-22 14:13 UTC (permalink / raw)
To: 'jkb0932', Help-gnu-emacs
> - How do I pass arguments to a function call? i.e. if I do "M-x
> some-function" and "some-function" takes optional arguments,
> how do I pass those arguments to the function call?
If you are writing the function, then you do this using an `interactive' spec.
`C-h i m elisp m using interactive'.
If you are not writing the function yourself, and it has no `interactive' spec,
and it does not use the universal argument (`C-u') in any conditional way, then
you're (almost) out of luck. In that case, you can use `M-: (function arg 1
arg2...)' or define your own command (function with an interactive spec) that
takes care of the arguments and then calls the ready-made function.
> - Also, why is it that "C-h f function-name" will document
> some functions, but when I type "M-x function-name" it says
> [no match]?
`M-x' is for commands, that is, interactive functions, that is, functions that
have an `interactive' spec. `[no match]' tells you that the function is not a
command.
You will help yourself if you take a look at the doc. Start with the Emacs
manual, but the Elisp manual is helpful for writing your own functions
(including commands). See also the `Emacs Lisp Intro' manual.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing arguments to functions
2011-02-22 14:13 ` Drew Adams
@ 2011-02-22 15:55 ` Perry Smith
0 siblings, 0 replies; 5+ messages in thread
From: Perry Smith @ 2011-02-22 15:55 UTC (permalink / raw)
To: GNU Emacs List
[-- Attachment #1: Type: text/plain, Size: 2482 bytes --]
Let me take a stab at this. This reply is good but I think the
user might be asking from the perspective of using emacs
instead of writing lisp code.
On Feb 22, 2011, at 8:13 AM, Drew Adams wrote:
>> - How do I pass arguments to a function call? i.e. if I do "M-x
>> some-function" and "some-function" takes optional arguments,
>> how do I pass those arguments to the function call?
There are two types of functions. I may be mistaken but I think
some parts of Emacs' documentation refers to "commands" and
"functions". In any case, some functions are "interactive" and
some are not. For example:
isearch-forward is an interactive compiled Lisp function in
`isearch.el'.
verses
replace-match is a built-in function in `C source code'.
An interactive function uses optional arguments and prefix argument.
An interactive function is a super-set in the sense that you can call
an interactive function just like a function. e.g. I could call:
(isearch-forward "pattern")
To get a complete gist of interactive functions, do a help on
"interactive" and it will describe how an interactive function
takes it arguments. There are many options.
If a function is not interactive, then you can not call it via M-x. You
can do M-: (Meta-colon) in which case you can type in a lisp
s expressions and hit return and have it evaluated.
>
> If you are writing the function, then you do this using an `interactive' spec.
> `C-h i m elisp m using interactive'.
>
> If you are not writing the function yourself, and it has no `interactive' spec,
> and it does not use the universal argument (`C-u') in any conditional way, then
> you're (almost) out of luck. In that case, you can use `M-: (function arg 1
> arg2...)' or define your own command (function with an interactive spec) that
> takes care of the arguments and then calls the ready-made function.
>
>> - Also, why is it that "C-h f function-name" will document
>> some functions, but when I type "M-x function-name" it says
>> [no match]?
> `M-x' is for commands, that is, interactive functions, that is, functions that
> have an `interactive' spec. `[no match]' tells you that the function is not a
> command.
>
> You will help yourself if you take a look at the doc. Start with the Emacs
> manual, but the Elisp manual is helpful for writing your own functions
> (including commands). See also the `Emacs Lisp Intro' manual.
Hope this helps
Perry
[-- Attachment #2: Type: text/html, Size: 3577 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Passing arguments to functions
2011-02-20 13:11 Passing arguments to functions jkb0932
2011-02-22 13:44 ` Oleksandr Gavenko
2011-02-22 14:13 ` Drew Adams
@ 2011-02-23 4:28 ` Kevin Rodgers
2 siblings, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2011-02-23 4:28 UTC (permalink / raw)
To: help-gnu-emacs
On 2/20/11 6:11 AM, jkb0932 wrote:
>
> This answer to this question should be obvious, but no one seems to address
> it explcitly:
>
> How do I pass arguments to a function call? i.e. if I do "M-x some-function"
> and "some-function" takes optional arguments, how do I pass those arguments
> to the function call?
If the function's interactive form supports it, it will be documented (e.g.
"with a prefix arg, prompt and read optional arg FOO from the minibuffer").
If the function's interactive form does not support it, call the function
non-interactively with M-: instead of M-x:
M-: (some-function ARG-1 ... ARG-N) RET
--
Kevin Rodgers
Denver, Colorado, USA
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-02-23 4:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-20 13:11 Passing arguments to functions jkb0932
2011-02-22 13:44 ` Oleksandr Gavenko
2011-02-22 14:13 ` Drew Adams
2011-02-22 15:55 ` Perry Smith
2011-02-23 4:28 ` Kevin Rodgers
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.