"Panteck" <[EMAIL PROTECTED]> writes: > I've got three sets of tags ( letter/a4/bigprint, part/score, and > original/edit ). What I want to do is something like \keepWithTag > #'letter #'part #'edit, but \keepWithTag doesn't take multiple values, > and \keepWithTag #'value1{ \keepWithTag #'value2 } doesn't work, > because the inner \keep strips out all the other tags. > > Has anyone else ever attempted to do something like this? Is there a > better way of doing what I'm after? > > Thanks!
I use the following (maybe there's something already available in LilyPond that I've missed): #(use-modules (srfi srfi-1)) #(define* (has-some-member? list1 list2 #:key (test eqv?)) "Return a true value iif there exists an element of list1 that also belongs to list2 under test." (if (null? list1) #f (or (member (car list1) list2 test) (has-some-member? (cdr list1) list2 #:test test)))) #(define (symbol-or-symbols? x) (or (null? x) (symbol? x) (and (list? x) (every symbol? x)))) keepWithTags = #(define-music-function (parser location tags music) (symbol-or-symbols? ly:music?) (music-filter (lambda (m) (let ((m.tags (ly:music-property m 'tags))) (cond ((symbol? tags) (or (null? m.tags) (memq tags m.tags))) ((null? tags) (null? m.tags)) ((list? tags) (or (null? m.tags) (has-some-member? tags m.tags))) (else #t)))) music)) \keepWithTags #'foo \music --> same as \keepWithTag #'foo \music \keepWithTags #'(foo baz) \music --> keep elements tagged with foo or baz, and elements not tagged \keepWithTags #'() \music --> keep elements not tagged. nicolas _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user