Dear Richard,

Am 12.08.26 um 12:35 schrieb Richard Shann:
Could you please provide the original, working (with an older
LilyPond
version) state of your code before convert-ly changed it?
Thank you for getting back to me:

This is the code working in 2.24

Ah, I see. That code makes assumptions on the internal representation of grace music that are no longer valid in 2.26.

But the original code is also more involved than necessary. If I'm not mistaken, it can be replaced by something as simple as:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\version "2.24"

#(define (after-grace-factor? x)
   (and (rational? x)
        (< 0 x 1)))

#(define (grace-music? m)
   (and (ly:music? m)
        (music-is-of-type? m 'grace-music)))

attachGraces =
#(define-music-function (frac note graces) (after-grace-factor? ly:music? grace-music?)
    #{
      <<
        #note
        {
          \skip $(make-duration-of-length (ly:music-length note)) * #frac
          #graces
        }
      >>
    #})

\score {
  \new Staff
  {
    \attachGraces #3/4 g''4 \grace { f'8 }
  }
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Incidentally, this version should work out of the box in 2.26 as in 2.24. It behaves a bit differently from your original, though: Your original (I think) strips away the additional code that make up, for instance, an \appoggiatura in contrast to a simple \grace. The code I'm proposing doesn't touch the inner structure of the grace music.

But actually, are you aware that stock LilyPond \afterGrace accepts an optional argument that (I think) does just what your code achieves, without you having to enter \grace explicitly? Try:

\afterGrace #3/4 g''4 f'8

Lukas


Reply via email to