unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jean Louis <bugs@gnu.support>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: 38427@debbugs.gnu.org, Tim Landscheidt <tim@tim-landscheidt.de>
Subject: bug#38427: 26.2; skeleton-insert does not set str consistently
Date: Sun, 1 Nov 2020 23:23:29 +0300	[thread overview]
Message-ID: <X58ZQYg3bTZdn0IX@protected.rcdrun.com> (raw)
In-Reply-To: <87mu019lvl.fsf@gnus.org>

* Lars Ingebrigtsen <larsi@gnus.org> [2020-11-01 17:48]:
> Tim Landscheidt <tim@tim-landscheidt.de> writes:
> 
> > 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".
> 
> Evaluating that form gives me:
> 
> Debugger entered--Lisp error: (void-variable somevalues)
>   (assoc str somevalues)
>   (cdr (assoc str somevalues))
>   eval((cdr (assoc str somevalues)))
>   skeleton-internal-1((cdr (assoc str somevalues)) nil nil)
> 
> I'm not at all familiar with how skeleton works, but a test case that
> works would help when trying to debug.  :-)

I am using skeletong often. And I was of opinion it was made to create
M-x interactive functions as skeletons to quickly insert such snippets
or interactive templates:

(define-skeleton dear-friend
  "Start a letter"
  nil
  "Dear " (setq name (skeleton-read "Name: ")) ", 

Thank you for your feedback.

" _ "

Greetings,
Joe
")

This gives me M-x dear-friend

If there is region marked the _ will replace it with region. It is
very handy.

Tim, I suggest that you define skeleton that works by
`define-skeleton' and then try using it in a function. On the other
hand using skeletons in function somehow beats their purpose.

(let ((somevalues '(("a" . "123") ("b" . "456"))))
(skeleton-insert
 '(nil (setq str (skeleton-read "Var: "))
 (cdr (assoc str somevalues)) | str ?\n)))

Does that work?

I have no idea what | means here.





  reply	other threads:[~2020-11-01 20:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-12-09 15:14   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X58ZQYg3bTZdn0IX@protected.rcdrun.com \
    --to=bugs@gnu.support \
    --cc=38427@debbugs.gnu.org \
    --cc=larsi@gnus.org \
    --cc=tim@tim-landscheidt.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).