[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SVG export - how might you add classes for all graphical objects?
From: |
David Kastrup |
Subject: |
Re: SVG export - how might you add classes for all graphical objects? |
Date: |
Tue, 29 Jun 2021 22:45:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Aaron Hill <lilypond@hillvisions.com> writes:
> On 2021-06-29 1:20 pm, David Kastrup wrote:
>>> %%%%
>>> \version "2.22.0"
>>> SvgAddClassName =
>>> #(lambda (ctxt)
>>> (define (add-class-name grob)
>>> (let* ((attribs (ly:grob-property grob 'output-attributes '()))
>>> (class (ly:assoc-get 'class attribs '()))
>>> (name (grob::name grob)))
>>> (set! class (if (null? class) name (format #f "~a ~a" class
>>> name)))
>>> (set! attribs (assoc-set! attribs 'class class))
>>> (ly:grob-set-property! grob 'output-attributes attribs)))
>>> (make-engraver
>>> (acknowledgers
>>> ((grob-interface engraver grob source)
>>> (add-class-name grob)))))
>> That assoc-set! looks like a stinker. Doesn't it mess with shared
>> data
>> structures?
>
> Hrm... would it be better to explicitly alist-copy the result from
> ly:assoc-get? Actually, I guess you could do:
>
> ;;;;
> (alist-cons 'class ... (alist-delete 'class attribs))
> ;;;;
Either that or not even bother about deleting the other entry.
> ...since the SRFI says that alist-delete does not modify the original
> structure, only that it might return an alist with a common tail.
>
> And on this point, should LilyPond provide an ly:assoc-set to pair
> with ly:assoc-get that avoids potential issues with shared structures?
I am not sure that we'd want our own modifiers for basic data
structures. Though there may be a point in unifying hash tables,
association lists, vectors into a common data structure and provide
caching accessors for that.
I mean, stuff like notename languages and drum tables and so are already
an awkward mixture.
--
David Kastrup
- SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Carl Sorensen, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Jean Abou Samra, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, David Kastrup, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Aaron Hill, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?,
David Kastrup <=
- Re: SVG export - how might you add classes for all graphical objects?, Aaron Hill, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Carl Sorensen, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, David Kastrup, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Jean Abou Samra, 2021/06/29
- Re: SVG export - how might you add classes for all graphical objects?, Jean Abou Samra, 2021/06/29
- Message not available
- Fwd: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29
Re: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29
Re: SVG export - how might you add classes for all graphical objects?, Matt Hood, 2021/06/29