help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Define skeleton from alist?


From: Paul Rankin
Subject: Re: Define skeleton from alist?
Date: Thu, 14 Jul 2016 16:00:23 +1000

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 via email to

[Prev in Thread] Current Thread [Next in Thread]