%%%% You should have received a copy of the GNU General Public License
%%%% along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
-\version "2.19.22"
+\version "2.19.25"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
#(use-modules (srfi srfi-1)
(ice-9 optargs))
-%% TODO: using define-music-function in a .scm causes crash.
-
absolute =
#(define-music-function (music)
(ly:music?)
(member 'spanner-interface
(assoc-get 'interfaces
(assoc-get 'meta description))))
- (override (append item (if (symbol? property)
+ (propertyOverride (append item (if (symbol? property)
(list property)
property))
(value-for-spanner-piece arg))
(func music))
applyOutput =
-#(define-music-function (ctx proc) (symbol? procedure?)
- (_i "Apply function @code{proc} to every layout object in context @code{ctx}")
- (make-music 'ApplyOutputEvent
- 'procedure proc
- 'context-type ctx))
+#(define-music-function (target proc) (symbol-list-or-symbol? procedure?)
+ (_i "Apply function @code{proc} to every layout object matched by
+@var{target} which takes the form @code{Context} or @code{Context.Grob}.")
+ (let ((p (check-grob-path target (*location*) #:max 2)))
+ (if p
+ (make-music 'ApplyOutputEvent
+ 'procedure proc
+ 'context-type (car p)
+ (if (pair? (cdr p))
+ (list (cons 'symbol (cadr p)))
+ '()))
+ (make-music 'Music))))
appoggiatura =
#(def-grace-function startAppoggiaturaMusic stopAppoggiaturaMusic
(make-grob-property-override 'Beam 'positions (check-slope-callbacks comp)))
autochange =
-#(define-music-function (music) (ly:music?)
- (_i "Make voices that switch between staves automatically")
- (make-autochange-music music))
-
-
+#(define-music-function (pitch clef-1 clef-2 music)
+ ((ly:pitch? (ly:make-pitch 0 0)) (ly:context-mod?)(ly:context-mod?) ly:music?)
+ (_i "Make voices that switch between staves automatically. As an option the
+pitch where to switch staves may be specified. The clefs for the staves are
+optional as well. Setting clefs works only for implicitly instantiated
+staves.")
+ (let ;; keep the contexts alive for the full duration
+ ((skip (make-duration-of-length (ly:music-length music)))
+ (clef-1 (or clef-1 #{ \with { \clef "treble" } #}))
+ (clef-2 (or clef-2 #{ \with { \clef "bass" } #})))
+ (make-simultaneous-music
+ (list
+ (descend-to-context (make-autochange-music pitch music) 'Staff
+ "up" clef-1)
+ (context-spec-music (make-skip-music skip) 'Staff
+ "up" clef-1)
+ (context-spec-music (make-skip-music skip) 'Staff
+ "down" clef-2)))))
balloonGrobText =
#(define-music-function (grob-name offset text)
'automatically-numbered (not mark)
'text (or mark (make-null-markup))
'footnote-text footnote)))
- (once (tweak 'footnote-music mus item))))
+ (once (propertyTweak 'footnote-music mus item))))
grace =
#(def-grace-function startGraceMusic stopGraceMusic
@code{Context.GrobName}, the result is an override for the grob name
specified by it. If @var{item} is a music expression, the result is
the same music expression with an appropriate tweak applied to it.")
- (tweak 'transparent #t item))
+ (propertyTweak 'transparent #t item))
inStaffSegno =
#(define-music-function () ()
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)
(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))))
+markupMap =
+#(define-music-function (path markupfun music)
+ (symbol-list-or-symbol? markup-function? ly:music?)
+ (_i "This applies the given markup function @var{markupfun} to all markup
+music properties matching @var{path} in @var{music}.
+
+For example,
+@example
+\\new Voice @{ g'2 c'' @}
+\\addlyrics @{
+ \\markupMap LyricEvent.text
+ \\markup \\with-color #red \\etc
+ @{ Oh yes! @}
+@}
+@end example
+")
+ (let* ((p (check-music-path path (*location*)))
+ (name (and p (car p)))
+ (prop (and p (cadr p))))
+ (if p
+ (for-some-music
+ (lambda (m)
+ (if (or (not name) (eq? (ly:music-property m 'name) name))
+ (let ((text (ly:music-property m prop)))
+ (if (markup? text)
+ (set! (ly:music-property m prop)
+ (list markupfun text)))))
+ #f)
+ music)))
+ music)
+
musicMap =
#(define-music-function (proc mus) (procedure? ly:music?)
(_i "Apply @var{proc} to @var{mus} and all of the music it contains.")
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 =
@code{Context.GrobName}, the result is an override for the grob name
specified by it. If @var{item} is a music expression, the result is
the same music expression with an appropriate tweak applied to it.")
- (tweak 'stencil #f item))
+ (propertyTweak 'stencil #f item))
once =
#(define-music-function (music) (ly:music?)
in @var{music}. This will complain about music with an actual
duration. As a special exception, if @var{music} contains
@samp{tweaks} it will be silently ignored in order to allow for
-@code{\\once \\tweak} to work as both one-time override and proper
+@code{\\once \\propertyTweak} to work as both one-time override and proper
tweak.")
(if (not (pair? (ly:music-property music 'tweaks)))
(for-some-music
(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)
d d | e e | f f |
}
<==>
- A = { c c | d d | }
- B = { d d | e e | }
- C = { e e | f f | }
+ A = { c c | d d }
+ B = { d d | e e }
+ C = { e e | f f }
@end verbatim
The last bar checks in a sequence are not copied to the result in
(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)))
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 }
\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 =
#{ \with { \voiceTwo \override DynamicLineSpanner.direction = #DOWN } #}
#{ \with { \voiceTwo \override DynamicLineSpanner.direction = #DOWN } #} ))
-partcombineForce =
-#(define-music-function (type once) (boolean-or-symbol? boolean?)
- (_i "Override the part-combiner.")
- (make-music 'EventChord
- 'elements (list (make-music 'PartCombineForceEvent
- 'forced-type type
- 'once once))))
-partcombineApart = \partcombineForce #'apart ##f
-partcombineApartOnce = \partcombineForce #'apart ##t
-partcombineChords = \partcombineForce #'chords ##f
-partcombineChordsOnce = \partcombineForce #'chords ##t
-partcombineUnisono = \partcombineForce #'unisono ##f
-partcombineUnisonoOnce = \partcombineForce #'unisono ##t
-partcombineSoloI = \partcombineForce #'solo1 ##f
-partcombineSoloIOnce = \partcombineForce #'solo1 ##t
-partcombineSoloII = \partcombineForce #'solo2 ##f
-partcombineSoloIIOnce = \partcombineForce #'solo2 ##t
-partcombineAutomatic = \partcombineForce ##f ##f
-partcombineAutomaticOnce = \partcombineForce ##f ##t
+%% Part combine forcing to be found in ly/property-init.ly
partial =
#(define-music-function (dur) (ly:duration?)
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))))
+
+propertyTweak =
+#(define-music-function (prop value item)
+ (symbol-list-or-symbol? scheme? symbol-list-or-music?)
+ (_i "Add a tweak to the following @var{item}, usually music.
+This generally behaves like @code{\\tweak} but will turn into an
+@code{\\override} when @var{item} is a symbol list.
+
+In that case, @var{item} specifies the grob path to override. This is
+mainly useful when using @code{\\propertyTweak} as as a component for
+building other functions like @code{\\omit}. It is not the default
+behavior for @code{\\tweak} since many input strings in
+@code{\\lyricmode} can serve equally as music or as symbols which
+causes surprising behavior when tweaking lyrics using the less
+specific semantics of @code{\\propertyTweak}.
+
+@var{prop} can contain additional elements in which case a nested
+property (inside of an alist) is tweaked.")
+ ;; Why not instead make the parser treat strings preferably as
+ ;; music in lyrics mode rather than as symbol? Because then
+ ;;
+ ;; \tweak text "whatever" mylyrics
+ ;;
+ ;; will try putting a lyric event with text "whatever" in the text
+ ;; property of lyrics. So we want expressions allowing both
+ ;; strings and lyrics to deliver strings: more complex conversions
+ ;; should only be attempted when the simple uses don't match the
+ ;; given predicate.
+ (if (ly:music? item)
+ (if (music-is-of-type? item 'context-specification)
+ ;; This is essentially dealing with the case
+ ;; \propertyTweak color #red \propertyTweak font-size #3 NoteHead
+ ;; namely when stacked tweaks end in a symbol list
+ ;; rather than a music expression.
+ ;;
+ ;; We have a tweak here to convert into an override,
+ ;; so we need to know the grob to apply it to. That's
+ ;; easy if we have a directed tweak, and otherwise we
+ ;; need to find the symbol in the expression itself.
+ (let* ((p (check-grob-path prop (*location*)
+ #:start 1
+ #:default #t
+ #:min 2))
+ (elt (ly:music-property item 'element))
+ (seq (if (music-is-of-type? elt 'sequential-music)
+ elt
+ (make-sequential-music (list elt))))
+ (elts (ly:music-property seq 'elements))
+ (symbol (if (symbol? (car p))
+ (car p)
+ (and (pair? elts)
+ (ly:music-property (car elts)
+ 'symbol)))))
+ (if (symbol? symbol)
+ (begin
+ (set! (ly:music-property seq 'elements)
+ (cons (make-music 'OverrideProperty
+ 'symbol symbol
+ 'grob-property-path (cdr p)
+ 'pop-first #t
+ 'grob-value value
+ 'origin (*location*))
+ elts))
+ (set! (ly:music-property item 'element) seq))
+ (begin
+ (ly:parser-error (_ "Cannot \\propertyTweak")
+ (*location*))
+ (ly:music-message item (_ "untweakable"))))
+ item)
+ (tweak prop value item))
+ (propertyOverride (append item (if (symbol? prop) (list prop) prop))
+ value)))
+
+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?)
'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)
@code{\\once\\override} for the specified grob type. If @var{item} is
a music expression, the result is the same music expression with an
appropriate tweak applied.")
- (define (shape-curve grob)
+ (define (shape-curve grob coords)
(let* ((orig (ly:grob-original grob))
(siblings (if (ly:spanner? grob)
(ly:spanner-broken-into orig) '()))
- (total-found (length siblings))
- (function (assoc-get 'control-points
- (reverse (ly:grob-basic-properties grob))))
- (coords (function grob)))
-
+ (total-found (length siblings)))
(define (offset-control-points offsets)
(if (null? offsets)
coords
(if (>= total-found 2)
(helper siblings offsets)
(offset-control-points (car offsets)))))
- (once (tweak 'control-points shape-curve item)))
+ (once (propertyTweak 'control-points
+ (grob-transformer 'control-points shape-curve)
+ item)))
shiftDurations =
#(define-music-function (dur dots arg)
#{ \unset tupletSpannerDuration #}))
tweak =
-#(define-music-function (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}
+#(define-music-function (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}
set to @var{value}. If @var{prop} has the form @samp{Grob.property}, like with
@example
\\tweak Accidental.color #red cis'
@samp{NoteHead}) can be tweaked; otherwise only directly created grobs
are affected.
-As a special case, @var{item} may be a symbol list specifying a grob
-path, in which case @code{\\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 this use case would call for @code{\\once \\override} rather than a
-plain @code{\\override}, writing @code{\\once \\tweak @dots{}} can be
-convenient.
-
@var{prop} can contain additional elements in which case a nested
property (inside of an alist) is tweaked.")
- (if (ly:music? item)
- (let ((p (check-grob-path prop (*location*)
- #:start 1
- #:default #t
- #:min 2)))
- (if p
- (set! (ly:music-property item 'tweaks)
- (acons (cond ((pair? (cddr p)) p)
- ((symbol? (car p))
- (cons (car p) (cadr p)))
- (else (cadr p)))
- value
- (ly:music-property item 'tweaks))))
- item)
- (override (append item (if (symbol? prop) (list prop) prop)) value)))
+ (let ((p (check-grob-path prop (*location*)
+ #:start 1
+ #:default #t
+ #:min 2)))
+ (cond ((not p))
+ ;; p now contains at least two elements. The first
+ ;; element is #t when no grob has been explicitly
+ ;; specified, otherwise it is a grob name.
+ (else
+ (set! (ly:music-property music 'tweaks)
+ (acons (cond ((pair? (cddr p)) p)
+ ((symbol? (car p))
+ (cons (car p) (cadr p)))
+ (else (cadr p)))
+ value
+ (ly:music-property music 'tweaks)))))
+ music))
+
undo =
#(define-music-function (music)
(let
((lst
(fold-some-music
- (lambda (m) (or (music-is-of-type? m 'layout-instruction-event)
- (music-is-of-type? m 'context-specification)
- (music-is-of-type? m 'apply-context)
- (music-is-of-type? m 'time-signature-music)))
+ (music-type-predicate '(layout-instruction-event
+ context-specification
+ apply-context
+ time-signature-music))
(lambda (m overrides)
(case (ly:music-property m 'name)
((OverrideProperty)