lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Immutable Properties


From: Bret Whissel
Subject: Immutable Properties
Date: Tue, 25 Mar 2025 11:48:53 -0400
User-agent: Evolution 3.44.4-0ubuntu2

Hi, Devs.

I'm running lilypond from Git sources, so I'm currently using v2.25.26.

I had written a function so that I could globally tweak some 'padding'
settings for a few articulations:

tweakartprop =
#(define-void-function
  (art prop val) 
  (symbol? symbol? scheme?)
  (let*
   ((ent (assoc art default-script-alist))
    (props (if ent (cdr ent) #f)))
   (if props
    (if (assoc prop props)
     (begin
      (set! props (assoc-set! props prop val))
      (set! default-script-alist (assoc-set! default-script-alist art props)))
     (ly:warning "tweakartprop: Unknown property ~s for articulation ~s, 
ignored"
      prop art))
    (ly:warning "tweakartprop: Unknown articulation ~s, ignored" art))))

\tweakartprop tenuto padding 0.4
[... more tweaks as desired ...]

This worked fine until I updated my repo to the latest sources, and now
I get this error:

Parsing...ERROR: In procedure assoc-set!:
In procedure set-cdr!: Wrong type argument in position 1 (expecting
mutable pair): (padding . 0.2)

After some research, I found that guile/scheme now treats this as an
error because of how the A-list in defined, as if it's a constant, so
elements of the A-list are no longer mutable. This is not unreasonable,
but it does make it more difficult to adjust these settings.

To work around this behavior, I now make a deep copy of the original A-
list, and work from that:

#(use-modules (ice-9 copy-tree))

newScriptAlist = #(copy-tree default-script-alist)

tweakartprop =
#(define-void-function
  (art prop val) 
  (symbol? symbol? scheme?)
  (let*
   ((ent (assoc art newScriptAlist))
    (props (if ent (cdr ent) #f)))
   (if props
    (if (assoc prop props)
     (begin
      (set! props (assoc-set! props prop val))
      (set! newScriptAlist (assoc-set! newScriptAlist art props)))
     (ly:warning "tweakartprop: Unknown property ~s for articulation
~s, ignored"
      prop art))
    (ly:warning "tweakartprop: Unknown articulation ~s, ignored"
art))))

\tweakartprop tenuto padding 0.4
[... more tweaks as desired ...]

\layout {
  \context {
    \Score

    scriptDefinitions = #newScriptAlist
  }
}

So this works to my satisfaction.

But is there a better way to address this? or given the new behavior
for static definitions, is there something that should be changed in
how lilypond makes these definitions initially?

With kind regards and deep respect for what you all have accomplished
with LilyPond,
Bret Whissel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]