all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Perry Smith <pedzsan@gmail.com>
To: GNU Emacs List <Help-gnu-emacs@gnu.org>
Subject: Re: Passing arguments to functions
Date: Tue, 22 Feb 2011 09:55:19 -0600	[thread overview]
Message-ID: <AD5DA226-C109-450F-9B2C-F5D82DAFACEC@gmail.com> (raw)
In-Reply-To: <6D8EB470761945C5A34EFB1CB5B4727E@us.oracle.com>

[-- 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 --]

  reply	other threads:[~2011-02-22 15:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2011-02-23  4:28 ` Kevin Rodgers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AD5DA226-C109-450F-9B2C-F5D82DAFACEC@gmail.com \
    --to=pedzsan@gmail.com \
    --cc=Help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.