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