Hi,

On Fri, May 18, 2012 at 3:40 PM, Kieren MacMillan <
[email protected]> wrote:

> p.s.
>
> Come to think of it, wouldn't this be a good place for a Scheme engraver
> [written by someone who, unlike me, knows Scheme well]? To wit, if the
> measures in a piece aren't all 4/4, then our suggestion(s) won't work; and
> every time the total number of measures changes you need to update; etc.
>
> Couldn't there just be an engraver that says, “If I'm the k-th barline
> since the last system break, then break, otherwise noBreak”, that could be
> \consists-ed into the \Score?
>

I can't believe that this works :) !!

\version "2.15.38"

#(define bars-per-line 4)

#(define line-break-every-nth-engraver
  (lambda (context)
     (make-engraver
       (acknowledgers ((paper-column-interface engraver grob
source-engraver)
 (let ((current-bar (ly:context-property context 'currentBarNumber)))
   (if (= (remainder current-bar bars-per-line) 1)
       (if (eq? #t (ly:grob-property grob 'non-musical))
   (set! (ly:grob-property grob 'line-break-permission) 'force)
   (set! (ly:grob-property grob 'line-break-permission) '())))))))))

\relative c' {
  \repeat unfold 10 {
    \time 2/4
    c4 c
    \time 4/4
    c c c c
    \time 3/4
    c c c
    \time 1/4
    c
    \time 5/4
    c c c c c
    \time 7/4
    c c c c c c c
    \time 2/4
    c c
    \time 7/8
    c8 c c c c c c
    \time 2/2
    c2 c
  }
}

\layout {
  \context {
    \Score
    %% the following line necessary if you want to put more
    %% measures to a line than Lily wants to allow
    \override NonMusicalPaperColumn #'line-break-permission = ##f
    \consists #line-break-every-nth-engraver
  }
}
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to