]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/user/invoking.itexi
*** empty log message ***
[lilypond.git] / Documentation / user / invoking.itexi
1 @c -*-texinfo-*-
2 @node Invoking LilyPond
3 @chapter Invoking LilyPond
4
5 This chapter details the technicalities of running LilyPond.
6
7  
8 @menu
9 * Invoking lilypond::           Titling LilyPond scores.
10 * Invoking the lilypond binary::  
11 * Error messages::              
12 * Reporting bugs::              
13 * Editor support::              
14 * Point and click::             
15 @end menu
16
17 @node Invoking lilypond
18 @section Invoking lilypond
19
20 Nicely titled output is created through a separate program:
21 @file{@code{lilypond}} is a script that uses the LilyPond formatting
22 engine (which is in a separate program) and La@TeX{} to create a
23 nicely titled piece of sheet music, in PDF (Portable Document Format)
24 format.
25
26 @example
27         @code{lilypond} [@var{option}]@dots{} @var{file}@dots{}
28 @end example
29
30 To have @code{lilypond} read from stdin, use a dash @code{-} for
31 @var{file}.  The program supports the following options.
32
33 @cindex stdin, reading
34
35 @table @code
36 @item -k,--keep
37     Keep the temporary directory with all output
38 files. The temporary directory is created in the current directory as @code{@code{lilypond}.dir}.
39 @item -h,--help
40     Print usage help.
41 @item -I,--include=@var{dir}
42     Add @var{dir} to LilyPond's include path.
43 @item -m,--no-paper
44     Produce MIDI output only.
45 @item --no-lily
46     Do not run @file{lilypond-bin}. Useful for debugging @code{lilypond}.
47 @item -o,--output=@var{file}
48     Generate output to @var{file}.  The extension of @var{file} is ignored.
49 @item --no-pdf
50     Do not generate  (PDF) or PS.
51
52 @cindex PDF
53 @cindex Scalable fonts
54     
55 @item --png
56     Also generate pictures of each page, in PNG format. 
57 @item --psgz
58     Gzip the postscript file.
59 @item --html
60     Make a .HTML file with links to all output files.
61 @item --preview
62     Also generate a picture of the first system of the score.
63
64 @cindex preview
65 @cindex picture
66 @cindex bitmap
67 @cindex pixmap
68 @cindex thumbnail
69 @cindex screen shot
70     
71 @item -s,--set=@var{key}=@var{val}
72     Add @var{key}= @var{val} to the settings, overriding those specified
73 in the files. Possible keys: @code{language}, @code{latexheaders},
74 @code{latexpackages}, @code{latexoptions}, @code{papersize},
75 @code{pagenumber}, @code{linewidth}, @code{orientation},
76 @code{textheight}.
77 @item -v,--version
78 Show version information.
79 @item -V,--verbose
80 Be verbose. This prints out commands as they are executed, and more
81 information about the formatting process is printed.
82 @item --debug
83 Print even more information. This is useful when generating bug reports.
84 @item -w,--warranty
85 Show the warranty with which GNU LilyPond comes. (It comes with 
86 @strong{NO WARRANTY}!)
87 @end table
88
89
90
91 @subsection Additional parameters
92
93 The @code{lilypond} program responds to several parameters specified
94 in a @code{\paper} section of the input file. They can be overridden
95 by supplying a @code{--set} command line option.
96
97 @table @code
98 @item language
99     Specify La@TeX{} language: the @code{babel} package will be
100 included.  Default: unset.
101
102         Read from the @code{\header} block.
103
104 @item latexheaders
105     Specify additional La@TeX{} headers file.
106 <
107         Normally read from the @code{\header} block. Default value: empty.
108
109 @item latexpackages
110     Specify additional La@TeX{} packages file. This works cumulative,
111 so you can add multiple packages using multiple @code{-s=latexpackages} options.
112        Normally read from the @code{\header} block. Default value:
113 @code{geometry}.
114
115 @item latexoptions
116     Specify additional options for the La@TeX{}
117 @code{\documentclass}. You can put any valid value here. This was
118 designed to allow @code{lilypond} to produce output for double-sided
119 paper, with balanced margins and page numbers on alternating sides. To
120 achieve this specify @code{twoside}.
121
122 @item orientation
123     Set orientation. Choices are @code{portrait} or @code{landscape}. Is
124 read from the @code{\paper} block, if set.
125         
126 @item textheight
127     The vertical extension of the music on the page. It is normally 
128     calculated automatically, based on the paper size.
129
130 @item linewidth
131         The music line width. It is normally read from the @code{\paper}
132 block.
133
134 @item papersize
135    The paper size (as a name, e.g. @code{a4}). It is normally read from
136 the @code{\paper} block.
137   
138 @item fontenc
139      The font encoding, should be set identical to the @code{font-encoding}
140      property in the score.
141 @end table
142
143
144
145 @node Invoking the lilypond binary
146 @section Invoking the lilypond binary
147 @cindex Invoking LilyPond
148 @cindex command line options
149 @cindex options, command line
150 @cindex switches
151
152
153 The formatting system consists of two parts: a binary executable
154 (@file{lilypond-bin}), which is responsible for the formatting
155 functionality, and support scripts, which post-process the resulting
156 output. Normally, the support scripts are called, which in turn invoke
157 the @code{lilypond-bin} binary. However, @code{lilypond-bin} may be
158 called directly as follows.
159
160 @example
161         lilypond-bin [@var{option}]@dots{} @var{file}@dots{}
162 @end example
163
164
165 When invoked with a filename that has no extension, the @file{.ly}
166 extension is tried first.  To read input from  stdin, use a
167 dash @code{-} for @var{file}.
168
169 When @file{filename.ly} is processed it will produce
170 @file{filename.tex} as output (or @file{filename.ps} for PostScript
171 output).  If @file{filename.ly} contains more than one @code{\score}
172 block, then the rest of the scores will be output in numbered files,
173 starting with @file{filename-1.tex}.  Several files can be specified;
174 they will each be processed independently.  @footnote{The status of
175 GUILE is not reset across invocations, so be careful not to change any
176 system defaults from within Scheme.}
177
178
179 @section Command line options
180
181 The following options are supported:
182
183 @table @code
184
185 @item -e,--evaluate=@var{expr}
186 Evaluate the Scheme @var{expr} before parsing any @file{.ly} files.
187 Multiple @code{-e} options may be given, they will be evaluated
188 sequentially.  The function @code{ly:set-option} allows for access to
189 some internal variables.  Use @code{-e '(ly:option-usage)'} for more
190 information.
191
192 @item -f,--format=@var{format}
193 @c
194 @c
195 A comma separated list of output formats.  Choices are @code{tex} (for
196 @TeX{} output, to be processed with La@TeX{}, and @code{ps} for
197 PostScript.
198
199 Other output options are intended for developers. 
200
201
202 @cindex output format, setting
203 @cindex PostScript output
204 @cindex Scheme dump
205
206 @item -h,--help
207 Show a summary of usage.
208 @item --include, -I=@var{directory}
209 Add @var{directory} to the search path for input files.
210 @cindex file searching
211 @cindex search path
212 @item -i,--init=@var{file}
213 Set init file to @var{file} (default: @file{init.ly}).
214 @item -m,--no-paper
215 @cindex MIDI
216 Disable @TeX{} output. If you have a @code{\midi} definition MIDI output
217 will be generated.
218 @item -o,--output=@var{FILE}
219 Set the default output file to @var{FILE}.
220
221 @item -s,--safe
222 Do not trust the @code{.ly} input. 
223
224 When LilyPond formatting available through a web server, the
225 @code{--safe} @b{MUST} be passed.  This will prevent code like
226
227 @verbatim
228   #(system "rm -rf /")
229   \score {
230     c4^#(ly:export (ly:gulp-file "/etc/passwd"))
231   }
232 @end verbatim
233
234 The @code{--safe} option works by evaluating in-line Scheme
235 expressions in a special safe module. This safe module is derived from
236 GUILE @file{safe-r5rs} module, but adds a number of functions of the
237 LilyPond API. These functions are listed in @file{safe-lily.scm}.
238
239 In addition, @code{--safe} disallows @code{\include} directives and
240 disables the use of backslashes in @TeX{} strings.
241
242 In @code{--safe} mode, it is not possible to import LilyPond variables
243 into Scheme. 
244
245 @item -v,--version
246 Show version information.
247 @item -V,--verbose
248 Be verbose: show full paths of all  files read, and give timing
249 information.
250
251 @item -w,--warranty
252 Show the warranty with which GNU LilyPond comes. (It comes with 
253 @strong{NO WARRANTY}!)
254 @end table
255
256 @section Environment variables
257
258
259 For processing both the @TeX{} and the PostScript output, the
260 appropriate environment variables must be set.  The following scripts
261 do this:
262
263 @itemize @bullet
264 @item @file{buildscripts/out/lilypond-profile}
265 (for SH shells)
266 @item  @file{buildscripts/out/lilypond-login} (for C-shells)
267 @end itemize
268
269 They should normally be sourced as part of the login process. If these
270 scripts are not run from the system wide login process, then you must
271 run it yourself.
272
273 @cindex installing LilyPond
274
275 If you use sh, bash, or a similar shell, then add the following to
276 your @file{.profile}:
277 @example
278         . @var{/the/path/to/}lilypond-profile
279 @end example
280
281 If you use csh, tcsh or a similar shell, then add the following to
282 your @file{~/.login}:
283 @example
284         source @var{/the/path/to/}lilypond-login
285 @end example
286
287 Of course, in both cases, you should substitute the proper location of
288 either script.
289
290 These scripts set the following variables:
291 @table @code
292 @item TEXMF
293  To make sure that @TeX{} and lilypond find data files (among
294 others @file{.tex}, @file{.mf} and @file{.tfm}),
295 you have to set @code{TEXMF} to point to the lilypond data
296 file tree. A typical setting would be
297 @example
298 @{/usr/share/lilypond/1.6.0,@{!!/usr/share/texmf@}@}
299 @end example
300
301
302 @item GS_LIB
303 For processing PostScript output (obtained with
304 @code{-f ps}) with Ghostscript you have to set @code{GS_LIB} to
305 point to the directory containing library PS files.
306
307 @item GS_FONTPATH
308 For processing PostScript output (obtained with
309 @code{-f ps}) with Ghostscript you have to set @code{GS_FONTPATH} to
310 point to the directory containing  PFA files.
311
312 When you print direct PS output, remember to send the PFA files to the
313 printer as well.
314 @end table
315
316
317 @cindex ghostscript
318 @cindex PostScript
319 @cindex GS_FONTPATH
320 @cindex GS_LIB
321 @cindex TEXMF
322 @cindex printing postscript
323
324 The  binary itself recognizes the following environment variables:
325 @table @code
326 @item LILYPONDPREFIX
327 This specifies a directory where locale messages and
328 data files will be looked up by default. The directory should contain
329 subdirectories called @file{ly/}, @file{ps/}, @file{tex/}, etc.
330
331 @item LANG
332 This selects the language for the warning messages.
333 @end table
334
335 @cindex LANG
336 @cindex LILYPONDPREFIX
337
338 @node Error messages
339 @section Error messages
340
341 @cindex error messages
342 Different error messages can appear while compiling a file:
343
344 @table @emph
345 @cindex warning
346
347 @item Warning
348   Something looks suspect. If you are requesting something out of the
349 ordinary then you will understand the message, and can ignore it.
350 However, warnings usually indicate that something is wrong with the
351 input file.
352
353 @item Error
354 Something is definitely wrong.  The current processing step (parsing,
355 interpreting, or formatting) will be finished, but the next step will
356 be skipped.
357
358 @cindex error
359 @cindex fatal error
360 @item Fatal error
361 Something is definitely wrong, and LilyPond cannot continue. This
362 happens rarely. The most usual cause is misinstalled fonts.
363
364 @cindex trace, Scheme
365 @cindex call trace
366 @cindex Scheme error
367 @item Scheme error
368 Errors that occur while executing Scheme code are caught by the Scheme
369 interpreter. If running with the verbose option (@code{-V} or
370 @code{--verbose}) then a call trace is printed of the offending
371 function call.
372
373 @cindex Programming error
374 @item Programming error
375 There was some internal inconsistency. These error messages are
376 intended to help the programmers and debuggers. Usually, they can be
377 ignored. Sometimes, they come in such big quantities that they obscure
378 other output. In this case, file a bug-report.
379
380 @item Aborted (core dumped)
381 This signals a serious programming error that caused the program to
382 crash. Such errors are considered critical. If you stumble on one,
383 send a bugreport.
384
385
386 @end table
387
388 @cindex errors, message format
389 If warnings and errors can
390 be linked to some part of the input file, then error messages have the
391 following form
392
393 @example
394   @var{filename}:@var{lineno}:@var{columnno}: @var{message}
395   @var{offending input line}
396 @end example 
397
398 A line-break is inserted in offending line to indicate the column
399 where the error was found. For example, 
400
401 @example
402 test.ly:2:19: error: not a duration: 5:
403   \notes @{ c'4 e'5 
404                    g' @}
405 @end example
406
407
408 @node Reporting bugs
409 @section Reporting bugs
410
411 @cindex bugs
412 @cindex reporting bugs
413
414 If you have input that results in a crash or an erroneous output, then
415 that is a bug. We try respond to bug-reports promptly, and fix them as
416 soon as possible. For this, we need to reproduce and isolate the
417 problem. Help us by sending a defective input file, so we can
418 reproduce the problem. Make it small, so we can easily debug the
419 problem. Don't forget to tell which version you use, and on which
420 platform you run it.  Send the report to
421 @email{bug-lilypond@@gnu.org}.
422
423 @node Editor support
424 @section Editor support
425
426 @cindex editors
427 @cindex vim
428 @cindex emacs
429 @cindex modes, editor 
430 @cindex syntax coloring
431 @cindex coloring, syntax
432
433 There is support from different editors  for LilyPond.
434
435 @table @asis
436 @item Emacs
437  Emacs has a @file{lilypond-mode}, which provides keyword
438 autocompletion, indentation, LilyPond specific parenthesis matching
439 and syntax coloring, handy compile short-cuts and reading LilyPond
440 manuals using Info.  If lilypond-mode is not installed on your
441 platform, then refer to the installation instructions for more
442 information.
443
444 @item VIM
445
446 For @uref{http://www.vim.org,VIM}, a vimrc is supplied, along with
447 syntax coloring tools. For more information, refer to the
448 @ifhtml
449 @uref{../../../topdocs/out-www/INSTALL.html,installation instructions}.
450 @end ifhtml
451 @ifnothtml
452 installation instructions.
453 @end ifnothtml
454
455
456 For both editors, there is also a facility to jump in the input file
457 to the source of errors in the graphical output. See @ref{Point and
458 click}.
459
460 @item JEdit
461
462 There exists a plugin for @uref{http://www.jedit.org/,jEdit}. Refer to
463 the @uref{http://lily4jedit.sourceforge.net,plugin website} for more
464 information.
465
466 @end table
467
468 @node Point and click
469 @section Point and click
470 @cindex point and click
471
472 @cindex source specials
473 @cindex specials, source
474
475 Point and click lets you find notes in the input by clicking on them in
476 the Xdvi window. This makes it easier to find input that causes some
477 error in the sheet music.
478
479 To use it, you need the following software:
480 @itemize @bullet
481 @item a dvi viewer that supports src specials:
482 @itemize @bullet
483 @item Xdvi, version 22.36 or newer.  Available from
484 @uref{ftp://ftp.math.berkeley.edu/pub/Software/TeX/xdvi.tar.gz,ftp.math.berkeley.edu}.
485
486    Most @TeX{} distributions ship with xdvik, which is always a few
487 versions behind the official Xdvi. To find out which Xdvi you are
488 running, try @code{xdvi -version} or @code{xdvi.bin -version}.
489 @item KDVI.  A dvi viewer for KDE.  You need KDVI from KDE 3.0 or
490 newer.  Enable option @emph{Inverse search} in the menu @emph{Settings}.
491
492 Apparently, KDVI does not process PostScript specials correctly. Beams
493 and slurs will not be visible in KDVI.
494
495 @cindex Xdvi
496 @cindex KDVI
497 @cindex KDE
498
499
500
501 @end itemize
502 @item an editor with a client/server interface (or a lightweight GUI
503 editor):
504
505 @cindex editor
506
507 @itemize @bullet
508 @item Emacs. Emacs is an extensible text-editor.  It is available from
509 @uref{http://www.gnu.org/software/emacs/}.  You need version 21 to use
510 column location.
511
512 @c move this elsewhere?
513
514
515 @cindex Emacs
516 @cindex Emacs mode
517 @cindex lilypond-mode for Emacs
518 @cindex syntax coloring
519
520 @item XEmacs. XEmacs is very similar to Emacs.
521
522 @cindex XEmacs
523
524 @item NEdit.  NEdit runs under Windows, and Unix.
525   It is available from @uref{http://www.nedit.org}.
526
527 @cindex NEdit
528
529 @item GVim.  GVim is a GUI variant of VIM, the popular VI
530 clone.  It is available from @uref{http://www.vim.org}.
531
532 @cindex GVim
533 @cindex Vim
534
535 @end itemize
536 @end itemize
537
538
539 Xdvi must be configured to find the @TeX{} fonts and music
540 fonts. Refer to the Xdvi documentation for more information.
541
542 To use point-and-click, add one of these lines to the top of your .ly
543 file:
544 @example
545 #(ly:set-point-and-click 'line)
546 @end example
547 @cindex line-location
548
549 When viewing, Control-Mousebutton 1 will take you to the originating
550 spot in the @file{.ly} file.  Control-Mousebutton 2 will show all
551 clickable boxes.
552
553 If you correct large files with point-and-click, be sure to start
554 correcting at the end of the file. When you start at the top, and
555 insert one line, all following locations will be off by a line.
556
557 @cindex Emacs
558 For using point-and-click with Emacs,  add the following
559 In your Emacs startup file (usually @file{~/.emacs}):
560 @example
561 (server-start)
562 @end example
563
564 Make sure that the environment variable @var{XEDITOR} is set to
565 @example
566 emacsclient --no-wait +%l %f
567 @end example
568 @cindex @var{XEDITOR}
569 If you use XEmacs instead of Emacs, you use @code{(gnuserve-start)} in
570 your @file{.emacs}, and set @code{XEDITOR} to @code{gnuclient -q +%l %f}.
571
572 For using Vim, set @code{XEDITOR} to @code{gvim --remote +%l %f}, or
573 use this argument with Xdvi's @code{-editor} option.
574
575 @cindex NEdit
576 For using NEdit, set @code{XEDITOR} to @code{nc -noask +%l %f}, or
577 use this argument with Xdvi's @code{-editor} option.
578
579 If can also make your editor jump to the exact location of the note
580 you clicked. This is only supported on Emacs and VIM. Users of Emacs version
581 20 must apply the patch @file{emacsclient.patch}. Users of version 21
582 must apply @file{server.el.patch} (version 21.2 and earlier).  At the
583 top of the @code{ly} file, replace the @code{set-point-and-click} line
584 with the following line:
585 @example
586 #(ly:set-point-and-click 'line-column)
587 @end example
588 @cindex line-column-location
589 and set @code{XEDITOR} to @code{emacsclient --no-wait +%l:%c %f}.  Vim
590 users can set @var{XEDITOR} to @code{gvim --remote +:%l:norm%c| %f}.
591
592