> On Feb 25, 2016, at 12:28 PM, tisimst <[email protected]> wrote:
>
> David,
>
> On Thu, Feb 25, 2016 at 9:55 AM, David Kastrup [via Lilypond] <[hidden email]
> <x-msg://5/user/SendEmail.jtp?type=node&node=187724&i=0>> wrote:
> tisimst <[hidden email]
> <http://user/SendEmail.jtp?type=node&node=187722&i=0>> writes:
>
> > David,
> >
> > On Thu, Feb 25, 2016 at 9:28 AM, David Kastrup [via Lilypond] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=187722&i=1>>
> > wrote:
> >
> >> Abraham Lee <[hidden email]
> >> <http:///user/SendEmail.jtp?type=node&node=187720&i=0
> >> <http://user/SendEmail.jtp?type=node&node=187720&i=0>>> writes:
>
> >>
> >> > All,
> >> >
> >> > In the docs are numerous sections that discuss how to modify context
> >> > properties. This is not complicated. However, a handful of recent
> >> threads
> >> > on the user list have got me wondering about the correct way(s) of
> >> > _accessing_ these properties within, for example, a music function. The
> >> > music function may or may not modify the same or another context
> >> property.
> >> > If music functions are NOT the way to go, then what is preferred?
> >> >
> >> > Thanks, in advance, for all insights and instruction.
> >>
> >> I have no idea what you want. Music functions are called when parsing
> >> LilyPond source code. At that time, there are no contexts and no
> >> context properties. Consequently, music functions have no way
> >> whatsoever to read or modify context properties. All they can do is
> >> create music expressions (typically overrides or applyContext calls,
> >> possibly as context modifications) that contain callbacks of some form
> >> that, when ultimately called during iteration of the music expression,
> >> will be able to access actual properties.
> >>
> >> So for your actual question, there is little insight and instruction to
> >> be had.
> >
> >
> > Thanks for your response. That helps knowing that music functions cannot
> > read or modify context properties.
> >
> > Let me give some examples of what I might want to do:
> >
> > 1. Determine the currentBarNumber in order to print a custom stencil
> > 2. Access the System or Staff's vertical position on the page in order to
> > change it
> > 3. Determine which page I'm on so I can print a particular stencil on that
> > page only
> > 4. Determine the current time signature so I can create a MMR of the exact
> > size needed to fill a measure
> > etc.
> All of that cannot be done from within a music function. I repeat: All
> they can do is create music expressions (typically overrides or
> applyContext calls, possibly as context modifications) that contain
> callbacks of some form that, when ultimately called during iteration of
> the music expression, will be able to access actual properties.
>
> That has nothing to do with music functions at all but rather with the
> kind of music expressions you'd want the music function to create.
>
> I got that from your first message. I promise. I just am not sure what this
> means. Can you point me to a snippet (in the LSR?) that shows this? That
> would help a lot.
>
> > These are just examples and I'm not even asking for specifics on how
> > to do these (as they've partially been discussed in other
> > threads). What approach would I want to follow in order to access the
> > properties so I could make a change elsewhere?
>
> Have you read what I wrote? Music functions are not able to access
> properties. Various music expressions (possibly created by music
> functions) may contain callbacks that might be used for such purposes.
>
> Thanks you for your reply. Yes, I definitely read what you wrote. I realize
> that music functions aren't the way to go and you've made that perfectly
> clear. I didn't even mean to imply in my previous response that I wanted to
> do those things with music functions. I don't care what the mechanism is. I
> just want to know what it is! That is exactly why I asked "what approach
> would I follow in order to access the properties so I could make a change
> elsewhere?". I have no idea where your statements are supposed to be leading
> me. I'd really like to know, though. Would you be kind enough to show how YOU
> would access a context property and use its value in an grob override?
> Perhaps it's too dependent on what I'd actually like to do. If so, knowing
> that helps, too.
>
> I'm asking this because I know that if I can get my hands on a grob, I know
> how to access its properties (with ly:grob-property) and use that property's
> value to make a change if I want (e.g., with ly:grob-set-property!). I just
> don't know the equivalent process for getting my hands on a context to access
> its properties. I know there's ly:context-property, but I just don't have as
> much experience with it as normal grobs.
>
> Now, when you say a music expression that contains callbacks might be used,
> do you mean like this (Warning: made-up, non-functional pseudo-code ahead):
>
> %%%%%%%
>
> test = { \applyContext ... (get currentBarNumber, change MMR stencil using
> currentBarNumber set bar number visibility, etc.) ... }
>
> { c1 \test R1*2 d2 e }
>
> %%%%%%%
>
> Best,
> Abraham
>
> View this message in context: Re: Accessing Context Properties
> <http://lilypond.1069038.n5.nabble.com/Accessing-Context-Properties-tp187719p187724.html>
> Sent from the User mailing list archive
> <http://lilypond.1069038.n5.nabble.com/User-f3.html> at Nabble.com.
> _______________________________________________
> lilypond-user mailing list
> [email protected]
> https://lists.gnu.org/mailman/listinfo/lilypond-user
Abraham,
Is this the sort of thing you’re looking for?
http://www.lilypond.org/doc/v2.18/Documentation/extending/callback-functions
<http://www.lilypond.org/doc/v2.18/Documentation/extending/callback-functions>
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user