lilypond-learning: The once prefix
The ‘\once’ prefix
..................
Both the ‘\override’ and the ‘\set’ commands may be prefixed by ‘\once’.
This causes the following ‘\override’ or ‘\set’ command to be effective
only during the current musical moment before the property reverts back
to its previous value (this can be different from the default if another
‘\override’ is still in effect). Using the same example, we can change
the color of a single note like this:
c4 d
\override NoteHead.color = #red
e4 f |
\once \override NoteHead.color = #green
g4 a
\revert NoteHead.color
b c |
[image src="" alt="[image of music]" text="image of music" ]
The ‘\once’ prefix may also be used in front of many predefined
commands to limit their effect to one musical moment:
c4 d
\once \stemDown
e4 f |
g4 a
\once \hideNotes
b c |
[image src="" alt="[image of music]" text="image of music" ]
However, predefined commands of the form ‘\...Neutral’, ‘\...Off’ and
‘\un...’ use ‘\revert’ internally rather than ‘\override’ so prefixing
these with ‘\once’ has no effect.