lilypond-devel
[Top][All Lists]

## Re: [PATCH] autochange.scm: Use averaged chord pitches to determinestaf

 From: Neil Puttock Subject: Re: [PATCH] autochange.scm: Use averaged chord pitches to determinestaff. Date: Tue, 28 Jul 2009 22:12:05 +0100

2009/7/28 Mark Polesky <address@hidden>:

> I intend to define a new context-property called
> "autochangeMargin" so that the user can do this sort of thing:
>
> \new PianoStaff \autochange \relative {
>  \set autochangeMargin = #2
>  c8 d e f g f e d
>  c b a g f g a b
>  c d e f g f e d
> }

Making this a context property would imply some kind of relationship
with an engraver, so I don't think it's appropriate here.

>
> However, I can't figure out how to do that. I understand that I need
> to:
>
> 1) add an entry to define-context-properties.scm
> 2) maybe initialize a value somewhere in engraver-init.ly (?)

This would be the right approach; you'd probably set the property in
the Score definition.

> ie. passing the location argument to the function, with the vague idea
> that somehow the location argument would get me closer to the context.

I think location' is mainly used to indicate the position in a file
where an error occurred, so you're unlikely to get anything useful
from it.

>
> Can someone please tell me how to get the context in this situation,
> so that I can do this:
>
>  (define margin (ly:context-property context 'autochangeMargin))

It might be possible using ApplyContext, but it's such a convoluted
way of accessing a property that you're better off creating a parser
variable (with the limitation that you couldn't set it within the
music) or passing the value directly through the music function (which
means changing the signature of the function, requiring a convert
rule).

Regards,
Neil

`