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

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

Re: Iinteractive function allowing multiple inputs


From: Jean Louis
Subject: Re: Iinteractive function allowing multiple inputs
Date: Tue, 10 Dec 2024 02:08:51 +0300
User-agent: Mutt/2.2.12 (2023-09-09)

* Stefan Monnier via Users list for the GNU Emacs text editor 
<help-gnu-emacs@gnu.org> [2024-12-10 00:24]:
> > (defun my-multi-input-function (input1 input2 input3)
> >   "An example function that takes three inputs and displays them."
> >   (interactive
> >    (list
> >     (read-string "Enter the first input: ")
> >     (read-string "Enter the second input: ")
> >     (read-string "Enter the third input: ")))
> >   (message "You entered: %s, %s, %s" input1 input2 input3))
> [...]
> > Me personally, I don't like that style, I like using `let' and reading
> > what I need to read within function, while leaving (interactive) as it
> > is.
> 
> The difference between the two is that the above code provides both
> a command and a function, whereas if you move the `read-string`s outside
> of the `interactive` form, then it can't really be used as a function
> any more.

But I replace it with:

(defun my-multi-input-function (&optional input1 input2 input3)

and then it can be used as function again in the context how I think
or guess that you mean it.

Only if arguments are removed then it cannot be used as function.  

Am I right?

-- 
Jean Louis



reply via email to

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