lilypond-user
[Top][All Lists]
Advanced

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

Re: function that inserts a toplevel expression


From: Urs Liska
Subject: Re: function that inserts a toplevel expression
Date: Thu, 10 May 2012 12:40:07 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1

Hi David,

thank you for the reply

Am 10.05.2012 12:05, schrieb David Kastrup:
Urs Liska<address@hidden>  writes:

So now the question:
How can I write a function that produces a toplevel expression?
No such thing.
:-(
I want to be able to write:

\debugCurvesOn

or

#(debug-curves-on)

(or something similar) which should then expand to

\layout {
   \context {
     \Score
     \override Slur #'stencil = #(display-control-points)
     \override PhrasingSlur #'stencil = #(display-control-points)
\override Tie #'stencil = #(display-control-points) }
}

(you see where this is going? ;-) )
debugCurvesOn = \layout {
    \context {
      \Score
      \override Slur #'stencil = #(display-control-points)
      \override PhrasingSlur #'stencil = #(display-control-points)
  \override Tie #'stencil = #(display-control-points) }
}

That created a layout definition (more accurately: an output definition
suitable for use in layouts).  Which can be used in \layout:

\layout { \debugCurvesOn  [Other stuff ...] }
OK, instead of

\debugCurvesOn

I now have to insert

\layout { \debutCurvesOn }

in my main file.
It is not perfectly what I had hoped for, but it's fine nevertheless (definitely better than the current solution).
So we may consider this as solved.
If you want to turn this into a function, you use define-scheme-function
and construct the return value using #{ \layout { ... } #}.
Not necessary anymore. But I think I see now better how this works.

Furthermore I will later want to write functions for the \score block,
and I will want to pass some parameters in there - which doesn't work
with include files.
Not clear to me what you want.

I wanted to be able to write

\liedScore "Stimme" "Klavier"
or
\liedScore "Voice" "Piano"
and get back the respective \score block with the parameters substituted.
But from your answers to the other part of the question I now know that this isn't possible.

Probably I'll look for a solution through defining a variable and then including the file with the \score definition. For the project at hand it's not necessary because I can have the score block be hardcoded. But I want to distill a more generic library/framework for use after this project.

Thanks again
Urs



reply via email to

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