]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/invoking.itely
* Documentation/topdocs/NEWS.texi (Top): add -f texstr
[lilypond.git] / Documentation / user / invoking.itely
1 @c -*- coding: latin-1; mode: texinfo; -*-
2 @node Running LilyPond
3 @chapter Running LilyPond
4
5 This chapter details the technicalities of running LilyPond.
6
7
8 @menu
9 * Invoking lilypond::
10 * Error messages::
11 * Reporting bugs::
12 * Editor support::
13 * Invoking lilypond-latex::
14 @end menu
15
16 @node Invoking lilypond
17 @section Invoking lilypond
18 @cindex Invoking LilyPond
19 @cindex command line options
20 @cindex options, command line
21 @cindex switches
22
23
24 The @code{lilypond} executable may be called as follows from the command line.
25
26 @example
27 lilypond [@var{option}]@dots{} @var{file}@dots{}
28 @end example
29
30
31 When invoked with a filename that has no extension, the @file{.ly}
32 extension is tried first.  To read input from stdin, use a
33 dash (@code{-}) for @var{file}.
34
35 When @file{filename.ly} is processed it will produce
36 @file{filename.tex} as output (or @file{filename.ps} for PostScript
37 output).  If @file{filename.ly} contains more than one @code{\score}
38 block, then the rest of the scores will be output in numbered files,
39 starting with @file{filename-1.tex}.  Several files can be specified;
40 they will each be processed independently.  @footnote{The status of
41 GUILE is not reset after processing a @code{.ly} file, so be careful
42 not to change any system defaults from within Scheme.}
43
44
45 @section Command line options
46
47 The following options are supported:
48
49 @table @code
50
51 @item -e,--evaluate=@var{expr}
52 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
53 Multiple @code{-e} options may be given, they will be evaluated
54 sequentially.  The function @code{ly:set-option} allows access to
55 some internal variables.  Use @code{-e '(ly:option-usage)'} for more
56 information.
57
58
59 @item -f,--format=@var{format}
60 the output format to use for the back-end.  Choices are
61 @table @code
62 @item tex
63 for @TeX{} output, to be processed with La@TeX{}.  If present, the file
64 @file{file.textmetrics} is read to determine text extents.
65 @item texstr
66 dump text strings to @file{.texstr} file, which can be run through
67 (La)@TeX{}, resulting in a @code{.textmetrics} file, which contains the
68 extents of strings of text. 
69 @item ps
70  for PostScript
71 @cindex PostScript output
72 @item svg
73  for SVG (Scalable Vector Graphics)
74 @cindex SVG (Scalable Vector Graphics)
75 @item scm
76  for a dump of the raw, internal Scheme-based drawing commands.
77 @cindex Scheme dump
78 @end table
79  
80 @cindex output format, setting
81
82 @item -h,--help
83 Show a summary of usage.
84
85 @item --include, -I=@var{directory}
86 Add @var{directory} to the search path for input files.
87 @cindex file searching
88 @cindex search path
89
90 @item -i,--init=@var{file}
91 Set init file to @var{file} (default: @file{init.ly}).
92
93 @item -o,--output=@var{FILE}
94 Set the default output file to @var{FILE}.
95
96 @item --ps
97 Generate PostScript.
98
99 @item --dvi
100 Generate DVI files.  In this case, the @TeX{} backend should be
101 specified, i.e., @code{-f tex}.
102
103 @item --png
104 Generate pictures of each page, in PNG format.  This implies @code{--ps}.
105
106 @item --pdf
107 Generate PDF.  This implies @code{--ps}.
108
109 @item --preview
110 Generate an output file containing the titles and the first system
111
112 @item --no-pages
113 Do not generate the full pages.  Useful in combination with
114 @code{--preview}.
115
116 @item -s,--safe
117 Do not trust the @code{.ly} input.
118
119 When LilyPond formatting is available through a web server, the
120 @code{--safe} @b{MUST} be passed.  This will prevent inline Scheme
121 code from wreaking havoc, for example
122
123 @quotation
124 @verbatim
125 #(system "rm -rf /")
126 {
127   c4^#(ly:export (ly:gulp-file "/etc/passwd"))
128 }
129 @end verbatim
130 @end quotation
131
132 The @code{--safe} option works by evaluating in-line Scheme
133 expressions in a special safe module.  This safe module is derived from
134 GUILE @file{safe-r5rs} module, but adds a number of functions of the
135 LilyPond API.  These functions are listed in @file{scm/@/safe@/-lily@/.scm}.
136
137 In addition, @code{--safe} disallows @code{\include} directives and
138 disables the use of backslashes in @TeX{} strings.
139
140 In @code{--safe} mode, it is not possible to import LilyPond variables
141 into Scheme.
142
143 @code{--safe} does @emph{not} detect resource overuse. It is still
144 possible to make the program hang indefinitely, for example by feeding
145 cyclic data structures into the backend.  Therefore, if using LilyPond
146 on a publicly accessible webserver, the process should be limited in
147 both CPU and memory usage.
148
149 @item -v,--version
150 Show version information.
151
152 @item -V,--verbose
153 Be verbose: show full paths of all files read, and give timing
154 information.
155
156 @item -w,--warranty
157 Show the warranty with which GNU LilyPond comes. (It comes with
158 @strong{NO WARRANTY}!)
159 @end table
160
161
162 @section Environment variables
163
164 For processing both the @TeX{} and the PostScript output, the
165 appropriate environment variables must be set.  The following scripts
166 do this:
167
168 @itemize @bullet
169 @item @file{buildscripts/@/out/@/lilypond@/-profile}
170 (for SH shells)
171 @item @file{buildscripts/@/out/@/lilypond@/-login} (for C-shells)
172 @end itemize
173
174 They should normally be sourced as part of the login process.  If these
175 scripts are not run from the system wide login process, then you must
176 run them yourself.
177
178 @cindex installing LilyPond
179
180 If you use sh, bash, or a similar shell, then add the following to
181 your @file{.profile}:
182 @example
183 . @var{/the/path/to/}lilypond-profile
184 @end example
185
186 If you use csh, tcsh or a similar shell, then add the following to
187 your @file{~/.login}:
188 @example
189 source @var{/the/path/to/}lilypond-login
190 @end example
191
192 Of course, in both cases, you should substitute the proper location of
193 either script.
194
195 These scripts set the following variables:
196 @table @code
197 @item TEXMF
198 To make sure that @TeX{} and lilypond find data files (among
199 others @file{.tex}, @file{.mf}, and @file{.tfm}),
200 you have to set @code{TEXMF} to point to the lilypond data
201 file tree.  A typical setting would be
202 @example
203 @{/usr/share/lilypond/2.4.0,@{!!/usr/share/texmf@}@}
204 @end example
205
206 @end table
207
208
209 @cindex PostScript
210 @cindex TEXMF
211 @cindex printing postscript
212
213 The binary itself recognizes the following environment variables:
214 @table @code
215 @item LILYPONDPREFIX
216 This specifies a directory where locale messages and
217 data files will be looked up by default.  The directory should contain
218 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
219
220 @item LANG
221 This selects the language for the warning messages.
222 @end table
223
224 @cindex LANG
225 @cindex LILYPONDPREFIX
226
227 @node Error messages
228 @section Error messages
229
230 @cindex error messages
231 Different error messages can appear while compiling a file:
232
233 @table @emph
234 @cindex warning
235
236 @item Warning
237 Something looks suspect.  If you are requesting something out of the
238 ordinary then you will understand the message, and can ignore it.
239 However, warnings usually indicate that something is wrong with the
240 input file.
241
242 @item Error
243 Something is definitely wrong.  The current processing step (parsing,
244 interpreting, or formatting) will be finished, but the next step will
245 be skipped.
246
247 @cindex error
248 @cindex fatal error
249 @item Fatal error
250 Something is definitely wrong, and LilyPond cannot continue.  This
251 happens rarely.  The most usual cause is misinstalled fonts.
252
253 @cindex trace, Scheme
254 @cindex call trace
255 @cindex Scheme error
256 @item Scheme error
257 Errors that occur while executing Scheme code are caught by the Scheme
258 interpreter.  If running with the verbose option (@code{-V} or
259 @code{--verbose}) then a call trace of the offending
260 function call is printed.
261
262 @cindex Programming error
263 @item Programming error
264 There was some internal inconsistency.  These error messages are
265 intended to help the programmers and debuggers.  Usually, they can be
266 ignored.  Sometimes, they come in such big quantities that they obscure
267 other output.  In this case, file a bug-report.
268
269 @item Aborted (core dumped)
270 This signals a serious programming error that caused the program to
271 crash.  Such errors are considered critical.  If you stumble on one,
272 send a bug-report.
273
274
275 @end table
276
277 @cindex errors, message format
278 If warnings and errors can
279 be linked to some part of the input file, then error messages have the
280 following form
281
282 @example
283 @var{filename}:@var{lineno}:@var{columnno}: @var{message}
284 @var{offending input line}
285 @end example
286
287 A line-break is inserted in the offending line to indicate the column
288 where the error was found.  For example,
289
290 @example
291 test.ly:2:19: error: not a duration: 5:
292   @{ c'4 e'5
293              g' @}
294 @end example
295
296 These locations are LilyPond's best guess about where the warning or
297 error occured, but (by their very nature) warnings and errors occur
298 when something unexpected happens.  If you can't see an error in the
299 indicated line of your input file, try checking one or two lines
300 above the indicated position.
301
302
303 @node Reporting bugs
304 @section Reporting bugs
305
306 @cindex bugs
307 @cindex reporting bugs
308
309 If you have input that results in a crash or an erroneous output, then
310 that is a bug.  We try to respond to bug-reports promptly, and fix them as
311 soon as possible.  Help us by sending a defective input file, so we can
312 reproduce the problem.  Make it small, so we can easily debug the
313 problem.  Don't forget to tell which version of LilyPond you use!  Send
314 the report to @email{bug-lilypond@@gnu.org}.
315
316 When you've found a bug, have a look at our
317 @uref{http://@/lilypond@/.org/@/doc/@/v2.3/@/bugs/,bug database} to see if
318 it has already been reported.  You could also try to do a few searches
319 on the mailing list for the bug.  Sometimes the bug will have already
320 been reported and a fix or workaround is already known.
321
322 Here is an example of a good bug report:
323
324 @example
325 It seems that placement of accidentals is broken.  In the
326 following example, the accidental touches the note head.
327
328 Using Mac OSX 10.3.5, fink package lilypond-unstable
329
330 \version "2.3.22"
331 \relative c''@{
332    a4 b cis d
333 @}
334 @end example
335
336 @lilypond[quote]
337 \version "2.3.22"
338 \relative c''{
339   \override Accidental #'extra-offset = #'(1.0 . 0)
340   a4 b cis d
341 }
342 @end lilypond
343
344 @node Editor support
345 @section Editor support
346
347 @cindex editors
348 @cindex vim
349 @cindex emacs
350 @cindex modes, editor
351 @cindex syntax coloring
352 @cindex coloring, syntax
353
354 There is support from different editors for LilyPond.
355
356 @table @asis
357 @item Emacs
358 Emacs has a @file{lilypond-mode}, which provides keyword
359 autocompletion, indentation, LilyPond specific parenthesis matching
360 and syntax coloring, handy compile short-cuts and reading LilyPond
361 manuals using Info.  If @file{lilypond-mode} is not installed on your
362 platform, then read the
363 @ifhtml
364 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
365 @end ifhtml
366 @ifnothtml
367 installation instructions.
368 @end ifnothtml
369
370 @item VIM
371
372 For @uref{http://@/www@/.vim@/.org,VIM}, a @file{vimrc} is supplied, along
373 with syntax coloring tools.  For more information, refer to the
374 @ifhtml
375 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
376 @end ifhtml
377 @ifnothtml
378 installation instructions.
379 @end ifnothtml
380
381
382 @item JEdit
383
384 The @uref{http://@/www@/.jedit@/.org/,jEdit} editor has a LilyPond plugin.
385 This plugin includes a DVI viewer, integrated help and viewing via
386 GhostScript.  It can be installed by doing @key{Plugins > Plugin
387 Manager}, and selecting @code{LilyTool} from the @key{Install} tab.
388
389 @end table
390
391 All these editors can be made to jump into the input file to the source
392 of a symbol in the graphical output.  See @ref{Point and click}.
393
394
395
396
397 @node Invoking lilypond-latex
398 @section Invoking lilypond-latex
399
400 Before LilyPond 2.4, the @code{lilypond} program only generated music
401 notation.  Titles and page layout was done in a separate wrapper
402 program.  For compatibility with older files, this wrapper program has
403 been retained as @code{lilypond-latex}.  It uses the LilyPond program
404 and La@TeX{} to create a nicely titled piece of sheet music.  Use of
405 this program is only necessary if the input file contains special
406 La@TeX{} options or formatting codes in markup texts.
407
408 The @code{lilypond-latex} wrapper is invoked from the command-line as
409 follows
410 @example
411 @code{lilypond-latex} [@var{option}]@dots{} @var{file}@dots{}
412 @end example
413
414 To have @code{lilypond-latex} read from stdin, use a dash (@code{-}) for
415 @var{file}.  The program supports the following options.
416
417 @cindex stdin, reading
418
419 @table @code
420 @item -k,--keep
421 Keep the temporary directory with all output files.  The temporary
422 directory is created in the current directory as @code{@code{lilypond}.dir}.
423
424 @item -h,--help
425 Print usage help.
426
427 @item -I,--include=@var{dir}
428 Add @var{dir} to LilyPond's include path.
429
430 @item -o,--output=@var{file}
431 Generate output to @var{file}.  The extension of @var{file} is ignored.
432
433 @item --png
434 Also generate pictures of each page, in PNG format.
435
436 @item --preview
437 Also generate a picture of the first system of the score.
438
439 @cindex preview
440 @cindex picture
441 @cindex bitmap
442 @cindex pixmap
443 @cindex thumbnail
444 @cindex screen shot
445
446 @item -s,--set=@var{key}=@var{val}
447 Add @var{key}= @var{val} to the settings, overriding those specified
448 in the files.  Possible keys: @code{language}, @code{latexheaders},
449 @code{latexpackages}, @code{latexoptions}, @code{papersize},
450 @code{linewidth}, @code{orientation},
451 @code{textheight}.
452
453 @item -v,--version
454 Show version information.
455
456 @item -V,--verbose
457 Be verbose.  This prints out commands as they are executed, and more
458 information about the formatting process is printed.
459
460 @item --debug
461 Print even more information.  This is useful when generating bug reports.
462
463 @item -w,--warranty
464 Show the warranty with which GNU LilyPond comes. (It comes with
465 @strong{NO WARRANTY}!)
466 @end table
467
468
469 @subsection Additional parameters
470
471 The @code{lilypond} program responds to several parameters specified
472 in a @code{\layout} section of the input file.  They can be overridden
473 by supplying a @code{--set} command line option.
474
475 @table @code
476 @item language
477 Specify La@TeX{} language: the @code{babel} package will be
478 included.  Default: unset.
479
480 Read from the @code{\header} block.
481
482 @item latexheaders
483 Specify additional La@TeX{} header files.
484 Normally read from the @code{\header} block.  Default value: empty.
485
486 @item latexpackages
487 Specify additional La@TeX{} package files.  This works cumulative,
488 so you can add multiple packages using multiple @code{-s=latexpackages} options.
489 Normally read from the @code{\header} block.  Default value:
490 @code{geometry}.
491
492 @item latexoptions
493 Specify additional options for the La@TeX{}
494 @code{\documentclass}.  You can put any valid value here.  This was
495 designed to allow @code{lilypond} to produce output for double-sided
496 paper, with balanced margins and page numbers on alternating sides.  To
497 achieve this specify @code{twoside}.
498
499 @item orientation
500 Set orientation.  Choices are @code{portrait} or @code{landscape}.  Is
501 read from the @code{\layout} block, if set.
502
503 @item textheight
504 The vertical extension of the music on the page.  It is normally
505 calculated automatically, based on the paper size.
506
507 @item linewidth
508 The music line width.  It is normally read from the @code{\layout}
509 block.
510
511 @item papersize
512 The paper size (as a name, e.g., @code{a4}).  It is normally read from
513 the @code{\layout} block.
514
515 @item fontenc
516 The font encoding, should be set identical to the @code{font-encoding}
517 property in the score.
518 @end table