help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to fix/work around "first" skeleton evaluation of str in expressions


From: Tim Landscheidt
Subject: How to fix/work around "first" skeleton evaluation of str in expressions?
Date: Tue, 02 Aug 2022 21:36:15 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Hi,

given the example:

| (let
|     ((v '(("a" . "b"))))
|   (skeleton-insert `((completing-read "Input: " ',v)
|                      "str = " str ?\n
|                      "Output: " (cdr (assoc str ',v)) | str ?\n)))

when entering/choosing "a" at prompt, the output is:

| str = a
| Output: b

When entering "not-a", the output is:

| str = not-a
| Output: not-a

Everything is working as expected.  Now if the first line of
the skeleton is removed:

| (let
|     ((v '(("a" . "b"))))
|   (skeleton-insert `((completing-read "Input: " ',v)
|                      "Output: " (cdr (assoc str ',v)) | str ?\n)))

the output when entering "a" is:

| Output: a

The same happens if (completing-read "Input: " ',v) is re-
placed by a simple "Input: ".

skeleton-insert's documentation says:

| […]                             The following local variables are
| available:

|         str     first time: read a string according to INTERACTOR
|                 then: insert previously read string once more
| […]

so I can imagine that skeleton-insert gets confused by str
being first used inside an expression.

But what is the proper way to reliably use it "there"?

TIA,
Tim




reply via email to

[Prev in Thread] Current Thread [Next in Thread]