From 5ec4720aeb6b1bb96bfbe3f99887bf749eb905e0 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Wed, 10 Oct 2012 17:46:51 +0200 Subject: [PATCH] Change \tweak syntax to symbol syntax 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 | 26 +++++++++++++------------- python/convertrules.py | 5 ++++- scm/display-lily.scm | 2 +- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 9036f61e94..24b3c6dda6 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -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 = diff --git a/python/convertrules.py b/python/convertrules.py index 66ff152476..861e57ac4f 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -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) diff --git a/scm/display-lily.scm b/scm/display-lily.scm index 16f809fc8b..3348434da3 100644 --- a/scm/display-lily.scm +++ b/scm/display-lily.scm @@ -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)))) -- 2.39.5