From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: :noweb header argument Date: Sat, 14 Jan 2012 12:59:54 -0700 Message-ID: <878vla2gxx.fsf@gmx.com> References: <801ur8rnjg.fsf@somewhere.org> <87ty43ik2y.fsf@gmx.com> <808vlezmmy.fsf@somewhere.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:52147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rm9lp-0006h9-SD for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 15:00:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rm9ln-0003it-LI for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 15:00:09 -0500 Received: from mailout-us.gmx.com ([74.208.5.67]:41809) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Rm9ln-0003hB-Bg for emacs-orgmode@gnu.org; Sat, 14 Jan 2012 15:00:07 -0500 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: Sebastien Vauban Cc: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain >>> 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. --=-=-= Content-Type: text/x-org Content-Disposition: inline; filename=export-names.org #+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 --=-=-= Content-Type: text/plain 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 -- Eric Schulte http://cs.unm.edu/~eschulte/ --=-=-=--