On 6-Jan-05, at 1:29 PM, Nicolas Sceaux wrote:
Speaking of \keepWithTag, I usually use a custom version of it,
that let me write:

  \keepWithTag #'tag1 music

or

  \keepWithTag #'(tag1 tag2 ...) music

or

  \keepWithTag #'() music

(the last one being the same as \removeWithTag)

So your version adds the possibility of a list of tags to use? That could be useful -- especially if some people (like me) start using #'tag for complete instrument parts.

If one thinks that this is useful, I'll change the definition in
ly/music-functions-init.ly

Sounds good to me!

Cheers,
- Graham

#(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))))

keepWithTag = #(def-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))


nicolas




_______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to