[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#38427: 26.2; skeleton-insert does not set str consistently
From: |
Tim Landscheidt |
Subject: |
bug#38427: 26.2; skeleton-insert does not set str consistently |
Date: |
Fri, 29 Nov 2019 15:59:41 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
Given (A):
| (let
| ((somevalues '(("a" . "123") ("b" . "456"))))
| (skeleton-insert
| '("Prompt: "
| (cdr (assoc str somevalues)) | str ?\n)))
Emacs asks for input with "Prompt: " and with "a" given, it
outputs "a" instead of the expected "123".
However, with (B):
| (let
| ((somevalues '(("a" . "123") ("b" . "456"))))
| (skeleton-insert
| '("Prompt: "
| str ?\n
| (cdr (assoc str somevalues)) | str ?\n)))
and input "a", it outputs "a" and then "123".
This appears to be due to str being set on the first use on
its own and being:
| (setq str (skeleton-read (quote "Prompt: ") nil nil))
before that (which is not a key in somevalues).
This is probably best shown by (C):
| (let
| ((somevalues '(("a" . "123") ("b" . "456"))))
| (skeleton-insert
| '("Prompt: "
| (cdr (assoc str somevalues)) | "nothing" ?\n)))
which immediately outputs "nothing", without prompting the
user.
This might be a case of PEBKAC, but to me it feels "unnatu-
ral" that removing "str ?\n" from (B) to (A) does not only
remove the line from the output, but changes the meaning of
the skeleton altogether.
(In my use case, I could work around that by outputting str
in a comment, and in general one could probable just add
some dummy like "str (delete-backward-char (length str))",
but this feels very hackish and brittle.)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#38427: 26.2; skeleton-insert does not set str consistently,
Tim Landscheidt <=