[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problems with user-defined command line options
From: |
Nicolas Sceaux |
Subject: |
Re: problems with user-defined command line options |
Date: |
Sun, 25 Dec 2011 12:17:50 +0100 |
Le 25 déc. 2011 à 09:12, Marc Hohl a écrit :
> Hello Nicolas,
>
> Am 24.12.2011 11:13, schrieb Nicolas Sceaux:
>> Le 23 déc. 2011 à 09:39, Marc Hohl a écrit :
>>
>>> #(ly:add-option 'no-slurs #f
>>> "Whether to print a slur or not.")
>> The "no-" prefix is dealt with specially for options.
>> For instance, considering an option named `foo', if you use the
>> command line switch:
>>
>> lilypond -dno-foo ...
>>
>> then (ly:get-option 'foo) will return #f
>
> Is this mentioned anywhere in the documentation? I didn't find
> anything about "no-" ...
<http://lilypond.org/doc/v2.15/Documentation/usage/command_002dline-usage#command-line-options-for-lilypond>
-d,--define-default=var=val
This sets the internal program option var to the Scheme value
val. If val is not supplied, then #t is used. To switch off an
option, no- may be prefixed to var, e.g.
-dno-point-and-click
is the same as
-dpoint-and-click='#f'
But that does not seem to work fine anyway with user defined options,
which come too late, even if defined in an init file included with -i.
> address@hidden:~/sandbox$ Lilypond -dno-foo foo.ly
> GNU LilyPond 2.15.23
> Warnung: keine solche interne Option: no-foo
> »foo.ly« wird verarbeitet
> Analysieren...
> foo option: #t
> Success: compilation successfully completed
>
> so the value remains #t in both cases, and the option
> "no-foo" is marked as an unknown interal option.
>
> What is wrong here?
How embarrassing!
I so wanted the second one to be false that I misread it!
Actually, `ly:add-option' sets the value of the option, disregarding
the command-line parameter. (Now I remember why I never use it in my
own projects.)
So here is a solution: use a without-slur option (instead of no-slur),
and do not use `ly:add-option'.
$ cat toto.ly
\version "2.15.20"
#(format #t "~%without-slur option: ~a" (ly:get-option 'without-slur))
$ lilypond toto.ly
GNU LilyPond 2.15.20
Traitement de « toto.ly »
Analyse...
without-slur option: #f
Success: compilation successfully completed
$ lilypond -dwithout-slur toto.ly
GNU LilyPond 2.15.20
Avertissement : option interne inconnue : without-slur
Traitement de « toto.ly »
Analyse...
without-slur option: #t
Success: compilation successfully completed
You will have a warning for each unrecognized option.
Re: problems with user-defined command line options, Johan Vromans, 2011/12/24