lilypond-common-includes/scm/resolve_inherits.scm

22 lines
947 B
Scheme
Raw Permalink Normal View History

(define (resolve-inherit-entry-in-list alist entry)
2024-11-02 19:58:15 +01:00
(let* ((key (car entry))
(attributes (cdr entry))
(inherits (assoc-ref attributes "inherits")))
(if inherits
(let* ((alist-without-entry (alist-delete key alist))
(inherit-entry (assoc inherits alist-without-entry))
(inherits-attributes (if inherit-entry (alist-copy (cdr (resolve-inherit-entry-in-list alist-without-entry inherit-entry)))))
(override-attributes (alist-delete "inherits" attributes)))
(if inherit-entry
(begin
(for-each (lambda (attribute) (assoc-set! inherits-attributes (car attribute) (cdr attribute))) override-attributes)
(cons key inherits-attributes)
)
(ly:error "~a can not inherit from ~a" key inherits))
)
entry
)))
(define (resolve-inherits alist)
2024-11-02 19:58:15 +01:00
(map (lambda (entry) (resolve-inherit-entry-in-list alist entry)) alist)
)