]> git.donarmstrong.com Git - lilypond.git/commitdiff
Issue 3231: Make reference pitch for \relative non-optional
authorDavid Kastrup <dak@gnu.org>
Fri, 8 Mar 2013 10:52:53 +0000 (11:52 +0100)
committerDavid Kastrup <dak@gnu.org>
Thu, 21 Mar 2013 06:33:17 +0000 (07:33 +0100)
Using \relative without reference pitch has been deprecated for a long
time, so this change brings LilyPond's codebase (and files converted
using convert-ly) into conformance with recommended practices.

ly/music-functions-init.ly
python/convertrules.py

index 559d9777d5a3f78fe3f5b7611d05e810200650d2..ad9f7bdda27dfa7f9e7d5df1b5ca50742eaa6289 100644 (file)
@@ -1024,8 +1024,8 @@ usually contains spacers or multi-measure rests.")
 
 relative =
 #(define-music-function (parser location pitch music)
-   ((ly:pitch? (ly:make-pitch 0 0 0)) ly:music?)
-   (_i "Make @var{music} relative to @var{pitch} (default @code{c'}).")
+   (ly:pitch? ly:music?)
+   (_i "Make @var{music} relative to @var{pitch}.")
    (ly:make-music-relative! music pitch)
    (make-music 'RelativeOctaveMusic
               'element music))
index 274313b2604936e54756b294cb5b657045e48818..b0a46ebac8de9e357cfbc9271f9c45cc3c6b346d 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 # (setq py-indent-offset 4)
 
 
@@ -3520,12 +3521,30 @@ def conv(str):
                   r"\1/\2", str)
     return str
 
-@rule((2, 17, 15), r"#(ly:set-option 'old-relative)")
+@rule((2, 17, 15), r"""#(ly:set-option 'old-relative)
+\relative -> \relative c'""")
 def conv(str):
     if re.search (r"[#$]\(ly:set-option\s+'old-relative", str):
         stderr_write (NOT_SMART % "#(ly:set-option 'old-relative)")
         stderr_write (UPDATE_MANUALLY)
         raise FatalConversionError ();
+    # If the file contains a language switch to a language where the
+    # name of c is not "c", we can't reliably know which parts of the
+    # file will need "c" and which need "do".
+    m = re.search (r'\\language\s(?!\s*#?"(?:nederlands|deutsch|english|norsk|suomi|svenska))"', str)
+    if m:
+        # Heuristic: if there is a non-commented { before the language
+        # selection, we can't be sure.
+        # Also if there is any selection of a non-do language.
+        if (re.search ("^[^%\n]*\\{", m.string[:m.start()], re.M)
+            or re.search ('\\language\s(?!\s*#?"(?:catalan|espanol|español|italiano|français|portugues|vlaams))"', str)):
+            do = "$(ly:make-pitch 0 0)"
+        else:
+            do = "do'"
+    else:
+        do = "c'"
+    str = re.sub (r"(\\relative)(\s+(\{|[\\<]))",
+                  r"\1 " + do + r"\2", str)
     return str
 
 # Guidelines to write rules (please keep this at the end of this file)