lilypond-user
[Top][All Lists]
Advanced

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

Re: How to get \fromproperty to work with score headers?


From: Thomas Morley
Subject: Re: How to get \fromproperty to work with score headers?
Date: Mon, 30 Oct 2017 10:11:56 +0100

2017-10-29 11:21 GMT+01:00 Shevek <address@hidden>:
> Does anyone know if there's an updated version of
> http://lsr.di.unimi.it/LSR/Snippet?id=467 to work with score-level headers?
> It's listed as "to do" in the snippet, but I believe that dates back to
> several years ago. I'd like to use \fromproperty #'header:piece to put
> movement titles at the top of pages.
>
> If there isn't a newer version that supports this, I can mess around with
> trying to get it working, but I'd appreciated it if anyone can point me in
> the right direction to start; what would score-level headers be called? is
> the existing snippet structure adequate or is more complexity needed to cope
> with bookparts consisting of multiple scores?


You could do something at the lines of below, I doubt you'll be very
happy with it, though.

\version "2.19.65"

scI =
\score {
  { r2 }
  \header {
    piece = "PIECE-I"
    %% needed to distinguish from "piece"-settings in other scores
    pieceI = "PIECE-I"
  }
}

scII =
\score {
  { r2 }
  \header {
      piece = "PIECE-II"
    pieceII = "PIECE-II"
  }
}

scI-header = #(ly:score-header scI)
scII-header = #(ly:score-header scII)

#(define-markup-command (markupWithHeader layout props markup) (markup?)
   "Interpret the given markup with the header fields added to the props.
This way, one can re-use the same functions (using fromproperty
#'header:field) in the header block and as top-level markup."
   (let* (
     ;; TODO: If we are inside a score, add the score's local header block, too!
     ;; Currently, I only use the global header block, stored in $defaultheader
     ;; Make this list an argument of the markup-command?
     (scopes
       (list
         $defaultheader
         scI-header
         scII-header
         ))
     (alists (map ly:module->alist scopes))
     (prefixed-alist
      (map (lambda (alist)
         (map (lambda (entry)
            (cons
             (string->symbol (string-append "header:"
                            (symbol->string
                             (car entry))))
             (cdr entry)))
              alist))
       alists))
     (props (append prefixed-alist
            props
            (layout-extract-page-properties layout))))
     (interpret-markup layout props markup)))

\markup
  \markupWithHeader {
    \wordwrap {
        Pieces below are named \fromproperty #'header:pieceI and
        \fromproperty #'header:pieceII . %% Can't avoid space before dot easily
    }
  }

\scI
\scII


Cheers,
  Harm



reply via email to

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