lilypond-user
[Top][All Lists]
Advanced

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

Re: macro for \once\override


From: David Kastrup
Subject: Re: macro for \once\override
Date: Sat, 29 Aug 2020 19:38:11 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Aaron Hill <lilypond@hillvisions.com> writes:

> On 2020-08-29 6:44 am, David Kastrup wrote:
>> Hm.  \with instead of = would even fit into the parser.  But that
>> leaves
>> tweaks in the lurch.
>
> Not sure I am following.  Are you indicating that something like...
>
> %%%%
>   \once \override LaissezVibrerTie.details
>     \with { ratio = #0.5 height-limit = #2 }
>   b'4\laissezVibrer
> %%%%
>
> ...could be made to work

By changing the parser.

> but not...
>
> %%%%
>   b'4
>     -\tweak details \with { ratio = #0.5 height-limit = #2 }
>     \laissezVibrer
> %%%%
>
> ?

Well, \with ... is a valid expression, so this would already be
syntactically accepted by LilyPond.  How do you distinguish tweaking an
alist intelligently with just setting a property to a context mod?

> Another thought is whether nested use of \with makes sense.  Consider:
>
> %%%%
> \version "2.20.0"
>
> overrideII =
> #(define-music-function
>   (prop mods)
>   (key-list? ly:context-mod?)
>   (define (assign? mod) (eq? 'assign (car mod)))
>   (define (overrides prop mods)
>     (append-map
>       (lambda (mod)
>         (let ((subprop (cadr mod))
>               (value (caddr mod)))
>           (if (ly:context-mod? value)
>             (overrides (append prop (list subprop)) value)
>             (list #{ \override #prop . #subprop = #value #}))))
>       (filter assign? (ly:get-context-mods mods))))
>   #{ #@(overrides prop mods) #})
>
> \include "predefined-guitar-fretboards.ly"
> \storePredefinedDiagram #default-fret-table \chordmode { c' }
>                         #guitar-tuning
>                         #"x;1-1-(;3-2;3-3;3-4;1-1-);"
> <<
>   \new ChordNames {
>     \chordmode { c1 | c | c | d }
>   }
>   \new FretBoards {
>     % Set global properties of fret diagram
>     \overrideII FretBoard \with {
>       size = #1.2
>       fret-diagram-details = \with {
>         finger-code = #'in-dot
>         dot-color = #'white
>       }
>     }
>     \chordmode {
>       c
>       \once \overrideII FretBoard \with {
>         size = #1.0
>         fret-diagram-details = \with {
>           barre-type = #'straight
>           dot-color = #'black
>           finger-code = #'below-string
>         }
>       }
>       c'
>       \once \overrideII FretBoard.fret-diagram-details
>         \with {
>           barre-type = #'none
>           number-type = #'arabic
>           orientation = #'landscape
>           mute-string = #"M"
>           label-dir = #LEFT
>           dot-color = #'black
>         }
>       c'
>       \once \overrideII FretBoard.fret-diagram-details
>         \with {
>           finger-code = #'below-string
>           dot-radius = #0.35
>           dot-position = #0.5
>           fret-count = #3
>         }
>       d
>     }
>   }
>   \new Voice {
>     c'1 | c' | c' | d'
>   }
>>> 
> %%%%
>
> Is this pushing things too far?

Well, essentially a similar problem.  How do you figure out the
difference between setting something to a context mod, and making a
smart alist modification?

-- 
David Kastrup



reply via email to

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