X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fsong-util.scm;h=5eec46fdd69a34db7b00ce24f8aac3f6a95f2059;hb=e7638b90e908840010125d0c150db8c18a5016c7;hp=9a65d44c8eea934ca42b0248fc4031aea257110d;hpb=2bf520787e5668f22dcf0d5ab3faf74693376d6a;p=lilypond.git diff --git a/scm/song-util.scm b/scm/song-util.scm index 9a65d44c8e..5eec46fdd6 100644 --- a/scm/song-util.scm +++ b/scm/song-util.scm @@ -159,10 +159,13 @@ If it unsets the property, return @code{#f}." (define-public (music-elements music) "Return list of all @var{music}'s top-level children." (let ((elt (ly:music-property music 'element)) - (elts (ly:music-property music 'elements))) - (if (not (null? elt)) - (cons elt elts) - elts))) + (elts (ly:music-property music 'elements)) + (arts (ly:music-property music 'articulations))) + (if (pair? arts) + (set! elts (append elts arts))) + (if (null? elt) + elts + (cons elt elts)))) (define-public (find-child music predicate) "Find the first node in @var{music} that satisfies @var{predicate}." @@ -182,12 +185,17 @@ If it unsets the property, return @code{#f}." (define-public (process-music music function) "Process all nodes of @var{music} (including @var{music}) in the DFS order. Apply @var{function} on each of the nodes. If @var{function} applied on a -node returns @code{#t}, don't process the node's subtree." +node returns @code{#t}, don't process the node's subtree. + +If a non-boolean is returned, it is considered the material to recurse." (define (process-music queue) (if (not (null? queue)) (let* ((elt (car queue)) (stop (function elt))) - (process-music (if stop - (cdr queue) - (append (music-elements elt) (cdr queue))))))) + (process-music (if (boolean? stop) + (if stop + (cdr queue) + (append (music-elements elt) (cdr queue))) + ((if (cheap-list? stop) append cons) + stop (cdr queue))))))) (process-music (list music)))