On 20 Jul 2023, Ihor Radchenko wrote:
With your patch, I cannot produce png output. The file is just
not created: [...]
You're right. Thanks for the feedback.
I've made some changes and was able to produce the correct results
using pdf, eps, and png (tested with 2.20.0 and 2.24.1). I think
this gets us closer to the old behaviour, assuming there are no
other issues, of course.
--
Jonathan
diff --git a/lisp/ob-lilypond.el b/lisp/ob-lilypond.el
index 9693b89e2..8533cd8c7 100644
--- a/lisp/ob-lilypond.el
+++ b/lisp/ob-lilypond.el
@@ -178,28 +178,39 @@ specific arguments to =org-babel-tangle=."
(defun org-babel-lilypond-process-basic (body params)
"Execute a lilypond block in basic mode."
(let* ((out-file (cdr (assq :file params)))
+ (file-type (file-name-extension out-file))
(cmdline (or (cdr (assq :cmdline params))
""))
(in-file (org-babel-temp-file "lilypond-")))
(with-temp-file in-file
- (insert (org-babel-expand-body:generic body params)))
+ ;; 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. See:
+ ;; https://lilypond.org/doc/v2.24/Documentation/usage/other-programs
+ (insert
+ (format "#(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 '%s)))\n"
+ file-type)
+ (org-babel-expand-body:generic body params)))
(org-babel-eval
(concat
org-babel-lilypond-ly-command
" -dbackend=eps "
"-dno-gs-load-fonts "
"-dinclude-eps-fonts "
- (or (cdr (assoc (file-name-extension out-file)
- '(("pdf" . "--pdf ")
- ("ps" . "--ps ")
- ("png" . "--png "))))
+ (or (assoc-default file-type
+ '(("pdf" . "--pdf ")
+ ("eps" . "--eps ")))
"--png ")
"--output="
(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."