2 scm-option.cc -- implement option setting from Scheme
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "parse-scm.hh"
13 #include "lily-guile.hh"
14 #include "scm-option.hh"
18 This interface to option setting is meant for setting options are
19 useful to a limited audience. The reason for this interface is that
20 making command line options clutters up the command-line option name
24 preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats
25 another purpose of this very versatile interface, which is to
26 support multiple debug/testing options concurrently.
31 /* Write midi as formatted ascii stream? */
32 bool midi_debug_global_b
;
34 /* General purpose testing flag */
35 int testing_level_global
;
38 crash if internally the wrong type is used for a grob property.
40 bool internal_type_checking_global_b
;
42 LY_DEFINE (ly_option_usage
, "ly:option-usage", 0, 0, 0, (SCM
),
43 "Print ly-set-option usage")
45 printf ( _("lilypond -e EXPR means:").to_str0 ());
47 printf (_ (" Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
49 printf (_ (" Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
51 printf (_(" The function ly-set-option allows for access to some internal variables.").to_str0 ());
53 printf (_ ("Usage: lilypond -e \"(ly-set-option SYMBOL VAL)\"").to_str0 ());
55 printf (_ ("Where SYMBOL VAL pair is any of:").to_str0 ());
57 printf ( " help ANY-SYMBOL\n"
58 " internal-type-checking BOOLEAN\n"
59 " midi-debug BOOLEAN\n"
60 " parse-protect BOOLEAN\n"
61 " testing-level INTEGER\n");
64 return SCM_UNSPECIFIED
;
69 @item -T,--no-timestamps
70 don't timestamp the output
73 Switch on any experimental features. Not for general public use. */
74 LY_DEFINE (ly_set_option
, "ly:set-option", 2, 0, 0, (SCM var
, SCM val
),
75 "Set a global option value. Supported options include\n"
81 "If set to true, generate human readable MIDI\n"
82 "@item internal-type-checking\n"
83 "Set paranoia for property assignments\n"
84 "@item parse-protect\n"
85 "If protection is switched on, errors in inline scheme are caught in the parser. \n"
86 "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
89 "This function is useful to call from the command line: @code{lilypond -e\n"
90 "\"(ly-set-option 'midi-debug #t)\"}.\n")
92 if (var
== ly_symbol2scm ("help"))
94 /* lilypond -e "(ly-set-option 'help #t)" */
95 ly_option_usage (SCM_EOL
);
97 else if (var
== ly_symbol2scm ("midi-debug"))
99 midi_debug_global_b
= to_boolean (val
);
101 else if (var
== ly_symbol2scm ("testing-level"))
103 testing_level_global
= gh_scm2int (val
);
105 else if (var
== ly_symbol2scm ("parse-protect" ))
107 parse_protect_global
= to_boolean(val
);
109 else if (var
== ly_symbol2scm ("internal-type-checking"))
111 internal_type_checking_global_b
= to_boolean (val
);
113 else if (var
== ly_symbol2scm ("find-old-relative"))
116 Seems to have been broken for some time!
118 @item -Q,--find-old-relative
119 show all changes needed to convert a file to relative octave syntax.
128 warning (_("Unknown internal option!"));
131 return SCM_UNSPECIFIED
;