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