[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: \omit multiple/list
From: |
David Kastrup |
Subject: |
Re: \omit multiple/list |
Date: |
Thu, 05 Sep 2024 17:51:30 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Kieren MacMillan <kieren@kierenmacmillan.info> writes:
> Hi Damian,
>
>> how would I reduce e.g.
>>
>> \once \omit TupletBracket
>> \once \omit TupletNumber
>> \once \omit Stem
>>
>> to a structure conceptually like:
>>
>> \once \omit (TupletBracket, TupletNumber, Stem)
>>
>> i.e. put the grobs in a list
>
> Maybe something like this (but something that actually works LOL):
>
> %%% SNIPPET BEGINS
> \version "2.25.11"
>
> omitt =
> #(define-scheme-function (groblist) (grob-list?)
> (for-each
> (lambda (gr)
> #{ \omit gr #})
> groblist))
>
> \omitt #'(TimeSignature NoteHead)
> %%% SNIPPET ENDS
How about
omitt =
#(define-music-function (groblist) (symbol-list?)
#{ #@(map omit (map list groblist)) #})
\void \displayLilyMusic \omitt TimeSignature,NoteHead
I'll admit that the need for the "map list" surprised me. You can of
course write the non-surprising
omitt =
#(define-music-function (groblist) (symbol-list?)
#{ #@(map (lambda (gr) #{ \omit $gr #}) groblist) #})
\void \displayLilyMusic \omitt TimeSignature,NoteHead
> This snippet “works”, in that it iterates through the list and correctly
> outputs the grob name:
>
> %%% SNIPPET BEGINS
> omitt =
> #(define-scheme-function (groblist) (list?)
> (for-each
> (lambda (gr)
> (ly:message
> (format #f "~y" gr)))
> groblist))
>
> \omitt #'(TimeSignature NoteHead)
> %%% SNIPPET ENDS
>
> I’m just not sure the precise incantation to make the first snippet Do
> The Right Thing™.
You need to return music (instead of pretending that calling omit will
achieve anything by side-effect).
And of course you need a music function.
--
David Kastrup