Reviewers: ,
Message:
This patch allows \tweak to be displayed properly when using
\displayLilyMusic.
* scm/display-lily.scm (music->lily-string):
process 'tweaks via new function music->lily-string
This should read
process 'tweaks via new function tweaks->lily-string
Description:
Add display method for \tweak.
* input/regression/display-lily-tests.ly:
add tests for \tweak
* scm/define-music-display-methods.scm
(scheme-expr->lily-string): don't funnel booleans through pretty-print
(EventChord): treat simple_element with 'tweaks list as
note_chord_element
to preserve < > around tweaked note
* scm/display-lily.scm (music->lily-string):
process 'tweaks via new function music->lily-string
Please review this at http://codereview.appspot.com/4645077/
Affected files:
M input/regression/display-lily-tests.ly
M scm/define-music-display-methods.scm
M scm/display-lily.scm
Index: input/regression/display-lily-tests.ly
diff --git a/input/regression/display-lily-tests.ly
b/input/regression/display-lily-tests.ly
index
08a13bdc780cfa991a8f7ee5cffd52d35f03b1d8..008c4f20f2f13bec83ff45091b2224be572a3f06
100644
--- a/input/regression/display-lily-tests.ly
+++ b/input/regression/display-lily-tests.ly
@@ -241,6 +241,12 @@ stderr of this run."
%% \ottava
\test "" ##[ \ottava #1 #] % OttavaMusic
+%% \tweak
+\test "" ##[ < \tweak #'duration-log #2 c > #]
+\test "" ##[ < c \tweak #'transparent ##t e > #]
+\test "" ##[ < \tweak #'color #'(1.0 0.0 0.0) \tweak #'duration-log #2 c >
#]
+\test "" ##[ c-\tweak #'font-size #3 -> #]
+
%% end test.
#(read-hash-extend #\[ #f) %{ ] %}
Index: scm/define-music-display-methods.scm
diff --git a/scm/define-music-display-methods.scm
b/scm/define-music-display-methods.scm
index
3ecfce5aaf1cdffce6a962576f3454bb8d996011..c0041ba2a98344efe4fdef5fe097a9e0f832e0cb
100644
--- a/scm/define-music-display-methods.scm
+++ b/scm/define-music-display-methods.scm
@@ -16,7 +16,8 @@
;;;
(define (scheme-expr->lily-string scm-arg)
(cond ((or (number? scm-arg)
- (string? scm-arg))
+ (string? scm-arg)
+ (boolean? scm-arg))
(format #f "~s" scm-arg))
((or (symbol? scm-arg)
(list? scm-arg))
@@ -466,7 +467,9 @@ Otherwise, return #f."
;; as a note_chord_element to prevent spurious output, e.g.,
;; \displayLilyMusic < c-1\4 >8 -> c-1\48
(null? (filter post-event?
- (ly:music-property (car simple-elements)
'articulations))))
+ (ly:music-property (car simple-elements)
'articulations)))
+ ;; same for simple_element with \tweak
+ (null? (ly:music-property (car simple-elements) 'tweaks)))
;; simple_element : note | figure | rest | mmrest | lyric_element |
skip
(let* ((simple-element (car simple-elements))
(duration (ly:music-property simple-element 'duration))
Index: scm/display-lily.scm
diff --git a/scm/display-lily.scm b/scm/display-lily.scm
index
6fc933499df5c0ace9bb92ef2fda02b70d4683d9..302259fa23eda7d78d9704dc87f0c77fa6edbb15
100644
--- a/scm/display-lily.scm
+++ b/scm/display-lily.scm
@@ -79,6 +79,15 @@ display method will be called."
(format #f "~a\\tag #'~a" (if post-event? "-" "") tag))
(ly:music-property expr 'tags))))
+(define* (tweaks->lily-string expr #:optional (post-event? #f))
+ (format #f "~{~a ~}"
+ (map (lambda (tweak)
+ (format #f "~a\\tweak #'~a #~a"
+ (if post-event? "-" "")
+ (car tweak)
+ (scheme-expr->lily-string (cdr tweak))))
+ (ly:music-property expr 'tweaks))))
+
(define-public (music->lily-string expr parser)
"Print @var{expr}, a music expression, in LilyPond syntax."
(if (ly:music? expr)
@@ -90,8 +99,9 @@ display method will be called."
(proc expr parser))
procs))))
(if result-string
- (format #f "~a~a"
- (tag->lily-string expr (post-event? expr))
+ (format #f "~a~a~a"
+ (tag->lily-string expr (post-event? expr))
+ (tweaks->lily-string expr (post-event? expr))
result-string)
(format #f "%{ Print method not implemented for music type ~a %}"
music-type)))
_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel