]> git.donarmstrong.com Git - lilypond.git/commitdiff
Change \tweak syntax to symbol syntax
authorDavid Kastrup <dak@gnu.org>
Wed, 10 Oct 2012 15:46:51 +0000 (17:46 +0200)
committerDavid Kastrup <dak@gnu.org>
Thu, 25 Oct 2012 18:29:28 +0000 (20:29 +0200)
Instead of \tweak #'color, \tweak color can now be used.
Instead of \tweak Accidental #'color, \tweak Accidental.color is used.

The second change is mandatory, a convert-ly rule puts it in place.

ly/music-functions-init.ly
python/convertrules.py
scm/display-lily.scm

index 9036f61e94d3a59ca7ee58032ff311e69abd85c8..24b3c6dda646b0c1d5b199abc668980831521651 100644 (file)
@@ -1328,26 +1328,26 @@ transposition =
     'Staff))
 
 tweak =
-#(define-music-function (parser location grob prop value music)
-   ((string?) symbol? scheme? ly:music?)
+#(define-music-function (parser location prop value music)
+   (symbol-list-or-symbol? scheme? ly:music?)
    (_i "Add a tweak to the following @var{music}.
 Layout objects created by @var{music} get their property @var{prop}
-set to @var{value}.  If @var{grob} is specified, like with
+set to @var{value}.  If @var{prop} has the form @samp{Grob.property}, like with
 @example
-\\tweak Accidental #'color #red cis'
+\\tweak Accidental.color #red cis'
 @end example
 an indirectly created grob (@samp{Accidental} is caused by
 @samp{NoteHead}) can be tweaked; otherwise only directly created grobs
 are affected.")
-   (if (not (object-property prop 'backend-type?))
-       (begin
-        (ly:input-warning location (_ "cannot find property type-check for ~a") prop)
-        (ly:warning (_ "doing assignment anyway"))))
-   (set!
-    (ly:music-property music 'tweaks)
-    (acons (if grob (cons (string->symbol grob) prop) prop)
-          value
-          (ly:music-property music 'tweaks)))
+   (if (symbol? prop)
+       (set! prop (list prop)))
+   (if (and (<= 1 (length prop) 2)
+            (object-property (last prop) 'backend-type?))
+       (set! (ly:music-property music 'tweaks)
+             (acons (apply cons* prop)
+                    value
+                    (ly:music-property music 'tweaks)))
+       (ly:input-warning location (_ "cannot find property type-check for ~a") prop))
    music)
 
 undo =
index 66ff15247638b800c005552c0e1e971e4e2fd4c5..861e57ac4f3532da841897ed398e7e8f01c10714 100644 (file)
@@ -3425,7 +3425,8 @@ def conv(str):
 
 @rule ((2, 17, 6), r"""\accidentalStyle #'Context "style" -> \accidentalStyle Context.style
 \alterBroken "Context.grob" -> \alterBroken Context.grob
-\overrideProperty "Context.grob" -> \overrideProperty Context.grob""")
+\overrideProperty "Context.grob" -> \overrideProperty Context.grob
+\tweak Grob #'symbol -> \tweak Grob.symbol""")
 def conv (str):
     str = re.sub (r'''(\\accidentalStyle\s+)#?"([-A-Za-z]+)"''',
                   r"\1\2", str)
@@ -3433,6 +3434,8 @@ def conv (str):
                   r"\1\2.\3", str)
     str = re.sub (r'''(\\(?:alterBroken|overrideProperty)\s+)#?"([A-Za-z]+)\s*\.\s*([A-Za-z]+)"''',
                   r"\1\2.\3", str)
+    str = re.sub (r'''(\\tweak\s+)#?"?([A-Za-z]+)"?\s+?#'([-A-Za-z]+)''',
+                  r"\1\2.\3", str)
     return str
 
 # Guidelines to write rules (please keep this at the end of this file)
index 16f809fc8bca2306e6c71d57cc5722bdfdc009fc..3348434da33ddb987314240737a01c6034bef57f 100644 (file)
@@ -85,7 +85,7 @@ display method will be called."
                  (format #f "~a\\tweak ~a #~a"
                          (if post-event? "-" "")
                         (if (pair? (car tweak))
-                            (format #f "~a #'~a"
+                            (format #f "~a.~a"
                                     (caar tweak) (cdar tweak))
                             (format #f "#'~a" (car tweak)))
                          (scheme-expr->lily-string (cdr tweak))))