From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Literate Programming with Org mode Date: Sat, 01 Aug 2009 19:46:30 -0600 Message-ID: References: <87my6ordhh.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MXQ9q-0001Kf-Jx for emacs-orgmode@gnu.org; Sat, 01 Aug 2009 21:46:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MXQ9l-0001FX-Vn for emacs-orgmode@gnu.org; Sat, 01 Aug 2009 21:46:42 -0400 Received: from [199.232.76.173] (port=50089 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MXQ9l-0001FR-Sy for emacs-orgmode@gnu.org; Sat, 01 Aug 2009 21:46:37 -0400 Received: from mail-px0-f194.google.com ([209.85.216.194]:48312) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MXQ9l-0006Cz-9J for emacs-orgmode@gnu.org; Sat, 01 Aug 2009 21:46:37 -0400 Received: by pxi32 with SMTP id 32so1580736pxi.24 for ; Sat, 01 Aug 2009 18:46:36 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: =?utf-8?Q?S=C3=A9bastien?= Vauban Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable "Eric Schulte" writes: > Hi S=C3=A9bastien, > > Thanks for the description. This is very interesting and I think > warrants a re-working of the tangle functionality in org-babel. > > Given your description below I think I may try to add the Nuweb > link/reference syntax "<>" to org-babel. As > source-code blocks are already named in the current org-babel setup this > wouldn't be a very significant change. Once this is added it shouldn't > be difficult to expand these links/references on export. > > Under this new setup the example file you described would be analogous > to the this org-mode file. > > Does this sound like it would accomplish most of what you are after? > > I will reply to this message if/when I get this implemented. > Alright, I've changed the tangling functionality of org-babel so that it now follows some of the noweb conventions. With the newest version of org-babel [1], try opening the attached org-mode file [2] which is an org-mode translation of S=C3=A9bastien's noweb file from his previous email. Calling `org-babel-tangle' from within this file will create the Payment.sql, Lessons.sql, and Enterprise.sql source-code files. The document can also be exported into html and latex using org-mode's standard export functionality. Cheers -- Eric > > Cheers -- Eric > > S=C3=A9bastien Vauban writes: > >> Hi Eric and all, >> >> Here some promised description of how I'm using Literate Programming with >> LaTeX (up to now -- soon directly from Org mode?). >> >> I write an "enhanced LaTeX" file ([1], having the `.nw' -- for Nuweb -- >> extension). It is enhanced as I can put blocks of code in there (SQL blo= cks, >> for example), and give them a name for further referencing. >> >> Then, at some point in the file, I say how I want the code files to look= like, >> by assembling the blocks in a certain order, with some glue. >> >> For example: >> >> <>=3D >> <> >> SELECT abcID, etpID, etpAssurATPolNum >> FROM enterprise JOIN record >> ON (etpAbcID_fk =3D abcID) >> WHERE etpAbcID_fk >> <> >> @ %def=20 >> >> The above file is made up of two defined blocks (`sql-init' and `sql-con= d') >> plus some glue in between. >> >> The good thing is I can reuse the same blocks in other context, complete= ly >> avoiding copy/paste of code: >> >> <>=3D >> <> >> SELECT abcID, lesAlternNbrSem, lesNbrSem, >> CONVERT(varchar(10), lesDateDeb, @dateFmtStyleOut) AS lesDateDeb, >> CONVERT(varchar(10), lesDateFin, @dateFmtStyleOut) AS lesDateFin >> FROM lessons JOIN record >> ON (lesAbcID_fk =3D abcID) >> WHERE lesAbcID_fk >> <> >> @ %def=20 >> >> OK. So, my `org-lit-prog.nw' file is ready, and committed under Subversi= on >> (this is the only one I'm committing as it contains both the documentati= on of >> the code, and the source code itself). >> >> Then, I just type (in a terminal): >> >> noweb org-lit-prog.nw >> >> to extract both: >> >> o the LaTeX file [2] to be compiled into a PDF [3], >> o the different source code files (Enterprise.sql [4], Lessons.sql= [5], >> [6] and [7]) >> >> Just that easy to keep code and doc in sync, and get a very nice-to-read >> documentation of the code. >> >> Sometimes, I play an extra trick is made in the noweb file: I put blocks= of >> static code (for which I don't especially need any noweb feature) after = the >> end of the LaTeX document. That way, it gets outputted by noweb as a sou= rce >> file during the Tangle process, and included in my LaTeX document via the >> listings package. >> >> Why that trick? I could directly put the code in the body of the docume= nt! >> Yes, but I want the code to be highlighted via listings. Otherwise, it's= just >> black and white display of the code... >> >> For easy access, I've put all the above files on a my Web space: >> >> [1] http://www.mygooglest.com/sva/org-lit-prog.nw >> [2] http://www.mygooglest.com/sva/org-lit-prog.tex >> [3] http://www.mygooglest.com/sva/org-lit-prog.pdf >> [4] http://www.mygooglest.com/sva/Enterprise.sql >> [5] http://www.mygooglest.com/sva/Lessons.sql >> [6] http://www.mygooglest.com/sva/Payment.sql >> [7] http://www.mygooglest.com/sva/prsNumNat.awk >> >> From what I understand, what we both wanna reach is writing all of the `= .nw' >> file as an Org file directly, and let Org-babel extracts the source code= files >> and the documentation out of it. >> >> What should be good in the future, when it will be ready for prime time,= is >> that this becomes complete part of the export process: no tangle operati= on >> needed. >> >> Is the above description worth for you? Do you understand how I work wh= en >> documenting code? Pay attention: I'm *the* expert in literate programmi= ng. >> Just an amateur being seduced by some of its features. >> >> Best regards, >> Seb Footnotes:=20 [1] http://github.com/eschulte/org-babel/tree/master [2]=20=20 --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=org-babel-lit-prog.org Content-Transfer-Encoding: base64 IytUSVRMRTogU2hvd2luZyB0aGUgYmVuZWZpdHMgb2YgTGl0ZXJhdGUgUHJvZ3JhbW1pbmcKIytB VVRIT1I6IFNlYmFzdGllbiBWYXViYW4KIytPUFRJT05TOiB0b2M6bmlsIG51bTpuaWwgXjpuaWwK CiogQ29udGV4dAoKSSB3YW5uYSBzaG93IChvciwgYXQgbGVhc3QsIHRyeSB0byBzaG93KSBzb21l IGFkdmFudGFnZXMgb2YgbGl0ZXJhdGUKcHJvZ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9zcmMgc3FsIDp0YW5nbGUgTGVzc29ucwogIC0tIDw8c3FsLWlu aXQ+PgogIFNFTEVDVCBhYmNJRCwgbGVzQWx0ZXJuTmJyU2VtLCBsZXNOYnJTZW0sCiAgICAgICAg IENPTlZFUlQodmFyY2hhcigxMCksIGxlc0RhdGVEZWIsIEBkYXRlRm10U3R5bGVPdXQpIEFTIGxl c0RhdGVEZWIsCiAgICAgICAgIENPTlZFUlQodmFyY2hhcigxMCksIGxlc0RhdGVGaW4sIEBkYXRl Rm10U3R5bGVPdXQpIEFTIGxlc0RhdGVGaW4KICBGUk9NIGxlc3NvbnMgSk9JTiByZWNvcmQKICAg ICAgT04gKGxlc0FiY0lEX2ZrID0gYWJjSUQpCiAgV0hFUkUgbGVzQWJjSURfZmsKICAtLSA8PHNx bC1jb25kPj4KIytlbmRfc3JjCgoqKiogRmlsZSBQYXltZW50CgpTcGVjaWZpYyBwYXJ0IHRvIHBh eW1lbnQgaXM6CgojK3NyY25hbWU6IHBheW1lbnQKIytiZWdpbl9zcmMgc3FsIDp0YW5nbGUgUGF5 bWVudAogIC0tIDw8c3FsLWluaXQ+PgogIFNFTEVDVCBhYmNJRCwgcGF5RkROYnJLbSwgcGF5QWxs b2NUeXBlLCBwYXlDb21wZW5zLCBwYXlGRE1vbnRhbnRKLAogICAgICAgICBwYXlBbGxvY0Nob21C cnV0ZSwgcGF5QWxsb2NDaG9tQnJ1dGVKTSwgcGF5QXV0cmVzQWxsb2NzU29jQnJ1dGVzCiAgRlJP TSBwYXltZW50cyBKT0lOIHJlY29yZAogICAgICBPTiAocGF5QWJjSURfZmsgPSBhYmNJRCkKICBX SEVSRSBwYXlBYmNJRF9mawogIC0tIDw8c3FsLWNvbmQ+PgojK2VuZF9zcmMK --=-=-= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-orgmode mailing list Remember: use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode --=-=-=--