summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex54
1 files changed, 36 insertions, 18 deletions
diff --git a/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex b/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
index 2f4d7b936b5..4a6b57c67c8 100644
--- a/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
+++ b/Master/texmf-dist/tex/context/third/lilypond/t-lilypond.tex
@@ -1,9 +1,10 @@
%D \module
%D [ file=t-lilypond,
-%D version=2009.05.27,
+%D version=2009.06.04,
%D title=\CONTEXT\ User Modules,
-%D subtitle=LilyPond Connections (Music Typesetting),
+%D subtitle=LilyPond Bridge (Music Typesetting),
%D author={Christopher Creutzig, Henning Hraban Ramm, Mojca Miklavec, Wolfgang Schuster},
+%D maintainer={Henning Hraban Ramm, hraban@fiee.net},
%D date=\currentdate,
%D copyright=the authors]
%C
@@ -43,6 +44,7 @@
%D \item Proper support for multipage results.
%D \item Set LilyPond page size to remaining page space.
%D \item Place instrument names in margin.
+%D \item Work with existing PDFs on systems where LilyPond isn't installed.
%D \stopitemize
%D
%D {\bfa Commented Source}
@@ -55,7 +57,7 @@
\unprotect
-\definesystemvariable {lily}
+\definesystemvariable{lily}
%D Define the text snippets to be placed around fragments.
%D Since LilyPond uses similar syntax to TeX, we must do some catcode fiddling.
@@ -268,16 +270,6 @@
\noexpand\endbuffer
\stopexpanded
%D
-%D Generating a PDF directly always creates a whole page, so we generate EPS first.
-%D
- \def\LP{mtxrun --ifchanged="\lily!tmpfilename.tmp" --exec bin:lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files -o"\lily!tmpfilename" "\lily!tmpfilename.tmp"}
-%D
-%D It would be nice, if \type{-ddelete-intermediate-files} would delete all useless intermediate files.
-%D
-%D Remember: More possible options in \type{lily.scm}.
-%D
- \def\PDF{mtxrun --ifchanged="\lily!tmpfilename.eps" pstopdf "\lily!tmpfilename.eps"}
-%D
%D In Lua\TeX buffers are kept in memory
%D in contrast to older flavours of \TeX\ where they're written to a
%D file automatically. We have to require writing to a file explicitely
@@ -285,12 +277,38 @@
%D
%D That applies \type{\bufferprefix} automatically, so we can't directly write to our temp directory.
%D
- \ctxlua{ buffers.save("lilypond-\lily!figures") }
- \directlua{ os.rename('\lily!filename.tmp', '\tmpdir/\lily!filename.tmp') }
+%D At least on Windows, Lua's os.rename won't overwrite existing files, so we need to remove them before.
+%D
+%D
\writestatus{LilyPond}{\lily!filename}
- \executesystemcommand{\LP} % compile LilyPond
- \executesystemcommand{\PDF} % convert EPS to PDF
- \directlua{ os.rename('\lily!tmpfilename.pdf', '\lily!img') }
+ \startluacode
+ buffers.save('lilypond-\lily!figures')
+ if not lfs.isfile('\lily!filename.tmp') then
+ logs.report("LilyPond ERROR", "File '\lily!filename.tmp' was not written!")
+ else
+ if lfs.isfile('\tmpdir/\lily!filename.tmp') then
+ os.remove('\tmpdir/\lily!filename.tmp')
+ end
+ os.rename('\lily!filename.tmp', '\tmpdir/\lily!filename.tmp')
+ end
+%D
+%D Generating a PDF directly previously created always a whole page, so we generate EPS first.
+%D In recent versions of LilyPond that gets converted to PDF immediately, but we check for that.
+%D
+%D It would be nice, if \type{-ddelete-intermediate-files} would delete all useless intermediate files.
+%D It would be even better, if mtxrun wouldn't declare non-existing files as \quotation{unchanged}.
+%D
+%D Remember: More possible options in \type{lily.scm}.
+%D
+ os.execute('mtxrun --ifchanged="\lily!tmpfilename.tmp" --exec bin:lilypond -dbackend=eps -dno-gs-load-fonts -dinclude-eps-fonts -ddelete-intermediate-files -o"\lily!tmpfilename" "\lily!tmpfilename.tmp"')
+ if not lfs.isfile('\lily!tmpfilename.pdf') then
+ os.execute('mtxrun --ifchanged="\lily!tmpfilename.eps" --exec bin:pstopdf "\lily!tmpfilename.eps"')
+ end
+ if lfs.isfile('\lily!img') and lfs.isfile('\lily!tmpfilename.pdf') then
+ os.remove('\lily!img')
+ end
+ os.rename('\lily!tmpfilename.pdf', '\lily!img')
+ \stopluacode
%D
%D TODO: Get the relevant dimension directly from LilyPond,
%D to place the instrument name into the left margin for