Separating key cancellations from key signature changes: Difference between revisions

mNo edit summary
mNo edit summary
 
Line 3: Line 3:
The value of <code>break-align-orders</code> is a vector of length&nbsp;3, with quoted lists of breakable items as elements. Each list describes the default order of prefatory matter at the end, in the middle, and at the beginning of a line, respectively. We are only interested in changing the behaviour in the middle of a line.
The value of <code>break-align-orders</code> is a vector of length&nbsp;3, with quoted lists of breakable items as elements. Each list describes the default order of prefatory matter at the end, in the middle, and at the beginning of a line, respectively. We are only interested in changing the behaviour in the middle of a line.


If you look up the definition of <code>break-align-orders</code> in LilyPond's [https://lilypond.org/doc/v2.24/Documentation/internals/breakalignment Internals Reference], you get the following order in the second element:
If you look up the definition of <code>break-align-orders</code> in LilyPond's [{{LILYSTABLEDOC}}/internals/breakalignment Internals Reference], you get the following order in the second element:


<pre>...
...
staff-bar
staff-bar
key-cancellation
key-cancellation
key-signature
key-signature
...</pre>
...


We want to change that, moving <code>key-cancellation</code> before <code>staff-bar</code>. To make this happen we use the <code>grob-transformer</code> function, which gives us access to the original vector as the second argument of the lambda function, here called <var>orig</var> (we don't need the first argument, <var>grob</var>). We return a new vector, with unchanged first and last elements. For the middle element, we first remove <code>key-cancellation</code> from the list, then adding it again before <code>staff-bar</code>.
We want to change that, moving <code>key-cancellation</code> before <code>staff-bar</code>. To make this happen we use the <code>grob-transformer</code> function, which gives us access to the original vector as the second argument of the lambda function, here called <var>orig</var> (we don't need the first argument, <var>grob</var>). We return a new vector, with unchanged first and last elements. For the middle element, we first remove <code>key-cancellation</code> from the list, then adding it again before <code>staff-bar</code>.