]> git.donarmstrong.com Git - lilypond.git/blobdiff - ly/music-functions-init.ly
Adds documentation for optional octavation clef syntax
[lilypond.git] / ly / music-functions-init.ly
index 09607b1f0651bc9e69a3f86dc8e6e01189333175..df5d8a500523c5504bb4e6eec9ea325daef3de91 100644 (file)
@@ -260,7 +260,7 @@ as @code{\\compoundMeter #'((3 2 8))} or shorter
          (timesig (cons (ly:moment-main-numerator mlen)
                         (ly:moment-main-denominator mlen))))
   #{
-    \once \override Staff.TimeSignature #'stencil = #(lambda (grob)
+    \once \override Staff.TimeSignature.stencil = #(lambda (grob)
       (grob-interpret-markup grob (format-compound-time args)))
     \set Timing.timeSignatureFraction = $timesig
     \set Timing.baseMoment = $beat
@@ -273,11 +273,11 @@ crossStaff =
 #(define-music-function (parser location notes) (ly:music?)
   (_i "Create cross-staff stems")
   #{
-  \temporary \override Stem #'cross-staff = #cross-staff-connect
-  \temporary \override Flag #'style = #'no-flag
+  \temporary \override Stem.cross-staff = #cross-staff-connect
+  \temporary \override Flag.style = #'no-flag
   $notes
-  \revert Stem #'cross-staff
-  \revert Flag #'style
+  \revert Stem.cross-staff
+  \revert Flag.style
 #})
 
 cueClef =
@@ -410,9 +410,7 @@ to the preceding note or rest as a post-event with @code{-}.")
               'automatically-numbered (not mark)
               'text (or mark (make-null-markup))
               'footnote-text footnote)))
-     (if (ly:music? item)
-         #{ \tweak #'footnote-music #mus #item #}
-         #{ \once\override $item #'footnote-music = #mus #})))
+     #{ \tweak footnote-music #mus #item #}))
 
 grace =
 #(def-grace-function startGraceMusic stopGraceMusic
@@ -432,18 +430,18 @@ harmonicByFret = #(define-music-function (parser location fret music) (number? l
 harmonics played on a fretted instrument by touching the strings at @var{fret}.")
   #{
     \set harmonicDots = ##t
-    \temporary \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label (number->string fret))
-    \temporary \override NoteHead #'Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
+    \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (number->string fret))
+    \temporary \override NoteHead.Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
                                        (lambda (grob start end)
                                                (ly:grob::stencil-height grob)))
-    \temporary \override NoteHead #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
+    \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
                                             (ly:note-head::print grob))
     $(make-harmonic
        (calc-harmonic-pitch (fret->pitch (number->string fret)) music))
     \unset harmonicDots
-    \revert TabNoteHead #'stencil
-    \revert NoteHead #'Y-extent
-    \revert NoteHead #'stencil
+    \revert TabNoteHead.stencil
+    \revert NoteHead.Y-extent
+    \revert NoteHead.stencil
   #})
 
 harmonicByRatio = #(define-music-function (parser location ratio music) (number? ly:music?)
@@ -452,18 +450,18 @@ harmonics played on a fretted instrument by touching the strings at the point
 given through @var{ratio}.")
   #{
     \set harmonicDots = ##t
-    \temporary \override TabNoteHead #'stencil = #(tab-note-head::print-custom-fret-label (ratio->fret ratio))
-    \temporary \override NoteHead #'Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
+    \temporary \override TabNoteHead.stencil = #(tab-note-head::print-custom-fret-label (ratio->fret ratio))
+    \temporary \override NoteHead.Y-extent = #(ly:make-unpure-pure-container ly:grob::stencil-height
                                        (lambda (grob start end)
                                                (ly:grob::stencil-height grob)))
-    \temporary \override NoteHead #'stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
+    \temporary \override NoteHead.stencil = #(lambda (grob) (ly:grob-set-property! grob 'style 'harmonic-mixed)
                                             (ly:note-head::print grob))
     $(make-harmonic
       (calc-harmonic-pitch (ratio->pitch ratio) music))
     \unset harmonicDots
-    \revert TabNoteHead #'stencil
-    \revert NoteHead #'Y-extent
-    \revert NoteHead #'stencil
+    \revert TabNoteHead.stencil
+    \revert NoteHead.Y-extent
+    \revert NoteHead.stencil
   #})
 
 hide =
