[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Defining shortcuts for scheme code
From: |
Nicolas Sceaux |
Subject: |
Re: Defining shortcuts for scheme code |
Date: |
Wed, 22 Feb 2006 09:18:21 +0100 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) |
Erik Sandberg <address@hidden> writes:
> On Thursday 16 February 2006 13.14, Thies Albrecht wrote:
>> Hi everybody!
>>
>> To prevent having to use extensive scheme code inside my score I prefer
>> to define shortcuts for often used code snippets, e.g. when setting
>> ottavation on and off.
>>
>> In the following code example Point'n'click is turned off also IMHO I
>> have only defined the shortcut without using it. Now I wonder if my way
>> of defining shortcuts is okay or if I've misunderstood the documentation
>> on that.
>
> Unfortunately, the threshold for understanding how Scheme works in lilypond
> is
> rather high (or, at least it was for me).
>
> As soon as a #() expression is found in a ly file, it is evaluated (this
> happens _while_ the file is parsed). So in this case, what you really want to
> store in a variable, is a _function_ which sets the option accordingly:
> noPnC = #(def-music-function (parser location) (ly:set-option ...))
>
> When \noPnC is found in the score, that function will be called, and the
> option will be set.
To avoid a "warning: no music found in score", I'd even do (in LilyPond
2.7.3x):
noPnC = #(def-music-function (parser location) ()
(ly:set-option 'point-and-click #f)
(make-music 'SequentialMusic 'void #t))
\noPnC