I'm writing a Lilypond typesetting tutorial in Org to be published on a web page. I would like to exclude the line with set-default-paper-size from html export, cause it doesn't belong to the tutorial but is needed to shrink the size of the resulting png. How could this be done?
#+begin_src lilypond :file c-major.png :exports both
#(set-default-paper-size "a9" 'landscape) % How to exclude this line from export???
{ c d e f g a b c }
#+end_src
#+results:
[[file:c-major.png]]
An alternative would be if babel could invoke lilypond with the -e option when evaluating the code block. Any other ideas how to hide specific code lines are appreciated as well.
EDIT: The following solution works fine for a single code block:
#+begin_src lilypond :file c-major.png :exports both :prologue "#(set-default-paper-size \"a8landscape\")"
{ c d e f g a b c }
#+end_src
All I have to do is to escape the double quotes. Now I try the same for a default setting in .emacs:
(add-to-list 'org-babel-default-header-args:lilypond
'((:prologue . "#(set-default-paper-size \"a8landscape\")")))
Then the following error message is thrown:
org-babel-exp process lilypond at line 38...
Wrong type argument: stringp, (:prologue . "#(set-default-paper-size \"a8landscape\")")
This is the full backtrace:
Debugger entered--Lisp error: (void-function stringp\?)
(stringp\? "#(set-default-paper-size \"a8landscape\")")
eval((stringp\? "#(set-default-paper-size \"a8landscape\")") nil)
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
command-execute(eval-last-sexp)
:export results
? Or do you want the source and the results appear in a different export (s.a. LaTeX), but not in HTML? There's also a post-processing hook for exports. I.e. you could add an Emacs Lisp function to run on the contents of the generated file after it's exported. That's not a very general solution, but would work for a one-of case. – wvxvw Mar 18 '16 at 6:54