all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Symbols in interactive user input
@ 2024-11-28 12:13 Heime via Users list for the GNU Emacs text editor
  2024-11-28 13:14 ` Stephen Berman
  0 siblings, 1 reply; 2+ messages in thread
From: Heime via Users list for the GNU Emacs text editor @ 2024-11-28 12:13 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

Do user input commands allow using symbols rather than strings?
For instance using 'extended, 'disable, 'tabtrail, which are then
used in a pcase or cond conditionals.

  (interactive
    (let* ( (colw (read-number "Line Column: " 72))
            (cseq '("extended" "disable" "tabtrail"))
            (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
            (scope (completing-read "Scope: "
                     '("global" "local") nil t "local")) )

      ;; Pass a single list as argument
      (list (list colw rsel scope))) )





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Symbols in interactive user input
  2024-11-28 12:13 Symbols in interactive user input Heime via Users list for the GNU Emacs text editor
@ 2024-11-28 13:14 ` Stephen Berman
  0 siblings, 0 replies; 2+ messages in thread
From: Stephen Berman @ 2024-11-28 13:14 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor; +Cc: Heime

On Thu, 28 Nov 2024 12:13:53 +0000 Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> wrote:

> Do user input commands allow using symbols rather than strings?
> For instance using 'extended, 'disable, 'tabtrail, which are then
> used in a pcase or cond conditionals.
>
>   (interactive
>     (let* ( (colw (read-number "Line Column: " 72))
>             (cseq '("extended" "disable" "tabtrail"))
>             (rsel (completing-read "Selector: " cseq nil t "tabtrail"))
>             (scope (completing-read "Scope: "
>                      '("global" "local") nil t "local")) )
>
>       ;; Pass a single list as argument
>       (list (list colw rsel scope))) )

`completing-read' returns a string, even if the completion collection
consists of symbols.  But you can use `intern' to get the symbol from
the string (which is the symbol's name):

(let ((s (completing-read "Enter: " '(bla bli blu) nil t)))
  (list (stringp s) (symbolp s) (symbolp (intern s))))
=> (t nil t)

Steve Berman



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-28 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-28 12:13 Symbols in interactive user input Heime via Users list for the GNU Emacs text editor
2024-11-28 13:14 ` Stephen Berman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.