]> git.donarmstrong.com Git - lilypond.git/commitdiff
Allow \shape to tweak music, swap its arguments
authorDavid Kastrup <dak@gnu.org>
Mon, 1 Oct 2012 16:47:53 +0000 (18:47 +0200)
committerDavid Kastrup <dak@gnu.org>
Fri, 5 Oct 2012 20:19:48 +0000 (22:19 +0200)
ly/music-functions-init.ly
python/convertrules.py

index 801bde42b1fc60e6a0a83e62a119f964c9d935af..2180b895e12c2d0e06bb9f1fd7fedd1e0a32ffb6 100644 (file)
@@ -1119,12 +1119,16 @@ a context modification duplicating their effect.")
      mods))
 
 shape =
-#(define-music-function (parser location grob offsets)
-   (string? list?)
-   (_i "Offset control-points of @var{grob} by @var{offsets}.  The argument
-is a list of number pairs or list of such lists.  Each element of a pair
-represents an offset to one of the coordinates of a control-point.")
-   (define ((shape-curve offsets) grob)
+#(define-music-function (parser location offsets item)
+   (list? string-or-music?)
+   (_i "Offset control-points of @var{item} by @var{offsets}.  The
+argument is a list of number pairs or list of such lists.  Each
+element of a pair represents an offset to one of the coordinates of a
+control-point.  If @var{item} is a string, the result is
+@code{\\once\\override} for the specified grob type.  If @var{item} is
+a music expression, the result is the same music expression with an
+appropriate tweak applied.")
+   (define (shape-curve grob)
      (let* ((orig (ly:grob-original grob))
             (siblings (if (ly:spanner? grob)
                           (ly:spanner-broken-into orig) '()))
@@ -1155,10 +1159,13 @@ represents an offset to one of the coordinates of a control-point.")
        (if (>= total-found 2)
            (helper siblings offsets)
            (offset-control-points (car offsets)))))
-
-   #{
-     \once \override $grob #'control-points = #(shape-curve offsets)
-   #})
+   (if (ly:music? item)
+       #{
+         \tweak #'control-points #shape-curve $item
+       #}
+       #{
+         \once \override $item #'control-points = #shape-curve
+       #}))
 
 shiftDurations =
 #(define-music-function (parser location dur dots arg)
index fa63726069269c30b9581fe1bff94e87adc75bfa..b8921a02be3709ed546cac50dab9d137af8475b2 100644 (file)
@@ -3392,6 +3392,12 @@ def conv (str):
     str = re.sub ('blank-after-score-page-force', 'blank-after-score-page-penalty', str)
     return str
 
+@rule ((2, 17, 4), r"\shape Grob #offsets -> \shape #offsets Grob")
+def conv (str):
+    str = re.sub (r"\\shape(\s+(?:[a-zA-Z]+|" + matchstring + "))(" +
+                  matcharg + ")", r"\\shape\2\1", str)
+    return str
+
 # Guidelines to write rules (please keep this at the end of this file)
 #
 # - keep at most one rule per version; if several conversions should be done,