\version "2.21.0" \header { texidoc = "Lone post-events are integrated into surrounding expressions. Making it possible to attach them to expressions stored in variables. If no preceding expression is suitable they are attached to an empty chord and a warning is printed. Though, as a consequence post-events may not be detected correctly, if not inside of sequential music. " title = \markup \rounded-box \smaller \medium \wordwrap-string \texidoc } #(ly:expect-warning "Adding <>") nEv = c'4 seqM = { d'4 e' } addStaccato = #(define-music-function (mus)(ly:music?) ;; Adds staccato to every note-event (music-map (lambda (m) (if (music-is-of-type? m 'note-event) #{ $m -. #} m)) mus)) addMarkup = #(define-music-function (mus)(ly:music?) ;; add TextScript, relying on DynamicText (music-map (lambda (m) (if (music-is-of-type? m 'note-event) (let* ((arts (ly:music-property m 'articulations '())) (dyn-present? (any (lambda (a) (music-is-of-type? a 'absolute-dynamic-event)) arts))) (if dyn-present? #{ $m _"Dynamic present " #} #{ $m _"Dynamic not present " #})) m)) mus)) { %% tenuto is added to <>, a warning is issues (surpressed here) %% a Slur starts at \nEv -- \nEv ( %% a Slur-ending is applied to the last element of sequential music. \seqM ) %% every note gets a staccato \addStaccato { \nEv \seqM } \textLengthOn %% presence of an absolute-dynamic-event is detected wrongly \addMarkup \nEv \f ^"Selected wrongly" %% works within sequential music \addMarkup { \nEv \f } %% for reference \addMarkup c'\f }