[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Suppress user-prompting when calling commands in programs

From: Eric Abrahamsen
Subject: Re: Suppress user-prompting when calling commands in programs
Date: Sat, 14 Jun 2014 11:47:56 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

Drew Adams <address@hidden> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]