Re: duration-length becomes duration-moment, but script no longer works

Richard Shann <[email protected]>
Newsgroups gmane.comp.gnu.lilypond.general
Message-ID <[email protected]>
On Wed, 2026-08-12 at 15:43 +0200, Lukas-Fabian Moser wrote:
> 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.

That seems to work just fine, both in 2.24 and 2.26. I haven't heard of
people trying to use it on appogiaturas - I think the main application
is in 18th c music before they came in. So this is probably a benefit.

> 
> 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

I noticed that while digging around; I guess the problem is that it
might be difficult for Denemo to make sense of that syntax without
coding something up in C for it (because when you get to the grace note
it doesn't announce that it _is_ a grace note)

Thanks very much for this fix.
You also tipped me off about the use of (_ string) -  
I've tested out the G_ and have run into problems - despite (version)
reporting => 3.0.8 and the documents even for guile 2 saying G_ is the
conventional shorthand for gettext I get a "possibly unbound variable
`G_' " warning from using it. I guess I can always just define it.

Thank you once more,

best wishes

Richard
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.