diff options
author | David Kastrup <dak@gnu.org> | 2016-09-15 14:50:14 +0200 |
---|---|---|
committer | David Kastrup <dak@gnu.org> | 2016-09-28 09:28:14 +0200 |
commit | 8a493b7bc9aa4d34cd2970fc2223ec6920f0ed02 (patch) | |
tree | efb8fc4953daccc515b4803270fdd44b3cf45528 | |
parent | 36e230cf09bf2755528d2252ee256f88f330e66d (diff) |
Issue 4972: Make music-filter more conservative
Deleting music when its 'elements field becomes null? led
to repeat chords disappearing when articulations were
removed.
-rw-r--r-- | scm/music-functions.scm | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/scm/music-functions.scm b/scm/music-functions.scm index 9c36ceaf4d..e7728ec889 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -82,31 +82,33 @@ First it recurses over the children, then the function is applied to (define-public (music-filter pred? music) "Filter out music expressions that do not satisfy @var{pred?}." - (define (inner-music-filter pred? music) + (define (inner-music-filter music) "Recursive function." (let* ((es (ly:music-property music 'elements)) (e (ly:music-property music 'element)) (as (ly:music-property music 'articulations)) - (filtered-as (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) as))) + (filtered-as (filter ly:music? (map inner-music-filter as))) (filtered-e (if (ly:music? e) - (inner-music-filter pred? e) + (inner-music-filter e) e)) - (filtered-es (filter ly:music? (map (lambda (y) (inner-music-filter pred? y)) es)))) + (filtered-es (filter ly:music? (map inner-music-filter es)))) (if (not (null? e)) (set! (ly:music-property music 'element) filtered-e)) (if (not (null? es)) (set! (ly:music-property music 'elements) filtered-es)) (if (not (null? as)) (set! (ly:music-property music 'articulations) filtered-as)) - ;; if filtering emptied the expression, we remove it completely. + ;; if filtering invalidated 'element, we remove the music unless + ;; there are remaining 'elements in which case we just hope and + ;; pray. (if (or (not (pred? music)) - (and (eq? filtered-es '()) (not (ly:music? e)) - (or (not (eq? es '())) - (ly:music? e)))) + (and (null? filtered-es) + (not (ly:music? filtered-e)) + (ly:music? e))) (set! music '())) music)) - (set! music (inner-music-filter pred? music)) + (set! music (inner-music-filter music)) (if (ly:music? music) music (make-music 'Music))) ;must return music. |