On 5/26/09 4:03 PM, "Trevor Bača" <trevorb...@gmail.com> wrote:
<Snip some good comments about this code>

> %%% BEGIN #3 PROPORTIONAL SPACING WITHOUT STRICT NOTE SPACING AND WITH  EOL
> ADJUSTMENT %%%
> 
> adjustEOLMeterBarlineExtraOffset = #(define-music-function (parser location)
> ()
>    #{
>       #(define (foo grob)
>          (if (<= (ly:item-break-dir grob) 0)
>             (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
>       #(define (bar grob)
>          (if (<= (ly:item-break-dir grob) 0)
>             (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
>       \once \override Score.TimeSignature #'after-line-breaking = #foo
>       \once \override Staff.BarLine #'after-line-breaking = #bar
>    #})

As a stylistic matter, I don't like this definition , because foo and bar
are redefined globally every time adjustEOLMeterBarlineExtraOffset is
called.

I prefer to have foo and bar defined locally:

adjustEOLMeterBarlineExtraOffset =
#(define-music-function (parser location) ()
   (define (foo grob)
     (if (<= (ly:item-break-dir grob) 0)
     (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
   (define (bar grob)
     (if (<= (ly:item-break-dir grob) 0)
     (ly:grob-set-property! grob 'extra-offset (cons 2.8 0)) '() ))
#{
   \once \override Score.TimeSignature #'after-line-breaking = $foo
   \once \override Staff.BarLine #'after-line-breaking = $bar
#})

Note that in this implementation, we use $foo and $bar inside the #{ #}
construct to refer to a local scheme variable.

Furthermore, it seems to me that writing a function like this that has
embedded constants is less than desirable, because if some different offset
were desired, a new function would need to be written.  I think it would be
better to have

adjustEOLMeterBarlineExtraOffset =
#(define-music-function (parser location offset) (pair?)
   (define (foo grob)
     (if (<= (ly:item-break-dir grob) 0)
     (ly:grob-set-property! grob 'extra-offset offset) '() ))
   (define (bar grob)
     (if (<= (ly:item-break-dir grob) 0)
     (ly:grob-set-property! grob 'extra-offset offset) '() ))
#{
   \once \override Score.TimeSignature #'after-line-breaking = $foo
   \once \override Staff.BarLine #'after-line-breaking = $bar
#})

and call it with

\adjustEOLMeterBarlineExtraOffset #'(2.8 . 0)

HTH,

Carl



_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
http://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to