[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Any disadvantage to #'tag ?
From: |
Nicolas Sceaux |
Subject: |
Re: Any disadvantage to #'tag ? |
Date: |
Thu, 06 Jan 2005 22:29:26 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) |
Graham Percival <address@hidden> writes:
> At the beginning of your violin part, do
> \tag #'(violin score)
>
> In your printing section, use
> \keepWithTag #'violin
> or
> \keepWithTag #'score
> depending on what you want.
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)
If one thinks that this is useful, I'll change the definition in
ly/music-functions-init.ly
#(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