]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-book: Textwidth detection with included file (issue 3136).
authorJulien Rioux <jrioux@physics.utoronto.ca>
Wed, 23 Jan 2013 23:21:22 +0000 (18:21 -0500)
committerJulien Rioux <jrioux@physics.utoronto.ca>
Sun, 21 Apr 2013 18:21:12 +0000 (14:21 -0400)
Fix the automatic textwidth detection performed by lilypond-book.
This failed for lytex files that include an external file in the
preamble, when such file was compiled in an --output directory
different from the working directory, because then the included
file was missing. We use TEXINPUTS to let the latex process know
where to look for input files.

input/regression/lilypond-book/include/def.tex [new file with mode: 0644]
input/regression/lilypond-book/tex-include-preamble.lytex [new file with mode: 0644]
python/book_latex.py
scripts/lilypond-book.py

diff --git a/input/regression/lilypond-book/include/def.tex b/input/regression/lilypond-book/include/def.tex
new file mode 100644 (file)
index 0000000..e9879a2
--- /dev/null
@@ -0,0 +1 @@
+\def\signature{The LilyPond Team}
diff --git a/input/regression/lilypond-book/tex-include-preamble.lytex b/input/regression/lilypond-book/tex-include-preamble.lytex
new file mode 100644 (file)
index 0000000..a3815f2
--- /dev/null
@@ -0,0 +1,20 @@
+\documentclass{article}
+
+\input{include/def.tex}
+
+\begin{document}
+
+If the include file in the preamble is not available,
+the automatic line width detection would fail and the
+snippet below would have only one bar per line.
+
+\begin{lilypond}
+\relative c' {
+  a d a c e d a c
+  f g d e a d a c
+}
+\end{lilypond}
+
+Brought to you by \signature.
+
+\end{document}
index f2aa5e36cf6106e2c427fe30465bf9c1d446be6f..e1eda89983f2e3850df4695a1be838ff27e0ba7c 100644 (file)
@@ -13,6 +13,7 @@ global _;_=ly._
 progress = ly.progress
 warning = ly.warning
 error = ly.error
+debug = ly.debug_output
 
 # Recognize special sequences in the input.
 #
@@ -186,9 +187,10 @@ def get_latex_textwidth (source, global_options):
     tmp_handle.close ()
 
     progress (_ ("Running `%s' on file `%s' to detect default page settings.\n")
-              % (global_options.latex_program, tmpfile));
-    cmd = '%s %s' % (global_options.latex_program, tmpfile);
-    ly.debug_output ("Executing: %s\n" % cmd);
+              % (global_options.latex_program, tmpfile))
+    cmd = 'TEXINPUTS=%s:$TEXINPUTS %s %s' \
+        % (global_options.input_dir, global_options.latex_program, tmpfile)
+    debug ("Executing: %s\n" % cmd)
     run_env = os.environ.copy()
     run_env['LC_ALL'] = 'C'
 
index 903e5e522176b6a31b97a1edd424ae1179dda3a5..6d424a18521c289991723363c7f04381dc8e042c 100644 (file)
@@ -544,10 +544,12 @@ def do_file (input_filename, included=False):
         in_handle = file (input_fullname)
 
     if input_filename == '-':
+        global_options.input_dir = os.getcwd ()
         input_base = 'stdin'
     elif included:
         input_base = os.path.splitext (input_filename)[0]
     else:
+        global_options.input_dir = os.path.split (input_absname)[0]
         input_base = os.path.basename (
             os.path.splitext (input_filename)[0])