unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#38427: 26.2; skeleton-insert does not set str consistently
@ 2019-11-29 15:59 Tim Landscheidt
  2020-11-01 14:45 ` Lars Ingebrigtsen
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Landscheidt @ 2019-11-29 15:59 UTC (permalink / raw)
  To: 38427

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.)





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

end of thread, other threads:[~2020-12-09 15:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-29 15:59 bug#38427: 26.2; skeleton-insert does not set str consistently Tim Landscheidt
2020-11-01 14:45 ` Lars Ingebrigtsen
2020-11-01 20:23   ` Jean Louis
2020-12-09 15:14   ` Lars Ingebrigtsen

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).