From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Baum Subject: Re: How to pass a block of text to a code block as data? Date: Mon, 11 Feb 2013 16:49:11 -0500 Message-ID: References: <8638x6y2zn.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=089e0115f3be21c3bd04d579e18c Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53436) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U51FT-0000ya-Ft for emacs-orgmode@gnu.org; Mon, 11 Feb 2013 16:49:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U51FQ-0007G6-UQ for emacs-orgmode@gnu.org; Mon, 11 Feb 2013 16:49:15 -0500 Received: from mail-vc0-f181.google.com ([209.85.220.181]:58366) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U51FQ-0007Fd-KG for emacs-orgmode@gnu.org; Mon, 11 Feb 2013 16:49:12 -0500 Received: by mail-vc0-f181.google.com with SMTP id d16so4055144vcd.26 for ; Mon, 11 Feb 2013 13:49:11 -0800 (PST) In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Sean O'Halpin Cc: Sebastien Vauban , emacs-orgmode@gnu.org --089e0115f3be21c3bd04d579e18c Content-Type: text/plain; charset=ISO-8859-1 Sean, that helps too, thank you. Now that you and Sebastien have gone to all this trouble I found the part of the manual that sort of describes this, but I clearly didn't understand it before. Possible needs a more worked-out example for the slow among us, like self. I've noticed one curious thing in trying a perl example. See first: ---------------------8<---------------------------------- #+name: wake #+BEGIN_EXAMPLE riverrun, past Eve and Adam's, from swerve of shore to bend of bay, brings us by a commodius vicus of recirculation back to Howth Castle and Environs. Sir Tristram, violer d'amores, fr'over the short sea, had passen- core rearrived from North Armorica on this side the scraggy isthmus of Europe Minor to wielderfight his penisolate war: nor had topsawyer's rocks by the stream Oconee exaggerated themselse to Laurens County's gorgios while they went doublin their mumper all the time: nor avoice from afire bellowsed mishe mishe to #+END_EXAMPLE #+begin_src perl :var inlines=wake :results output foreach $aln (split(/$/,$inlines)) { print $aln; } #+end_src #+results: : riverrun, past Eve and Adam's, from swerve of shore to bend : of bay, brings us by a commodius vicus of recirculation back to : Howth Castle and Environs. : Sir Tristram, violer d'amores, fr'over the short sea, had passen- : core rearrived from North Armorica on this side the scraggy : isthmus of Europe Minor to wielderfight his penisolate war: nor : had topsawyer's rocks by the stream Oconee exaggerated themselse : to Laurens County's gorgios while they went doublin their mumper : all the time: nor avoice from afire bellowsed mishe mishe to ---------------------8<---------------------------------- and then a more complicated block that's closer to my real task: ---------------------8<---------------------------------- #+NAME: job2 #+BEGIN_EXAMPLE !START !ID:7655 !DATE:02/10/2013 !CLOSE:03/15/2013 !UNTILFILLED: !POSITION:Science Editor !COMPANY:East Newark Times Herald News and World Defender !BEGIN-DESCRIPTION Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. !END-DESCRIPTION !BEGIN-SPECIAL Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue. !END-SPECIAL !SALARY:16.67 per hour !BEGIN-CONTACT Please submit online at http://enthnawd.org/jobs !END-CONTACT !END #+END_EXAMPLE #+begin_src perl :var inlines=job2 :results output foreach $aln (split(/$/,$inlines)) { print $aln; } #+end_src #+results: #+begin_example !START !ID:7655 !DATE:02/10/2013 !CLOSE:03/15/2013 !UNTILFILLED: !POSITION:Science Editor !COMPANY:East Newark Times Herald News and World Defender !BEGIN-DESCRIPTION Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. !END-DESCRIPTION !BEGIN-SPECIAL Duis eget lorem ac odio lobortis suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui. Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis vitae orci purus, quis euismod augue. !END-SPECIAL !SALARY:16.67 per hour !BEGIN-CONTACT Please submit online at http://enthnawd.org/jobs !END-CONTACT !END #+end_example ---------------------8<---------------------------------- NOTICE THAT while both return the result as Example text, the first simple prepends each line with a colon, simple Example form, and the second wraps the result in an Example block without altering the lines. Not sure why? Is this just a function of the number of lines of the text? Michael -- ==================================== Michael Baum You should never have your best trousers on when you go out to fight for freedom and truth. - Ibsen --089e0115f3be21c3bd04d579e18c Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sean, that helps too, thank you. Now that you and Sebastien have gone to al= l this trouble I found the part of the manual that sort of describes this, = but I clearly didn't understand it before. Possible needs a more worked= -out example for the slow among us, like self.

