Re: problem with extending 'magnetic snapping lyrics' engraver

2022-04-06 Thread Werner LEMBERG

>> 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.
> 
> D'oh, so simple, thanks again!

Well, it doesn't work :-) The magnetic snapping engraver sets the
stencil of all affected `hyphen` grobs to `empty-stencil`.  On the
other hand, the solution with a separate property for the formatter to
be accessed with `ly:grob-property-data` seems to work just fine.


Werner


Re: problem with extending 'magnetic snapping lyrics' engraver

2022-04-06 Thread Werner LEMBERG

> 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, [...]

Thanks a lot for the explanation!

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

D'oh, so simple, thanks again!


Werner


Re: problem with extending 'magnetic snapping lyrics' engraver

2022-04-06 Thread Jean Abou Samra

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