]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 4911/2: convert-ly rule to put \with before context mods
authorDavid Kastrup <dak@gnu.org>
Thu, 30 Jun 2016 16:28:23 +0000 (18:28 +0200)
committerDavid Kastrup <dak@gnu.org>
Sun, 10 Jul 2016 17:39:10 +0000 (19:39 +0200)
python/convertrules.py

index 3e43a281330f089304ed199745d0abf7a8b5598b..dbe59faa9615b426ac7ee4431e378a930471e0b9 100644 (file)
@@ -3888,6 +3888,17 @@ def conv (str):
                   repl, str)
     return str
 
+@rule ((2, 19, 46), r"\context ... \modification -> \context ... \with \modification")
+def conv (str):
+    word=r'(?:#?"[^"]*"|\b' + wordsyntax + r'\b)'
+    mods = string.join (re.findall ("\n(" + wordsyntax + r")\s*=\s*\\with(?:\s|\\|\{)", str)
+                        + ['RemoveEmptyStaves','RemoveAllEmptyStaves'], "|")
+    str = re.sub (r"(\\(?:drums|figures|chords|lyrics|addlyrics|"
+                  + r"(?:new|context)\s*" + word
+                  + r"(?:\s*=\s*" + word + r")?)\s*)(\\(?:" + mods + "))",
+                  r"\1\\with \2", 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,