From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Define skeleton from alist? Date: Wed, 13 Jul 2016 19:38:00 -0700 Message-ID: References: <1468397487.752665.664828897.4AC040A5@webmail.messagingengine.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1468463939 17421 80.91.229.3 (14 Jul 2016 02:38:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 14 Jul 2016 02:38:59 +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 04:38:59 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 1bNWYD-0007Vq-Bb for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 04:38:57 +0200 Original-Received: from localhost ([::1]:51049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNWYC-0006kl-Ka for geh-help-gnu-emacs@m.gmane.org; Wed, 13 Jul 2016 22:38:56 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNWXd-0006jZ-B9 for help-gnu-emacs@gnu.org; Wed, 13 Jul 2016 22:38:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bNWXc-0001fq-8d for help-gnu-emacs@gnu.org; Wed, 13 Jul 2016 22:38:21 -0400 Original-Received: from mail-qk0-x22c.google.com ([2607:f8b0:400d:c09::22c]:36676) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNWXc-0001fm-3n for help-gnu-emacs@gnu.org; Wed, 13 Jul 2016 22:38:20 -0400 Original-Received: by mail-qk0-x22c.google.com with SMTP id 82so61784975qko.3 for ; Wed, 13 Jul 2016 19:38:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=jydZFdGcCJ/jGTjh6YyOgL9c/j7c55IVy9yzUz1Ajhg=; b=snFVgdeP3I9ZXoguFlIEmBdQx/G7XiLuc1FVaa3Y5dIWzMKccuzVO/ZvSeATyom0+g nXLGR/0E9f+MXv/cvzr7HuYF4MhHot6Q2YEqExUMAbZVxc2ZPKZb8EUq+7lTwpnHmjU/ LOdM/lFQ/0/0cBqOaiA30Xj2siHjm/sjjuKBBFweUL1MHHsKXtHmiumwV7q/Tn3DZBtS HvfWIy2xBff1uVOUtnhl/ebXHAq7+gUM7Qp8WbJGyQZ4U8v9zl3G0mZeqkNrN2ZeXjMf tTxtdMfiqSkvhWxNCteAVNTvVStagQGBNKAX4zuUI6VM/MF+93M7RoaezIqoBdUXL+Ei TEGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=jydZFdGcCJ/jGTjh6YyOgL9c/j7c55IVy9yzUz1Ajhg=; b=BNGNXkLJ9rQFhi3ak1HO8lbbHQl7DFESLjgDBakpV1c+wAqvwzq7/ltygQYro2n2n3 xiWDAsYc9uqHc29XWQ9OnFV6GIrJXWI3C5y2S56V3pmiA4oq7EJWT8pit6S+AjzFX6Ok 6SaQqKQnOeQqIt12GkwVvd2Fm0izMsueEe2YBGnj8ME/dOQiVrDaTR97spzhS99mwRKi 0SP/7Tu3xOVd97aRUlA7m0fBDSAFEOOWVNgPkpph7lToacfIB26KMu6w+eqVPypipSM3 /y6uHt0es/HBv/BOsjtvPS0KmK4Yz2fdRlBwa5uenYmxLKET66vQaIrDEMmmje6xty57 XdcA== X-Gm-Message-State: ALyK8tLu1JnoMgI7+2nIhFvv9cokj36adUJttZICNc/dRdqmo6XQD8SO1QGUf1cKSFnZX4OMrgCO5vcJEPHk5g== X-Received: by 10.55.132.7 with SMTP id g7mr14177551qkd.209.1468463899467; Wed, 13 Jul 2016 19:38:19 -0700 (PDT) Original-Received: by 10.237.48.77 with HTTP; Wed, 13 Jul 2016 19:38:00 -0700 (PDT) In-Reply-To: <1468397487.752665.664828897.4AC040A5@webmail.messagingengine.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400d:c09::22c 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:110829 Archived-At: 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? 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")))) 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. Back to your question, I don't see how you could do it with define-skeleton directly. I looked at the implementation of define-skeleton, and it hands off the work to a function called skeleton-proxy-new. I suppose you could call it directly with something ugly like the below. That's admittedly unsatisfying, so hopefully someone who actually knows skeleton will be along with a better answer shortly. (progn (put 'fountain-title-page-skeleton 'no-self-insert t) (defun fountain-title-page-skeleton (&optional str arg) (interactive "*P\nP") (skeleton-proxy-new `(nil ,@(let ((i 0)) (apply #'append (mapcar (lambda (elt) (let ((key (concat (car elt) ": ")) (val (cadr elt)) (sym (intern (format "v%d" (setq i (1+ i)))))) `(> ,key (setq ,sym (skeleton-read ,key ,val)) \n))) fountain-title-page-list)))) str arg))) Hope that helps John