From: David Kastrup Date: Mon, 1 Oct 2012 16:47:53 +0000 (+0200) Subject: Allow \shape to tweak music, swap its arguments X-Git-Tag: release/2.17.4-1~4^2~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0892e4cd4d8a4392ec789170fde721cefb18e1c7;p=lilypond.git Allow \shape to tweak music, swap its arguments --- diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 801bde42b1..2180b895e1 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -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) diff --git a/python/convertrules.py b/python/convertrules.py index fa63726069..b8921a02be 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -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,