Pb avec une fonction scheme

J'ai du denaturer une fonction écrite par jean; Qui me permetait de coloriser les notes altérées je ne vois pas ce qui manque .

voici la fonction:

\version "2.24.4"

\layout {
  \context {
    \Voice
    \override NoteHead.color =
      #(lambda (grob)
         (let* ((event (event-cause grob))
                (pitch (ly:event-property event 'pitch))
                (alteration (ly:pitch-alteration pitch))
                (key-alterations (ly:context-property (ly:grob-context grob) 'keyAlterations))
                (staff-key-signature (ly:context-property (ly:grob-context grob) 'keySignature)))
           (if (and (not (zero? alteration))
                    (or (and (list? key-alterations) (member alteration key-alterations))
                        (and (not (list? key-alterations))
                             (or (and (eq? staff-key-signature 'sharp) (> alteration 0))
                                 (and (eq? staff-key-signature 'flat) (< alteration 0))))))
               (assq-ref (ly:grob-property grob 'details) 'altered-color)
               (ly:grob-default grob 'color))))
  }
}

Par avance merci de vous pencher sur mon problème . Je ne pense pas que jean puisse me dépaner dans son pays lointains.

Bonne journée a tous

Salut Christian !

Est-ce que ça conviendrait ?

\header {
  title = "Accidental color"
  composer = ""
  tagline = \markup {
    Engraved at
    \simple #(strftime "%Y-%m-%d" (localtime (current-time)))
    with \with-url #"http://lilypond.org/"
    \line { LilyPond \simple #(lilypond-version) (http://lilypond.org/) }
  }
}

\relative {
  \key g \major
  \override Accidental.color = "red"
  \override NoteHead.color =
  #(lambda (grob)
     (if (ly:grob-object grob 'accidental-grob #f)
         "red"
         "black"))
  c'16 d e fis g fis e cis e2
}