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