Werner LEMBERG wrote:
> Very nice! Perhaps this can be wrapped into an even more convenient
> function so that a user just have to say, for example,
>
> \getAncestry { }
>
> at the place where grobs have to be manipulated.
>
> Definitely very useful stuff!
Werner,
I reformatted the output (slightly) to minimize duplicates. Do you
prefer this version or the earlier one?
- Mark
\version "2.13.2"
#(define (grob-name grob)
(if (ly:grob? grob)
(assoc-ref (ly:grob-property grob 'meta) 'name)
#f))
#(define (get-ancestry grob)
(if (not (null? (ly:grob-parent grob X)))
(list (grob-name grob)
(get-ancestry (ly:grob-parent grob X))
(get-ancestry (ly:grob-parent grob Y)))
(grob-name grob)))
#(define (format-ancestry lst generation)
(string-append
(symbol->string (car lst))
"\n"
(let ((X-ancestry
(if (list? (cadr lst))
(format-ancestry (cadr lst) (1+ generation))
(symbol->string (cadr lst))))
(Y-ancestry
(if (list? (caddr lst))
(format-ancestry (caddr lst) (1+ generation))
(symbol->string (caddr lst)))))
(if (equal? X-ancestry Y-ancestry)
(string-append
(make-string (* generation 3) #\space)
"X/Y: "
(if (list? (cadr lst))
(format-ancestry (cadr lst) (+ generation 2))
(symbol->string (cadr lst)))
"\n")
(string-append
(make-string (* generation 3) #\space)
"X: " X-ancestry "\n"
(make-string (* generation 3) #\space)
"Y: " Y-ancestry "\n")))))
#(define (display-ancestry grob)
(display
(string-append
(make-string 36 #\-)
"\n"
(format-ancestry (get-ancestry grob) 0))))
\relative {
%\once \override NoteHead #'before-line-breaking = #display-ancestry
f
%\once \override Accidental #'before-line-breaking = #display-ancestry
\once \override Arpeggio #'before-line-breaking = #display-ancestry
<f as c>\arpeggio
}
_______________________________________________
lilypond-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/lilypond-devel