]> git.donarmstrong.com Git - lilypond.git/blobdiff - scm/define-music-callbacks.scm
Warn when \time is used in mid-measure, and reset measurePosition.
[lilypond.git] / scm / define-music-callbacks.scm
index 60d7d35124687f7cd60980ce2c42490f5560f52c..e9fe53eb1b0a253e85d1af3b1d05d20ce767fae0 100644 (file)
@@ -102,7 +102,19 @@ to be used by the sequential-iterator"
                            structure))
                       (beaming-exception
                        (beam-exceptions fraction time-signature-settings))
-                      (new-measure-length (ly:make-moment num den)))
+                      (new-measure-length (ly:make-moment num den))
+                      (pos (ly:context-property context 'measurePosition)))
+                 ;;\time is OK at a negative measurePosition (after \partial),
+                 ;;but at a positive position it's probably a mistake, so warn
+                 ;;(like a barcheck) and reset it to 0 to prevent errors.
+                 (if (> (ly:moment-main pos) 0)
+                     (begin
+                       (if (not (ly:context-property context 'ignoreBarChecks #f))
+                           (ly:music-warning music
+                                             (_ "\\time in mid-measure at ~A")
+                                             (ly:moment-main pos)))
+                       (ly:context-set-property!
+                        context 'measurePosition (ly:make-moment 0))))
                  (ly:context-set-property!
                   context 'timeSignatureFraction fraction)
                  (ly:context-set-property!