I've noticed one curious thing in trying a perl example. See first:=

---------------------8<----------------------------------
#+n= ame: wake
#+BEGIN_EXAMPLE
=A0=A0=A0 riverrun, past Eve and Adam's= , from swerve of shore to bend
of bay, brings us by a commodius vicus of recirculation back to
Howth Ca= stle and Environs.
=A0=A0=A0 Sir Tristram, violer d'amores, fr'o= ver the short sea, had passen-
core rearrived from North Armorica on thi= s side the scraggy
isthmus of Europe Minor to wielderfight his penisolate war: nor
had tops= awyer's rocks by the stream Oconee exaggerated themselse
to Laurens = County's gorgios while they went doublin their mumper
all the time: = nor avoice from afire bellowsed mishe mishe to
#+END_EXAMPLE

#+begin_src perl :var inlines=3Dwake :results output=A0 foreach $aln (split(/$/,$inlines)) {
=A0=A0=A0=A0=A0=A0 print $aln= ;
=A0 }
#+end_src


#+results:
: riverrun, past Eve and A= dam's, from swerve of shore to bend
: of bay, brings us by a commodius vicus of recirculation back to
: Howt= h Castle and Environs.
:=A0=A0=A0=A0 Sir Tristram, violer d'amores, = fr'over the short sea, had passen-
: core rearrived from North Armor= ica on this side the scraggy
: isthmus of Europe Minor to wielderfight his penisolate war: nor
: had = topsawyer's rocks by the stream Oconee exaggerated themselse
: to La= urens County's gorgios while they went doublin their mumper
: all th= e time: nor avoice from afire bellowsed mishe mishe to

---------------------8<----------------------------------

and= then a more complicated block that's closer to my real task:

--= -------------------8<----------------------------------

#+NAME: j= ob2
#+BEGIN_EXAMPLE
!START
!ID:7655
!DATE:02/10/2013
!CLOSE:03/15/2= 013
!UNTILFILLED:
!POSITION:Science Editor
!COMPANY:East Newark Ti= mes Herald News and World Defender
!BEGIN-DESCRIPTION
Lorem ipsum dol= or sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod ti= ncidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad mini= m veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut = aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse mo= lestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros = et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril del= enit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis = suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui= . Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis= vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit o= nline at=A0 http://e= nthnawd.org/jobs
!END-CONTACT
!END
#+END_EXAMPLE


#+= begin_src perl :var inlines=3Djob2 :results output
=A0 foreach $aln (split(/$/,$inlines)) {
=A0=A0=A0=A0=A0=A0 print $aln;<= br>=A0 }
#+end_src

#+results:
#+begin_example
!START
!ID= :7655
!DATE:02/10/2013
!CLOSE:03/15/2013
!UNTILFILLED:
!POSITIO= N:Science Editor
!COMPANY:East Newark Times Herald News and World Defender
!BEGIN-DESCRIP= TION
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam = nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpa= t. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper sus= cipit lobortis nisl ut aliquip ex ea commodo consequat.

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse mo= lestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros = et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril del= enit augue duis dolore te feugait nulla facilisi.

!END-DESCRIPTION
!BEGIN-SPECIAL
Duis eget lorem ac odio lobortis = suscipit nec et neque. Sed at quam ut mauris scelerisque congue id eget dui= . Quisque tellus lectus, tristique eu posuere in, faucibus vitae urna. Duis= vitae orci purus, quis euismod augue.
!END-SPECIAL
!SALARY:16.67 per hour
!BEGIN-CONTACT
Please submit o= nline at=A0 http://e= nthnawd.org/jobs
!END-CONTACT
!END
#+end_example

------= ---------------8<----------------------------------

NOTICE THAT while both return the result as Example text, the first sim= ple prepends each line with a colon, simple Example form, and the second wr= aps the result in an Example block without altering the lines.

Not sure why? Is this just a function of the number of lines of the text?
Michael


--
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D
Michael Baum <maabaum@gmail.com>

You should never have your best trouse= rs on when you go out
=A0to fight for freedom and truth. - Ibsen --089e0115f3be21c3bd04d579e18c--