From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: :noweb header argument Date: Sun, 15 Jan 2012 08:28:13 -0700 Message-ID: <87y5t90yuq.fsf@gmx.com> References: <801ur8rnjg.fsf@somewhere.org> <87ty43ik2y.fsf@gmx.com> <808vlezmmy.fsf@somewhere.org> <878vla2gxx.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RmS0M-0006G4-MW for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 10:28:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RmS0K-00055N-Ux for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 10:28:22 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:38740 helo=mailout-us.mail.com) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1RmS0K-00054u-Pm for emacs-orgmode@gnu.org; Sun, 15 Jan 2012 10:28:20 -0500 In-Reply-To: (Thomas S. Dye's message of "Sat, 14 Jan 2012 13:06:13 -1000") 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: "Thomas S. Dye" Cc: Sebastien Vauban , Org-mode tsd@tsdye.com (Thomas S. Dye) writes: > Eric Schulte writes: > >>>>> As I recall this was originally implemented and then later removed because >>>>> it was causing more confusion and problems than it was worth. I hope it >>>>> hasn't crossed the line of existence more than once. At some point it >>>>> should be placed behind a user-customizable variable, preferably something >>>>> like `org-babel-export-code-format' which defaults to something like >>>>> "%code" but could be augmented to something like "Block Name: *%name*\n >>>>> %code". It is not immediately clear if such a variable should have >>>>> different values for different export backends or (likely preferable) >>>>> should expand into Org-mode text *before* export. >>>> >>>> I think you're right about getting this done early in the process. I've been >>>> thinking only about LaTeX export because that is my immediate goal--not a >>>> good design perspective. >>>> >> >> I've just pushed up a minor code change which makes customization of the >> format of exported code blocks possible. I've added a new customization >> variable named `org-babel-exp-code-template' which can be used to >> specify the text which replaces code block bodies during export. The >> default value of this variable specifies the existing export behavior. >> The attached Org-mode file demonstrates this variable in action. >> >> >> #+Title: Custom code block export formats >> >> - Example code block >> #+Name: foo >> #+BEGIN_SRC sh :bar baz >> echo qux >> #+END_SRC >> >> - Evaluate this block to export (shows the export of the name). >> #+Name: do-export-name >> #+BEGIN_SRC emacs-lisp :results silent >> (let ((org-babel-exp-code-template >> "\n=%name=:\n#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC")) >> (org-export-as-html nil)) >> #+END_SRC >> >> - Evaluate this block to export (shows the export of header arguments). >> #+Name: do-export-header-arguments >> #+BEGIN_SRC emacs-lisp :results silent >> (let ((org-babel-exp-code-template >> "Header arguments for =%name=. >> | header | value | >> |---------+----------| >> | bar | %bar | >> | results | %results |\n#+BEGIN_SRC %lang%flags\n%body\n#+END_SRC")) >> (org-export-as-html nil)) >> #+END_SRC >> >> >> I imagine that this variable would likely be customized on a >> file-by-file basis using "file local variables". >> >>>> >>>> Perhaps I could help by specifying what I'm trying to do? I'd like to write >>>> an article or book about particular statistical analyses. I want this also >>>> to be a piece of reproducible research so readers of the book can follow >>>> along and perhaps analyze data of their own. I'd like to write a code block >>>> once and then use it in the following ways: 1) evaluate and return the >>>> results of analyses; 2) export as a floating listing so I can refer to it in >>>> discussions of implementation; and 3) tangle to a source code file that can >>>> be used as the basis for a package that can be used outside of Org mode. >>>> >> >> Sounds like a very cool project. If this will be public I would love to >> link to it from [1] when it is complete. >> >>>> >>>> 1) is easy with #+call: With the :wrap header argument that we've >>>> partially implemented, I can mark the results off in whatever environment I >>>> like, which is a wonderful bit of flexibility. Different kinds of results >>>> can be presented distinctively. >>>> >>>> 2) is partially there--the code itself is handled nicely by minted and >>>> I'm able to make it look as good as I want. What I'm lacking now is an easy >>>> way to identify the code block. Seb's suggestion that the header lines be >>>> included is one way, though Eric F.'s point about the special characters >>>> tripping up LaTeX is well taken. It might be some work to get an >>>> intermediate representation that can be exported to all the targets. My >>>> alternate idea, which is to wrap the code block in an environment to which I >>>> can attach a caption and a label, is the LaTeX approach and might not work >>>> as well for other export targets. >> >> This new solution replaces the code block with Org-mode text before >> export. This should be the most flexible as arbitrary #+HTML and >> #+LATEX lines can be used in Org-mode. >> >> Best, >> >> Footnotes: >> [1] http://orgmode.org/worg/org-contrib/babel/uses.html > > Hi Eric, > > Many thanks. This works like a charm. It is deeply satisfying to find > my code block names in the book's "List of listings". > > I really appreciate your attention to these details. > Great to hear, Thanks Tom. -- Eric Schulte http://cs.unm.edu/~eschulte/