all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Rankin <hello@paulwrankin.com>
To: help-gnu-emacs@gnu.org
Subject: Re: Define skeleton from alist?
Date: Thu, 14 Jul 2016 16:00:23 +1000	[thread overview]
Message-ID: <1468476023.2261456.665866481.054747A3@webmail.messagingengine.com> (raw)
In-Reply-To: <CAOj2CQSHOHrAHe9TaZ7HAt06x5cizHJ9MjH=RaUGez9HZA4hmQ@mail.gmail.com>

John Mastro <john.b.mastro@gmail.com> on Wed, 13 Jul 2016 19:38 -0700:
> Paul Rankin <hello@paulwrankin.com> wrote:
> > I'd like to create a skeleton with define-skeleton using strings from
> > an alist. The skeleton should loop through the alist using the car of
> > each element as both the prompt and first string inserted, then the
> > cadr as initial value for user input.
> 
> I've never used skeleton but, from a quick look, it seems to me you
> might be better served by a normal command. Is there a specific reason
> you want/need to use skeleton?

I wanted to use a skeleton for auto-insert. It would appear define-auto-insert uses the skeleton language, but I would assume it can also be fed a command.

> If I understand correctly, this will achieve something like the final
> result you want:
> 
> (defun fountain-title-page-function ()
>   (interactive)
>   (dolist (elt fountain-title-page-list)
>     (let ((key (car elt))
>           (val (cadr elt)))
>       (insert key ": " (read-string (concat key ": ") val) "\n"))))

This works. Thank you. Although I ended up going with a static skeleton, because...

> The reason this seems preferable to me, based on the stated problem, is
> that it's impossible for a solution with skeleton to be much simpler
> than the command above. By definition, the solution with skeleton will
> still need a loop, etc.

It does seem like defining a skeleton from an arbitrarily long list is unduly difficult.

I wanted to use lisp expressions as initial values (e.g. (format-time-string "%F")) so in the end I figured it was unwise to go with a defcustom and then eval the cadrs. So I went with a static skeleton. More control for me, less for the user. Oh well.

Thanks for your help!



  reply	other threads:[~2016-07-14  6:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-13  8:11 Define skeleton from alist? Paul Rankin
2016-07-14  2:38 ` John Mastro
2016-07-14  6:00   ` Paul Rankin [this message]
     [not found] <mailman.1264.1468397506.26859.help-gnu-emacs@gnu.org>
2016-07-13 21:37 ` Gene
2016-07-14  1:12   ` Paul Rankin
     [not found]   ` <mailman.1366.1468458751.26859.help-gnu-emacs@gnu.org>
2016-07-15  1:13     ` Gene

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

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

  git send-email \
    --in-reply-to=1468476023.2261456.665866481.054747A3@webmail.messagingengine.com \
    --to=hello@paulwrankin.com \
    --cc=help-gnu-emacs@gnu.org \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.