From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/80270 Path: news.gmane.org!not-for-mail From: Sietse Brouwer Newsgroups: gmane.comp.tex.context Subject: Re: buffers (append) Date: Tue, 15 Jan 2013 14:41:04 +0100 Message-ID: References: <20130114090013.16b0a433@iram-hb-003386.extra.cea.fr> <1049A773-8637-4DB2-86D6-1148CB652C92@gmail.com> <20130114144824.3826f2d5@iram-hb-003386.extra.cea.fr> Reply-To: mailing list for ConTeXt users NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1358257314 13256 80.91.229.3 (15 Jan 2013 13:41:54 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 15 Jan 2013 13:41:54 +0000 (UTC) To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Tue Jan 15 14:42:10 2013 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane.org Original-Received: from balder.ntg.nl ([195.12.62.10]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tv6m6-0002u2-Ud for gctc-ntg-context-518@m.gmane.org; Tue, 15 Jan 2013 14:41:59 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 4C7C1101F6; Tue, 15 Jan 2013 14:41:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 3bjtmgzyNJ21; Tue, 15 Jan 2013 14:41:38 +0100 (CET) Original-Received: from balder.ntg.nl (localhost [IPv6:::1]) by balder.ntg.nl (Postfix) with ESMTP id 8D351101E5; Tue, 15 Jan 2013 14:41:38 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by balder.ntg.nl (Postfix) with ESMTP id 58ABE101E5 for ; Tue, 15 Jan 2013 14:41:36 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at balder.ntg.nl Original-Received: from balder.ntg.nl ([127.0.0.1]) by localhost (balder.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1tnKIDSAnXXz for ; Tue, 15 Jan 2013 14:41:35 +0100 (CET) Original-Received: from filter5-til.mf.surf.net (filter5-til.mf.surf.net [194.171.167.221]) by balder.ntg.nl (Postfix) with ESMTP id 68D41101E2 for ; Tue, 15 Jan 2013 14:41:35 +0100 (CET) Original-Received: from mail-ea0-f174.google.com (mail-ea0-f174.google.com [209.85.215.174]) by filter5-til.mf.surf.net (8.14.3/8.14.3/Debian-9.4) with ESMTP id r0FDVADG010334 for ; Tue, 15 Jan 2013 14:31:10 +0100 Original-Received: by mail-ea0-f174.google.com with SMTP id 1so45727eaa.5 for ; Tue, 15 Jan 2013 05:41:34 -0800 (PST) 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 :cc:content-type; bh=ezyZlrZKYTuXZtiDyUZsz6y9ANCuIIEzCfQbBgebY9Q=; b=Zshj9RIb1AAMOwEqkBSzR7RyPPDiRIwKbyoIS+OJZKEkHhV7t0eK+Tkvt9abXH2nIY jqYwuGxDIzY5dzwawaY2crOCaBpn8FmUsExYDTZ0IQl+uN+9PNvO0bIv9lyj5A91nKgJ YgkXxCLOmZbnZOgs2JNHFFkTS+ZpG8gS1qYfvBu/ofsl9RF48vndAlkN4jXwqJBBE5rV wv0BI7LXTxTRA8BTkHbMusJQ6NHkRLLv7U8WDjdaMCI9+F6anEQ5bLT68swzoaTMd54g e7ZU6vWE+v9Ds+QSAjoEzvtlHlcNfXvRu4zNzmgQQ9s98c73/UVUPOH8odbrT5ZzwDKm IzWg== Original-Received: by 10.14.207.6 with SMTP id m6mr241016168eeo.10.1358257294334; Tue, 15 Jan 2013 05:41:34 -0800 (PST) Original-Received: by 10.14.101.129 with HTTP; Tue, 15 Jan 2013 05:41:04 -0800 (PST) In-Reply-To: <20130114144824.3826f2d5@iram-hb-003386.extra.cea.fr> X-Bayes-Prob: 0.9999 (Score 4.7, tokens from: @@RPTN) X-CanIt-Geo: ip=209.85.215.174; country=US; region=CA; city=Mountain View; postalcode=94043; latitude=37.4192; longitude=-122.0574; metrocode=807; areacode=650; http://maps.google.com/maps?q=37.4192,-122.0574&z=6 X-CanItPRO-Stream: uu:ntg-context@ntg.nl (inherits from uu:default, base:default) X-Canit-Stats-ID: 0WIMdvaHE - 0b4a47725b82 - 20130115 X-Scanned-By: CanIt (www . roaringpenguin . com) on 194.171.167.221 X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.14 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: ntg-context-bounces@ntg.nl Xref: news.gmane.org gmane.comp.tex.context:80270 Archived-At: Hi Alan, >> > In addition to \startbuffer \stopbuffer >> > it would be nice to have \startappendbuffer \stopappendbuffer. >> > >> > I see that the lua function buffer.append() exists but I have not >> > worked-out how to add this functionality cleanly as conTeXt macros. Here you go! % We want to join appended pieces with a newline % but '\n' is a bit rotten to pass inside \ctxlua % so we simply prepare the appending function inside \startluacode, instead \startluacode userdata = userdata or { } function userdata.addTempToBuffer(buffername) buffers.append( buffername, '\n' .. buffers.getcontent('APPENDTEMP') ) end \stopluacode \def\startappendbuffer[#1]% {% 1: create a \stopappendbuffer that appends APPENDTEMP to the buffer #1 \def\stopappendbuffer% {\ctxlua{userdata.addTempToBuffer('#1')}} % 2: write the buffer to APPENDTEMP instead of overwriting buffer #1 % then addTempToBuffer will take care of the appending. \dostartbuffer[APPENDTEMP][startappendbuffer][stopappendbuffer]} %%% --- And here is an example --- %%% %%% --- With my respects to Dorothy L. Sayers --- %%% \setuplayout[backspace=6cm, leftmargin=5cm, width=11cm] \showframe \starttext \startbuffer[x] \inmargin{Harriet Vane} Here then at home, by no more storms distrest, Folding laborious hands we sit, wings furled; Here in close perfume lies the rose-leaf curled, Here the sun stands and knows not east nor west, Here no tide runs; we have come, last and best, >From the wide zone through dizzying circles hurled, To that still centre where the spinning world Sleeps on its axis, to the heart of rest. \stopbuffer \startlines \getbuffer[x] \stoplines ------ \startappendbuffer[x] \inmargin{Lord Peter Wimsey} Lay on thy whips, O Love, that we upright, Poised on the perilous point, in no lax bed May sleep, as tension at the verberant core Of music sleeps; for, if thou spare to smite, Staggering, we stoop, stooping, fall dumb and dead, And, dying so, sleep our sweet sleep no more. \stopappendbuffer \startlines \getbuffer[x] \stoplines ------ \typebuffer[x] \stoptext ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ___________________________________________________________________________________