lilypond-user
[Top][All Lists]
Advanced

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

Re: Invisible notes, Scheme contexts


From: Erik Sandberg
Subject: Re: Invisible notes, Scheme contexts
Date: Tue, 13 Dec 2005 12:28:17 +0100
User-agent: KMail/1.8.3

On Tuesday 13 December 2005 10.55, Don Blaheta wrote:
> Quoth Han-Wen Nienhuys:
> > Don Blaheta wrote:
> > > 2) Is there a Scheme function to retrieve the _current_ context?  It
> > > looks like all the functions require a context as an argument.
> >
> > What do you mean by "current" ? Where do you need it ?
>
> The context that is enclosing the point where the Scheme function is
> called.  I guess it's probably in the location variable that is the
> second argument to a music-function, but I'm not sure how to access it
> from there.
>
> I'm actually particularly interested in getting the id of the current
> context, so I can store it in a variable and use the value of that
> variable later.  I've also been having trouble typing in such an id
> literally; if I define a music function like

If you are a guru, you may want to look at \applycontext. Normally, scheme 
functions are called before the music is interpreted, but with \applycontext, 
functions can be called during iteration. Remember that contexts only exist 
during iteration.

>   foo = #(def-music-function (parser location str) (string?)
>           #{ \context Voice = $str { \override NoteHead #'font-size = #3 }
>           #})
>
> and then include in my code
>
>   \foo "blah"
>
> I get an error
>
>   funcs.ly:26:14: error: syntax error, unexpected STRING, expecting SCM_T
> or SCM_IDENTIFIER \foo "blah
>                 "
>   error: errors found, ignoring music expression

Try 
\foo #"blah"

> I can't figure out how to convert between Scheme strings and the
> lilypond-native things that look like strings but seem to be something
> else (often a LYRICS_STRING, though not in this case).

functions can only take scheme strings as parameters
(\bar and other commands aren't generic functions, they are hardcoded 
commands; that's why a different syntax is allowed)

-- 
Erik




reply via email to

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