Re: Calling (interactive) when choice is nil
Stefan Monnier via Users list for the GNU Emacs text editor <[email protected]> Mon, 27 Jul 2026 10:01:00 -0400
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <[email protected]> |
> Is it generally a good idea to call (interactive) when choice is nil?
I don't understand the question.
> (defun xia-dedicated-display-set (&optional choice)
> ""
> (interactive)
> (let ((selection (or choice
> (completing-read "Display: "
> '("new-window" "new-frame" "reuse") nil t))))
> (setq xia-dedicated-display (intern selection))
> (message "xia-dedicated-display set to: %s" xia-dedicated-display)))
I'd recommend moving the user-interaction to the `interactive` form:
(defun xia-dedicated-display-set (selection)
""
(interactive
(list (intern (completing-read "Display: "
'("new-window" "new-frame" "reuse") nil t))))
(setq xia-dedicated-display selection)
(message "xia-dedicated-display set to: %S" xia-dedicated-display))
=== Stefan