From: David Kastrup Date: Sun, 16 Sep 2012 20:04:07 +0000 (+0200) Subject: Issue 2717: Implement \single for converting overrides to tweaks X-Git-Tag: release/2.17.4-1~16 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=8060ec28b2839f70cf0474e5c23eca907ddaa112;p=lilypond.git Issue 2717: Implement \single for converting overrides to tweaks \single, like \once, can be applied to music consisting of one or more overrides. It translates such an override set, for example \easyHeadsOn, into a tweak on the following music item, so you can use it like { < \single\easyHeadsOn c' g' >2 q } inside of a chord and have it only affect a single notehead of the chord when \once\easyHeadsOn would affect all noteheads. In that manner, most overrides defined in ly/property-init.ly are made available as tweaks. --- diff --git a/ly/music-functions-init.ly b/ly/music-functions-init.ly index 0fa79af3dd..26db17c5ed 100644 --- a/ly/music-functions-init.ly +++ b/ly/music-functions-init.ly @@ -1146,6 +1146,31 @@ shiftDurations = (lambda (x) (shift-one-duration-log x dur dots)) arg)) +single = +#(define-music-function (parser location overrides music) + (ly:music? ly:music?) + (_i "Convert @var{overrides} to tweaks and apply them to @var{music}. +This does not convert @code{\\revert}, @code{\\set} or @code{\\unset} +and ignores nested overrides.") + (set! (ly:music-property music 'tweaks) + (fold-some-music + (lambda (m) (eq? (ly:music-property m 'name) + 'OverrideProperty)) + (lambda (m tweaks) + (let ((p (cond + ((ly:music-property m 'grob-property #f) => list) + (else + (ly:music-property m 'grob-property-path))))) + (if (pair? (cdr p)) + tweaks ;ignore nested properties + (acons (cons (ly:music-property m 'symbol) ;grob name + (car p)) ;grob property + (ly:music-property m 'grob-value) + tweaks)))) + (ly:music-property music 'tweaks) + overrides)) + music) + skip = #(define-music-function (parser location dur) (ly:duration?) (_i "Skip forward by @var{dur}.")