]> git.donarmstrong.com Git - lilypond.git/blob - Documentation/extending/programming-interface.itely
Fixed errors in Catalan translation
[lilypond.git] / Documentation / extending / programming-interface.itely
1 @c -*- coding: utf-8; mode: texinfo; -*-
2
3 @ignore
4     Translation of GIT committish: FILL-IN-HEAD-COMMITTISH
5
6     When revising a translation, copy the HEAD committish of the
7     version that you are working on.  For details, see the Contributors'
8     Guide, node Updating translation committishes..
9 @end ignore
10
11 @c \version "2.17.6"
12
13 @node Interfaces for programmers
14 @chapter Interfaces for programmers
15
16 Advanced tweaks may be performed by using Scheme.  If you are
17 not familiar with Scheme, you may wish to read our
18 @ref{Scheme tutorial}.
19
20 @menu
21 * LilyPond code blocks::
22 * Scheme functions::
23 * Music functions::
24 * Event functions::
25 * Markup functions::
26 * Contexts for programmers::
27 * Callback functions::
28 * Inline Scheme code::
29 * Difficult tweaks::
30 @end menu
31
32 @node LilyPond code blocks
33 @section LilyPond code blocks
34
35 @cindex LilyPond code blocks
36 @cindex code blocks, LilyPond
37 @funindex #@{ @dots{} #@}
38 @funindex $
39 @funindex #
40
41 Creating music expressions in Scheme can be tedious, as they are
42 heavily nested and the resulting Scheme code is large. For some
43 simple tasks this can be avoided by using LilyPond code blocks,
44 which enable common LilyPond syntax to be used within Scheme.
45
46 LilyPond code blocks look like
47
48 @example
49   #@{ @var{LilyPond code} #@}
50 @end example
51
52 Here is a trivial example:
53
54 @lilypond[verbatim,quote]
55 ritpp = #(define-event-function (parser location) ()
56   #{ ^"rit." \pp #}
57 )
58
59 { c'4 e'4\ritpp g'2 }
60 @end lilypond
61
62 LilyPond code blocks can be used anywhere where you can write Scheme
63 code.  The Scheme reader actually is changed for accommodating
64 LilyPond code blocks and can deal with embedded Scheme expressions
65 starting with @code{$} and@w{ }@code{#}.
66
67 @cindex parser (function argument)
68 @cindex location
69
70 The reader extracts the LilyPond code block and generates a runtime
71 call to the LilyPond @code{parser} to interpret the LilyPond code.
72 Scheme expressions embedded in the LilyPond code are evaluated in the
73 lexical environment of the LilyPond code block, so all local variables
74 and function parameters available at the point the LilyPond code block
75 is written may be accessed.  Variables defined in other Scheme modules,
76 like the modules containing @code{\header} and @code{\layout} blocks,
77 are not accessible as Scheme variables, i.e. prefixed
78 with@tie{}@code{#}, but they are accessible as LilyPond variables, i.e.
79 prefixed with@tie{}@code{\}.
80
81 If @code{location} (see @ref{Scheme functions}) refers to a valid
82 input location (which it usually does inside of music/@/Scheme
83 functions), all music generated inside the code block has its
84 @samp{origin} set to @code{location}.
85
86 A LilyPond code block may contain anything that you can use on the
87 right side of an assignment.  In addition, an empty LilyPond block
88 corresponds to a void music expression, and a LilyPond block
89 containing multiple music events gets turned into a sequential music
90 expression.
91
92 @node Scheme functions
93 @section Scheme functions
94 @cindex Scheme functions (LilyPond syntax)
95
96 @emph{Scheme functions} are Scheme procedures that can create Scheme
97 expressions from input written in LilyPond syntax.  They can be called
98 in pretty much all places where using @code{#} for specifying a value in
99 Scheme syntax is allowed.  While Scheme has functions of its own, this
100 chapter is concerned with @emph{syntactic} functions, functions that
101 receive arguments specified in LilyPond syntax.
102
103 @menu
104 * Scheme function definitions::
105 * Scheme function usage::
106 * Void scheme functions::
107 @end menu
108
109 @node Scheme function definitions
110 @subsection Scheme function definitions
111 @funindex define-scheme-function
112
113 The general form for defining scheme functions is:
114
115 @example
116 function =
117 #(define-scheme-function
118      (parser location @var{arg1} @var{arg2} @dots{})
119      (@var{type1?} @var{type2?} @dots{})
120    @var{body})
121 @end example
122
123 @noindent
124 where
125
126 @multitable @columnfractions .33 .66
127 @item @code{parser}
128 @tab needs to be literally @code{parser} in order to give LilyPond code
129 blocks (@code{#@{}@dots{}@code{#@}}) access to the parser.
130
131 @item @code{location}
132 @tab needs to be literally @code{location} in order to provide access
133 to the input location object, which is used to provide error messages
134 with file names and line numbers.
135
136 @item @code{@var{argN}}
137 @tab @var{n}th argument
138
139 @item @code{@var{typeN?}}
140 @tab a Scheme @emph{type predicate} for which @code{@var{argN}}
141 must return @code{#t}.  There is also a special form
142 @code{(@emph{predicate?} @emph{default})} for specifying optional
143 arguments.  If the actual argument is missing when the function is being
144 called, the default value is substituted instead.  Default values are
145 evaluated at definition time (including LilyPond code blocks!), so if
146 you need a default calculated at runtime, instead write a special value
147 you can easily recognize.  If you write the predicate in parentheses but
148 don't follow it with a default value, @code{#f} is used as the default.
149 Default values are not verified with @emph{predicate?} at either
150 definition or run time: it is your responsibility to deal with the
151 values you specify.  Default values that happen to be music expressions
152 are copied while setting @code{origin} to the @code{location} parameter.
153
154 @item @code{@var{body}}
155 @tab A sequence of Scheme forms evaluated in order, the last one being
156 used as the return value of the scheme function.  It may contain
157 LilyPond code blocks enclosed in hashed braces
158 (@tie{}@w{@code{#@{@dots{}#@}}}@tie{}), like described in
159 @ref{LilyPond code blocks}.  Within LilyPond code blocks, use @code{#}
160 to reference function arguments (eg., @samp{#arg1}) or to start an
161 inline Scheme expression containing function arguments (eg.,
162 @w{@samp{#(cons arg1 arg2)}}).  Where normal Scheme expressions using
163 @code{#} don't do the trick, you might need to revert to immediate
164 Scheme expressions using @code{$}, for example as @samp{$music}.
165
166 If your function returns a music expression, it is given a useful value
167 of @code{origin}.
168 @end multitable
169
170 @noindent
171 Suitability of arguments for the predicates is determined by
172 actually calling the predicate after LilyPond has already converted them
173 into a Scheme expression.  As a consequence, the argument can be
174 specified in Scheme syntax if desired (introduced with @code{#} or as
175 the result of calling a scheme function), but LilyPond will also convert
176 a number of LilyPond constructs into Scheme before actually checking the
177 predicate on them.  Currently, those include music, postevents, simple
178 strings (with or without quotes), numbers, full markups and markup
179 lists, score, book, bookpart, context definition and output definition
180 blocks.
181
182 For some kinds of expression (like most music not enclosed in braces)
183 LilyPond needs to look further than the expression itself in order to
184 determine its end.  If such an expression were considered for an
185 optional argument by evaluating its predicate, LilyPond would not be
186 able to @q{backup} when it decides the expression does not fit the
187 parameter.  So some forms of music might need to be enclosed in braces
188 to make them acceptable in some circumstances.  Some other
189 ambiguities LilyPond sorts out by checking with predicate
190 functions: is @samp{-3} a fingering postevent or a negative number?  Is
191 @code{"a" 4} in lyric mode a string followed by a number, or a lyric
192 event of duration @code{4}?  LilyPond tries the argument
193 predicate on successive interpretations until success, with an
194 order designed to minimize inconsistent interpretations and
195 lookahead.
196
197 For example, a predicate accepting both music expressions and
198 pitches will consider @code{c''} to be a pitch rather than a music
199 expression.  Immediately following durations or postevents might
200 not work with that interpretation.  So it's best to avoid overly
201 permissive predicates like @code{scheme?} when the application
202 rather calls for more specific argument types.
203
204 For a list of available predefined type predicates, see
205 @ruser{Predefined type predicates}.
206
207 @seealso
208
209 Notation Reference:
210 @ruser{Predefined type predicates}.
211
212 Installed Files:
213 @file{lily/music-scheme.cc},
214 @file{scm/c++.scm},
215 @file{scm/lily.scm}.
216
217 @node Scheme function usage
218 @subsection Scheme function usage
219
220 Scheme functions can be called pretty much anywhere where a Scheme
221 expression starting with @code{#} can be written.  You call a scheme
222 function by writing its name preceded by @code{\}, followed by its
223 arguments.  Once an optional argument predicate does not match an
224 argument, LilyPond skips this and all following optional arguments,
225 replacing them with their specified default, and @q{backs up} the
226 argument that did not match to the place of the next mandatory argument.
227 Since the backed up argument needs to go somewhere, optional arguments
228 are not actually considered optional unless followed by a mandatory
229 argument.
230
231 There is one exception: if you write @code{\default} in the place of an
232 optional argument, this and all following optional arguments are skipped
233 and replaced by their default.  This works even when no mandatory
234 argument follows since @code{\default} does not need to get backed up.
235 The @code{mark} and @code{key} commands make use of that trick to
236 provide their default behavior when just followed by @code{\default}.
237
238 Apart from places where a Scheme value is required, there are a few
239 places where @code{#} expressions are currently accepted and evaluated
240 for their side effects but otherwise ignored.  Mostly those are the
241 places where an assignment would be acceptable as well.
242
243 Since it is a bad idea to return values that can be misinterpreted in
244 some context, you should use normal scheme functions only for those
245 cases where you always return a useful value, and use void scheme
246 functions (@pxref{Void scheme functions}) otherwise.
247
248 @node Void scheme functions
249 @subsection Void scheme functions
250 @funindex define-void-function
251 @funindex \void
252
253 Sometimes a procedure is executed in order to perform an action rather
254 than return a value.  Some programming languages (like C and Scheme) use
255 functions for either concept and just discard the returned value
256 (usually by allowing any expression to act as statement, ignoring the
257 result).  This is clever but error-prone: most C compilers nowadays
258 offer warnings for various non-``void'' expressions being discarded.
259 For many functions executing an action, the Scheme standards declare the
260 return value to be unspecified.  LilyPond's Scheme interpreter Guile has
261 a unique value @code{*unspecified*} that it usually (such when using
262 @code{set!} directly on a variable) but unfortunately not consistently
263 returns in such cases.
264
265 Defining a LilyPond function with @code{define-void-function} makes
266 sure that this special value (the only value satisfying the predicate
267 @code{void?}) will be returned.
268
269 @example
270 noPointAndClick =
271 #(define-void-function
272      (parser location)
273      ()
274    (ly:set-option 'point-and-click #f))
275 @dots{}
276 \noPointAndClick   % disable point and click
277 @end example
278
279 If you want to evaluate an expression only for its side-effect and
280 don't want any value it may return interpreted, you can do so by
281 prefixing it with @code{\void}:
282
283 @example
284 \void #(hashq-set! some-table some-key some-value)
285 @end example
286
287 That way, you can be sure that LilyPond will not assign meaning to the
288 returned value regardless of where it encounters it.  This will also
289 work for music functions such as @code{\displayMusic}.
290
291 @node Music functions
292 @section Music functions
293
294 @cindex music functions
295
296 @emph{Music functions} are Scheme procedures that can create music
297 expressions automatically, and can be used to greatly simplify the
298 input file.
299
300 @menu
301 * Music function definitions::
302 * Music function usage::
303 * Simple substitution functions::
304 * Intermediate substitution functions::
305 * Mathematics in functions::
306 * Functions without arguments::
307 * Void music functions::
308 @end menu
309
310
311 @node Music function definitions
312 @subsection Music function definitions
313 @cindex defining music functions
314 @funindex define-music-function
315
316 The general form for defining music functions is:
317
318 @example
319 function =
320 #(define-music-function
321      (parser location @var{arg1} @var{arg2} @dots{})
322      (@var{type1?} @var{type2?} @dots{})
323    @var{body})
324 @end example
325
326 @noindent
327 quite in analogy to @ref{Scheme function definitions}.  More often than
328 not, @var{body} will be a @ref{LilyPond code blocks, LilyPond code block}.
329
330 For a list of available type predicates, see
331 @ruser{Predefined type predicates}.
332
333 @seealso
334
335 Notation Reference:
336 @ruser{Predefined type predicates}.
337
338 Installed Files:
339 @file{lily/music-scheme.cc},
340 @file{scm/c++.scm},
341 @file{scm/lily.scm}.
342
343
344 @node Music function usage
345 @subsection Music function usage
346 Music functions may currently be used in several places.  Depending on
347 where they are used, restrictions apply in order to be able to parse
348 them unambiguously.  The result a music function returns must be
349 compatible with the context in which it is called.
350
351 @itemize
352 @item
353 At top level in a music expression.  No restriction apply here.
354
355 @item
356 As a post-event, explicitly started with a direction indicator (one of
357 @code{-}, @code{^}, @w{and @code{_}}).
358
359 In this case, you can't use an @emph{open} music expression as the last
360 argument, one that would end with a music expression able to accept
361 additional postevents.
362
363 @item
364 As a chord constituent.  The returned expression must be of
365 @code{rhythmic-event} type, most likely a @code{NoteEvent}.
366 @end itemize
367
368 @noindent
369 The special rules for trailing arguments make it possible to write
370 polymorphic functions like @code{\tweak} that can be applied to
371 different constructs.
372
373 @node Simple substitution functions
374 @subsection Simple substitution functions
375
376 Simple substitution functions are music functions whose output
377 music expression is written in LilyPond format and contains
378 function arguments in the output expression.  They are described
379 in @ruser{Substitution function examples}.
380
381
382 @node Intermediate substitution functions
383 @subsection Intermediate substitution functions
384
385 Intermediate substitution functions involve a mix of Scheme code
386 and LilyPond code in the music expression to be returned.
387
388 Some @code{\override} commands require an argument consisting of
389 a pair of numbers (called a @emph{cons cell} in Scheme).
390
391 The pair can be directly passed into the music function,
392 using a @code{pair?} variable:
393
394 @example
395 manualBeam =
396 #(define-music-function
397      (parser location beg-end)
398      (pair?)
399    #@{
400      \once \override Beam.positions = #beg-end
401    #@})
402
403 \relative c' @{
404   \manualBeam #'(3 . 6) c8 d e f
405 @}
406 @end example
407
408 Alternatively, the numbers making up the pair can be
409 passed as separate arguments, and the Scheme code
410 used to create the pair can be included in the
411 music expression:
412
413 @lilypond[quote,verbatim,ragged-right]
414 manualBeam =
415 #(define-music-function
416      (parser location beg end)
417      (number? number?)
418    #{
419      \once \override Beam.positions = #(cons beg end)
420    #})
421
422 \relative c' {
423   \manualBeam #3 #6 c8 d e f
424 }
425 @end lilypond
426
427 @funindex \temporary
428 @cindex temporary overrides
429 @cindex overrides, temporary
430 @cindex properties, popping previous value
431
432 Properties are maintained conceptually using one stack per property
433 per grob per context.  Music functions may need to override one or
434 several properties for the duration of the function, restoring them
435 to their previous value before exiting.  However, normal overrides
436 pop and discard the top of the current property stack before
437 pushing to it, so the previous value of the property is lost when it
438 is overridden.  When the previous value must be preserved, prefix the
439 @code{\override} command with @code{\temporary}, like this:
440
441 @example
442 \temporary \override @dots{}
443 @end example
444
445 The use of @code{\temporary} causes the (usually set) @code{pop-first}
446 property in the override to be cleared, so the previous value is not
447 popped off the property stack before pushing the new value onto it.
448 When a subsequent @code{\revert} pops off the temporarily overriden
449 value, the previous value will re-emerge.
450
451 In other words, calling @code{\temporary \override} and @code{\revert}
452 in succession on the same property will have a net effect of zero.
453 Similarly, pairing @code{\temporary} and @code{\undo} on the same
454 music containing overrides will have a net effect of zero.
455
456 Here is an example of a music function which makes use of this.
457 The use of @code{\temporary} ensures the values of the
458 @code{cross-staff} and @code{style} properties are restored on exit
459 to whatever values they had when the @code{crossStaff} function was
460 called.  Without @code{\temporary} the default values would have been
461 set on exit.
462
463 @example
464 crossStaff =
465 #(define-music-function (parser location notes) (ly:music?)
466   (_i "Create cross-staff stems")
467   #@{
468   \temporary \override Stem.cross-staff = #cross-staff-connect
469   \temporary \override Flag.style = #'no-flag
470   #notes
471   \revert Stem.cross-staff
472   \revert Flag.style
473 #@})
474 @end example
475
476
477 @node Mathematics in functions
478 @subsection Mathematics in functions
479
480 Music functions can involve Scheme programming in
481 addition to simple substitution,
482
483 @lilypond[quote,verbatim,ragged-right]
484 AltOn =
485 #(define-music-function
486      (parser location mag)
487      (number?)
488    #{
489      \override Stem.length = #(* 7.0 mag)
490      \override NoteHead.font-size =
491        #(inexact->exact (* (/ 6.0 (log 2.0)) (log mag)))
492    #})
493
494 AltOff = {
495   \revert Stem.length
496   \revert NoteHead.font-size
497 }
498
499 \relative c' {
500   c2 \AltOn #0.5 c4 c
501   \AltOn #1.5 c c \AltOff c2
502 }
503 @end lilypond
504
505 @noindent
506 This example may be rewritten to pass in music expressions,
507
508 @lilypond[quote,verbatim,ragged-right]
509 withAlt =
510 #(define-music-function
511      (parser location mag music)
512      (number? ly:music?)
513    #{
514      \override Stem.length = #(* 7.0 mag)
515      \override NoteHead.font-size =
516        #(inexact->exact (* (/ 6.0 (log 2.0)) (log mag)))
517      #music
518      \revert Stem.length
519      \revert NoteHead.font-size
520    #})
521
522 \relative c' {
523   c2 \withAlt #0.5 { c4 c }
524   \withAlt #1.5 { c c } c2
525 }
526 @end lilypond
527
528
529 @node Functions without arguments
530 @subsection Functions without arguments
531
532 In most cases a function without arguments should be written
533 with a variable,
534
535 @example
536 dolce = \markup@{ \italic \bold dolce @}
537 @end example
538
539 However, in rare cases it may be useful to create a music function
540 without arguments,
541
542 @example
543 displayBarNum =
544 #(define-music-function
545      (parser location)
546      ()
547    (if (eq? #t (ly:get-option 'display-bar-numbers))
548        #@{ \once \override Score.BarNumber.break-visibility = ##f #@}
549        #@{#@}))
550 @end example
551
552 To actually display bar numbers where this function is called,
553 invoke @command{lilypond} with
554
555 @example
556 lilypond -d display-bar-numbers FILENAME.ly
557 @end example
558
559
560 @node Void music functions
561 @subsection Void music functions
562
563 A music function must return a music expression.  If you want to
564 execute a function only for its side effect, you should use
565 @code{define-void-function}.  But there may be cases where you
566 sometimes want to produce a music expression, and sometimes not (like
567 in the previous example).  Returning a @code{void} music expression
568 via @code{#@{ #@}} will achieve that.
569
570 @node Event functions
571 @section Event functions
572 @funindex define-event-function
573 @cindex event functions
574
575 To use a music function in the place of an event, you need to write a
576 direction indicator before it.  But sometimes, this does not quite match
577 the syntax of constructs you want to replace.  For example, if you want
578 to write dynamics commands, those are usually attached without direction
579 indicator, like @code{c'\pp}.  Here is a way to write arbitrary
580 dynamics:
581 @lilypond[quote,verbatim,ragged-right]
582 dyn=#(define-event-function (parser location arg) (markup?)
583          (make-dynamic-script arg))
584 \relative c' { c\dyn pfsss }
585 @end lilypond
586 You could do the same using a music function, but then you always would
587 have to write a direction indicator before calling it, like
588 @code{@w{c-\dyn pfsss}}.
589
590
591 @node Markup functions
592 @section Markup functions
593
594 Markups are implemented as special Scheme functions which produce a
595 @code{Stencil} object given a number of arguments.
596
597 @menu
598 * Markup construction in Scheme::
599 * How markups work internally::
600 * New markup command definition::
601 * New markup list command definition::
602 @end menu
603
604
605 @node Markup construction in Scheme
606 @subsection Markup construction in Scheme
607
608 @cindex defining markup commands
609 @funindex \displayScheme
610
611 Markup expressions are internally represented in Scheme using the
612 @code{markup} macro:
613
614 @example
615 (markup @var{expr})
616 @end example
617
618 To see a markup expression in its Scheme form, use the
619 @code{\displayScheme} command:
620
621 @example
622 \displayScheme
623 \markup @{
624   \column @{
625     \line @{ \bold \italic "hello" \raise #0.4 "world" @}
626     \larger \line @{ foo bar baz @}
627   @}
628 @}
629 @end example
630
631 @noindent
632 Compiling the code above will send the following to the display
633 console:
634
635 @example
636 (markup
637   #:line
638   (#:column
639    (#:line
640     (#:bold (#:italic "hello") #:raise 0.4 "world")
641     #:larger
642     (#:line
643      (#:simple "foo" #:simple "bar" #:simple "baz")))))
644 @end example
645
646 To prevent the markup from printing on the page, use
647 @w{@samp{\void \displayScheme @var{markup}}}.  Also, as with the
648 @code{\displayMusic} command, the output of @code{\displayScheme}
649 can be saved to an external file.  See
650 @ref{Displaying music expressions}.
651
652 @noindent
653 This example demonstrates the main translation rules between regular
654 LilyPond markup syntax and Scheme markup syntax.  Using @code{#@{
655 @dots{} #@}} for entering in LilyPond syntax will often be most
656 convenient, but we explain how to use the @code{markup} macro to get a
657 Scheme-only solution.
658
659 @quotation
660 @multitable @columnfractions .3 .3
661 @item @b{LilyPond} @tab @b{Scheme}
662 @item @code{\markup markup1} @tab @code{(markup markup1)}
663 @item @code{\markup @{ markup1 markup2 @dots{} @}} @tab
664         @code{(markup markup1 markup2 @dots{} )}
665 @item @code{\markup-command} @tab @code{#:markup-command}
666 @item @code{\variable} @tab @code{variable}
667 @item @code{\center-column @{ @dots{} @}} @tab
668         @code{#:center-column ( @dots{} )}
669 @item @code{string} @tab @code{"string"}
670 @item @code{#scheme-arg} @tab @code{scheme-arg}
671 @end multitable
672 @end quotation
673
674 The whole Scheme language is accessible inside the
675 @code{markup} macro.  For example, You may use function calls inside
676 @code{markup} in order to manipulate character strings.  This is
677 useful when defining new markup commands (see
678 @ref{New markup command definition}).
679
680
681 @knownissues
682
683 The markup-list argument of commands such as @code{#:line},
684 @code{#:center}, and @code{#:column} cannot be a variable or
685 the result of a function call.
686
687 @lisp
688 (markup #:line (function-that-returns-markups))
689 @end lisp
690
691 @noindent
692 is invalid.  One should use the @code{make-line-markup},
693 @code{make-center-markup}, or @code{make-column-markup} functions
694 instead,
695
696 @lisp
697 (markup (make-line-markup (function-that-returns-markups)))
698 @end lisp
699
700
701 @node How markups work internally
702 @subsection How markups work internally
703
704 In a markup like
705
706 @example
707 \raise #0.5 "text example"
708 @end example
709
710 @noindent
711 @code{\raise} is actually represented by the @code{raise-markup}
712 function.  The markup expression is stored as
713
714 @example
715 (list raise-markup 0.5 (list simple-markup "text example"))
716 @end example
717
718 When the markup is converted to printable objects (Stencils), the
719 @code{raise-markup} function is called as
720
721 @example
722 (apply raise-markup
723        @var{\layout object}
724        @var{list of property alists}
725        0.5
726        @var{the "text example" markup})
727 @end example
728
729 The @code{raise-markup} function first creates the stencil for the
730 @code{text example} string, and then it raises that Stencil by 0.5
731 staff space.  This is a rather simple example; more complex examples
732 are in the rest
733 of this section, and in @file{scm/define-markup-commands.scm}.
734
735
736 @node New markup command definition
737 @subsection New markup command definition
738
739 This section discusses the definition of new markup commands.
740
741 @menu
742 * Markup command definition syntax::
743 * On properties::
744 * A complete example::
745 * Adapting builtin commands::
746 @end menu
747
748 @node Markup command definition syntax
749 @unnumberedsubsubsec Markup command definition syntax
750
751 New markup commands can be defined using the
752 @code{define-markup-command} Scheme macro, at top-level.
753
754 @lisp
755 (define-markup-command (@var{command-name} @var{layout} @var{props} @var{arg1} @var{arg2} @dots{})
756     (@var{arg1-type?} @var{arg2-type?} @dots{})
757     [ #:properties ((@var{property1} @var{default-value1})
758                     @dots{}) ]
759   @dots{}command body@dots{})
760 @end lisp
761
762 The arguments are
763
764 @table @code
765 @item @var{command-name}
766 the markup command name
767 @item layout
768 the @q{layout} definition.
769 @item props
770 a list of associative lists, containing all active properties.
771 @item @var{argi}
772 @var{i}th command argument
773 @item @var{argi-type?}
774 a type predicate for the i@var{th} argument
775 @end table
776
777 If the command uses properties from the @code{props} arguments,
778 the @code{#:properties} keyword can be used to specify which
779 properties are used along with their default values.
780
781 Arguments are distinguished according to their type:
782 @itemize
783 @item a markup, corresponding to type predicate @code{markup?};
784 @item a list of markups, corresponding to type predicate
785 @code{markup-list?};
786 @item any other scheme object, corresponding to type predicates such as
787 @code{list?}, @code{number?}, @code{boolean?}, etc.
788 @end itemize
789
790 There is no limitation on the order of arguments (after the
791 standard @code{layout} and @code{props} arguments).  However,
792 markup functions taking a markup as their last argument are
793 somewhat special as you can apply them to a markup list, and the
794 result is a markup list where the markup function (with the
795 specified leading arguments) has been applied to every element of
796 the original markup list.
797
798 Since replicating the leading arguments for applying a markup
799 function to a markup list is cheap mostly for Scheme arguments,
800 you avoid performance pitfalls by just using Scheme arguments for
801 the leading arguments of markup functions that take a markup as
802 their last argument.
803
804 @funindex \markup
805 @cindex markup macro
806 @funindex interpret-markup
807 Markup commands have a rather complex life cycle.  The body of a
808 markup command definition is responsible for converting the
809 arguments of the markup command into a stencil expression which is
810 returned.  Quite often this is accomplished by calling the
811 @code{interpret-markup} function on a markup expression, passing
812 the @var{layout} and @var{props} arguments on to it.  Those
813 arguments are usually only known at a very late stage in
814 typesetting.  Markup expressions have their components assembled
815 into markup expressions already when @code{\markup} in a LilyPond
816 expression or the @code{markup} macro in Scheme is expanded.  The
817 evaluation and typechecking of markup command arguments happens at
818 the time @code{\markup}/@code{markup} are interpreted.
819
820 But the actual conversion of markup expressions into stencil
821 expressions by executing the markup function bodies only happens
822 when @code{interpret-markup} is called on a markup expression.
823
824 @node On properties
825 @unnumberedsubsubsec On properties
826
827 The @code{layout} and @code{props} arguments of markup commands bring a
828 context for the markup interpretation: font size, line width, etc.
829
830 The @code{layout} argument allows access to properties defined in
831 @code{paper} blocks, using the @code{ly:output-def-lookup} function.
832 For instance, the line width (the same as the one used in scores) is
833 read using:
834
835 @example
836 (ly:output-def-lookup layout 'line-width)
837 @end example
838
839 The @code{props} argument makes some properties accessible to markup
840 commands.  For instance, when a book title markup is interpreted, all
841 the variables defined in the @code{\header} block are automatically
842 added to @code{props}, so that the book title markup can access the book
843 title, composer, etc.  It is also a way to configure the behaviour of a
844 markup command: for example, when a command uses font size during
845 processing, the font size is read from @code{props} rather than having a
846 @code{font-size} argument.  The caller of a markup command may change
847 the value of the font size property in order to change the behaviour.
848 Use the @code{#:properties} keyword of @code{define-markup-command} to
849 specify which properties shall be read from the @code{props} arguments.
850
851 The example in next section illustrates how to access and override
852 properties in a markup command.
853
854 @node A complete example
855 @unnumberedsubsubsec A complete example
856
857 The following example defines a markup command to draw a double box
858 around a piece of text.
859
860 Firstly, we need to build an approximative result using markups.
861 Consulting the @ruser{Text markup commands} shows us the @code{\box}
862 command is useful:
863
864 @lilypond[quote,verbatim,ragged-right]
865 \markup \box \box HELLO
866 @end lilypond
867
868 Now, we consider that more padding between the text and the boxes is
869 preferable.  According to the @code{\box} documentation, this command
870 uses a @code{box-padding} property, which defaults to 0.2.  The
871 documentation also mentions how to override it:
872
873 @lilypond[quote,verbatim,ragged-right]
874 \markup \box \override #'(box-padding . 0.6) \box A
875 @end lilypond
876
877 Then, the padding between the two boxes is considered too small, so we
878 override it too:
879
880 @lilypond[quote,verbatim,ragged-right]
881 \markup \override #'(box-padding . 0.4) \box
882      \override #'(box-padding . 0.6) \box A
883 @end lilypond
884
885 Repeating this lengthy markup would be painful.  This is where a markup
886 command is needed.  Thus, we write a @code{double-box} markup command,
887 taking one argument (the text).  This draws the two boxes, with some
888 padding.
889
890 @lisp
891 #(define-markup-command (double-box layout props text) (markup?)
892   "Draw a double box around text."
893   (interpret-markup layout props
894     #@{\markup \override #'(box-padding . 0.4) \box
895             \override #'(box-padding . 0.6) \box @{ #text @}#@}))
896 @end lisp
897
898 or, equivalently
899
900 @lisp
901 #(define-markup-command (double-box layout props text) (markup?)
902   "Draw a double box around text."
903   (interpret-markup layout props
904     (markup #:override '(box-padding . 0.4) #:box
905             #:override '(box-padding . 0.6) #:box text)))
906 @end lisp
907
908 @code{text} is the name of the command argument, and @code{markup?} its
909 type: it identifies it as a markup.  The @code{interpret-markup}
910 function is used in most of markup commands: it builds a stencil, using
911 @code{layout}, @code{props}, and a markup.  In the second case, this
912 markup is built using the @code{markup} scheme macro, see @ref{Markup
913 construction in Scheme}.  The transformation from @code{\markup}
914 expression to scheme markup expression is straight-forward.
915
916 The new command can be used as follow:
917
918 @example
919 \markup \double-box A
920 @end example
921
922 It would be nice to make the @code{double-box} command customizable:
923 here, the @code{box-padding} values are hard coded, and cannot be
924 changed by the user.  Also, it would be better to distinguish the
925 padding between the two boxes, from the padding between the inner box
926 and the text.  So we will introduce a new property,
927 @code{inter-box-padding}, for the padding between the two boxes.  The
928 @code{box-padding} will be used for the inner padding.  The new code is
929 now as follows:
930
931 @lisp
932 #(define-markup-command (double-box layout props text) (markup?)
933   #:properties ((inter-box-padding 0.4)
934                 (box-padding 0.6))
935   "Draw a double box around text."
936   (interpret-markup layout props
937     #@{\markup \override #`(box-padding . ,inter-box-padding) \box
938                \override #`(box-padding . ,box-padding) \box
939                @{ #text @} #@}))
940 @end lisp
941
942 Again, the equivalent version using the markup macro would be:
943
944 @lisp
945 #(define-markup-command (double-box layout props text) (markup?)
946   #:properties ((inter-box-padding 0.4)
947                 (box-padding 0.6))
948   "Draw a double box around text."
949   (interpret-markup layout props
950     (markup #:override `(box-padding . ,inter-box-padding) #:box
951             #:override `(box-padding . ,box-padding) #:box text)))
952 @end lisp
953
954 Here, the @code{#:properties} keyword is used so that the
955 @code{inter-box-padding} and @code{box-padding} properties are read from
956 the @code{props} argument, and default values are given to them if the
957 properties are not defined.
958
959 Then, these values are used to override the @code{box-padding}
960 properties used by the two @code{\box} commands.  Note the backquote and
961 the comma in the @code{\override} argument: they allow you to introduce
962 a variable value into a literal expression.
963
964 Now, the command can be used in a markup, and the boxes padding be
965 customized:
966
967 @lilypond[quote,verbatim,ragged-right]
968 #(define-markup-command (double-box layout props text) (markup?)
969   #:properties ((inter-box-padding 0.4)
970                 (box-padding 0.6))
971   "Draw a double box around text."
972   (interpret-markup layout props
973     #{\markup \override #`(box-padding . ,inter-box-padding) \box
974               \override #`(box-padding . ,box-padding) \box
975               { #text } #}))
976
977 \markup \double-box A
978 \markup \override #'(inter-box-padding . 0.8) \double-box A
979 \markup \override #'(box-padding . 1.0) \double-box A
980 @end lilypond
981
982 @node Adapting builtin commands
983 @unnumberedsubsubsec Adapting builtin commands
984
985 A good way to start writing a new markup command, is to take example on
986 a builtin one.  Most of the markup commands provided with LilyPond can be
987 found in file @file{scm/define-markup-commands.scm}.
988
989 For instance, we would like to adapt the @code{\draw-line} command, to
990 draw a double line instead.  The @code{\draw-line} command is defined as
991 follow (documentation stripped):
992
993 @lisp
994 (define-markup-command (draw-line layout props dest)
995   (number-pair?)
996   #:category graphic
997   #:properties ((thickness 1))
998   "@dots{}documentation@dots{}"
999   (let ((th (* (ly:output-def-lookup layout 'line-thickness)
1000                thickness))
1001         (x (car dest))
1002         (y (cdr dest)))
1003     (make-line-stencil th 0 0 x y)))
1004 @end lisp
1005
1006 To define a new command based on an existing one, copy the definition,
1007 and change the command name.  The @code{#:category} keyword can be
1008 safely removed, as it is only used for generating LilyPond
1009 documentation, and is of no use for user-defined markup commands.
1010
1011 @lisp
1012 (define-markup-command (draw-double-line layout props dest)
1013   (number-pair?)
1014   #:properties ((thickness 1))
1015   "@dots{}documentation@dots{}"
1016   (let ((th (* (ly:output-def-lookup layout 'line-thickness)
1017                thickness))
1018         (x (car dest))
1019         (y (cdr dest)))
1020     (make-line-stencil th 0 0 x y)))
1021 @end lisp
1022
1023 Then, a property for setting the gap between two lines is added, called
1024 @code{line-gap}, defaulting e.g. to 0.6:
1025
1026 @lisp
1027 (define-markup-command (draw-double-line layout props dest)
1028   (number-pair?)
1029   #:properties ((thickness 1)
1030                 (line-gap 0.6))
1031   "@dots{}documentation@dots{}"
1032   @dots{}
1033 @end lisp
1034
1035 Finally, the code for drawing two lines is added.  Two calls to
1036 @code{make-line-stencil} are used to draw the lines, and the resulting
1037 stencils are combined using @code{ly:stencil-add}:
1038
1039 @lilypond[quote,verbatim,ragged-right]
1040 #(define-markup-command (my-draw-line layout props dest)
1041   (number-pair?)
1042   #:properties ((thickness 1)
1043                 (line-gap 0.6))
1044   "..documentation.."
1045   (let* ((th (* (ly:output-def-lookup layout 'line-thickness)
1046                 thickness))
1047          (dx (car dest))
1048          (dy (cdr dest))
1049          (w (/ line-gap 2.0))
1050          (x (cond ((= dx 0) w)
1051                   ((= dy 0) 0)
1052                   (else (/ w (sqrt (+ 1 (* (/ dx dy) (/ dx dy))))))))
1053          (y (* (if (< (* dx dy) 0) 1 -1)
1054                (cond ((= dy 0) w)
1055                      ((= dx 0) 0)
1056                      (else (/ w (sqrt (+ 1 (* (/ dy dx) (/ dy dx))))))))))
1057      (ly:stencil-add (make-line-stencil th x y (+ dx x) (+ dy y))
1058                      (make-line-stencil th (- x) (- y) (- dx x) (- dy y)))))
1059
1060 \markup \my-draw-line #'(4 . 3)
1061 \markup \override #'(line-gap . 1.2) \my-draw-line #'(4 . 3)
1062 @end lilypond
1063
1064
1065 @node New markup list command definition
1066 @subsection New markup list command definition
1067 @funindex define-markup-list-command
1068 @funindex interpret-markup-list
1069 Markup list commands are defined with the
1070 @code{define-markup-list-command} Scheme macro, which is similar to the
1071 @code{define-markup-command} macro described in
1072 @ref{New markup command definition}, except that where the latter returns
1073 a single stencil, the former returns a list of stencils.
1074
1075 In a similar vein, @code{interpret-markup-list} is used instead of
1076 @code{interpret-markup} for converting a markup list into a list
1077 of stencils.
1078
1079 In the following example, a @code{\paragraph} markup list command is
1080 defined, which returns a list of justified lines, the first one being
1081 indented.  The indent width is taken from the @code{props} argument.
1082
1083 @example
1084 #(define-markup-list-command (paragraph layout props args) (markup-list?)
1085    #:properties ((par-indent 2))
1086    (interpret-markup-list layout props
1087      #@{\markuplist \justified-lines @{ \hspace #par-indent #args @} #@}))
1088 @end example
1089
1090
1091 The version using just Scheme is more complex:
1092 @example
1093 #(define-markup-list-command (paragraph layout props args) (markup-list?)
1094    #:properties ((par-indent 2))
1095    (interpret-markup-list layout props
1096      (make-justified-lines-markup-list (cons (make-hspace-markup par-indent)
1097                                              args))))
1098 @end example
1099
1100 Besides the usual @code{layout} and @code{props} arguments, the
1101 @code{paragraph} markup list command takes a markup list argument, named
1102 @code{args}.  The predicate for markup lists is @code{markup-list?}.
1103
1104 First, the function gets the indent width, a property here named
1105 @code{par-indent}, from the property list @code{props}.  If the
1106 property is not found, the default value is @code{2}.  Then, a
1107 list of justified lines is made using the built-in markup list command
1108 @code{\justified-lines}, which is related to the
1109 @code{make-justified-lines-markup-list} function.  A
1110 horizontal space is added at the beginning using @code{\hspace} (or the
1111 @code{make-hspace-markup} function).  Finally, the markup list is
1112 interpreted using the @code{interpret-markup-list} function.
1113
1114 This new markup list command can be used as follows:
1115 @example
1116 \markuplist @{
1117   \paragraph @{
1118     The art of music typography is called \italic @{(plate) engraving.@}
1119     The term derives from the traditional process of music printing.
1120     Just a few decades ago, sheet music was made by cutting and stamping
1121     the music into a zinc or pewter plate in mirror image.
1122   @}
1123   \override-lines #'(par-indent . 4) \paragraph @{
1124     The plate would be inked, the depressions caused by the cutting
1125     and stamping would hold ink.  An image was formed by pressing paper
1126     to the plate.  The stamping and cutting was completely done by
1127     hand.
1128   @}
1129 @}
1130 @end example
1131
1132 @node Contexts for programmers
1133 @section Contexts for programmers
1134
1135 @menu
1136 * Context evaluation::
1137 * Running a function on all layout objects::
1138 @end menu
1139
1140 @node Context evaluation
1141 @subsection Context evaluation
1142
1143 @cindex calling code during interpreting
1144 @funindex \applyContext
1145
1146 Contexts can be modified during interpretation with Scheme code.  The
1147 syntax for this is
1148 @example
1149 \applyContext @var{function}
1150 @end example
1151
1152 @code{@var{function}} should be a Scheme function that takes a
1153 single argument: the context in which the @code{\applyContext}
1154 command is being called.  The following code will print the
1155 current bar number on the standard output during the compile:
1156
1157 @example
1158 \applyContext
1159   #(lambda (x)
1160     (format #t "\nWe were called in barnumber ~a.\n"
1161      (ly:context-property x 'currentBarNumber)))
1162 @end example
1163
1164
1165
1166 @node Running a function on all layout objects
1167 @subsection Running a function on all layout objects
1168
1169
1170 @cindex calling code on layout objects
1171 @funindex \applyOutput
1172
1173 The most versatile way of tuning an object is @code{\applyOutput} which
1174 works by inserting an event into the specified context
1175 (@rinternals{ApplyOutputEvent}).  Its syntax is
1176 @example
1177 \applyOutput @var{Context} @var{proc}
1178 @end example
1179
1180 @noindent
1181 where @code{@var{proc}} is a Scheme function, taking three arguments.
1182
1183 When interpreted, the function @code{@var{proc}} is called for
1184 every layout object found in the context @code{@var{Context}} at
1185 the current time step, with the following arguments:
1186 @itemize
1187 @item the layout object itself,
1188 @item the context where the layout object was created, and
1189 @item the context where @code{\applyOutput} is processed.
1190 @end itemize
1191
1192
1193 In addition, the cause of the layout object, i.e., the music
1194 expression or object that was responsible for creating it, is in the
1195 object property @code{cause}.  For example, for a note head, this is a
1196 @rinternals{NoteHead} event, and for a stem object,
1197 this is a @rinternals{Stem} object.
1198
1199 Here is a function to use for @code{\applyOutput}; it blanks
1200 note-heads on the center-line and next to it:
1201
1202 @lilypond[quote,verbatim,ragged-right]
1203 #(define (blanker grob grob-origin context)
1204    (if (and (memq 'note-head-interface (ly:grob-interfaces grob))
1205             (< (abs (ly:grob-property grob 'staff-position)) 2))
1206        (set! (ly:grob-property grob 'transparent) #t)))
1207
1208 \relative c' {
1209   a'4 e8 <<\applyOutput #'Voice #blanker a c d>> b2
1210 }
1211 @end lilypond
1212
1213 To have @var{function} interpreted at the @code{Score} or @code{Staff}
1214 level use these forms
1215
1216 @example
1217 \applyOutput #'Score #@var{function}
1218 \applyOutput #'Staff #@var{function}
1219 @end example
1220
1221
1222 @node Callback functions
1223 @section Callback functions
1224
1225 Properties (like @code{thickness}, @code{direction}, etc.) can be
1226 set at fixed values with @code{\override}, e.g.
1227
1228 @example
1229 \override Stem.thickness = #2.0
1230 @end example
1231
1232 Properties can also be set to a Scheme procedure,
1233
1234 @lilypond[fragment,verbatim,quote,relative=2]
1235 \override Stem.thickness = #(lambda (grob)
1236     (if (= UP (ly:grob-property grob 'direction))
1237         2.0
1238         7.0))
1239 c b a g b a g b
1240 @end lilypond
1241
1242 @noindent
1243 In this case, the procedure is executed as soon as the value of the
1244 property is requested during the formatting process.
1245
1246 Most of the typesetting engine is driven by such callbacks.
1247 Properties that typically use callbacks include
1248
1249 @table @code
1250 @item stencil
1251   The printing routine, that constructs a drawing for the symbol
1252 @item X-offset
1253   The routine that sets the horizontal position
1254 @item X-extent
1255   The routine that computes the width of an object
1256 @end table
1257
1258 The procedure always takes a single argument, being the grob.
1259
1260 That procedure may access the usual value of the property, by first
1261 calling the function that is the usual callback for that property, which
1262 can by found in the Internals Reference or the file 'define-grobs.scm':
1263
1264 @example
1265 \relative c'' @{
1266   \override Flag #'X-offset = #(lambda (flag)
1267     (let ((default (ly:flag::calc-x-offset flag)))
1268       (* default 4.0)))
1269   c4. d8 a4. g8
1270 @}
1271 @end example
1272
1273 If routines with multiple arguments must be called, the current grob
1274 can be inserted with a grob closure.  Here is a setting from
1275 @code{AccidentalSuggestion},
1276
1277 @example
1278 `(X-offset .
1279   ,(ly:make-simple-closure
1280     `(,+
1281         ,(ly:make-simple-closure
1282            (list ly:self-alignment-interface::centered-on-x-parent))
1283       ,(ly:make-simple-closure
1284            (list ly:self-alignment-interface::x-aligned-on-self)))))
1285 @end example
1286
1287 @noindent
1288 In this example, both @code{ly:self-alignment-interface::x-aligned-on-self} and
1289 @code{ly:self-alignment-interface::centered-on-x-parent} are called
1290 with the grob as argument.  The results are added with the @code{+}
1291 function.  To ensure that this addition is properly executed, the whole
1292 thing is enclosed in @code{ly:make-simple-closure}.
1293
1294 In fact, using a single procedure as property value is equivalent to
1295
1296 @example
1297 (ly:make-simple-closure (ly:make-simple-closure (list @var{proc})))
1298 @end example
1299
1300 @noindent
1301 The inner @code{ly:make-simple-closure} supplies the grob as argument
1302 to @var{proc}, the outer ensures that result of the function is
1303 returned, rather than the @code{simple-closure} object.
1304
1305 From within a callback, the easiest method for evaluating a markup is
1306 to use grob-interpret-markup.  For example:
1307
1308 @example
1309 my-callback = #(lambda (grob)
1310                  (grob-interpret-markup grob (markup "foo")))
1311 @end example
1312
1313 @node Inline Scheme code
1314 @section Inline Scheme code
1315
1316 TODO: after this section had been written, LilyPond has improved
1317 to the point that finding a @emph{simple} example where one would
1318 @emph{have} to revert to Scheme has become rather hard.
1319
1320 Until this section gets a rewrite, let's pretend we don't know.
1321
1322 The main disadvantage of @code{\tweak} is its syntactical
1323 inflexibility.  For example, the following produces a syntax error
1324 (or rather, it did so at some point in the past).
1325
1326 @example
1327 F = \tweak font-size #-3 -\flageolet
1328
1329 \relative c'' @{
1330   c4^\F c4_\F
1331 @}
1332 @end example
1333
1334 @noindent
1335 Using Scheme, this problem can be avoided.  The route to the
1336 result is given in @ref{Adding articulation to notes (example)},
1337 especially how to use @code{\displayMusic} as a helping guide.
1338
1339 @example
1340 F = #(let ((m (make-music 'ArticulationEvent
1341                           'articulation-type "flageolet")))
1342        (set! (ly:music-property m 'tweaks)
1343              (acons 'font-size -3
1344                     (ly:music-property m 'tweaks)))
1345        m)
1346
1347 \relative c'' @{
1348   c4^\F c4_\F
1349 @}
1350 @end example
1351
1352 @noindent
1353 Here, the @code{tweaks} properties of the flageolet object
1354 @code{m} (created with @code{make-music}) are extracted with
1355 @code{ly:music-property}, a new key-value pair to change the
1356 font size is prepended to the property list with the
1357 @code{acons} Scheme function, and the result is finally
1358 written back with @code{set!}.  The last element of the
1359 @code{let} block is the return value, @code{m} itself.
1360
1361
1362
1363 @node Difficult tweaks
1364 @section Difficult tweaks
1365
1366 There are a few classes of difficult adjustments.
1367
1368 @itemize
1369
1370
1371 @item
1372 One type of difficult adjustment involves the appearance of
1373 spanner objects, such as slurs and ties.  Usually, only one
1374 spanner object is created at a time, and it can be adjusted with
1375 the normal mechanism.  However, occasionally a spanner crosses a
1376 line break.  When this happens, the object is cloned.  A separate
1377 object is created for every system in which the spanner appears.
1378 The new objects are clones of the original object and inherit all
1379 properties, including @code{\override}s.
1380
1381
1382 In other words, an @code{\override} always affects all pieces of a
1383 broken spanner.  To change only one part of a spanner at a line break,
1384 it is necessary to hook into the formatting process.  The
1385 @code{after-line-breaking} callback contains the Scheme procedure that
1386 is called after the line breaks have been determined and layout
1387 objects have been split over different systems.
1388
1389 In the following example, we define a procedure
1390 @code{my-callback}.  This procedure
1391
1392 @itemize
1393 @item
1394 determines if the spanner has been split across line breaks
1395 @item
1396 if yes, retrieves all the split objects
1397 @item
1398 checks if this grob is the last of the split objects
1399 @item
1400 if yes, it sets @code{extra-offset}.
1401 @end itemize
1402
1403 This procedure is installed into @rinternals{Tie}, so the last part
1404 of the broken tie is repositioned.
1405
1406 @lilypond[quote,verbatim,ragged-right]
1407 #(define (my-callback grob)
1408    (let* (
1409           ;; have we been split?
1410           (orig (ly:grob-original grob))
1411
1412           ;; if yes, get the split pieces (our siblings)
1413           (siblings (if (ly:grob? orig)
1414                         (ly:spanner-broken-into orig)
1415                         '())))
1416
1417      (if (and (>= (length siblings) 2)
1418               (eq? (car (last-pair siblings)) grob))
1419          (ly:grob-set-property! grob 'extra-offset '(-2 . 5)))))
1420
1421 \relative c'' {
1422   \override Tie.after-line-breaking =
1423   #my-callback
1424   c1 ~ \break
1425   c2 ~ c
1426 }
1427 @end lilypond
1428
1429 @noindent
1430 When applying this trick, the new @code{after-line-breaking} callback
1431 should also call the old one, if such a default exists.  For example,
1432 if using this with @code{Hairpin}, @code{ly:spanner::kill-zero-spanned-time}
1433 should also be called.
1434
1435
1436 @item
1437 Some objects cannot be changed with @code{\override} for
1438 technical reasons.  Examples of those are @code{NonMusicalPaperColumn}
1439 and @code{PaperColumn}.  They can be changed with the
1440 @code{\overrideProperty} function, which works similar to @code{\once
1441 \override}, but uses a different syntax.
1442
1443 @example
1444 \overrideProperty
1445 Score.NonMusicalPaperColumn       % Grob name
1446   . line-break-system-details     % Property name
1447   . next-padding                  % Optional subproperty name
1448   #20                             % Value
1449 @end example
1450
1451 Note, however, that @code{\override}, applied to
1452 @code{NonMusicalPaperColumn} and @code{PaperColumn}, still works as
1453 expected within @code{\context} blocks.
1454
1455 @end itemize
1456
1457 @node LilyPond Scheme interfaces
1458 @chapter LilyPond Scheme interfaces
1459
1460 This chapter covers the various tools provided by LilyPond to help
1461 Scheme programmers get information into and out of the music streams.
1462
1463 TODO -- figure out what goes in here and how to organize it
1464