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

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

Re: Functions with multiple optional arguments


From: Heime
Subject: Re: Functions with multiple optional arguments
Date: Mon, 17 Oct 2022 16:24:19 +0000

------- Original Message -------
On Monday, October 17th, 2022 at 5:42 AM, Heime <heimeborgia@protonmail.com> 
wrote:


> ------- Original Message -------
> On Monday, October 17th, 2022 at 4:05 AM, Jean Louis bugs@gnu.support wrote:
> 
> 
> 
> > * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org 
> > [2022-10-17 00:06]:
> > 
> > > Have been writing a function that has two optional arguments. It is
> > > turning out to be a difficult task in situations when one in missing
> > > an argument. Anybody has experience about this, as I have not seen
> > > much code with multiple optional arguments.
> > 
> > If argument is optional but required by your function, I use this method:
> > 
> > (defun my-fun (&optional title description)
> > (let ((title (or title "Best Movie"))
> > (description (or description "Description")))
> > (message "%s: %s" title description)))
> > 
> > (my-fun)
 
I want the last argument to use a symbol.  Would you be so kind to scrutinise 
my implementation please.

(defun mesgb (mesg &optional bufr actm)
  "Display message except on 'nogo symbol."

  (let ((bfr (or bufr "*Gundit*"))
        (acm (or actm 'go)))

    (when (not (eq 'nogo acm))
      (with-current-buffer (get-buffer-create bfr)
        (org-mode)
        (insert mesg))) ))




reply via email to

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