lilypond-user
[Top][All Lists]
Advanced

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

Re: Need help with Scheme code


From: Aaron Hill
Subject: Re: Need help with Scheme code
Date: Tue, 17 Dec 2019 17:07:07 -0800
User-agent: Roundcube Webmail/1.3.8

On 2019-12-17 4:21 pm, Paolo Prete wrote:
Hi Stefano,

unfortunately, it doesn't increment the counter globally, and the two ids
in the SVG file are identical

You will need to define a music function so that the (serial) procedure is called on each occurrence. Here's an option that rolls in the counter logic:

%%%%
\version "2.19.83"

token = #(let* ((ctr 0) (ctr! (lambda () (set! ctr (1+ ctr)) ctr)))
  (define-music-function (mus) (ly:music?)
    (let ((id (format #f "foobar_~a" (ctr!))))
      #{ \tweak output-attributes #`((id . ,id)) #mus #})))

\relative { c'4 d8 -\token [ e ] f -\token [ g ] c,4 }
%%%%


-- Aaron Hill



reply via email to

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