@@ -476,7 +474,7 @@ If @var{item} is a symbol list of form @code{GrobName} or
 specified by it.  If @var{item} is a music expression, the result is
 the same music expression with an appropriate tweak applied to it.")
    (if (ly:music? item)
-       #{ \tweak #'transparent ##t $item #}
+       #{ \tweak transparent ##t $item #}
        #{ \override $item #'transparent = ##t #}))
 
 inStaffSegno =
@@ -684,7 +682,7 @@ If @var{item} is a symbol list of form @code{GrobName} or
 specified by it.  If @var{item} is a music expression, the result is
 the same music expression with an appropriate tweak applied to it.")
    (if (ly:music? item)
-       #{ \tweak #'stencil ##f $item #}
+       #{ \tweak stencil ##f $item #}
        #{ \override $item #'stencil = ##f #}))
 
 once =
@@ -1165,13 +1163,7 @@ appropriate tweak applied.")
        (if (>= total-found 2)
            (helper siblings offsets)
            (offset-control-points (car offsets)))))
-   (if (ly:music? item)
-       #{
-         \tweak #'control-points #shape-curve $item
-       #}
-       #{
-         \once \override $item #'control-points = #shape-curve
-       #}))
+   #{ \tweak control-points #shape-curve #item #})
 
 shiftDurations =
 #(define-music-function (parser location dur dots arg)
@@ -1225,8 +1217,7 @@ spacingTweaks =
    (_i "Set the system stretch, by reading the 'system-stretch property of
 the `parameters' assoc list.")
    #{
-     \overrideProperty Score.NonMusicalPaperColumn
-     #'line-break-system-details
+     \overrideProperty Score.NonMusicalPaperColumn.line-break-system-details
      #(list (cons 'alignment-extra-space (cdr (assoc 'system-stretch parameters)))
             (cons 'system-Y-extent (cdr (assoc 'system-Y-extent parameters))))
    #})
@@ -1238,15 +1229,17 @@ styledNoteHeads =
    (style-note-heads heads style music))
 
 tag =
-#(define-music-function (parser location tag arg) (symbol? ly:music?)
-
-   (_i "Add @var{tag} to the @code{tags} property of @var{arg}.")
+#(define-music-function (parser location tag music) (symbol-list-or-symbol? ly:music?)
+   (_i "Tag the following @var{music} with @var{tag} and return the
+result, by adding the single symbol or symbol list @var{tag} to the
+@code{tags} property of @var{music}.")
 
    (set!
-    (ly:music-property arg 'tags)
-    (cons tag
-         (ly:music-property arg 'tags)))
-   arg)
+    (ly:music-property music 'tags)
+    ((if (symbol? tag) cons append)
+     tag
+     (ly:music-property music 'tags)))
+   music)
 
 temporary =
 #(define-music-function (parser location music)
@@ -1346,27 +1339,46 @@ transposition =
     'Staff))
 
 tweak =
-#(define-music-function (parser location prop value music)
-   (symbol-list-or-symbol? scheme? ly:music?)
-   (_i "Add a tweak to the following @var{music}.
-Layout objects created by @var{music} get their property @var{prop}
+#(define-music-function (parser location prop value item)
+   (symbol-list-or-symbol? scheme? symbol-list-or-music?)
+   (_i "Add a tweak to the following @var{item}, usually music.
+Layout objects created by @var{item} get their property @var{prop}
 set to @var{value}.  If @var{prop} has the form @samp{Grob.property}, like with
 @example
 \\tweak Accidental.color #red cis'
 @end example
 an indirectly created grob (@samp{Accidental} is caused by
 @samp{NoteHead}) can be tweaked; otherwise only directly created grobs
-are affected.")
-   (if (symbol? prop)
-       (set! prop (list prop)))
-   (if (and (<= 1 (length prop) 2)
-            (object-property (last prop) 'backend-type?))
-       (set! (ly:music-property music 'tweaks)
-             (acons (apply cons* prop)
-                    value
-                    (ly:music-property music 'tweaks)))
-       (ly:input-warning location (_ "cannot find property type-check for ~a") prop))
-   music)
+are affected.
+
+As a special case, @var{item} may be a symbol list specifying a grob
+path, in which case @code{\\once\\override} is called on it instead of
+creating tweaked music.  This is mainly useful when using
+@code{\\tweak} as as a component for building other functions.")
+   (if (ly:music? item)
+       (let ((p (check-grob-path prop parser location
+                                 #:start 1
+                                 #:default #t
+                                 #:min 2
+                                 #:max 2)))
+         (if p
+             (set! (ly:music-property item 'tweaks)
+                   (acons (if (eq? (car p) #t)
+                              (cadr p)
+                              (cons (car p) (cadr p)))
+                          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 ((a (check-grob-path item parser location
+                                 #:default 'Bottom #:min 2 #:max 2))
+             (b (check-grob-path prop parser location
+                                 #:start 2)))
+         (if (and a b)
+             #{ \once\override #(append a b) = #value #}
+             (make-music 'Music)))))
 
 undo =
 #(define-music-function (parser location music)