From 508a9588e53be24ee4d4fd0c905152b4929d85ea Mon Sep 17 00:00:00 2001
From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Wed, 10 Mar 2004 01:39:59 +0000
Subject: [PATCH] * lily/score.cc (default_rendering): clean protection.

* lily/paper-book.cc (mark_smob): implement smob marking.
---
 ChangeLog                                     |  4 +++
 Documentation/user/changing-defaults.itely    |  9 +----
 Documentation/user/lilypond-book.itely        | 16 +++++++++
 Documentation/user/notation.itely             |  2 +-
 .../user/programming-interface.itely          |  6 ++--
 lily/include/paper-book.hh                    |  7 +---
 lily/input-file-results.cc                    |  8 +++--
 lily/paper-book.cc                            | 34 +++++++++----------
 lily/score.cc                                 |  9 +----
 9 files changed, 49 insertions(+), 46 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d1cb760472..a47a52b1bb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2004-03-10  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+	* lily/score.cc (default_rendering): clean protection.
+
+	* lily/paper-book.cc (mark_smob): implement smob marking.
+
 	* scripts/lilypond.py (make_html_menu_file): remove --psgz option
 
 	* Documentation/user/*.itely: user manual edits. 
diff --git a/Documentation/user/changing-defaults.itely b/Documentation/user/changing-defaults.itely
index 711c426e36..439af71b37 100644
--- a/Documentation/user/changing-defaults.itely
+++ b/Documentation/user/changing-defaults.itely
@@ -404,12 +404,6 @@ The back-end is not very strict in type-checking object properties.
 Cyclic references in Scheme values for properties can cause hangs
 and/or crashes.
 
-@menu
-* Constructing a tweak::        
-* Applyoutput::                 
-* Font selection::              
-* Text markup::                 
-@end menu
 
 @node Constructing a tweak
 @subsection Constructing a tweak
@@ -647,8 +641,7 @@ is a  symbol indicating the series of the font. There are typically several
 font series for each font family and shape. Choices are @code{medium}
 and @code{bold}. 
 
-@end table
-
+@end itemize
 
 Fonts selected in the way sketched above come from a predefined style
 sheet.
diff --git a/Documentation/user/lilypond-book.itely b/Documentation/user/lilypond-book.itely
index 6804502182..92f1d8083d 100644
--- a/Documentation/user/lilypond-book.itely
+++ b/Documentation/user/lilypond-book.itely
@@ -329,6 +329,22 @@ documents are composed from small @file{.ly} files in this way:
 @item relative, relative=@var{N}
 uses relative octave mode.  By default, notes are specified relative
 to middle C.  The optional integer argument specifies the octave of the
+@item relative, relative=@var{N}
+uses relative octave mode.  By default, notes are specified relative
+to middle C.  The optional integer argument specifies the octave of the
+starting note, where the default @code{1} is middle C.
+@end table
+
+
+@node Invoking lilypond-book
+@section Invoking lilypond-book
+
+
+Running @command{lilypond-book} generates lots of small files that
+LilyPond will process.  To avoid all that garbage in the source
+directory use the @option{--output} command line option, and change to
+that directory before running La@TeX{} or @file{makeinfo}:
+
 @example
 lilypond-book --output=out yourfile.lytex
 cd out && latex yourfile.tex
diff --git a/Documentation/user/notation.itely b/Documentation/user/notation.itely
index cc9a6f58bb..f97d8025ef 100644
--- a/Documentation/user/notation.itely
+++ b/Documentation/user/notation.itely
@@ -7304,7 +7304,7 @@ The following are supported
         r
     }
     \context Lyrics \lyrics {
-    \override LyricText #'font = #'typewriter
+    \override LyricText #'font-family = #'typewriter
       "shortfermata" "fermata"  "longfermata" "verylongfermata"
     } >>
 }
diff --git a/Documentation/user/programming-interface.itely b/Documentation/user/programming-interface.itely
index b83c689dd2..18e2997d95 100644
--- a/Documentation/user/programming-interface.itely
+++ b/Documentation/user/programming-interface.itely
@@ -311,7 +311,7 @@ a type predicate for the i@var{th} argument
 the `paper' definition
 @item props
 a list of alists, containing all active properties. 
-@end lisp
+@end table
 
 As a simple example, we show how to add a @code{\smallcaps} command,
 which selects @TeX{}'s small caps font.  Normally, we could select the
@@ -423,7 +423,7 @@ letter a little larger:
 
 @example
 #(def-markup-command (smallcaps paper props str) (string?)
-   "Print the string argument in small caps. Syntax: \\smallcaps #\"string\""
+   "Print the string argument in small caps."
    (interpret-markup paper props
     (make-line-markup
      (map (lambda (s)
@@ -456,7 +456,7 @@ to the @code{interpret-markup} function, with the @code{paper} and
 
 @menu
 * Context evaluation::		
-* Applyoutput::			
+* Running a function on all layout objects::  
 @end menu
 
 @node Context evaluation
diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh
index 1f481c2dd4..2e58a51388 100644
--- a/lily/include/paper-book.hh
+++ b/lily/include/paper-book.hh
@@ -19,7 +19,6 @@
 class Paper_book
 {
 public:
-  Protected_scm protect_;
   Array<SCM> headers_;
   Array<SCM> global_headers_;
   Link_array<Paper_def> papers_;
@@ -31,11 +30,7 @@ public:
   Stencil* get_title (int);
   void output (String);
   void classic_output (String);
-
-  SCM smobbed_copy () const;
-
-private:
-  DECLARE_SIMPLE_SMOBS (Paper_book, )
+  DECLARE_SMOBS (Paper_book, )
 };
 
 DECLARE_UNSMOB (Paper_book, paper_book)
diff --git a/lily/input-file-results.cc b/lily/input-file-results.cc
index 05729cf669..92fa4f329c 100644
--- a/lily/input-file-results.cc
+++ b/lily/input-file-results.cc
@@ -230,9 +230,11 @@ do_one_file (char const *file)
   if (!proc)
     proc = scm_c_eval_string ("dump-gc-protects");
 
-  Paper_book book;
-  paper_book = &book;
+  paper_book = new Paper_book ();;
   Input_file_results inp_file (init, in_file, out_file);
   if (output_format_global == PAGE_LAYOUT)
-    book.output (out_file);
+    paper_book->output (out_file);
+
+  scm_gc_unprotect_object (paper_book->self_scm ());
+  paper_book = 0;
 }
diff --git a/lily/paper-book.cc b/lily/paper-book.cc
index 5eedc873fe..999fd0255b 100644
--- a/lily/paper-book.cc
+++ b/lily/paper-book.cc
@@ -79,12 +79,14 @@ Page::text_height ()
   return h;
 }
 
+/****************************************************************/
 
