* Building complicated functions::
* Markup programmer interface::
* Contexts for programmers::
+* Scheme procedures as properties::
@end menu
@menu
* Overview of music functions::
* Simple substitution functions::
-* Paired substition functions::
+* Paired substitution functions::
* Mathematics in functions::
* Void functions::
@end menu
@node Overview of music functions
@subsection Overview of music functions
-Making a funcion which substitutes a variable into LilyPond
+Making a function which substitutes a variable into LilyPond
code is easy. The general form of these functions is
@example
@end lilypond
-@node Paired substition functions
-@subsection Paired substition functions
+@node Paired substitution functions
+@subsection Paired substitution functions
Some @code{\override} commands require a pair of numbers
(called a @code{cons cell} in Scheme). To pass these numbers
@end example
Scheme code is evaluated as soon as the parser encounters it. To
-define some scheme code in a macro (to be called later), use
+define some Scheme code in a macro (to be called later), use
@ref{Void functions} or
@example
interfaces, for example, a note is an @code{event}, but it is also a
@code{note-event}, a @code{rhythmic-event}, and a
@code{melodic-event}. All classes of music are listed in the
-Profram reference, under
+Program reference, under
@internalsref{Music classes}.
@item
@subsection Displaying music expressions
@cindex internal storage
-@findex \displayMusic
-@findex \displayLilyMusic
+@funindex \displayMusic
+@funindex \displayLilyMusic
When writing a music function it is often instructive to inspect how
a music expression is stored internally. This can be done with the
@end example
The @code{display-scheme-music} function is the function used by
-@code{\displayMusic} to display the scheme representation of a music
+@code{\displayMusic} to display the Scheme representation of a music
expression.
@example
(ly:make-pitch 0 0 0))
@end example
-Then the note pitch is accessed thourgh the @code{'pitch} property
+Then the note pitch is accessed through the @code{'pitch} property
of the @code{NoteEvent} object,
@example
used elsewhere.
Now we have a @code{result-event-chord}, which is a
-@code{oteEventChord} expression and is a copy of @code{event-chord}. We
+@code{NoteEventChord} expression and is a copy of @code{event-chord}. We
add the marcato to its elements list property.
@example
@end multitable
@end quotation
-The whole scheme language is accessible inside the
+The whole Scheme language is accessible inside the
@code{markup} macro. For example, You may use function calls inside
@code{markup} in order to manipulate character strings. This is
useful when defining new markup commands (see
@subsection New markup command definition
New markup commands can be defined
-with the @code{define-markup-command} scheme macro.
+with the @code{define-markup-command} Scheme macro.
@lisp
(define-markup-command (@var{command-name} @var{layout} @var{props} @var{arg1} @var{arg2} ...)
@subsection Context evaluation
@cindex calling code during interpreting
-@findex \applyContext
+@funindex \applyContext
Contexts can be modified during interpretation with Scheme code. The
syntax for this is
@cindex calling code on layout objects
-@findex \applyOutput
+@funindex \applyOutput
The most versatile way of tuning an object is @code{\applyOutput}. Its
(set! (ly:grob-property grob 'transparent) #t)))
@end example
+
+@node Scheme procedures as properties
+@section Scheme procedures as properties
+
+Properties (like thickness, direction, etc.) can be set at fixed values
+with \override, e.g.
+
+@example
+\override Stem #'thickness = #2.0
+@end example
+
+Properties can also be set to a Scheme procedure,
+
+@lilypond[fragment,verbatim,quote,relative=2]
+\override Stem #'thickness = #(lambda (grob)
+ (if (= UP (ly:grob-property grob 'direction))
+ 2.0
+ 7.0))
+c b a g b a g b
+@end lilypond
+
+Procedures may also be combined like that with
+"grob closure". Here is a setting from
+@code{AccidentalSuggestion},
+
+@example
+(X-offset .
+ ,(ly:make-simple-closure
+ `(,+
+ ,(ly:make-simple-closure
+ (list ly:self-alignment-interface::centered-on-x-parent))
+ ,(ly:make-simple-closure
+ (list ly:self-alignment-interface::x-aligned-on-self)))))
+@end example
+
+