all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: help-gnu-emacs@gnu.org
Subject: Re: Suppress user-prompting when calling commands in programs
Date: Sat, 14 Jun 2014 11:47:56 +0800	[thread overview]
Message-ID: <87r42sjgnn.fsf@ericabrahamsen.net> (raw)
In-Reply-To: b5b9f0ea-6a95-498b-9a05-39404c575bff@default

Drew Adams <drew.adams@oracle.com> writes:

>> > What's wrong with them pushing the read into the interactive spec?
>> >
>> > (defun foo (&optional arg bar)
>> >   (interactive (list current-prefix-arg
>> >                      (org-icompleting-read ...))))
>> >   ...)
>> 
>> A quick side-question: Everyone here is using &optional for the prefix
>> arg name.
>
> I used &optional because that is what was used in the original `foo'.
> Presumably there is existing code that uses `foo' and expects that
> signature, e.g., tries to evaluate `(foo)'.
>
>> I have several functions lying around that use the "P"
>> interactive spec but don't specify arg as &optional, and seem to work
>> fine. My understanding is that, if there is no prefix arg, arg will
>> simply be nil, as it should be.
>
> Correct.
>
>> Apart from style/code clarity, are there other reasons for specifying
>> &optional?
>
> See above.  Use &optional if you want to be able to call the function
> without passing that argument.

Ah, of course -- sort of the inverse of the OP's question. Thanks!




  reply	other threads:[~2014-06-14  3:47 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13 13:51 Suppress user-prompting when calling commands in programs Thorsten Jolitz
2014-06-13 14:03 ` Eli Zaretskii
2014-06-13 14:25   ` Stefan Monnier
2014-06-13 15:09     ` Thorsten Jolitz
2014-06-13 15:29     ` Drew Adams
2014-06-13 15:49       ` Thorsten Jolitz
2014-06-13 14:20 ` Nicolas Richard
2014-06-13 15:18   ` Thorsten Jolitz
2014-06-13 16:04     ` Drew Adams
2014-06-13 18:14       ` Thorsten Jolitz
2014-06-14  3:33       ` Eric Abrahamsen
2014-06-14  3:36         ` Drew Adams
2014-06-14  3:47           ` Eric Abrahamsen [this message]
     [not found]   ` <mailman.3579.1402672740.1147.help-gnu-emacs@gnu.org>
2014-06-13 18:55     ` Stefan Monnier
2014-06-14  8:07       ` Thorsten Jolitz
2014-06-14  8:22         ` Thorsten Jolitz
2014-06-15  1:58           ` Stefan Monnier
2014-06-14 15:52         ` Drew Adams
2014-06-14 16:27           ` Thorsten Jolitz

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=87r42sjgnn.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --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.