]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
Doc-fr: updates NR-5 changing defaults
[lilypond.git] / ly / music-functions-init.ly
index 4e7e1d41050cdc8923058ab52bf1ac8babc53821..98e6203630dedd13dabc1b4aaa3ee02a06218674 100644 (file)
@@ -119,10 +119,10 @@ form of a spanner event, @var{property} may also have the form
                  (member 'spanner-interface
                          (assoc-get 'interfaces
                                     (assoc-get 'meta description))))
-            #{
-              \override #item . #property =
-              #(value-for-spanner-piece arg)
-            #}
+            (propertyOverride (append item (if (symbol? property)
+                                       (list property)
+                                       property))
+                      (value-for-spanner-piece arg))
             (begin
               (ly:input-warning (*location*) (_ "not a spanner name, `~a'") name)
               (make-music 'Music))))))
@@ -177,9 +177,25 @@ assertBeamSlope =
 autochange =
 #(define-music-function (music) (ly:music?)
    (_i "Make voices that switch between staves automatically")
-   (make-autochange-music music))
-
-
+   (let ;; keep the contexts alive for the full duration
+       ((skip (make-skip-music (make-duration-of-length 
+                                (ly:music-length music)))))
+     #{
+       <<
+         \context Staff = "up" <<
+           #(make-autochange-music music)
+           \new Voice { #skip }
+         >>
+         \context Staff = "down" \with {
+           clefGlyph = "clefs.F"
+           clefPosition = 2
+           middleCPosition = 6
+           middleCClefPosition = 6
+         } {
+           \new Voice { #skip }
+         }
+       >>
+     #} ))
 
 balloonGrobText =
 #(define-music-function (grob-name offset text)
@@ -808,7 +824,7 @@ transpose from @var{around} to @var{to}.")
 
 mark =
 #(define-music-function
-   (label) ((scheme? '()))
+   (label) ((number-or-markup?))
   "Make the music for the \\mark command."
   (let* ((set (and (integer? label)
                    (context-spec-music (make-property-set 'rehearsalMark label)
@@ -819,7 +835,7 @@ mark =
     (if set
         (make-sequential-music (list set ev))
         (begin
-          (set! (ly:music-property ev 'label) label)
+          (if label (set! (ly:music-property ev 'label) label))
           ev))))
 
 musicMap =
@@ -890,9 +906,7 @@ appropriate tweak applied.")
                                      property)) (*location*)
                          #:default 'Bottom #:min 3 #:max 3)))
         (if prop-path
-            #{
-              \override #prop-path = #(offsetter (third prop-path) offsets)
-            #}
+            (propertyOverride prop-path (offsetter (third prop-path) offsets))
             (make-music 'Music)))))
 
 omit =
@@ -933,33 +947,6 @@ ottava =
    (make-music 'OttavaMusic
                'ottava-number octave))
 
-#(ly:expect-warning
-  (ly:translate-cpp-warning-scheme "identifier name is a keyword: `%s'")
-  "override")
-override =
-#(define-music-function (grob-property-path value)
-   (symbol-list? scheme?)
-   (_i "Set the grob property specified by @var{grob-property-path} to
-@var{value}.  @var{grob-property-path} is a symbol list of the form
-@code{Context.GrobName.property} or @code{GrobName.property}, possibly
-with subproperties given as well.  Because @code{\\override} is a
-reserved word with special syntax in LilyPond input, this music
-function will generally only be accessible from Scheme.")
-   (let ((p (check-grob-path grob-property-path (*parser*) (*location*)
-                             #:default 'Bottom
-                             #:min 3)))
-     (if p
-         (context-spec-music
-          (make-music 'OverrideProperty
-                      'symbol (cadr p)
-                      'origin (*location*)
-                      'grob-value value
-                      'grob-property-path (cddr p)
-                      'pop-first #t)
-          (car p))
-         (make-music 'Music))))
-
-
 overrideTimeSignatureSettings =
 #(define-music-function
    (time-signature base-moment beat-structure beam-exceptions)
@@ -1149,18 +1136,17 @@ change to the following voice."
        (and (or split-elt split-elts)
             (map
              (lambda (e es)
-               (apply music-clone music
-                      (append
-                       ;; reassigning the origin of the parent only
-                       ;; makes sense if the first expression in the
-                       ;; result is from a distributed origin
-                       (let ((origin
-                              (if (ly:music? elt)
-                                  (and (ly:music? e) (ly:music-property e 'origin #f))
-                                  (and (pair? es) (ly:music-property (car es) 'origin #f)))))
-                         (if origin (list 'origin origin) '()))
-                       (if (ly:music? e) (list 'element e) '())
-                       (if (pair? es) (list 'elements es) '()))))
+               (let ((m (ly:music-deep-copy music
+                       ;;; reassigning the origin of the parent only
+                       ;;; makes sense if the first expression in the
+                       ;;; result is from a distributed origin
+                                            (or (and (ly:music? e) e)
+                                                (and (pair? es) (car es))))))
+                 (if (ly:music? e)
+                     (set! (ly:music-property m 'element) e))
+                 (if (pair? es)
+                     (set! (ly:music-property m 'elements) es))
+                 m))
              (or split-elt (circular-list #f))
              (or split-elts (circular-list #f))))))
    (let ((voices (recurse-and-split music)))
@@ -1195,12 +1181,42 @@ parenthesize =
           two-context-settings
           shared-context-settings)
 
-   (let* ((pc-music (make-part-combine-music (list part1 part2) direction chord-range))
+   (let* ((pc-music (make-music 'PartCombineMusic))
+          (m1 (context-spec-music (make-non-relative-music part1) 'Voice "one"))
+          (m2 (context-spec-music (make-non-relative-music part2) 'Voice "two"))
+          (listener (ly:parser-lookup 'partCombineListener))
+          (evs2 (recording-group-emulate m2 listener))
+          (evs1 (recording-group-emulate m1 listener))
+          (split-list
+           (if (and (assoc "one" evs1) (assoc "two" evs2))
+               (determine-split-list (reverse! (assoc-get "one" evs1) '())
+                                     (reverse! (assoc-get "two" evs2) '())
+                                     chord-range)
+               '()))
           (L1 (ly:music-length part1))
           (L2 (ly:music-length part2))
           ;; keep the contexts alive for the full duration
           (skip (make-skip-music (make-duration-of-length
                                   (if (ly:moment<? L1 L2) L2 L1)))))
+
+     (set! (ly:music-property pc-music 'elements)
+           (list (make-music
+                  'PartCombinePartMusic
+                  'element m1
+                  'context-change-list
+                  (make-part-combine-context-changes
+                   default-part-combine-context-change-state-machine-one
+                   split-list))
+                 (make-music
+                  'PartCombinePartMusic
+                  'element m2
+                  'context-change-list
+                  (make-part-combine-context-changes
+                   default-part-combine-context-change-state-machine-two
+                   split-list))))
+
+     (set! (ly:music-property pc-music 'direction) direction)
+
      #{ \context Staff <<
           \context Voice = "one" \with #one-context-settings { #skip }
           \context Voice = "two" \with #two-context-settings { #skip }
@@ -1209,8 +1225,7 @@ parenthesize =
           \context NullVoice = "null" { #skip }
           #pc-music
           #(make-part-combine-marks
-            default-part-combine-mark-state-machine
-            (ly:music-property pc-music 'split-list))
+            default-part-combine-mark-state-machine split-list)
         >> #} ))
 
 partcombine =
@@ -1307,6 +1322,81 @@ print @var{secondary-note} as a stemless note head in parentheses.")
                            trill-events)))))
      main-note))
 
+propertyOverride =
+#(define-music-function (grob-property-path value)
+   (symbol-list? scheme?)
+   (_i "Set the grob property specified by @var{grob-property-path} to
+@var{value}.  @var{grob-property-path} is a symbol list of the form
+@code{Context.GrobName.property} or @code{GrobName.property}, possibly
+with subproperties given as well.  This music function is mostly intended
+for use from Scheme as a substitute for the built-in @code{\\override}
+command.")
+   (let ((p (check-grob-path grob-property-path (*location*)
+                             #:default 'Bottom
+                             #:min 3)))
+     (if p
+         (context-spec-music
+          (make-music 'OverrideProperty
+                      'symbol (cadr p)
+                      'origin (*location*)
+                      'grob-value value
+                      'grob-property-path (cddr p)
+                      'pop-first #t)
+          (car p))
+         (make-music 'Music))))
+
+propertyRevert =
+#(define-music-function (grob-property-path)
+   (symbol-list?)
+   (_i "Revert the grob property specified by @var{grob-property-path} to
+its previous value.  @var{grob-property-path} is a symbol list of the form
+@code{Context.GrobName.property} or @code{GrobName.property}, possibly
+with subproperties given as well.  This music function is mostly intended
+for use from Scheme as a substitute for the built-in @code{\\revert}
+command.")
+   (let ((p (check-grob-path grob-property-path (*location*)
+                             #:default 'Bottom
+                             #:min 3)))
+     (if p
+         (context-spec-music
+          (make-music 'RevertProperty
+                      'symbol (cadr p)
+                      'origin (*location*)
+                      'grob-property-path (cddr p))
+          (car p))
+         (make-music 'Music))))
+
+propertySet =
+#(define-music-function (property-path value)
+   (symbol-list-or-symbol? scheme?)
+   (_i "Set the context property specified by @var{property-path} to
+@var{value}.  This music function is mostly intended for use from
+Scheme as a substitute for the built-in @code{\\set} command.")
+   (let ((p (check-context-path property-path (*location*))))
+     (if p
+         (context-spec-music
+          (make-music 'PropertySet
+                      'symbol (cadr p)
+                      'value value
+                      'origin (*location*))
+          (car p))
+         (make-music 'Music))))
+
+propertyUnset =
+#(define-music-function (property-path)
+   (symbol-list-or-symbol?)
+   (_i "Unset the context property specified by @var{property-path}.
+This music function is mostly intended for use from Scheme as a
+substitute for the built-in @code{\\unset} command.")
+   (let ((p (check-context-path property-path (*location*))))
+     (if p
+         (context-spec-music
+          (make-music 'PropertyUnset
+                      'symbol (cadr p)
+                      'origin (*location*))
+          (car p))
+         (make-music 'Music))))
+
 pushToTag =
 #(define-music-function (tag more music)
    (symbol? ly:music? ly:music?)
@@ -1329,30 +1419,6 @@ usually contains spacers or multi-measure rests.")
                'element main-music
                'quoted-music-name what))
 
-#(ly:expect-warning
-  (ly:translate-cpp-warning-scheme "identifier name is a keyword: `%s'")
-  "revert")
-revert =
-#(define-music-function (grob-property-path)
-   (symbol-list?)
-   (_i "Revert the grob property specified by @var{grob-property-path} to
-its previous value.  @var{grob-property-path} is a symbol list of the form
-@code{Context.GrobName.property} or @code{GrobName.property}, possibly
-with subproperties given as well.  Because @code{\\revert} is a
-reserved word with special syntax in LilyPond input, this music
-function will generally only be accessible from Scheme.")
-   (let ((p (check-grob-path grob-property-path (*parser*) (*location*)
-                             #:default 'Bottom
-                             #:min 3)))
-     (if p
-         (context-spec-music
-          (make-music 'RevertProperty
-                      'symbol (cadr p)
-                      'origin (*location*)
-                      'grob-property-path (cddr p))
-          (car p))
-         (make-music 'Music))))
-
 
 relative =
 #(define-music-function (pitch music)
@@ -1772,15 +1838,7 @@ property (inside of an alist) is tweaked.")
                           value
                           (ly:music-property item 'tweaks))))
          item)
-       ;; We could just throw this at \override and let it sort this
-       ;; out on its own, but this way we should get better error
-       ;; diagnostics.
-       (let ((p (check-grob-path
-                 (append item (if (symbol? prop) (list prop) prop)) (*location*)
-                 #:default 'Bottom #:min 3)))
-         (if p
-             #{ \override #p = #value #}
-             (make-music 'Music)))))
+       (propertyOverride (append item (if (symbol? prop) (list prop) prop)) value)))
 
 undo =
 #(define-music-function (music)