From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Gene Newsgroups: gmane.emacs.help Subject: Re: Define skeleton from alist? Date: Thu, 14 Jul 2016 18:13:09 -0700 (PDT) Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1468545342 3134 80.91.229.3 (15 Jul 2016 01:15:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 15 Jul 2016 01:15:42 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jul 15 03:15:42 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 1bNrjB-00062v-AX for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Jul 2016 03:15:41 +0200 Original-Received: from localhost ([::1]:57727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bNrjA-0007o2-MZ for geh-help-gnu-emacs@m.gmane.org; Thu, 14 Jul 2016 21:15:40 -0400 X-Received: by 10.129.155.86 with SMTP id s83mr13668888ywg.44.1468545190120; Thu, 14 Jul 2016 18:13:10 -0700 (PDT) X-Received: by 10.36.222.198 with SMTP id d189mr55125itg.2.1468545190081; Thu, 14 Jul 2016 18:13:10 -0700 (PDT) Original-Path: usenet.stanford.edu!j37no1615278qta.0!news-out.google.com!d130ni3071ith.0!nntp.google.com!f6no367853ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=67.255.103.23; posting-account=xePGxQoAAAAgJalA5zaHmrGIX9Wk_gLW Original-NNTP-Posting-Host: 67.255.103.23 User-Agent: G2/1.0 Injection-Date: Fri, 15 Jul 2016 01:13:10 +0000 Original-Xref: usenet.stanford.edu gnu.emacs.help:218541 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:110851 Archived-At: On Wednesday, July 13, 2016 at 9:12:33 PM UTC-4, Paul Rankin wrote: > Gene on Wed, 13 Jul 2016 14:37 -0700: > > At first blush it seems as you might have an impoverished mental model >=20 > Okay. >=20 > > Thus I present the following for your `eval'uation: > >=20 > > (mapcar 'identity fountain-title-page-list) > >=20 > > (mapcar (lambda (elt)(identity elt)) fountain-title-page-list) > >=20 > > (mapcar (lambda (elt)(car elt)) fountain-title-page-list) > >=20 > > (mapcar (lambda (elt)(cdr elt)) fountain-title-page-list) > >=20 > > (mapcar (lambda (elt)(cons (car elt)(cdr elt))) fountain-title-page-lis= t) >=20 > None of this produces a skeleton. See (info "(autotype) Skeleton Language= ") I'm not sure whether to respond with `Point taken' or `Really?' If I were to acknowledge my failure to unequivocally reveal how `cons' can = be used to CONStruct any/every list type -- alists and skeletons included -= - then I'd have to concede my failure via `point taken'. As the `cons' in the subexpression `(cons (car elt)(cdr elt))(cons (car elt= )(cdr elt))' reveals how to CONStruct atomic elements into some of the comp= onents in both an alist and skeleton I might be tempted to chock this up to= failure of imagination ... especially given that `car' and `cons' are inve= rses which allow analytical decomposition and synthetic composition, respec= tively. The point of my one-liners was to reveal the low-level cons_cell-cum-list o= perators and how they can be used to both decompose and compose lists ... o= f which both alists and skeletons are -- arguably -- subspecies. As strings are employed in Skeletons I'll provide the following inverses to= reveal how to decompose then recompose a string encoding some of that info= you suggested I read: (let ; this be evaluated to generate a side-effect in the form of a demo=20 ( (string=20 "Skeletons are an shorthand extension to the Lisp language, where various a= toms directly perform either actions on the current buffer or rudimentary f= low control mechanisms. =20 Skeletons are interpreted by the function skeleton-insert. =20 A skeleton is a list starting with an interactor, which is usually a prompt= -string, or nil when not needed, but can also be a Lisp expression for comp= lex read functions or for returning some calculated value. =20 The rest of the list are any number of elements as described in the followi= ng table:" );string (sentence-end ". ") (word-delimiter " ")=20 list-of-sentences list-of-words-within-sentences sentences-from-words paragraph-from-sentences ) (setq=20 list-of-sentences=20 (split-string ; the inverse of mapconcat=20 ; 'identity ; FUNCTION ; this argument is needed by mapconcat, though n= ot split-string string ; STRING ... which corresponds with SEQUENCE after the string ha= s been split to form a list useable by mapconcat sentence-end ; SEPARATORS ... which corresponds with SEPERATOR -- singu= lar -- when used by mapconcat ) ) (setq list-of-words-within-sentences (mapcar (lambda (sentence) (split-string sentence word-delimiter )) list-of-sentences=20 ) ) =20 (setq sentences-from-words (mapcar (lambda (list-of-words) (mapconcat ; the inverse of split-string when both use mutually-compat= ible arguments 'identity ; FUNCTION used to concatenate substrings into larger, synt= hesized, composited strings list-of-words ; SEQUENCE word-delimiter ; SEPARATOR )) list-of-words-within-sentences ) ) (setq paragraph-from-sentences (list) ; to be replaced via (mapcar (lambda mapconcat)) FUNCTIONAL const= ruct by those following the demo-cum-exercise ) (list=20 (cons 'string string) (cons 'sentence-end sentence-end) (cons 'word-delimiter word-delimiter) (cons 'list-of-sentences list-of-sentences) (cons 'list-of-words-within-sentences list-of-words-within-sentences) (cons 'sentences-from-words sentences-from-words) (cons 'paragraph-from-sentences paragraph-from-sentences) ) ) I agree that I didn't provide a complete set of dots to connect. I hope you'll agree that I DID provide `cons' as a means of ultimately conn= ecting an ordered set of metaphorical dots, as well as `car' as a means -- = perhaps recursively as with mapcar -- to decompose/deconstruct both partial= ly and completely composed lists ... be they `be' or SEEM either alists or = skeletons. Reminder from info: "A skeleton is a list starting with ..." Thus a skeleton as A LIST can be CONStructed via functional paradigm as wel= l as statically created via the declarative paradigm. I have responded to your admission "My feeble non-functional attempt at the= define-skeleton: " as if you might be interested in clues on how you might= bridge the gap between your essentially `declarative' first attempt and wh= atever perhaps-hybrid implementation you end up with. Admittedly, perhaps you want a quick and direct solution which doesn't enta= il squandering time or getting your hands dirty at a lower-than-necessary l= evel of detail. If so ... NEVERMIND! As John Mastro seems to have addressed your problem at a/the level you desi= red I suppose we can consider this issue closed. Hopefully some of the from-the-ground-upwards and take-it-appart-then-put-i= t-back-together-again programmers out there might get some use out of my ex= amples involving analytic-synthetic inverses. Cheers! Gene P.S. Although perhaps you personally have low to no interest in metaprogram= ming, I'll reveal that the use of the functional paradigm to CONStruct your= otherwise static data structure put's one's mindset several steps closer t= o exploiting metaprogramming to CONStruct static-declarative -- TO THE REST= OF THE WORLD -- `code'.=20 Any/every alist and skeleton can be disassembled into a recipe via `car' an= d its relatives in the `mapcar' family. Then this recipe -- using `cons' to correspond with the `car' function used= to disassemble either the alist or skeleton -- can be `eval'uated to produ= ce the quasiStatic data structure originally implemented -- if not conceive= d -- via the declarative paradigm. In a sentence, one can start with a Cathedral then disassemble its structur= e to produce a recipe for a next-generation Cathedral ... never having to s= ettle for a helter skelter bazaar. G /pedantic tripe