[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with extending 'magnetic snapping lyrics' engraver
From: |
Jean Abou Samra |
Subject: |
Re: problem with extending 'magnetic snapping lyrics' engraver |
Date: |
Wed, 6 Apr 2022 11:40:10 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 |
Le 06/04/2022 à 09:49, Werner LEMBERG a écrit :
I'm trying to generalize the 'magnetic snapping lyrics' engraver (the
most recent version posted as
https://lists.gnu.org/archive/html/lilypond-user/2019-05/msg00389.html)
by providing a new property `hyphen-formatter`, to be used instead of
the hard-coded `ly:lyric-hyphen::print`. Attached you can see the
final file together with a diff to the original version (ignoring
whitespace), and an example. Unfortunately, it doesn't work, and I
can't find the problem: It aborts with
```
ERROR: Wrong type to apply: ()
```
Please advise.
It's uncomfortable to have grob properties of procedure type,
since they are automatically resolved as callbacks. You set
LyricWord.hyphen-formatter to ly:lyric-hyphen::print. Then,
when you do
(ly:grob-property grob 'hyphen-formatter)
this not only looks up ly:lyric-hyphen::print in the property,
but executes it on the LyricWord and returns the result. Since
ly:lyric-hyphen::print is written to work on a LyricHyphen and
not a LyricWord, it gives up and returns '(). Then you try to
apply the "formatter" '() to the hyphen, which goes wrong. You
could use ly:grob-property-data, which skips callbacks, but how
about just changing
(let* ((hyphen-sten (ly:lyric-hyphen::print hyphen))
to
(let* ((hyphen-sten (ly:grob-property hyphen 'stencil))
? Then you can do \override LyricHyphen.stencil = #what-you-want to
get the result.
Jean