0

Would like to have an interactive function that enables or disables two features (either auto-complete or company). Is this how I can use the interactive clause to pass two function arguments? I get confused because customarily, let returns only one thing, the result of the last command.

(defun complt (featr actm)
  "Enable or disable text completion."

(interactive (list (let* ( (cseq '("acomplt" "company")) (cftr (completing-read "Featr: " cseq nil t "company")) (csel (completing-read "Actm: " '("disable" "enable") nil t "enable")) ) cftr csel)))

(message "DO THIS") (message "DO THAT"))

Dilna
  • 1
  • 3
  • 11

2 Answers2

0

Indeed let returns a single value, while for passing two values via 'interactive' you would like to pass a list containing two elements/values,

therefore, just place the list inside the let as follows to get what you want:

(defun complt (featr actm)
  "Enable or disable text completion."

(interactive (let* ( (cseq '("acomplt" "company")) (cftr (completing-read "Featr: " cseq nil t "company")) (csel (completing-read "Actm: " '("disable" "enable") nil t "enable")) ) (list cftr csel)))

(message "DO THIS") (message "DO THAT"))

dalanicolai
  • 7,795
  • 8
  • 24
0

Yes, you have confused these two things: (list (form a b)) and (form (list a b)).

I think a simpler way to write this avoids let entirely:

(defun complt (featr actm)
  "Enable or disable text completion."

(interactive (list (completing-read "Featr: " '("acomplt" "company") nil t "company") (completing-read "Actm: " '("disable" "enable") nil t "enable")))

(message "DO THIS") (message "DO THAT"))

Here is another version using let:

(defun complt (featr actm)
  "Enable or disable text completion."

(interactive (list (let ((choices '("acomplt" "company")) (completing-read "Featr: " choices nil t "company"))) (let ((choices '("disable" "enable")) (completing-read "Actm: " choices nil t "enable")))))

(message "DO THIS") (message "DO THAT"))