emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <eric.schulte@gmx.com>
To: Sebastien Vauban <wxhgmqzgwmuf@spammotel.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: :noweb header argument
Date: Sat, 14 Jan 2012 12:59:54 -0700	[thread overview]
Message-ID: <878vla2gxx.fsf@gmx.com> (raw)
In-Reply-To: 808vlezmmy.fsf@somewhere.org

[-- Attachment #1: Type: text/plain, Size: 1267 bytes --]

>>> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: export-names.org --]
[-- Type: text/x-org, Size: 842 bytes --]

#+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

[-- Attachment #3: Type: text/plain, Size: 2063 bytes --]


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/

  parent reply	other threads:[~2012-01-14 20:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08 23:04 :noweb header argument Thomas S. Dye
2012-01-10  8:04 ` Sebastien Vauban
2012-01-10  8:24   ` Andreas Leha
2012-01-10 11:30   ` Eric S Fraga
2012-01-10 15:41   ` Thomas S. Dye
2012-01-10 16:44     ` Eric Schulte
2012-01-10 18:42       ` Thomas S. Dye
2012-01-11  8:09         ` Sebastien Vauban
2012-01-11 15:06           ` Eric S Fraga
2012-01-14 19:59           ` Eric Schulte [this message]
2012-01-14 23:06             ` Thomas S. Dye
2012-01-15 15:28               ` Eric Schulte
2012-01-18 10:03             ` Eric S Fraga
2012-01-18 19:11               ` Yagnesh Raghava Yakkala
2012-01-11 17:17         ` Eric Schulte
2012-01-10 21:04       ` Eric S Fraga

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878vla2gxx.fsf@gmx.com \
    --to=eric.schulte@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=wxhgmqzgwmuf@spammotel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).