On 18 Jul 2023, Ihor Radchenko wrote:
Jonathan Gregory <j...@autistici.org> writes:
I also checked what will happen with future versions, and it
looks like \version "2.24.1" actually means >=.
That's good to know.
I know version 2.20.0 works without the update, so perhaps we
could set those variables conditionally, WDYT?
\version "2.20"
#(if (ly:get-option 'use-paper-size-for-page)
(begin (ly:set-option 'use-paper-size-for-page #f)
(ly:set-option 'tall-page-formats 'pdf)))
I do not mind. But remember that we are talking just about an
example file. What you are suggesting appears to be closer to
what we might do in ob-lilypond itself, when calculating default
layout.
That would be even better, I agree.
Can you test my patch?
Command-line options are normally added to
`org-babel-lilypond-ly-command`, but since we're trying to set
variables conditionally to accommodate different versions, I don't
see how we can do this without using scheme. WDYT?
Side note: ob-lilypond even has
`org-babel-lilypond-toggle-midi-play' that plays sound
corresponding to the lilypond source. Pretty cool, especially in
the context of the discussion about non-textual output types in
babel.
https://list.orgmode.org/orgmode/87ttu95xst.fsf@localhost/
Sure, I'll think about adding a MIDI example as well.
--
Jonathan
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 9693b89e2..3cbdd2b27 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -183,6 +183,12 @@ specific arguments to =org-babel-tangle=."
(in-file (org-babel-temp-file "lilypond-")))
(with-temp-file in-file
+ ;; To create music fragments suitable for mixing music and text,
+ ;; newer versions of lilypond require setting at least the
+ ;; following two variables introduced in version 2.22.
+ (insert "#(if (ly:get-option 'use-paper-size-for-page)
+(begin (ly:set-option 'use-paper-size-for-page #f)
+(ly:set-option 'tall-page-formats 'pdf)))\n")
(insert (org-babel-expand-body:generic body params)))
(org-babel-eval
(concat
@@ -199,7 +205,9 @@ specific arguments to =org-babel-tangle=."
(file-name-sans-extension out-file)
" "
cmdline
- in-file) "")) nil)
+ in-file)
+ ""))
+ nil)
(defun org-babel-prep-session:lilypond (_session _params)
"Return an error because LilyPond exporter does not support sessions."