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 21:02:09 +0000





Sent with Proton Mail secure email.

On Tuesday, December 10th, 2024 at 8:48 AM, Heime via Users list for the GNU 
Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> 
> 
> 
> 
> 
> Sent with Proton Mail secure email.
> 
> 
> On Tuesday, December 10th, 2024 at 8:43 AM, Jean Louis bugs@gnu.support wrote:
> 
> > * Heime via Users list for the GNU Emacs text editor help-gnu-emacs@gnu.org 
> > [2024-12-09 21:42]:
> > 
> > > Is there a way for an interactive function to allow multiple inputs?
> > 
> > (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))
> > 
> > ;; To use the function, execute it with M-x my-multi-input-function
> > 
> > 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. - Jean Louis
> 
> 
> But then you would not be able to use it in elisp code because it would
> ask for the values.

Have found completing-read-multiple.  But need some help understanding 
the exact format.  I want to set company-backends.  How would one pass
the multiple arguments in elisp code?  

Should I use

   (defun cbackends (&rest actm-seqr)

or keep it as is?

(defun cbackends (actm-seqr)

  (interactive
    (let* ( (cseq '("company-dabbrev"
                    "company-dabbrev-code"
                    "company-keywords"
                    "company-capf"
                    "company-yasnippet"
                    "company-files"))

            (backends-seltr
                (completing-read-multiple
                  "Backends Multi-Seltr (comma-separated): "
                  cseq nil t)))

      (list (mapcar #'intern backends-seltr))))

    (setq company-backends actm-seqr))







reply via email to

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