* Make optional argument equal to 0
@ 2007-02-09 11:16 weber
2007-02-09 12:10 ` Juanma Barranquero
[not found] ` <mailman.4228.1171023032.2155.help-gnu-emacs@gnu.org>
0 siblings, 2 replies; 3+ messages in thread
From: weber @ 2007-02-09 11:16 UTC (permalink / raw)
To: help-gnu-emacs
Hello.
I'd like to set 'arg' to zero when nothing is passed as argument.
Here is a test function:
(defun try-arg (&optional arg)
"Show which arg is passed."
(interactive "p")
(or arg (setq arg 0))
(message "arg = %d" arg))
If I just call it with M-x try-arg, shouldn't I be geting a 0 ?
I'm getting a 1! :)
Thanks in advance,
weber
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make optional argument equal to 0
2007-02-09 11:16 Make optional argument equal to 0 weber
@ 2007-02-09 12:10 ` Juanma Barranquero
[not found] ` <mailman.4228.1171023032.2155.help-gnu-emacs@gnu.org>
1 sibling, 0 replies; 3+ messages in thread
From: Juanma Barranquero @ 2007-02-09 12:10 UTC (permalink / raw)
To: weber; +Cc: help-gnu-emacs
On 9 Feb 2007 03:16:54 -0800, weber <hugows@gmail.com> wrote:
> If I just call it with M-x try-arg, shouldn't I be geting a 0 ?
> I'm getting a 1! :)
Try with (interactive "P"), not "p". With "p" arg is never nil.
/L/e/k/t/u
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Make optional argument equal to 0
[not found] ` <mailman.4228.1171023032.2155.help-gnu-emacs@gnu.org>
@ 2007-02-09 12:22 ` weber
0 siblings, 0 replies; 3+ messages in thread
From: weber @ 2007-02-09 12:22 UTC (permalink / raw)
To: help-gnu-emacs
On 9 fev, 09:10, "Juanma Barranquero" <lek...@gmail.com> wrote:
> On 9 Feb 2007 03:16:54 -0800, weber <hug...@gmail.com> wrote:
>
> > If I just call it with M-x try-arg, shouldn't I be geting a 0 ?
> > I'm getting a 1! :)
>
> Try with (interactive "P"), not "p". With "p" arg is never nil.
>
> /L/e/k/t/u
Works!
Thanks
weber
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-09 12:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-09 11:16 Make optional argument equal to 0 weber
2007-02-09 12:10 ` Juanma Barranquero
[not found] ` <mailman.4228.1171023032.2155.help-gnu-emacs@gnu.org>
2007-02-09 12:22 ` weber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).