GNU bug report logs - #38427
26.2; skeleton-insert does not set str consistently

Previous Next

Package: emacs;

Reported by: Tim Landscheidt <tim <at> tim-landscheidt.de>

Date: Fri, 29 Nov 2019 16:00:02 UTC

Severity: normal

Tags: moreinfo

Found in version 26.2

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tim Landscheidt <tim <at> tim-landscheidt.de>
To: bug-gnu-emacs <at> gnu.org
Subject: 26.2; skeleton-insert does not set str consistently
Date: Fri, 29 Nov 2019 15:59:41 +0000
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.)




This bug report was last modified 4 years and 165 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.