2.8 Inline Scheme code

TODO: the example for this section is ill-chosen since

F = -\tweak #'font-size #-3 -\flageolet

(note the ‘-’ marking it as a post event) will actually work fine for the stated purpose. Until this section gets a rewrite, let’s pretend we don’t know.

The main disadvantage of \tweak is its syntactical inflexibility. For example, the following produces a syntax error.

F = \tweak #'font-size #-3 -\flageolet

\relative c'' {
  c4^\F c4_\F
}

Using Scheme, this problem can be avoided. The route to the result is given in Adding articulation to notes (example), especially how to use \displayMusic as a helping guide.

F = #(let ((m (make-music 'ArticulationEvent
                          'articulation-type "flageolet")))
       (set! (ly:music-property m 'tweaks)
             (acons 'font-size -3
                    (ly:music-property m 'tweaks)))
       m)

\relative c'' {
  c4^\F c4_\F
}

Here, the tweaks properties of the flageolet object m (created with make-music) are extracted with ly:music-property, a new key-value pair to change the font size is prepended to the property list with the acons Scheme function, and the result is finally written back with set!. The last element of the let block is the return value, m itself.


Other languages: deutsch, español, français.
About automatic language selection.

LilyPond — Extending