From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Rankin Newsgroups: gmane.emacs.help Subject: Re: Define skeleton from alist? Date: Thu, 14 Jul 2016 16:00:23 +1000 Message-ID: <1468476023.2261456.665866481.054747A3@webmail.messagingengine.com> References: <1468397487.752665.664828897.4AC040A5@webmail.messagingengine.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1468477964 26768 80.91.229.3 (14 Jul 2016 06:32:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2016 06:32:44 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jul 14 08:32:35 2016 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1bNaCJ-0003Ry-6Y for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 08:32:35 +0200 Original-Received: from localhost ([::1]:51868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNaCI-0000wn-FI for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 02:32:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44564) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNZhQ-0005hX-99 for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 02:00:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNZhM-0003nm-4K for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 02:00:39 -0400 Original-Received: from out5-smtp.messagingengine.com ([66.111.4.29]:59272) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNZhJ-0003ln-Jd for help-gnu-emacs@gnu.org; Thu, 14 Jul 2016 02:00:35 -0400 Original-Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 1FBD32059E for ; Thu, 14 Jul 2016 02:00:24 -0400 (EDT) Original-Received: from web1 ([10.202.2.211]) by compute3.internal (MEProxy); Thu, 14 Jul 2016 02:00:24 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=paulwrankin.com; h=content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=arspGkCl2Bf5ggStbupwUIRAtSo=; b=qUDFfZ t0piq3+s05I1JPMZ/JSXMdxRIKAc23nftiuB/ZPVi+SMHgDc9llPR3VYVL1DBq6J dSV/9ZFNdE4qSWIqIlIeKvnPMVT/RaN4/y2OViyn34Jqf/b/Xsy96mifdTPXuPel LDf1/37tSvtTWkNoxxRnMbojsZEajDsIptedc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=arspGkCl2Bf5ggS tbupwUIRAtSo=; b=gkB1IcEG6sRKAx4YOky0biuVTIRf//W+a72EK5ImdRwQYYn 8PDdddNUU6FbEAh/PQq4uaL/XEpVJUDBBR7whmbj/tJOdQ71jzinXOwuaZP1A4ML OddeEHyRjyLSdv6DBojeNhumf7ITO0K3SD98bjkcUSMjB+c0fgEZsyAUl1uI= Original-Received: by mailuser.nyi.internal (Postfix, from userid 99) id D04616A23B; Thu, 14 Jul 2016 02:00:23 -0400 (EDT) X-Sasl-Enc: pObNR4cdDykbWGYelIoeQKiILb34O7msv6ulLIHCh6wp 1468476023 X-Mailer: MessagingEngine.com Webmail Interface - ajax-bf4e2c8f In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.29 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:110834 Archived-At: John Mastro on Wed, 13 Jul 2016 19:38 -0700: > Paul Rankin 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!