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 Backwards compatibility.
40 bool lily_1_8_relative = true;
42 crash if internally the wrong type is used for a grob property.
44 bool internal_type_checking_global_b;
46 LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
47 "Print ly-set-option usage")
49 printf ( _("lilypond -e EXPR means:").to_str0 ());
51 printf (_ (" Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
53 printf (_ (" Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
55 printf (_(" The function ly-set-option allows for access to some internal variables.").to_str0 ());
57 printf (_ ("Usage: lilypond -e \"(ly-set-option SYMBOL VAL)\"").to_str0 ());
59 printf (_ ("Where SYMBOL VAL pair is any of:").to_str0 ());
61 printf ( " help ANY-SYMBOL\n"
62 " internal-type-checking BOOLEAN\n"
63 " midi-debug BOOLEAN\n"
64 " parse-protect BOOLEAN\n"
65 " testing-level INTEGER\n");
68 return SCM_UNSPECIFIED;
73 @item -T,--no-timestamps
74 don't timestamp the output
77 Switch on any experimental features. Not for general public use. */
78 LY_DEFINE (ly_set_option, "ly:set-option", 2, 0, 0, (SCM var, SCM val),
79 "Set a global option value. Supported options include\n"
85 "If set to true, generate human readable MIDI\n"
86 "@item internal-type-checking\n"
87 "Set paranoia for property assignments\n"
88 "@item parse-protect\n"
89 "If protection is switched on, errors in inline scheme are caught in the parser. \n"
90 "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
91 "@item old-relative\n"
92 "Relative for simultaneous functions similar to chord syntax\n"
93 "@item new-relative\n"
94 "Relative for simultaneous functions similar to sequential music\n"
97 "This function is useful to call from the command line: @code{lilypond -e\n"
98 "\"(ly-set-option 'midi-debug #t)\"}.\n")
100 if (var == ly_symbol2scm ("help"))
102 /* lilypond -e "(ly-set-option 'help #t)" */
103 ly_option_usage (SCM_EOL);
105 else if (var == ly_symbol2scm ("midi-debug"))
107 midi_debug_global_b = to_boolean (val);
109 else if (var == ly_symbol2scm ("testing-level"))
111 testing_level_global = gh_scm2int (val);
113 else if (var == ly_symbol2scm ("parse-protect" ))
115 parse_protect_global = to_boolean(val);
117 else if (var == ly_symbol2scm ("internal-type-checking"))
119 internal_type_checking_global_b = to_boolean (val);
121 else if (var == ly_symbol2scm ("old-relative"))
123 lily_1_8_relative = true;
125 else if (var == ly_symbol2scm ("new-relative"))
127 lily_1_8_relative = false;
131 warning (_("Unknown internal option!"));
134 return SCM_UNSPECIFIED;