-Paper_book *paper_book;
+
+Paper_book *paper_book;		// huh? global var? --hwn
 
 Paper_book::Paper_book ()
 {
-  protect_ = SCM_EOL;
+  smobify_self ();
 }
 
 void
@@ -248,21 +250,21 @@ Paper_book::classic_output (String outname)
 #include "ly-smobs.icc"
 
 IMPLEMENT_DEFAULT_EQUAL_P (Paper_book);
-IMPLEMENT_SIMPLE_SMOBS (Paper_book)
-IMPLEMENT_TYPE_P (Paper_book, "ly:paper_book?")
+IMPLEMENT_SMOBS (Paper_book)
+IMPLEMENT_TYPE_P (Paper_book, "ly:paper-book?")
 
 SCM
 Paper_book::mark_smob (SCM smob)
 {
-  Paper_book *b = (Paper_book*) SCM_CELL_WORD_1 (smob);
-
-#if 0 //TODO
-  scm_gc_mark (b->scores_);
-  scm_gc_mark (b->global_headers_);
-  scm_gc_mark (b->headers_);
-  scm_gc_mark (b->papers_);
-#endif
-
+  Paper_book *pb = (Paper_book*) SCM_CELL_WORD_1 (smob);
+  for (int i = 0; i < pb->headers_.size (); i++)
+    scm_gc_mark (pb->headers_[i]);
+  for (int i = 0; i < pb->global_headers_.size (); i++)
+    scm_gc_mark (pb->global_headers_[i]);
+  for (int i = 0; i < pb->papers_.size (); i++)
+    scm_gc_mark (pb->papers_[i]->self_scm ());
+  for (int i = 0; i < pb->scores_.size (); i++)
+    scm_gc_mark (pb->scores_[i]);
   return SCM_EOL;
 }
 
@@ -279,9 +281,7 @@ Paper_book::print_smob (SCM smob, SCM port, scm_print_state*)
   return 1;
 }
 
-SCM
-Paper_book::smobbed_copy () const
+Paper_book::~Paper_book ()
 {
-  Paper_book *b = new Paper_book (*this);
-  return b->smobbed_self ();
 }
+
diff --git a/lily/score.cc b/lily/score.cc
index b1c1c554b3..d0124b2c74 100644
--- a/lily/score.cc
+++ b/lily/score.cc
@@ -176,14 +176,7 @@ default_rendering (SCM music, SCM outdef, SCM header, SCM outname)
       if (systems != SCM_UNDEFINED)
 	{
 	  Paper_score *ps = dynamic_cast<Paper_score*> (output);
-#if 1
-	  paper_book->protect_ = scm_cons (systems, paper_book->protect_);
-	  paper_book->protect_ = scm_cons (global_input_file->header_,
-					   paper_book->protect_);
-	  paper_book->protect_ = scm_cons (header, paper_book->protect_);
-	  paper_book->protect_ = scm_cons (ps->paper_->smobbed_copy (),
-					   paper_book->protect_);
-#endif
+
 	  paper_book->papers_.push (ps->paper_);
 	  paper_book->scores_.push (systems);
 	  paper_book->global_headers_.push (global_input_file->header_);
-- 
2.39.5