0

I have got the following function but want to pass a numeric mode even if completing-read asks for a string.

(defun mycompany (mode)
  "Enables or disables company text completion in buffer."
  (interactive
   (list
    (let ( (cseq '("enable" "disable")) )
      (completing-read "Mode: " cseq nil t "disable"))))
  
 (pcase mode
   ("enable"  (global-company-mode  1))
   ("disable" (global-company-mode -1))))

1 Answer 1

0

The question is unclear, alas. Is this all you're looking for?

(defun mycompany (mode)
  "..."
  (interactive
   (list (if (equal "enable" (completing-read "Mode: "
                                              '("enable" "disable")
                                              nil
                                              t
                                              "disable"))
             1
          -1)))
  (global-company-mode mode))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.