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: Heime
Subject: Re: Iinteractive function allowing multiple inputs
Date: Mon, 09 Dec 2024 23:39:59 +0000





Sent with Proton Mail secure email.

On Tuesday, December 10th, 2024 at 11:08 AM, Jean Louis <bugs@gnu.support> 
wrote:

> * 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

Right.



reply via email to

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