lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Any disadvantage to #'tag ?


From: Graham Percival
Subject: Re: Any disadvantage to #'tag ?
Date: Sun, 16 Jan 2005 20:10:51 -0800


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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]