From: David Kastrup Date: Fri, 8 Mar 2013 10:52:53 +0000 (+0100) Subject: Issue 3231: Make reference pitch for \relative non-optional X-Git-Tag: release/2.17.15-1~17^2~14 X-Git-Url: https://git.donarmstrong.com/lilypond.git?a=commitdiff_plain;h=ab5782659bc39ce7afaa6ea6402e9df75ea0454a;p=lilypond.git Issue 3231: Make reference pitch for \relative non-optional 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. --- diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 559d9777d5..ad9f7bdda2 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -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)) diff --git a/python/convertrules.py b/python/convertrules.py index 274313b260..b0a46ebac8 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -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)