*** empty log message ***
[lilypond.git] / lily / scm-option.cc
blobd05f3a06f94798fab16484505c85940ab7551023
1 /*
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>
8 */
9 #include <stdio.h>
11 #include "parse-scm.hh"
12 #include "string.hh"
13 #include "lily-guile.hh"
14 #include "scm-option.hh"
15 #include "warn.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
21 space.
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 ());
46 puts ("");
47 printf (_ (" Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
48 puts ("");
49 printf (_ (" Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
50 puts ("");
51 printf (_(" The function ly-set-option allows for access to some internal variables.").to_str0 ());
52 puts ("\n");
53 printf (_ ("Usage: lilypond -e \"(ly-set-option SYMBOL VAL)\"").to_str0 ());
54 puts ("\n");
55 printf (_ ("Where SYMBOL VAL pair is any of:").to_str0 ());
56 puts ("");
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");
63 exit (0);
64 return SCM_UNSPECIFIED;
67 /* Add these as well:
69 @item -T,--no-timestamps
70 don't timestamp the output
72 @item -t,--test
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"
76 "\n"
77 "@table @code\n"
78 "@item help\n"
79 "List all options.\n"
80 "@item midi-debug\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"
87 "@end table\n"
88 "\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.
126 else
128 warning (_("Unknown internal option!"));
131 return SCM_UNSPECIFIED;