help-gnu-emacs
[Top][All Lists]
Advanced

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

RE: Suppress user-prompting when calling commands in programs


From: Drew Adams
Subject: RE: Suppress user-prompting when calling commands in programs
Date: Fri, 13 Jun 2014 20:36:47 -0700 (PDT)

> > 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.



reply via email to

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