lilypond-user
[Top][All Lists]
Advanced

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

Re: v2.15.24: void-, scheme- or music-function in toc-section?


From: Jan-Peter Voigt
Subject: Re: v2.15.24: void-, scheme- or music-function in toc-section?
Date: Mon, 16 Jan 2012 09:37:23 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.24) Gecko/20111108 Lightning/1.0b2 Thunderbird/3.1.16

Hi Thomas,

the problem with summarizing this functionality is, that you get 'SequentialMusic or 'SimultaneousMusic in your first approach and lilypond creates a score context for that.
The second approach fails, because only the last (make-music 'EventChord ... 'LabelEvent ...) is returned as you already saw.
So You might change your add-<something>item! functions to take a predefined label and then return one 'EventChord-'LabelEvent with that label:

--snip--
% add optional label parm
#(define-public (add-index-item! markup-symbol text . lab) #f)
#(define-public (index-items) #f)

#(let ((index-item-list (list)))
     (set! add-index-item!
       (lambda (markup-symbol text . lab)
                            ;; use optional label or generate it if not given
               (let ((label (if (> (length lab) 0) (car lab) (gensym "index"))))
                    (set! index-item-list
                      ;; We insert index items sorted from the beginning on and do
                      ;; not sort them later - this saves pretty much computing time
                      (delete-eq-cdr (insert-alphabetical-sorted! (list label markup-symbol text)
                          index-item-list)))
                    (make-music 'EventChord
                      'page-marker #t
                      'page-label label
                      'elements (list (make-music 'LabelEvent
                              'page-label label))))))
     (set! index-items (lambda ()
               index-item-list)))
--snip--

than you can combine the add-functions and return that one label:

--snip--
indexItems =
#(define-music-function (parser location text) (markup?)
  (let* ((text-rev (if (string? text)
                       text
                       (markup->string text)))
        
         (args (string-split text-rev #\#))
         (initial (string-upcase (substring (car args) 0 1)))
         (label (gensym "index-item")))
        ;; add label to all index-lists with predefined label
        (add-abctoc-item! 'abcTocItemMarkup text-rev label)
        (add-index-item! 'indexItemMarkup text-rev label)
        (add-index-item! 'indexSectionMarkup initial label)
        (add-customtoc-item! 'customTocItemMarkup text-rev label)
        ;; return labeled EventChord
        (make-music
          'EventChord
          'elements (list (make-music 'LabelEvent 'page-label label))
          'page-label label
          'page-marker #t)
))
--snip--

I attached a file with these little changes.

HTH
Cheers, Jan-Peter


Am 16.01.2012 00:17, schrieb Thomas Morley:
Hi,

I've tried to retrieve different table-of-content-sections (a normal
one, an alphabetical sorted and an alphabetical sorted index, showing
initial letters) all with three columns: piece, composer and page,
defining several new "toc-items": abcTocItem, indexItem, indexSection
and customTocItem etc.
So far it works fine.

But it's a lot of typing in the file. And because nearly all Items are
using equal arguments I tried to create a summarizing function:

\version "2.15.24"

% full code -> attached file

indexItems =
#(define-music-function (parser location text) (markup?)
(let* ((text-rev (if (string? text)
                         text
                         (markup->string text)))

      (args (string-split text-rev #\#))
      (initial (string-upcase (substring (car args) 0 1))))
#{
       \abcTocItem $text-rev
       \indexItem $text-rev
       \indexSection $initial
       \customTocItem $text-rev
#}))

But now the page-numbers aren't printed and the link doesn't work!
And a log-warning: no music found in score


Also, I tried:

indexItems =
#(define-music-function (parser location text) (markup?)
(let* ((text-rev (if (string? text)
                         text
                         (markup->string text)))

      (args (string-split text-rev #\#))
      (initial (string-upcase (substring (car args) 0 1))))
 (begin
  (add-abctoc-item! 'abcTocItemMarkup text-rev)
  (add-index-item! 'indexItemMarkup text-rev)
  (add-index-item! 'indexSectionMarkup initial)
  (add-customtoc-item! 'customTocItemMarkup text-rev)
  )))

No warning, but only the last setting (add-customtoc-item!
'customTocItemMarkup text-rev) works.

define-void-function or define-scheme-function seems not to work, too.

Any hint?

Cheers,
 Harm

_______________________________________________ lilypond-user mailing list address@hidden https://lists.gnu.org/mailman/listinfo/lilypond-user

Attachment: alphabetical-index-06.ly
Description: Text Data


reply via email to

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