Calling (interactive) when choice is nil
Heime <[email protected]> Sun, 26 Jul 2026 18:00:53 +0000
| Newsgroups | gmane.emacs.help |
|---|---|
| Message-ID | <hCokOc6-_tAhxajKrLsOpGXh9uDE2kEcN5q0RsSAlh7GUeGvlVEt8NDqjwv77mMCOm48cLOsQfYOpia6qIOov3lnTDxfLp-yHmZv0wwsTKE=@protonmail.com> |
I've written this function to modify the value of a global variable,=20
making it usable both interactively and programmatically in Elisp=20
code. When choice is nil, the function prompts the user interactively=20
to select a value. If choice is provided, it sets the variable=20
directly based on that value.
Is it generally a good idea to call (interactive) when choice is nil?
(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)))