]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/scm-option.cc
* po/nl.po: Some updates.
[lilypond.git] / lily / scm-option.cc
index ffa343dc53c289e8d5144a9fe27d49f70559aa31..32cff36a22d6ef3cc914ba48e1a618e02404ce89 100644 (file)
@@ -1,10 +1,10 @@
-/*   
+/*
   scm-option.cc --  implement option setting from Scheme
-  
+
   source file of the GNU LilyPond music typesetter
-  
-  (c) 2001--2003  Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
+
+  (c) 2001--2004  Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
  */
 #include <stdio.h>
 
@@ -13,6 +13,7 @@
 #include "lily-guile.hh"
 #include "scm-option.hh"
 #include "warn.hh"
+#include "main.hh"
 
 /*
   This interface to option setting is meant for setting options are
@@ -24,7 +25,7 @@
   preferably, also dont use TESTING_LEVEL_GLOBAL, since it defeats
   another purpose of this very versatile interface, which is to
   support multiple debug/testing options concurrently.
-  
+
  */
 
 
@@ -45,27 +46,25 @@ bool lily_1_8_compatibility_used = false;
  */
 bool internal_type_checking_global_b;
 
+
+/*
+  What is this function for ? 
+ */
 LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
-                 "Print ly-set-option usage")
-{  
+                 "Print ly:set-option usage")
+{
   printf ( _("lilypond -e EXPR means:").to_str0 ());
   puts ("");
   printf (_ ("  Evalute the Scheme EXPR before parsing any .ly files.").to_str0 ());
   puts ("");
   printf (_ ("  Multiple -e options may be given, they will be evaluated sequentially.").to_str0 ());
   puts ("");
-  printf (_("  The function ly-set-option allows for access to some internal variables.").to_str0 ());
+  printf (_("  The function ly:set-option allows for access to some internal variables.").to_str0 ());
   puts ("\n");
-  printf (_ ("Usage: lilypond -e \"(ly-set-option SYMBOL VAL)\"").to_str0 ());
+  printf (_ ("Usage: lilypond -e \"(ly:set-option SYMBOL VAL)\"").to_str0 ());
   puts ("\n");
-  printf (_ ("Where SYMBOL VAL pair is any of:").to_str0 ());
-  puts ("");
-  printf ( "  help ANY-SYMBOL\n"
-          "  internal-type-checking BOOLEAN\n"
-          "  midi-debug BOOLEAN\n"
-          "  parse-protect BOOLEAN\n"
-          "  testing-level INTEGER\n");
-  
+  printf (_ ("Use help as  SYMBOL to get online help.").to_str0 ());
+
   exit (0);
   return SCM_UNSPECIFIED;
 }
@@ -76,7 +75,11 @@ LY_DEFINE (ly_option_usage, "ly:option-usage", 0, 0, 0, (SCM),
 don't timestamp the output
 
 @item -t,--test
-Switch on any experimental features.  Not for general public use. */
+Switch on any experimental features.  Not for general public use.
+
+*/
+
+
 LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
            "Set a global option value.  Supported options include\n"
 "\n"
@@ -91,56 +94,46 @@ LY_DEFINE (ly_set_option, "ly:set-option", 1, 1, 0, (SCM var, SCM val),
 "If protection is switched on, errors in inline scheme are caught in the parser. \n"
 "If off, GUILE will halt on errors, and give a stack trace. Default is protected evaluation. \n"
 "@item old-relative\n"
-"Relative for simultaneous functions similar to chord syntax\n"
+"Relative for simultaneous music functions similar to chord syntax\n"
 "@item new-relative\n"
-"Relative for simultaneous functions similar to sequential music\n"
+"Relative for simultaneous music functions similar to sequential music\n"
 "@end table\n"
 "\n"
 "This function is useful to call from the command line: @code{lilypond -e\n"
-"\"(ly-set-option 'midi-debug #t_)\"}.\n")
+"\"(ly:set-option 'midi-debug #t)\"}.\n")
 {
   if (val == SCM_UNDEFINED)
     val = SCM_BOOL_T;
 
   if (var == ly_symbol2scm ("help"))
-    {
-      /* lilypond -e "(ly-set-option 'help #t)" */
-      ly_option_usage (SCM_EOL);
-    }
+    /* lilypond -e "(ly:set-option 'help #t)" */
+    ly_option_usage (SCM_EOL);
   else if (var == ly_symbol2scm ("midi-debug"))
-    {
-      midi_debug_global_b = to_boolean (val);
-    }
+    midi_debug_global_b = to_boolean (val);
   else if (var == ly_symbol2scm ("testing-level"))
-    {
-     testing_level_global = gh_scm2int (val); 
-    }
+    testing_level_global = ly_scm2int (val);
   else if (var == ly_symbol2scm ("parse-protect" ))
-    {
-      parse_protect_global = to_boolean(val);
-    }
+    parse_protect_global = to_boolean (val);
   else if (var == ly_symbol2scm ("internal-type-checking"))
-    {
-     internal_type_checking_global_b = to_boolean (val); 
-    }
+    internal_type_checking_global_b = to_boolean (val);
   else if (var == ly_symbol2scm ("old-relative"))
     {
       lily_1_8_relative = true;
-      lily_1_8_compatibility_used = false; 
+      /*  Needs to be reset for each file that uses this option.  */
+      lily_1_8_compatibility_used = false;
     }
   else if (var == ly_symbol2scm ("new-relative"))
-    {
-      lily_1_8_relative = false;
-    }
+    lily_1_8_relative = false;
   else
     {
-      warning (_("Unknown internal option!"));
+      if (ly_c_symbol_p (var))
+       var = scm_symbol_to_string (var);
+      
+      warning (_f ("No such internal option: %s", ly_scm2string (var)));
     }
-
   return SCM_UNSPECIFIED;
 }
 
-
 LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
            "Get a global option setting.  Supported options include\n"
           "@table @code\n"
@@ -148,21 +141,22 @@ LY_DEFINE (ly_get_option, "ly:get-option", 1, 0, 0, (SCM var),
           "Report whether old-relative compatibility mode is necessary\n"
           "@item old-relative\n"
           "Report whether old-relative compatibility mode is used\n"
+          "@item verbose\n"
+          "Report whether we are running in verbose mode\n"
           "@end table\n"
           "\n")
 {
-  if (var == ly_symbol2scm ("old-relative-used"))
-    {
-      return gh_bool2scm (lily_1_8_compatibility_used);
-    }
-  if (var == ly_symbol2scm ("old-relative"))
-    {
-      return gh_bool2scm (lily_1_8_relative);
-    }
+  SCM o = SCM_UNSPECIFIED;
+  
+  if (var == ly_symbol2scm ("safe")) // heavily used; put in front. 
+    o = ly_bool2scm (safe_global_b);
+  else  if (var == ly_symbol2scm ("old-relative-used"))
+    o = ly_bool2scm (lily_1_8_compatibility_used);
+  else if (var == ly_symbol2scm ("old-relative"))
+    o = ly_bool2scm (lily_1_8_relative);
+  else if (var == ly_symbol2scm ("verbose"))
+    o = ly_bool2scm (verbose_global_b);
   else
-    {
-      warning (_("Unknown internal option!"));
-    }
-
-  return SCM_UNSPECIFIED;
+    warning (_f ("No such internal option: %s", ly_scm2string (var)));
+  return o;
 }