Separating key cancellations from key signature changes

By default, the accidentals used for key cancellations are placed adjacent to those for key signature changes. This behavior can be changed by overriding the break-align-orders property of the BreakAlignment grob.

If you look up the definition of the break-alignment-interface in LilyPond’s Internals Reference, you get the following list of available break-align symbols:

ambitus
breathing-sign
clef
cue-clef
cue-end-clef
custos
key-cancellation
key-signature
left-edge
signum-repetitionis
staff-bar
staff-ellipsis
time-signature

From this list, we find that we want to move key-cancellation so that it comes before staff-bar. This is accomplished with the \breakAlignInsert function.

music = { \key es \major d'1 \bar "||"
          \key a \major d'1 }

{ <>^\markup "default"
  \music }

{ <>^\markup "cancellation first"
  \breakAlignInsert key-cancellation before staff-bar
  \music }
[image of music]

Frammenti LilyPond v2.25.35 (development-branch).