\version "2.19.82" \language "english" remove-if-sibling = #(define-scheme-function (offsets) (list?) (lambda (grob) (let* ( ;; The parent of a VerticalAxisGroup is a VerticalAlignment (parent (ly:grob-parent grob 1)) ;; Get the children VerticalAxisGroups of the parent (siblings (ly:grob-object parent 'elements)) (siblings-list (if (ly:grob-array? siblings) (ly:grob-array->list siblings) '())) ;; Find the siblings above or below me by offsets (my-vindex (ly:grob-get-vertical-axis-group-index grob)) (enemy-indices (map (lambda (offset) (+ offset my-vindex)) offsets)) (enemy-vaxis? (lambda (v) (member (ly:grob-get-vertical-axis-group-index v) enemy-indices))) (enemy-vaxes (filter enemy-vaxis? siblings-list)) ) ;; Suicide if an enemy sibling is alive (map (lambda (enemy-vaxis) (ly:pointer-group-interface::add-grob grob 'make-dead-when enemy-vaxis)) enemy-vaxes) ) ) ) global = { s1 \break s1*3 \break s1 \bar "||" } flute = { \clef treble \set Voice.midiInstrument = "flute" R1*3 | % Notice that without the hairpin, the Ob. 2 staff doesn't disappear c''1\< | c''1 <>\! | } oboeI = { \clef treble \set Voice.midiInstrument = "oboe" \context Staff = "Ob1" { \unset Staff.keepAliveInterfaces } R1 | c''1 | R1 | \context Staff = "Ob1" { \set Staff.keepAliveInterfaces = #'() } R1*2 | } oboeII = { \clef treble \set Voice.midiInstrument = "oboe" R1*2 | c'1 | R1*2 | } \score { << \new Staff = "Fl1" \with { instrumentName = "Flute" shortInstrumentName = "Fl." } << \global \flute >> \new StaffGroup \with { instrumentName = "Oboe" shortInstrumentName = "Ob." systemStartDelimiter = #'SystemStartSquare \override SystemStartSquare.collapse-height = #5 } << \new Staff = "Ob1+2" \with { instrumentName = \markup\right-column {"1" "2"} shortInstrumentName = \markup\right-column {"1" "2"} \override VerticalAxisGroup.before-line-breaking = \remove-if-sibling #'(1) } { <> << \global \partcombine \oboeI \oboeII >> } \new Staff = "Ob1" \with { instrumentName = "1" shortInstrumentName = "1" \override VerticalAxisGroup.remove-empty = ##t \override VerticalAxisGroup.remove-first = ##t } << \global \oboeI >> \new Staff = "Ob2" \with { instrumentName = "2" shortInstrumentName = "2" \override VerticalAxisGroup.before-line-breaking = \remove-if-sibling #'(-2) } << \global \oboeII >> >> >> \layout { \context { \Score \override InstrumentName.self-alignment-X = #1 \override InstrumentName.padding = #3 } \context { \Staff \override InstrumentName.padding = 0.3 } } }