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