]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/main.cc
Merge with master
[lilypond.git] / lily / main.cc
index 9161511e68370b9caa46caf6e91942dab6387799..7a524d77dc8b45295c838e9079195252a7dc123d 100644 (file)
@@ -77,7 +77,7 @@ bool be_verbose_global = false;
 
 /* Scheme code to execute before parsing, after .scm init.
    This is where -e arguments are appended to.  */
-string init_scheme_code_string_global;
+string init_scheme_code_global;
 string init_scheme_variables_global;
 
 /* Generate preview of first system.  */
@@ -153,7 +153,7 @@ static Long_option_init options_static[]
   {_i ("BACK"), "backend", 'b', _i ("use backend BACK (eps, gnome, ps [default],\nscm, svg, tex, texstr)")},
 
   {_i ("SYM[=VAL]"), "define-default", 'd',
-   _i ("set Scheme option SYM to VAL (default: #t)\n"
+   _i ("set Scheme option SYM to VAL (default: #t).\n"
        "Use -dhelp for help.")},
 
   {_i ("EXPR"), "evaluate", 'e', _i ("evaluate scheme code")},
@@ -511,7 +511,7 @@ parse_argv (int argc, char **argv)
          break;
          
        case 'e':
-         init_scheme_code_string_global += option_parser->optional_argument_str0_ + string (" ");
+         init_scheme_code_global += option_parser->optional_argument_str0_ + string (" ");
          break;
        case 'w':
          warranty ();
@@ -627,3 +627,25 @@ main (int argc, char **argv)
   /* Only reachable if GUILE exits.  That is an error.  */
   return 1;
 }
+
+SCM atexit_list = SCM_EOL;
+
+LY_DEFINE (ly_atexit, "ly:atexit",
+          2, 0, 0, (SCM proc, SCM args),
+          "Just before exiting, call the procedure given. "
+"If this is called multiple times, the procedures are called "
+"in LIFO order.")
+{
+  atexit_list = scm_cons (scm_cons (proc, args), atexit_list);
+  scm_gc_protect_object (atexit_list);
+  return SCM_UNSPECIFIED;
+}
+
+LY_DEFINE (ly_do_atexit, "ly:do-atexit",
+          0, 0, 0, (),
+          "Call the atexit procedures.")
+{
+  for (SCM s = atexit_list; scm_is_pair (s); s = scm_cdr (s))
+    scm_apply_0 (scm_caar (s), scm_cdar (s));
+  return SCM_UNSPECIFIED;
+}