"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
;; 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)
"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