lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scheme function that conditionally sets several variables in \paper?


From: Paul Morris
Subject: Re: scheme function that conditionally sets several variables in \paper?
Date: Sun, 16 Nov 2014 08:31:39 -0700 (MST)

Thomas Morley-2 wrote
> Hi Paul,
> 
> maybe something at the lines of:
> 
> my-paper-settings =
>  #'((system-system-spacing . (padding . 10))
>     ;(score-system-spacing . (padding . 0))
>     ;(markup-system-spacing . (padding . 0))
>     ;(score-markup-spacing . (padding . 0))
>     ;(markup-markup-spacing . (padding . 0))
>     (top-system-spacing . (padding . 10))
>     ;(top-markup-spacing . (padding . 0))
>     (ragged-last-bottom . #f)
>     (last-bottom-spacing . (padding . 10))
>     )
> 
> foo =
> #(define-scheme-function (parser location lst)(list?)
>   (let* ((paper (ly:parser-lookup parser '$defaultpaper)))
>     (for-each
>       (lambda (x)
>         (ly:output-def-set-variable!
>           paper
>           (car x)
>           (if (pair? (cdr x))
>               (list (cdr x))
>               (cdr x))))
>       lst)))
> 
> \foo \my-paper-settings
> 
> % EXAMPLE MUSIC
> global = { \key c \major \time 4/4 }
> somenotes = \repeat unfold 48 { c8[ c] }
> chordNames = \chordmode { \global \repeat unfold 12 { c1:m } }
> melody = \relative c'' { \global \somenotes }
> verse = \lyricmode { \repeat unfold 48 { la la } }
> right = \relative c'' { \global \somenotes }
> left = \relative c' { \global \somenotes }
> \score {
>   <<
>     <<
>       \new ChordNames \chordNames
>       \new Staff { \melody }
>       \addlyrics { \verse }
>     >>
>     \new PianoStaff <<
>       \new Staff = "right" { \right }
>       \new Staff = "left" { \clef bass \left }
>     >>
>   >>
>   \layout { }
> }

Thanks Harm!

Looks like this will do the trick. I had looked at the various
ly:output-def... functions, but I was not sure how to get the output
definition (i.e. paper or layout).  So it's good you know how to do that.  

For future reference, how did you figure out how to do this:  

  (ly:parser-lookup parser '$defaultpaper)

Did you look at the source code, or somewhere in the documentation, or the
LSR?  I didn't find anything on these output definitions in the internals
reference.  It looks like the following will work for layout:

  (ly:parser-lookup parser '$defaultlayout)

Thanks again!
-Paul



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/scheme-function-that-conditionally-sets-several-variables-in-paper-tp168580p168743.html
Sent from the User mailing list archive at Nabble.com.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]