[Top][All Lists]

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

Re: (interactive) and &optional

From: Jean Louis
Subject: Re: (interactive) and &optional
Date: Sat, 25 Mar 2023 17:32:06 +0300
User-agent: Mutt/2.2.9+54 (af2080d) (2022-11-21)

* Dr Rainer Woitok <> [2023-03-25 15:05]:
> > I do not like involving `interactive' at all, so I do the handling by
> > providing optional argument and telling function to check for it, or
> > ask for it.
> > 
> > (defun search-something (&optional query)
> >   "Search something by using QUERY."
> >   (interactive)
> >   (let* ((query (or query (read-from-minibuffer "Query: "))))
> >     (do-the-search query)))
> Correct me if I'm wrong,  but doesn't this  unconditionally call  "read-
> from-minibuffer"  when non-interactively called  without argument?  Non-
> interactively I would like the function to simply use my default value.

Yet, it calls unconditionally if that is the choice of programmer.

If you want default value, then you can do so:

(let* ((query (or query my-default-value (read-from-minibuffer "Query: "))))
  (do-the-search query)))

or like this:

(let* ((query (or query my-default-value)))
  (do-the-search query))


Take action in Free Software Foundation campaigns:

In support of Richard M. Stallman

reply via email to

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