]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.7
authorfred <fred>
Tue, 26 Mar 2002 22:43:39 +0000 (22:43 +0000)
committerfred <fred>
Tue, 26 Mar 2002 22:43:39 +0000 (22:43 +0000)
lily/lily-guile.cc
lily/paper-outputter.cc

index 20f470b0bd274d327e7327f067516a6140150333..c88ba15d4869158c0572a3193962e4c21fae8573 100644 (file)
@@ -96,7 +96,15 @@ ly_parse_scm (char const* s, int* n)
 SCM
 ly_quote_scm (SCM s)
 {
+#if 0
+  /*
+    This internal quote symbol breaks list->string and display,
+    and thus scm output.
+   */
   return scm_m_quote (scm_cons2 (SCM_EOL, s, SCM_EOL) ,SCM_EOL);
+#else
+  return gh_list (ly_symbol2scm ("quote"), s, SCM_UNDEFINED);
+#endif
 }
 
 
index 293475c0d6851b0f0b74ed80840ff33a21a2d80a..dea59e6cf18ba29746f85b57368c5696431f4742 100644 (file)
@@ -131,41 +131,78 @@ Paper_outputter::output_scheme (SCM scm)
 
 
 void
-Paper_outputter::dump_onto (Paper_stream *os)
+Paper_outputter::dump_onto (Paper_stream *ps)
 {
-  
-  if (output_global_ch == String ("scm"))
-    *os << ""
-      "(primitive-load-path 'lily.scm)\n"
-      "(eval (tex-scm 'all-definitions))\n"
-      ";(eval (ps-scm 'all-definitions))\n"
-      "(display (map (lambda (x) (string-append (eval x) \"\\n\")) '(\n"
-    ;
-
-  for (SCM s = gh_cdr (molecules_); gh_pair_p (s); s = gh_cdr (s))
+  if (String (output_global_ch) == "scm")
+#if 1  // both are fine
+    {
+      /*
+        default to stdin
+       */
+      int fd = 1;
+      if (ofstream* of = dynamic_cast<ofstream*> (ps->os))
+       fd = of->rdbuf ()->fd ();
+      SCM port = scm_fdes_to_port (fd, "a", SCM_EOL);
+
+      /*
+        lilypond -f scm x.ly
+        guile -s x.scm
+       */
+      scm_display (gh_str02scm (
+       ";;; Usage: guile -s x.scm > x.tex\n"
+       "(primitive-load-path 'lily.scm)\n"
+       "(scm-tex-output)\n"
+       ";(scm-ps-output)\n"
+       "(map (lambda (x) (display (eval x))) '(\n"
+       ), port);
+
+      SCM newline = gh_str02scm ("\n");
+      for (SCM s = gh_cdr (molecules_); gh_pair_p (s); s = gh_cdr (s))
+        {
+         scm_write (gh_car (s), port);
+         scm_display (newline, port);
+         scm_flush (port);
+       }
+      scm_display (gh_str02scm (")))"), port);
+      scm_display (newline, port);
+      scm_flush (port);
+      scm_close_port (port);
+    }
+#else
     {
-      if (String (output_global_ch) == "scm")
+      /*
+        lilypond -f scm x.ly
+        guile -s x.scm
+       */
+      if (output_global_ch == String ("scm"))
+       *ps << ""
+         ";;; Usage: guile -s x.scm > x.tex\n"
+         "(primitive-load-path 'lily.scm)\n"
+         "(scm-tex-output)\n"
+         ";(scm-ps-output)\n"
+         "(map (lambda (x) (display (eval x))) '(\n"
+       ;
+      for (SCM s = gh_cdr (molecules_); gh_pair_p (s); s = gh_cdr (s))
        {
          SCM result =  scm_eval (scm_listify (ly_symbol2scm ("scm->string"),
                                               ly_quote_scm (gh_car (s)), SCM_UNDEFINED));
          
-         *os << ly_scm2string (result);
+         *ps << ly_scm2string (result);
        }
-      else
+      *ps << ")))";
+    }
+#endif
+  
+  else
+    {
+      for (SCM s = gh_cdr (molecules_); gh_pair_p (s); s = gh_cdr (s))
        {
          SCM result = scm_eval (gh_car (s));
          char *c=gh_scm2newstr (result, NULL);
          
-         *os << c;
+         *ps << c;
          free (c);
        }
-
-    }
-
-
-  if (String (output_global_ch) == "scm")
-    {
-      *os << ")))";
     }
 }