Le 29/12/2021 à 09:45, Lukas-Fabian Moser a écrit :

A cleaner and more surgical solution would be:

\version "2.18"

#(assoc-set! (assoc-ref default-script-alist "tenuto") 'padding 0.5)

\new Staff {
  \relative c'' {\time 3/4 a g e--}
}

Although this approach manipulates internal data structures of LilyPond, it has the advantage of dealing with your issue at the root and not causing side effects for other scripts. Unfortunately, this approach does not work directly for the (still experimental) LilyPond builds using Guile2.



Be mindful that assoc-set! is not guaranteed to
mutate its input. You're not the first one tripped
up by this API quirk :-)  See
https://www.gnu.org/software/guile/manual/html_node/Adding-or-Setting-Alist-Entries.html.
I'm occasionally using helpers like the following
to set values in nested alists:

\version "2.22.1" % also works in 2.18 and with Guile 2

#(use-modules (ice-9 match))
#(define (set-path path value alist)
   (let loop ((path path)
              (copy (copy-tree alist)))
       (match path
         (() value)
         ((p . rest)
          (assoc-set! copy p (loop rest (assoc-get p copy '())))))))

\layout {
  \context {
    \Score
    scriptDefinitions = #(set-path '("tenuto" padding) 0.5 default-script-alist)
  }
}

{
  \relative c'' {\time 3/4 a g e--}
}

Regards,
Jean


Reply via email to