unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* Defaulting optional numeric and string arguments
@ 2024-09-12 17:39 Heime
  2024-09-12 19:17 ` Stefan Monnier via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 5+ messages in thread
From: Heime @ 2024-09-12 17:39 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

I have an optional numeric argument n passed to a function. 

Am having difficulty setting a default for it to cater for both the 
interactive and non-interactive cases.

Is the below how to do it ?   

  (setq n (if (or (not n) (not numberp n)) 0 n))

I also have an optional string bfrn, to which I am using

  (setq bfrn  (if (or (not bfrn) (string= bfrn "")) "Context" bfrn))




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-12 20:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 17:39 Defaulting optional numeric and string arguments Heime
2024-09-12 19:17 ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-09-12 20:00   ` Heime
2024-09-12 20:18     ` Stefan Monnier
2024-09-12 20:29       ` Heime

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