Hi Luca,

without having tested your code: You're using append! wrong.

>From the Guile documentation: "append! is permitted, but not required, to
modify the given lists to form its return."
So the exclamation mark does not imply that your list gets modified
in-place, but rather that you don't care whether or not append! changes
your original list. So try

(set! fl (append fl ...))

where you could probably also use append! instead of append (I imagine it
might be more efficient).

Lukas

Luca Fascione <l.fasci...@gmail.com> schrieb am Di., 30. Juli 2024, 04:03:

> Hi,
> I'm trying to understand a problem I'm seeing.
>
> I have this engraver that acknowledges stems and fingerings,
> this is meant to work with a before-line-breaking callback that
> repositions the fingerings.
> So I thought that I could just sit there, listen for the fingerings as
> they got to me,
> and put them into a list attached to the stem.
> Except that I only ever get only the fingering for the last note in a
> chord,
> and no evidence of the others.
> The display statements below print this:
>
> fl () - fingering (#<Grob Fingering >)4
> fl () - fingering (#<Grob Fingering >)2
>
> I don't understand why the fl list stays empty and what happens to all the
> other fingerings.
>
> Any help/pointers appreciated,
> Luca
>
> #(define (Guitar_fingering_engraver context)
>    (let ((stem #f)
>          (fingering #f)
>          (fl '())
>          (old-fingering '()))
>      (make-engraver
>       (acknowledgers
>        ((finger-interface engraver grob source-engraver)
>         (begin
>           (set! fingering grob)
>           (append! fl (list grob))
>           )
>         )
>        ((stem-interface engraver grob source-engraver)
>         (set! stem grob)))
>       ((process-music engraver)
>
>        (if (and fingering stem)
>            (begin
>                (set! old-fingering (assoc-get 'fingering (ly:grob-property
> stem 'details) '()))
>                (ly:grob-set-property! stem 'details
>                                   `((fingering . ,(append old-fingering
> (list fingering)))
>                                      . ,(ly:grob-property stem 'details))))
>            )
>
>        (if stem
>            (begin
>                (display "fl ") (display fl) (display " - fingering ")
>                (display (assoc-get 'fingering (ly:grob-property stem
> 'details)))
>                (if fingering
>                    (display (ly:grob-property fingering 'text))
>                    )
>                (display "\n")))
>
>        (set! stem #f)
>        (set! fingering #f)
>        (set! fl '())))))
>
> \layout {
>   \context {
>     \Voice
>     % this makes use of the New_fingering_engraver, which attaches
> fingering in the way we want
>     \remove Fingering_engraver
>     \consists #Guitar_fingering_engraver
>   }
> }
>
> guitar = {
>     \key c \major
>     \time 2/4
>     \clef "violin_8"
>
>     <g-1 b-2 e'-4>4
>     <ges-1 bis-2 e'-4>4
> }
>
> \score {
>   \new Staff = "guitar" {
>     \key c \major
>     \time 2/4
>     \clef "violin_8"
>
>     <g-1 b-2 e'-4>4
>     <ges-1 e'-4 bis-2>4
>   }
>   \layout {  }
> }
>
> --
> Luca Fascione
>
>

Reply via email to