X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=scm%2Fmusic-functions.scm;h=304becef0331f593e305add09ae891e1d44ef140;hb=79ec8cdb524e8f2965425a47156763e13326c649;hp=a952a8284649d78dfa71e19522111d55e2139b51;hpb=2ca356d824f37951de81d60f76eaaaefda436cff;p=lilypond.git diff --git a/scm/music-functions.scm b/scm/music-functions.scm index a952a82846..304becef03 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -35,6 +35,14 @@ "Does @code{mus} belong to the music class @code{type}?" (memq type (ly:music-property mus 'types))) +(define-safe-public (music-type-predicate types) + "Returns a predicate function that can be used for checking +music to have one of the types listed in @var{types}." + (if (cheap-list? types) + (lambda (m) + (any (lambda (t) (music-is-of-type? m t)) types)) + (lambda (m) (music-is-of-type? m types)))) + ;; TODO move this (define-public ly:grob-property (make-procedure-with-setter ly:grob-property @@ -739,9 +747,7 @@ duration is replaced with the specified @var{duration}." ;; articulations on individual events since they can't actually get ;; into a repeat chord given its input syntax. - (define (keep-element? m) - (any (lambda (t) (music-is-of-type? m t)) - event-types)) + (define keep-element? (music-type-predicate event-types)) (for-each (lambda (field) @@ -1998,12 +2004,7 @@ not recursing into matches themselves." "Return a flat list of all music with @var{type} (either a single type symbol or a list of alternatives) inside of @var{music}, not recursing into matches themselves." - (extract-music - music - (if (cheap-list? type) - (lambda (m) - (any (lambda (t) (music-is-of-type? m t)) type)) - (lambda (m) (music-is-of-type? m type))))) + (extract-music music (music-type-predicate type))) (define*-public (event-chord-wrap! music) "Wrap isolated rhythmic events and non-postevent events in