lilypond-devel
[Top][All Lists]
Advanced

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

Scheme pattern for retrieving data in objects


From: Jean Abou Samra
Subject: Scheme pattern for retrieving data in objects
Date: Fri, 1 Apr 2022 18:43:10 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

Folks,

Just a random thought in passing: I just wrote something of this kind once again:

(let ((elements (ly:music-property m 'elements))
      (element (ly:music-property m 'element))
      (articulations (ly:music-property m 'articulations)))
  ...)

(let ((padding (assoc-ref details 'padding))
      (common-Y (assoc-ref details 'common-Y)))
  ...)

(let ((padding (ly:grob-property grob 'padding)
      (shorten-pair (ly:grob-property grob 'shorten-pair))
      (normalized-endpoints (ly:grob-property grob 'normalized-endpoints)))
  ...)


Does anyone find a value in defining a macro for this?


\version "2.23.8"

#(define-syntax-rule (fetch obj getter (sym ...) body body* ...)
   (let ((evald-obj obj)
         (evald-getter getter))
     (let ((sym (getter obj 'sym))
           ...)
       body body* ...)))
{
  c'1
  \tweak after-line-breaking
    #(lambda (grob)
       (fetch grob ly:grob-property (left-bound-info)
         (fetch left-bound-info assoc-ref (common-Y X padding attach-dir)
           (ly:message "common-Y=~a X=~a padding=~a attach-dir=~a" common-Y X padding attach-dir))))
  \startTextSpan
  c'1\stopTextSpan
}


Jean



reply via email to

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