Set up label in add-toc-item!

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Set up label in add-toc-item!

Robert Kubosz-2

I have a question that bothers me. Can I put a label in a markup
function/add-toc-item! ? I'll explain:
I have scores, that obviously use a \header {} block. I use a custom
scoreTitleMarkup, that obviously manages each piece's title markup and
also calls add-toc-item! that puts an item in toc-items list. I want the
add-toc-item! to put the piece label also to the 'label-page-table, so
there would be no need for an extra toplevel "\label 'someSymbol" command.

Below is a snippet that compiles, but it clearly does not work as I want
it to do. I would be very grateful if somebody would help me with this
or give proper guidance where to find a solution.

\version "2.19.83"

#(let ((toc-item-list (list)))
      (set! add-toc-item!
            (lambda (label markup-symbol text . rest)
                (set! toc-item-list
                      (cons (append! (list label markup-symbol text) rest)
             (make-music 'EventChord
                'page-marker #t
                'page-label label
                'elements (list (make-music 'LabelEvent
                                            'page-label label)))))
      (set! toc-items (lambda ()

                          (reverse toc-item-list))))

#(define-markup-command (mymarkupfunction layout props) ()

      (let ((title (chain-assoc-get 'header:piece props))
            ;; (label (gensym "piece"))
            (label 'piece1 ))
          (display (toc-items))
          (display "<-should be empty \n")
          (add-toc-item! label 'tocPieceMarkup title "123") ;;"123" is a
piece number, take it here as placeholder
          (display (toc-items))
          (display "<-one toc item \n")
          (let ((table (ly:output-def-lookup layout 'label-page-table)))
              (display table)
              (display "<-here should be at least one item, but isn't!\n"))
          (interpret-markup layout props (markup title))))

\paper {
     scoreTitleMarkup = \markup \mymarkupfunction

\score {
     \header {
         piece = "foo"
     {c' c' c' c'}

\markup { There should be a working page reference \page-ref #'piece1
"0" "?" }