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