From: Han-Wen Nienhuys <hanwen@xs4all.nl>
Date: Thu, 27 May 2004 22:29:01 +0000 (+0000)
Subject: new file, move from
X-Git-Tag: release/2.3.3~16
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=664070d837cc4855091455892cb942cdcedeef0c;p=lilypond.git

new file, move from
music-output-def.hh


	* lily/include/paper-def.hh: move all functionality out of class.
	Junk header.

	* lily/include/music-output-def.hh: rename Music_output_def to
	Output_def.

	* input/wilhelmus.ly: only set space for Paper formatting.

	* lily/include/midi-def.hh: remove file, remove class.
	Move functions to Music-output-def.
---

diff --git a/ChangeLog b/ChangeLog
index 191ed30360..2dda116c80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,9 +1,27 @@
+2004-05-28  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+	* lily/include/output-def.hh: new file, move from
+	music-output-def.hh
+
 2004-05-27  Jan Nieuwenhuizen  <janneke@gnu.org>
 
 	* scm/output-gnome.scm: Describe feta-cork hack.
 
 2004-05-27  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+	* lily/include/book-paper-def.hh: derive from Output_def 
+
+	* lily/include/paper-def.hh: move all functionality out of class.
+	Junk header.
+
+	* lily/include/music-output-def.hh: rename Music_output_def to
+	Output_def.
+
+	* input/wilhelmus.ly: only set space for Paper formatting. 
+
+	* lily/include/midi-def.hh: remove file, remove class.
+	Move functions to Music-output-def.
+
 	* lily/music-output-def.cc (Music_output_def): remove separate
 	translator table. Lookup translators in scope directly. This
 	obviates Context suffix for context identifiers, i.e.
diff --git a/Documentation/user/notation.itely b/Documentation/user/notation.itely
index 103e9f61f7..74eec643a8 100644
--- a/Documentation/user/notation.itely
+++ b/Documentation/user/notation.itely
@@ -4596,7 +4596,7 @@ empty after the line-breaking process, they are removed.
 For normal staves, a specialized @internalsref{Staff} context is
 available, which does the same: staves containing nothing (or only
 multi measure rests) are removed. The context definition is stored in
-@code{\RemoveEmptyStaff} variable. Observe how the second staff
+@code{\RemoveEmptyStaffContext} variable. Observe how the second staff
 in this example disappears in the second line
 
 
@@ -4608,7 +4608,7 @@ in this example disappears in the second line
   >>
   \paper {
     linewidth = 6.\cm 
-    \context { \RemoveEmptyStaff }
+    \context { \RemoveEmptyStaffContext }
   }
 }
 @end lilypond
diff --git a/buildscripts/mf-to-table.py b/buildscripts/mf-to-table.py
index 3e102d76ad..972cbdd81a 100644
--- a/buildscripts/mf-to-table.py
+++ b/buildscripts/mf-to-table.py
@@ -198,12 +198,12 @@ def write_fontlist (file, global_info, charmetrics):
     interscoreline = 1.0
     indent = 0.0 \cm
     \context {
-      \LyricsContext
+      \Lyrics
       \override SeparationItem #'padding = #2
       minimumVerticalExtent = ##f
     }
     \context {
-	\ScoreContext
+	\Score
 	\remove "Bar_number_engraver"
 	}
 	}
diff --git a/input/wilhelmus.ly b/input/wilhelmus.ly
index cb43459464..26e1990de7 100644
--- a/input/wilhelmus.ly
+++ b/input/wilhelmus.ly
@@ -14,10 +14,13 @@
 #(define (prepend-grob-property grob-name
 	  grob-prop entry)
   (lambda (context)
-   (ly:context-pushpop-property context grob-name grob-prop
-    (cons
-     entry
-     (assoc-get grob-prop (car (ly:context-property context grob-name)))))))
+   (let*
+    ((grob-def (ly:context-property context grob-name)))
+    (if (pair? grob-def)
+     (ly:context-pushpop-property context grob-name grob-prop
+      (cons
+       entry
+       (assoc-get grob-prop (car grob-def))))))))
 
 #(define (set-extra-space grob-name entry value)
   (prepend-grob-property grob-name 'space-alist
@@ -183,7 +186,7 @@ oneHalfNoteTime = \markup {
     }
   >>
   \paper {}
-%  \midi {}
+  \midi {}
 }
 
 %%% Local variables:
diff --git a/lily/accidental.cc b/lily/accidental.cc
index 755ce60e10..0958dbae8e 100644
--- a/lily/accidental.cc
+++ b/lily/accidental.cc
@@ -8,7 +8,7 @@
 #include "item.hh"
 #include "stencil.hh"
 #include "accidental-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "pitch.hh"
 
 /*
diff --git a/lily/align-interface.cc b/lily/align-interface.cc
index 3928ae8f6e..8f5ece2511 100644
--- a/lily/align-interface.cc
+++ b/lily/align-interface.cc
@@ -12,7 +12,7 @@
 #include "group-interface.hh"
 #include "axis-group-interface.hh"
 #include "hara-kiri-group-spanner.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 MAKE_SCHEME_CALLBACK (Align_interface,alignment_callback,2);
 SCM
diff --git a/lily/ambitus.cc b/lily/ambitus.cc
index 669cd61a07..e864fa0bbd 100644
--- a/lily/ambitus.cc
+++ b/lily/ambitus.cc
@@ -13,7 +13,7 @@
 #include "note-head.hh"
 #include "item.hh"
 #include "font-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "lookup.hh"
 
 /*
diff --git a/lily/apply-context-iterator.cc b/lily/apply-context-iterator.cc
index 38036708c0..c2251bed27 100644
--- a/lily/apply-context-iterator.cc
+++ b/lily/apply-context-iterator.cc
@@ -1,6 +1,16 @@
+/* 
+  apply-context-iterator.cc --  implement Apply_context_iterator
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2004 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  
+*/
+
 #include "simple-music-iterator.hh"
 #include "context.hh"
 #include "music.hh"
+#include "input.hh"
 
 /**
   Iterate a property.  
@@ -19,7 +29,10 @@ Apply_context_iterator::process (Moment m)
 {
   SCM proc = get_music ()->get_property ("procedure");
 
-  scm_call_1 (proc, get_outlet ()->self_scm ());
+  if (ly_c_procedure_p (proc))
+    scm_call_1 (proc, get_outlet ()->self_scm ());
+  else
+    get_music ()->origin ()->warning (_("\\applycontext argument is not a procedure"));
   
   Simple_music_iterator::process (m);
 }
diff --git a/lily/arpeggio.cc b/lily/arpeggio.cc
index ce076af4d8..ad0ca353e1 100644
--- a/lily/arpeggio.cc
+++ b/lily/arpeggio.cc
@@ -7,7 +7,7 @@
  */
 
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "arpeggio.hh"
 #include "grob.hh"
 #include "stem.hh"
diff --git a/lily/balloon.cc b/lily/balloon.cc
index 43ee85e7e8..bda3fa20cb 100644
--- a/lily/balloon.cc
+++ b/lily/balloon.cc
@@ -13,7 +13,7 @@
 #include "font-interface.hh"
 #include "stencil.hh"
 #include "lily-guile.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "misc.hh"
 
 class Balloon_interface
diff --git a/lily/bar-line.cc b/lily/bar-line.cc
index 716c776d72..28d4e88ca7 100644
--- a/lily/bar-line.cc
+++ b/lily/bar-line.cc
@@ -14,7 +14,7 @@
 #include "bar-line.hh"
 #include "string.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 
 #include "all-font-metrics.hh"
diff --git a/lily/bar-number-engraver.cc b/lily/bar-number-engraver.cc
index 4328e81a91..7ba942a3b3 100644
--- a/lily/bar-number-engraver.cc
+++ b/lily/bar-number-engraver.cc
@@ -9,7 +9,7 @@
 
 #include "lily-guile.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "side-position-interface.hh"
 #include "item.hh"
 #include "moment.hh"
diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc
index 3a6f5e9aaf..25df72abb1 100644
--- a/lily/beam-quanting.cc
+++ b/lily/beam-quanting.cc
@@ -19,7 +19,7 @@
 #include "staff-symbol-referencer.hh"
 #include "beam.hh"
 #include "stem.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "group-interface.hh"
 #include "align-interface.hh"
 
diff --git a/lily/beam.cc b/lily/beam.cc
index 0ef6741fac..91574c3484 100644
--- a/lily/beam.cc
+++ b/lily/beam.cc
@@ -35,7 +35,7 @@ Notes:
 #include "misc.hh"
 #include "least-squares.hh"
 #include "stem.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "lookup.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
diff --git a/lily/book-paper-def.cc b/lily/book-paper-def.cc
index 42d8bd623d..5dae02d31b 100644
--- a/lily/book-paper-def.cc
+++ b/lily/book-paper-def.cc
@@ -1,5 +1,5 @@
 /* 
-  book-paper-def.cc --  implement Book_paper_def
+  book-paper-def.cc --  implement Book_output_def
   
   source file of the GNU LilyPond music typesetter
   
@@ -8,7 +8,7 @@
 */
 
 #include "ly-module.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "dimensions.hh"
 #include "book-paper-def.hh"
 #include "ly-smobs.icc"
@@ -16,59 +16,41 @@
 #include "virtual-font-metric.hh"
 #include "scaled-font-metric.hh"
 
-IMPLEMENT_SMOBS (Book_paper_def);
-IMPLEMENT_DEFAULT_EQUAL_P (Book_paper_def);
-
-Book_paper_def::Book_paper_def ()
+Book_output_def::Book_output_def ()
 {
   output_scale_ = 1.0;
   scaled_fonts_ = SCM_EOL;
-  scope_ = SCM_EOL;
-  smobify_self ();
   scaled_fonts_ = scm_c_make_hash_table (11);
-  scope_ = ly_make_anonymous_module (false); 
 }
 
-Book_paper_def::Book_paper_def (Book_paper_def const & src)
+Real
+Book_output_def::output_scale () const
+{
+  return output_scale_;
+}
+
+Book_output_def::Book_output_def (Book_output_def const & src)
+  : Output_def (src)
 {
   output_scale_ = src.output_scale_;
-  scope_ = SCM_EOL;
   scaled_fonts_ = SCM_EOL;
-  smobify_self ();
-  scope_= ly_make_anonymous_module (false);
-  if (is_module (src.scope_))
-    ly_import_module (scope_, src.scope_);
-
   scaled_fonts_ = scm_c_make_hash_table (11); // copying is not done with live defs. hopefully.
 }
 
-Book_paper_def::~Book_paper_def ()
+void
+Book_output_def::derived_mark ()
 {
+  scm_gc_mark (scaled_fonts_);
 }
 
-SCM
-Book_paper_def::mark_smob (SCM m)
-{
-  Book_paper_def *mo = (Book_paper_def*) SCM_CELL_WORD_1 (m);
 
-  scm_gc_mark (mo->scope_);
-  return mo->scaled_fonts_;
-}
-
-int
-Book_paper_def::print_smob (SCM s, SCM p, scm_print_state*)
-{
-  (void) s;
-  scm_puts ("#<Book_paper>", p);
-  return 1;
-}
 
 Font_metric*
-Book_paper_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
+Book_output_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
 {
   Real lookup_mag = m;
   if (!dynamic_cast<Virtual_font_metric*> (f))
-    lookup_mag /= output_scale_;
+    lookup_mag /= output_scale ();
   
   SCM sizes = scm_hashq_ref (scaled_fonts_, f->self_scm (), SCM_BOOL_F);
   if (sizes != SCM_BOOL_F)
@@ -114,13 +96,11 @@ Book_paper_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
     {
       if (!ly_c_symbol_p (input_enc_name))
 	{
-#if 0
-	  /* FIXME.*/
 	  SCM var = ly_module_lookup (scope_, ly_symbol2scm ("inputencoding"));
-	  input_enc_name = scm_variable_ref (var);
-      
-#endif
-	  input_enc_name = ly_symbol2scm ("latin1"); 
+	  if (var != SCM_BOOL_F) 
+	    input_enc_name = scm_variable_ref (var);
+	  if (!ly_c_symbol_p (input_enc_name))
+	    input_enc_name = ly_symbol2scm ("latin1"); 
 	}
 
       val = Modified_font_metric::make_scaled_font_metric (input_enc_name,
@@ -133,17 +113,17 @@ Book_paper_def::find_scaled_font (Font_metric *f, Real m, SCM input_enc_name)
   return unsmob_metrics (val);
 }
 
-Paper_def * 
-Book_paper_def::scale_paper (Paper_def *pd) const
+Output_def* 
+Book_output_def::scale_paper (Output_def *pd) const
 {
   SCM proc = ly_scheme_function ("scale-paper");
   SCM new_pap = scm_call_2 (proc, pd->self_scm (), self_scm ());
 
   scm_gc_protect_object (new_pap);
 
-  Paper_def *p = unsmob_paper (new_pap);
+  Output_def *p = unsmob_output_def (new_pap);
   
-  p->bookpaper_ = (Book_paper_def*) this;
+  p->parent_ = (Output_def*) this;
   return p;
 }
 
@@ -152,7 +132,7 @@ LY_DEFINE (ly_make_bookpaper, "ly:make-bookpaper",
 	   (SCM size),
 	   "Make a paperbook, for staff space SIZE, which is in INTERNAL_UNIT.") 
 {
-  Book_paper_def *bp = new Book_paper_def ;
+  Book_output_def *bp = new Book_output_def ;
 
   SCM_ASSERT_TYPE (ly_c_number_p (size), size,
 		   SCM_ARG1, __FUNCTION__, "number");
@@ -162,12 +142,18 @@ LY_DEFINE (ly_make_bookpaper, "ly:make-bookpaper",
   return scm_gc_unprotect_object (bp->self_scm ());
 }
 
+Book_output_def *
+unsmob_book_output_def (SCM bp)
+{
+  return dynamic_cast<Book_output_def*> (unsmob_output_def (bp));
+}
+
 LY_DEFINE (ly_bookpaper_fonts, "ly:bookpaper-fonts",
 	   1, 0, 0,
 	   (SCM bp),
 	   "Return fonts scaled up BP")
 {
-  Book_paper_def *b = unsmob_book_paper_def (bp);
+  Book_output_def *b = unsmob_book_output_def (bp);
   
   SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "bookpaper");
 
@@ -195,32 +181,18 @@ LY_DEFINE (ly_bookpaper_outputscale, "ly:bookpaper-outputscale",
 	  (SCM bp),
 	  "Get outputscale for BP.")
 {
-  Book_paper_def *b = unsmob_book_paper_def (bp);
+  Book_output_def *b = unsmob_book_output_def (bp);
   SCM_ASSERT_TYPE (b, bp, SCM_ARG1, __FUNCTION__, "bookpaper");
   return scm_make_real (b->output_scale_);
 }
 
 
-SCM
-Book_paper_def::lookup_variable (SCM sym) const
-{
-  SCM var = ly_module_lookup (scope_, sym);
-
-  return scm_variable_ref (var);
-}
-
-SCM
-Book_paper_def::c_variable (String s) const
-{
-  return lookup_variable (ly_symbol2scm (s.to_str0 ()));
-}
-
 
-LY_DEFINE (ly_book_paper_def_scope, "ly:bookpaper-def-scope",
+LY_DEFINE (ly_book_output_def_scope, "ly:bookpaper-def-scope",
 	   1, 0,0, (SCM def),
 	   "Get the variable scope inside @var{def}.")
 {
-  Book_paper_def *op = unsmob_book_paper_def (def);
+  Book_output_def *op = unsmob_book_output_def (def);
   SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
   return op->scope_;
 }
diff --git a/lily/book.cc b/lily/book.cc
index 8ff6521d77..c970a964fe 100644
--- a/lily/book.cc
+++ b/lily/book.cc
@@ -16,12 +16,12 @@
 #include "ly-module.hh"
 #include "main.hh"
 #include "music-iterator.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "music-output.hh"
 #include "music.hh"
 #include "page.hh"
 #include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "score.hh"
 #include "warn.hh"
 
@@ -62,14 +62,14 @@ Book::print_smob (SCM, SCM p, scm_print_state*)
 }
 
 void
-Book::process (String outname, Music_output_def *default_def, SCM header)
+Book::process (String outname, Output_def *default_def, SCM header)
 {
   Paper_book *paper_book = new Paper_book ();
   paper_book->bookpaper_ = bookpaper_;
   int score_count = scores_.size ();
   for (int i = 0; i < score_count; i++)
     {
-      Paper_def *paper = 0;
+      Output_def *paper = 0;
       SCM systems = scores_[i]->book_rendering (outname,
 						bookpaper_,
 						default_def, &paper);
@@ -89,14 +89,14 @@ Book::process (String outname, Music_output_def *default_def, SCM header)
 
 /* FIXME: WIP, this is a hack.  Return first page as stencil.  */
 SCM
-Book::to_stencil (Music_output_def *default_def, SCM header)
+Book::to_stencil (Output_def *default_def, SCM header)
 {
   Paper_book *paper_book = new Paper_book ();
   paper_book->bookpaper_ = bookpaper_;
   int score_count = scores_.size ();
   for (int i = 0; i < score_count; i++)
     {
-      Paper_def *paper = 0;
+      Output_def *paper = 0;
       SCM systems = scores_[i]->book_rendering ("<markup>",
 						bookpaper_,
 						default_def,
diff --git a/lily/break-algorithm.cc b/lily/break-algorithm.cc
index 5db8a7c08e..72d7021e95 100644
--- a/lily/break-algorithm.cc
+++ b/lily/break-algorithm.cc
@@ -8,7 +8,7 @@
 
 #include "paper-column.hh"
 #include "break-algorithm.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "system.hh"
 #include "paper-score.hh"
 #include "paper-column.hh"
diff --git a/lily/break-align-interface.cc b/lily/break-align-interface.cc
index b8c5c739ab..6bbd74a950 100644
--- a/lily/break-align-interface.cc
+++ b/lily/break-align-interface.cc
@@ -17,7 +17,7 @@
 #include "lily-guile.hh"
 #include "break-align-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-column.hh"
 #include "group-interface.hh"
 #include "align-interface.hh"
diff --git a/lily/breathing-sign.cc b/lily/breathing-sign.cc
index 312c3463d5..511fbd8373 100644
--- a/lily/breathing-sign.cc
+++ b/lily/breathing-sign.cc
@@ -15,7 +15,7 @@
 #include "breathing-sign.hh"
 #include "string.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "lookup.hh"
 
 #include "dimensions.hh"
diff --git a/lily/chord-name-engraver.cc b/lily/chord-name-engraver.cc
index 252dfb8743..88635e5285 100644
--- a/lily/chord-name-engraver.cc
+++ b/lily/chord-name-engraver.cc
@@ -9,9 +9,9 @@
 #include "engraver.hh"
 #include "chord-name.hh"
 #include "event.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "dimensions.hh"
 #include "item.hh"
 #include "pitch.hh"
diff --git a/lily/chord-name.cc b/lily/chord-name.cc
index 92f8c2418b..ce7099fa7d 100644
--- a/lily/chord-name.cc
+++ b/lily/chord-name.cc
@@ -8,7 +8,7 @@
 
 #include "chord-name.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "grob.hh"
 #include "paper-column.hh"
diff --git a/lily/cluster.cc b/lily/cluster.cc
index 687eaabae3..794c42640b 100644
--- a/lily/cluster.cc
+++ b/lily/cluster.cc
@@ -19,7 +19,7 @@
 #include "lookup.hh"
 #include "box.hh"
 #include "interval.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 
 
diff --git a/lily/completion-note-heads-engraver.cc b/lily/completion-note-heads-engraver.cc
index 73d3473a89..525e53ca36 100644
--- a/lily/completion-note-heads-engraver.cc
+++ b/lily/completion-note-heads-engraver.cc
@@ -7,7 +7,7 @@
 #include <ctype.h>
 
 #include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "event.hh"
 #include "dots.hh"
 #include "dot-column.hh"
diff --git a/lily/context-def.cc b/lily/context-def.cc
index adb33c9abc..42ea516f91 100644
--- a/lily/context-def.cc
+++ b/lily/context-def.cc
@@ -16,7 +16,7 @@
 #include "context-def.hh"
 #include "translator-group.hh"
 #include "warn.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "ly-smobs.icc"
 #include "score-context.hh"
 
@@ -175,7 +175,7 @@ Context_def::get_accepted (SCM user_mod) const
 
 	   
 Link_array<Context_def>
-Context_def::path_to_acceptable_context (SCM type_sym, Music_output_def* odef) const
+Context_def::path_to_acceptable_context (SCM type_sym, Output_def* odef) const
 {
   assert (ly_c_symbol_p (type_sym));
   
@@ -184,7 +184,7 @@ Context_def::path_to_acceptable_context (SCM type_sym, Music_output_def* odef) c
   Link_array<Context_def> accepteds;
   for (SCM s = accepted; ly_c_pair_p (s); s = ly_cdr (s))
     {
-      Context_def *t = unsmob_context_def (odef->find_context_def (ly_car (s)));
+      Context_def *t = unsmob_context_def (find_context_def (odef, ly_car (s)));
       if (!t)
 	continue;
       accepteds.push (t);
diff --git a/lily/context.cc b/lily/context.cc
index b97a5f1a62..3a4a875ec1 100644
--- a/lily/context.cc
+++ b/lily/context.cc
@@ -11,7 +11,7 @@
 #include "context-def.hh"
 #include "context.hh"
 #include "warn.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "scm-hash.hh"
 #include "main.hh"
 #include "ly-smobs.icc"
@@ -193,7 +193,7 @@ Context::get_default_interpreter ()
   if (!is_bottom_context ())
     {
       SCM nm = default_child_context_name ();
-      SCM st = get_output_def ()->find_context_def (nm);
+      SCM st = find_context_def (get_output_def (), nm);
 
       Context_def *t = unsmob_context_def (st);
       if (!t)
@@ -344,7 +344,7 @@ Context::get_score_context () const
     return 0;
 }
 
-Music_output_def *
+Output_def *
 Context::get_output_def () const
 {
   return  (daddy_context_)
diff --git a/lily/dots.cc b/lily/dots.cc
index d324027a1a..c93a6f8c67 100644
--- a/lily/dots.cc
+++ b/lily/dots.cc
@@ -9,7 +9,7 @@
 #include "dots.hh"
 #include "item.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "lookup.hh"
 #include "staff-symbol-referencer.hh"
diff --git a/lily/font-interface.cc b/lily/font-interface.cc
index a85bd4db74..f8ff01ab65 100644
--- a/lily/font-interface.cc
+++ b/lily/font-interface.cc
@@ -10,7 +10,7 @@
 #include "font-metric.hh"
 #include "font-interface.hh"
 #include "grob.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 
 
diff --git a/lily/font-select.cc b/lily/font-select.cc
index df98d77cee..45a5b9e749 100644
--- a/lily/font-select.cc
+++ b/lily/font-select.cc
@@ -11,7 +11,7 @@
 
 #include "book-paper-def.hh"
 #include "all-font-metrics.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "warn.hh"
 
@@ -22,7 +22,7 @@ LY_DEFINE (ly_paper_get_font, "ly:paper-get-font", 2, 0, 0,
 	   "in the alist chain @var{chain}.\n"
 	   "(An alist chain is a list of alists, containing grob properties).\n")
 {
-  Paper_def *pap = unsmob_paper (paper);
+  Output_def *pap = unsmob_output_def (paper);
   SCM_ASSERT_TYPE (pap, paper, SCM_ARG1, __FUNCTION__, "paper definition");
   
   Font_metric *fm = select_font (pap, chain);
@@ -33,7 +33,7 @@ LY_DEFINE (ly_paper_get_number, "ly:paper-get-number", 2, 0, 0,
 	   (SCM paper, SCM name),
 	   "Return the paper variable @var{name}.")
 {
-  Paper_def *pap = unsmob_paper (paper);
+  Output_def *pap = unsmob_output_def (paper);
   SCM_ASSERT_TYPE (pap, paper, SCM_ARG1, __FUNCTION__, "paper definition");
   return scm_make_real (pap->get_dimension (name));
 }
@@ -51,7 +51,7 @@ wild_compare (SCM field_val, SCM val)
   design size is specced in advance.
  */
 Font_metric*
-get_font_by_design_size (Paper_def* paper, Real requested,
+get_font_by_design_size (Output_def* paper, Real requested,
 			 SCM font_vector, SCM input_encoding_name)
 {
   int n = SCM_VECTOR_LENGTH (font_vector);
@@ -84,13 +84,15 @@ get_font_by_design_size (Paper_def* paper, Real requested,
     }
 
   Font_metric *fm = unsmob_metrics (scm_force (SCM_VECTOR_REF (font_vector, i)));
-  return paper->bookpaper_->find_scaled_font (fm, requested / size, input_encoding_name);
+  return dynamic_cast<Book_output_def*> (paper->parent_)
+    // ugh.
+    ->find_scaled_font (fm, requested / size, input_encoding_name);
 
 }
 
 
 Font_metric*
-get_font_by_mag_step (Paper_def* paper, Real requested_step,
+get_font_by_mag_step (Output_def* paper, Real requested_step,
 		      SCM font_vector, Real default_size, SCM input_encoding_name)
 {
   return get_font_by_design_size (paper,
@@ -108,7 +110,7 @@ properties_to_font_size_family (SCM fonts, SCM alist_chain)
 
 
 Font_metric *
-select_encoded_font (Paper_def *paper, SCM chain, SCM encoding_name)
+select_encoded_font (Output_def *paper, SCM chain, SCM encoding_name)
 {
   SCM name = ly_assoc_chain (ly_symbol2scm  ("font-name"), chain);
   
@@ -129,7 +131,8 @@ select_encoded_font (Paper_def *paper, SCM chain, SCM encoding_name)
       Font_metric * fm = all_fonts_global->find_font (ly_scm2string (name));
       
       
-      return paper->bookpaper_->find_scaled_font (fm, rmag, encoding_name);
+      return dynamic_cast<Book_output_def*> (paper->parent_)
+	->find_scaled_font (fm, rmag, encoding_name);
     }
   else if (scm_instance_p (name))
     {
@@ -151,7 +154,7 @@ select_encoded_font (Paper_def *paper, SCM chain, SCM encoding_name)
 }
 
 Font_metric *
-select_font (Paper_def *paper, SCM chain)
+select_font (Output_def *paper, SCM chain)
 {
   return select_encoded_font (paper, chain, SCM_EOL);
 }
diff --git a/lily/global-context.cc b/lily/global-context.cc
index 7b43d2b174..77a67639c4 100644
--- a/lily/global-context.cc
+++ b/lily/global-context.cc
@@ -15,19 +15,19 @@
 #include "global-context.hh"
 #include "score-context.hh"
 #include "context-def.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "grace-fixup.hh"
 
-Global_context::Global_context (Music_output_def *o, Moment final)
+Global_context::Global_context (Output_def *o, Moment final)
 {
   output_def_ = o;
   final_mom_ = final;
-  definition_ = o->find_context_def (ly_symbol2scm ("Global"));
+  definition_ = find_context_def (o, ly_symbol2scm ("Global"));
   unsmob_context_def (definition_)->apply_default_property_operations (this);
   accepts_list_ = scm_list_1 (ly_symbol2scm ("Score"));
 }
 
-Music_output_def* 
+Output_def* 
 Global_context::get_output_def () const
 {
   return output_def_;
@@ -145,8 +145,7 @@ Global_context::run_iterator_on_me (Music_iterator * iter)
       if (!get_score_context ()) 
 	{
 	  SCM key = ly_symbol2scm ("Score");
-	  Context_def * t = unsmob_context_def (get_output_def ()
-						->find_context_def (key));
+	  Context_def * t = unsmob_context_def (find_context_def (get_output_def (), key));
 	  if (!t)
 	    error (_f ("can't find `%s' context", "Score"));
 
diff --git a/lily/gourlay-breaking.cc b/lily/gourlay-breaking.cc
index 789710daba..9cfd6b531f 100644
--- a/lily/gourlay-breaking.cc
+++ b/lily/gourlay-breaking.cc
@@ -14,7 +14,7 @@
 #include "main.hh"
 #include "paper-column.hh"
 #include "paper-score.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "simple-spacer.hh"
 #include "system.hh"
 
@@ -106,7 +106,7 @@ Gourlay_breaking::do_solve () const
 	  cp.cols_ = line;
 
 	  Interval line_dims
-	    = pscore_->paper_->line_dimensions_int (optimal_paths[start_idx].line_);
+	    = line_dimensions_int (pscore_->paper_, optimal_paths[start_idx].line_);
 	  Simple_spacer * sp = generate_spacing_problem (line, line_dims);
 	  bool last_line = break_idx == breaks.size ()-1;
 	  bool ragged = ragged_right
diff --git a/lily/grob-property.cc b/lily/grob-property.cc
index 8cb4b84cd7..72353140f3 100644
--- a/lily/grob-property.cc
+++ b/lily/grob-property.cc
@@ -10,7 +10,7 @@
 #include "group-interface.hh"
 #include "misc.hh"
 #include "paper-score.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "grob.hh"
 #include "spanner.hh"
 #include "item.hh"
diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc
index 1557d3105b..740491f52a 100644
--- a/lily/grob-scheme.cc
+++ b/lily/grob-scheme.cc
@@ -11,7 +11,7 @@
 #include "warn.hh"
 #include "spanner.hh"
 #include "item.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "system.hh"
 
 
diff --git a/lily/grob.cc b/lily/grob.cc
index b32b83a201..5ca831a51a 100644
--- a/lily/grob.cc
+++ b/lily/grob.cc
@@ -158,7 +158,7 @@ Grob::stencil_extent (SCM element_smob, SCM scm_axis)
   return ly_interval2scm (e);
 }
 
-Paper_def*
+Output_def*
 Grob::get_paper ()  const
 {
  return pscore_ ? pscore_->paper_ : 0;
diff --git a/lily/hairpin.cc b/lily/hairpin.cc
index 28b5a0910f..4c31cbad2e 100644
--- a/lily/hairpin.cc
+++ b/lily/hairpin.cc
@@ -13,7 +13,7 @@
 #include "spanner.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 #include "paper-column.hh"
 #include "lookup.hh"
diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc
index 4961721496..de9ccb3251 100644
--- a/lily/horizontal-bracket.cc
+++ b/lily/horizontal-bracket.cc
@@ -11,7 +11,7 @@
 #include "lookup.hh"
 #include "group-interface.hh"
 #include "directional-element-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "staff-symbol-referencer.hh"
 
 struct Horizontal_bracket
diff --git a/lily/include/book-paper-def.hh b/lily/include/book-paper-def.hh
index a0f3bcfab6..2d4386b927 100644
--- a/lily/include/book-paper-def.hh
+++ b/lily/include/book-paper-def.hh
@@ -1,5 +1,5 @@
 /*
-  book-paper-def.hh -- declare Book_paper_def
+  book-paper-def.hh -- declare Book_output_def
 
   source file of the GNU LilyPond music typesetter
 
@@ -10,27 +10,24 @@
 #define BOOK_PAPER_DEF_HH
 
 #include "lily-proto.hh"
-#include "smobs.hh"
-#include "virtual-methods.hh"
+#include "output-def.hh"
 
-class Book_paper_def
+class Book_output_def : public Output_def
 {
-  DECLARE_SMOBS (Book_paper_def, Music_output_def);
-
 public:
-  VIRTUAL_COPY_CONSTRUCTOR (Book_paper_def, Book_paper_def);
-  Book_paper_def (Book_paper_def const &);
-  SCM scope_;
+  VIRTUAL_COPY_CONSTRUCTOR (Output_def, Book_output_def);
+  Book_output_def (Book_output_def const &);
   SCM scaled_fonts_;
   Real output_scale_;
+  Real output_scale () const;
 
-  Book_paper_def ();
-  SCM c_variable (String id) const;
-  SCM lookup_variable (SCM sym) const;
+  Book_output_def ();
 
+  virtual void derived_mark ();
   Font_metric *find_scaled_font (Font_metric *f, Real m, SCM input_enc_name);
-  Paper_def *scale_paper (Paper_def *pd) const;
+  Output_def *scale_paper (Output_def *pd) const;
 };
-DECLARE_UNSMOB (Book_paper_def, book_paper_def);
+
+Book_output_def *unsmob_book_output_def (SCM bp);
 
 #endif /* BOOK_PAPER_DEF_HH */
diff --git a/lily/include/book.hh b/lily/include/book.hh
index b815b75edc..0c5e46863b 100644
--- a/lily/include/book.hh
+++ b/lily/include/book.hh
@@ -20,13 +20,13 @@ class Book : public Input
 
 public:
   SCM header_;
-  Book_paper_def *bookpaper_;
+  Book_output_def *bookpaper_;
   
   Link_array<Score> scores_;
   Book ();
 
-  void process (String outname, Music_output_def*, SCM header);
-  SCM to_stencil (Music_output_def*, SCM header);
+  void process (String outname, Output_def*, SCM header);
+  SCM to_stencil (Output_def*, SCM header);
 };
 DECLARE_UNSMOB (Book, book);
 
diff --git a/lily/include/context-def.hh b/lily/include/context-def.hh
index 01484666a6..c734ed9240 100644
--- a/lily/include/context-def.hh
+++ b/lily/include/context-def.hh
@@ -42,7 +42,7 @@ public:
   void set_acceptor (SCM accepts, bool add);
 
   Link_array<Context_def> path_to_acceptable_context (SCM type_string,
-						      Music_output_def*) const;
+						      Output_def*) const;
   Context * instantiate (SCM extra_ops);
 
   SCM to_alist () const;
diff --git a/lily/include/context.hh b/lily/include/context.hh
index 6413d8b49f..af504c1218 100644
--- a/lily/include/context.hh
+++ b/lily/include/context.hh
@@ -64,7 +64,7 @@ public:
   Global_context * get_global_context () const;
   
   virtual Score_context * get_score_context () const;  
-  virtual Music_output_def *get_output_def () const;
+  virtual Output_def *get_output_def () const;
   virtual Moment now_mom () const;
   virtual Context *get_default_interpreter ();
 
@@ -78,7 +78,7 @@ public:
   Context *find_create_context (SCM context_name,
 				String id, SCM ops);
   Link_array<Context> path_to_acceptable_context (SCM alias,
-						  Music_output_def*) const;
+						  Output_def*) const;
 
 };
 
diff --git a/lily/include/global-context.hh b/lily/include/global-context.hh
index c3f1834f02..353b8cf044 100644
--- a/lily/include/global-context.hh
+++ b/lily/include/global-context.hh
@@ -16,11 +16,11 @@
 class Global_context : public virtual Context
 {
   PQueue<Moment> extra_mom_pq_;
-  Music_output_def*  output_def_;
+  Output_def*  output_def_;
   
-  friend class Music_output_def;
+  friend class Output_def;
 public:
-  Global_context (Music_output_def*, Moment final);
+  Global_context (Output_def*, Moment final);
   int get_moments_left () const;
   Moment sneaky_insert_extra_moment (Moment);
   void add_moment_to_process (Moment);
@@ -34,7 +34,7 @@ public:
   virtual void prepare (Moment);
   virtual void one_time_step ();
   virtual void finish ();
-  virtual Music_output_def* get_output_def () const; 
+  virtual Output_def* get_output_def () const; 
   virtual Moment now_mom () const;
   virtual Context *get_default_interpreter ();
 
diff --git a/lily/include/grob.hh b/lily/include/grob.hh
index fba4a8eaad..ba7a7b8a0d 100644
--- a/lily/include/grob.hh
+++ b/lily/include/grob.hh
@@ -82,7 +82,7 @@ public:
   /*
     related classes.
    */
-  Paper_def *get_paper () const;
+  Output_def *get_paper () const;
 
   /**
     add a dependency. It may be the 0 pointer, in which case, it is ignored.
diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh
index f74f32d978..b1fa3c44aa 100644
--- a/lily/include/lily-proto.hh
+++ b/lily/include/lily-proto.hh
@@ -37,7 +37,7 @@ class Beaming_info_list;
 class Bezier;
 class Bezier_bow;
 class Book;
-class Book_paper_def;
+class Book_output_def;
 class Break_algorithm;
 class Change_iterator;
 class Change_translator;
@@ -78,7 +78,6 @@ class Lyric_performer;
 class Lyric_phrasing_engraver;
 class Mensural_ligature_engraver;
 class Midi_chunk;
-class Midi_def;
 class Midi_duration;
 class Midi_dynamic;
 class Midi_header;
@@ -100,7 +99,7 @@ class Music;
 class Music_iterator;
 class Music_list;
 class Music_output;
-class Music_output_def;
+class Output_def;
 class Music_sequence;
 class Music_wrapper;
 class Music_wrapper_iterator;
@@ -111,7 +110,7 @@ class Note_performer;
 class Output_property;
 class Paper_book;
 class Paper_column;
-class Paper_def;
+class Output_def;
 class Paper_line;
 class Paper_outputter;
 class Paper_score;
diff --git a/lily/include/midi-def.hh b/lily/include/midi-def.hh
deleted file mode 100644
index c919a87606..0000000000
--- a/lily/include/midi-def.hh
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-  midi-def.hh -- declare Midi_def
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2004 Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-
-
-#ifndef MIDI_DEF_HH
-#define MIDI_DEF_HH
-
-#include "lily-proto.hh"
-#include "real.hh"
-#include "string.hh"
-#include "moment.hh"
-#include "music-output-def.hh"
-
-/** 
-  definitions for midi output. Rather empty
- */
-class Midi_def : public Music_output_def
-{
-  static int score_count_;
-
-public:
-  Midi_def ();
-  VIRTUAL_COPY_CONSTRUCTOR (Music_output_def, Midi_def);
-
-  int get_tempo (Moment moment);
-  void set_tempo (Moment moment, int count_per_minute_i);
-};
-
-#endif /* MIDI_DEF_HH */
diff --git a/lily/include/music-output-def.hh b/lily/include/music-output-def.hh
deleted file mode 100644
index d95ee038bc..0000000000
--- a/lily/include/music-output-def.hh
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  music-output-def.hh -- declare Music_output_def
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-#ifndef MUSIC_OUTPUT_DEF_HH
-#define MUSIC_OUTPUT_DEF_HH
-
-#include "string.hh"
-#include "lily-proto.hh"
-#include "lily-guile.hh"
-#include "virtual-methods.hh"
-#include "smobs.hh"
-#include "input.hh"
-
-/**
-  Definition of how to output lilypond.
- */
-class Music_output_def   
-{
-public:
-  Input input_origin_;
-  SCM scope_;
-
-  void assign_context_def (SCM transdef);
-  SCM find_context_def (SCM name) const;
-
-  Music_output_def (Music_output_def const&);
-  Music_output_def ();
-  VIRTUAL_COPY_CONSTRUCTOR (Music_output_def, Music_output_def);
-
-  Context *get_group_translator (String type) const;
-  String outname_string () ;
-  SCM c_variable (String id) const;
-  SCM lookup_variable (SCM sym) const;
-  void set_variable (SCM, SCM sym);
-  DECLARE_SMOBS (Music_output_def,);
-};
-
-DECLARE_UNSMOB (Music_output_def, music_output_def);
-
-#endif /* MUSIC_OUTPUT_DEF_HH */
diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh
index f8138e15c0..0f97dabf0f 100644
--- a/lily/include/my-lily-parser.hh
+++ b/lily/include/my-lily-parser.hh
@@ -79,7 +79,8 @@ SCM ly_parser_print_score (SCM, SCM);
 SCM ly_parser_bookify (SCM, SCM);
 SCM ly_parser_scorify (SCM, SCM);
 
-Music_output_def *get_paper (My_lily_parser *parser);
-Book_paper_def *get_bookpaper (My_lily_parser *parser);
+Output_def *get_paper (My_lily_parser *parser);
+Output_def *get_midi (My_lily_parser *parser);
+Book_output_def *get_bookpaper (My_lily_parser *parser);
 
 #endif /* MY_LILY_PARSER_HH */
diff --git a/lily/include/output-def.hh b/lily/include/output-def.hh
new file mode 100644
index 0000000000..e18326f845
--- /dev/null
+++ b/lily/include/output-def.hh
@@ -0,0 +1,59 @@
+/*
+  music-output-def.hh -- declare Output_def
+
+  source file of the GNU LilyPond music typesetter
+
+  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+*/
+
+#ifndef MUSIC_OUTPUT_DEF_HH
+#define MUSIC_OUTPUT_DEF_HH
+
+#include "string.hh"
+#include "lily-proto.hh"
+#include "lily-guile.hh"
+#include "virtual-methods.hh"
+#include "smobs.hh"
+#include "input.hh"
+
+/**
+  Definition of how to output lilypond.
+ */
+class Output_def   
+{
+public:
+  VIRTUAL_COPY_CONSTRUCTOR (Output_def, Output_def);
+  DECLARE_SMOBS (Output_def,);
+public:
+  Output_def * parent_;
+  Input input_origin_;
+  SCM scope_;
+
+  Output_def (Output_def const&);
+  Output_def ();
+  virtual void derived_mark ();
+  
+  /*
+    variables.
+   */
+  SCM c_variable (String id) const;
+  SCM lookup_variable (SCM sym) const;
+  void set_variable (SCM sym, SCM val);
+  Real get_dimension (SCM symbol) const;
+};
+
+void assign_context_def (Output_def *m, SCM transdef);
+SCM find_context_def (Output_def const *m, SCM name);
+
+int get_tempo (Output_def*def, Moment moment);
+void set_tempo (Output_def*def, Moment moment, int count_per_minute_i);
+
+Interval line_dimensions_int (Output_def*def, int);
+ 
+
+Font_metric *select_encoded_font (Output_def *paper, SCM input_encoding, SCM chain);
+Font_metric *select_font (Output_def *paper, SCM chain);
+
+DECLARE_UNSMOB (Output_def, output_def);
+
+#endif /* MUSIC_OUTPUT_DEF_HH */
diff --git a/lily/include/page.hh b/lily/include/page.hh
index e082b6ab18..07d76d909c 100644
--- a/lily/include/page.hh
+++ b/lily/include/page.hh
@@ -18,8 +18,8 @@ class Page
   DECLARE_SMOBS (Page, );
 
 public:
-  Paper_def *paper_;		// todo: make private? 
-  Book_paper_def * bookpaper () const;
+  Output_def *paper_;		// todo: make private? 
+  Book_output_def * bookpaper () const;
   static int page_count_;
   static Real MIN_COVERAGE_;
   int number_;
@@ -38,7 +38,7 @@ public:
   Real top_margin_;
   Real bottom_margin_;
 
-  Page (Paper_def*, int);
+  Page (Output_def*, int);
 
   /* available area for text.  */
   Real text_height () const;
diff --git a/lily/include/paper-book.hh b/lily/include/paper-book.hh
index e0cab4c45b..2e0d3863b3 100644
--- a/lily/include/paper-book.hh
+++ b/lily/include/paper-book.hh
@@ -18,7 +18,7 @@ struct Score_lines
   SCM lines_;
   SCM header_;
   SCM global_header_;
-  Paper_def *paper_;
+  Output_def *paper_;
 
   Score_lines () ;
   void gc_mark ();
@@ -34,7 +34,7 @@ class Paper_book
   SCM tagline_;
 public:
   Array<Score_lines> score_lines_;
-  Book_paper_def *bookpaper_;
+  Book_output_def *bookpaper_;
 
   Paper_book ();
 
diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh
index a23afe7f45..e69de29bb2 100644
--- a/lily/include/paper-def.hh
+++ b/lily/include/paper-def.hh
@@ -1,74 +0,0 @@
-/*
-  paper-def.hh -- declare Paper_def
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#ifndef PAPER_DEF_HH
-#define PAPER_DEF_HH
-
-
-#include "lily-proto.hh"
-#include "lily-guile.hh"
-#include "real.hh"
-#include "array.hh"
-#include "interval.hh"
-#include "music-output-def.hh"
-
-
-/** 
-
-  Symbols, dimensions and constants pertaining to visual output.
-
-  This struct takes care of all kinds of symbols, dimensions and
-  constants. Most of them are related to the point-size of the fonts,
-  so therefore, the lookup table for symbols is also in here.
-
-  TODO: 
-  
-  add support for multiple fontsizes 
-
-  remove all utility funcs 
-  
-
-  add support for other len->wid conversions.
-
-
-  Interesting variables:
-  
-  /// The distance between lines
-  interline
-  
-*/
-class Paper_def : public Music_output_def 
-{
-protected:
-  VIRTUAL_COPY_CONSTRUCTOR (Music_output_def, Paper_def);
-  
-public:
-  Book_paper_def * bookpaper_;
-  static int score_count_;
-  
-  Paper_def ();
-  Paper_def (Paper_def const&);
-  virtual ~Paper_def ();
-  
-  Paper_outputter* get_paper_outputter (String) const;
-  SCM font_descriptions () const;
-  void reinit ();
-  Interval line_dimensions_int (int) const;
-  void output_settings (Paper_outputter*) const;
-  Font_metric *find_scaled_font (Font_metric *fm, Real mag, SCM enc_name);
-  Real get_dimension (SCM symbol) const;
-  
-  friend int yyparse (void*);
-};
-
-Paper_def * unsmob_paper (SCM x);
-Font_metric *select_encoded_font (Paper_def *paper, SCM input_encoding, SCM chain);
-Font_metric *select_font (Paper_def *paper, SCM chain);
-
-#endif /* PAPER_DEF_HH */
diff --git a/lily/include/paper-outputter.hh b/lily/include/paper-outputter.hh
index bbd67d495b..dca083ffa8 100644
--- a/lily/include/paper-outputter.hh
+++ b/lily/include/paper-outputter.hh
@@ -32,8 +32,8 @@ class Paper_outputter
   String filename_;
   
   void output_expr (SCM expr, Offset o);
-  void output_metadata (Book_paper_def*, SCM);
-  void output_music_output_def (Music_output_def* odef);
+  void output_metadata (Output_def *, SCM);
+  void output_music_output_def (Output_def* odef);
 
 public:
   Paper_outputter (String nm);
@@ -42,9 +42,11 @@ public:
   void dump_scheme (SCM);
   void output_scheme (SCM scm);
   void output_stencil (Stencil);
-  void output_header (Book_paper_def*, SCM, int, bool);
+  void output_header (Output_def*, SCM, int, bool);
   void output_line (SCM, Offset*, bool);
   void output_page (Page*, bool);
 };
 
+Paper_outputter* get_paper_outputter (String);
+
 #endif /* PAPER_OUTPUTTER_HH */
diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh
index 43bc6a5836..2adfdafb38 100644
--- a/lily/include/paper-score.hh
+++ b/lily/include/paper-score.hh
@@ -20,7 +20,7 @@
 class Paper_score : public Music_output
 {
 public:
-  Paper_def *paper_;
+  Output_def *paper_;
   System *system_;
 
   Paper_score ();
diff --git a/lily/include/performance.hh b/lily/include/performance.hh
index 907b1ec998..4163493711 100644
--- a/lily/include/performance.hh
+++ b/lily/include/performance.hh
@@ -29,7 +29,7 @@ public:
 
   Link_array<Audio_staff> audio_staffs_;
   Cons<Audio_element> *audio_elem_p_list_;
-  Midi_def *midi_;
+  Output_def *midi_;
 };
 
 #endif /* PERFORMANCE_HH */
diff --git a/lily/include/score.hh b/lily/include/score.hh
index ca25c3d0f9..d9a81f79e8 100644
--- a/lily/include/score.hh
+++ b/lily/include/score.hh
@@ -21,13 +21,13 @@ class Score : public Input
   DECLARE_SMOBS (Score, foo);
 
 public:
-  Link_array<Music_output_def> defs_;
+  Link_array<Output_def> defs_;
   SCM music_;
   SCM header_;
     
   Score ();
   Score (Score const&);
-  SCM book_rendering (String, Book_paper_def*, Music_output_def*, Paper_def**);
+  SCM book_rendering (String, Book_output_def*, Output_def*, Output_def**);
 };
 
 DECLARE_UNSMOB (Score, score);
diff --git a/lily/include/translator.hh b/lily/include/translator.hh
index e4ae2fb343..1050cac31a 100644
--- a/lily/include/translator.hh
+++ b/lily/include/translator.hh
@@ -43,7 +43,7 @@ public:
 
   SCM internal_get_property (SCM symbol) const;
   
-  virtual Music_output_def *get_output_def () const;
+  virtual Output_def *get_output_def () const;
   virtual Translator_group* get_daddy_translator ()const;
   virtual Moment now_mom () const;  
   virtual bool try_music (Music *req);
diff --git a/lily/key-signature-interface.cc b/lily/key-signature-interface.cc
index 7f9a96b1d7..1990b336a5 100644
--- a/lily/key-signature-interface.cc
+++ b/lily/key-signature-interface.cc
@@ -11,7 +11,7 @@
 #include "item.hh"
 
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
diff --git a/lily/line-interface.cc b/lily/line-interface.cc
index 317df83495..33c0f38209 100644
--- a/lily/line-interface.cc
+++ b/lily/line-interface.cc
@@ -12,7 +12,7 @@ source file of the GNU LilyPond music typesetter
 #include "grob.hh"
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 
 Stencil
diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc
index 023c504f21..9dc4562539 100644
--- a/lily/line-spanner.cc
+++ b/lily/line-spanner.cc
@@ -12,7 +12,7 @@
 #include "item.hh"
 #include "spanner.hh"
 #include "line-spanner.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-column.hh"
 #include "staff-symbol-referencer.hh"
 #include "font-interface.hh"
diff --git a/lily/lyric-extender.cc b/lily/lyric-extender.cc
index 9fda17d946..7343b6bfcd 100644
--- a/lily/lyric-extender.cc
+++ b/lily/lyric-extender.cc
@@ -13,7 +13,7 @@
 #include "lookup.hh"
 #include "stencil.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "lyric-extender.hh"
 #include "note-head.hh"
 #include "group-interface.hh"
diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc
index 0f5460b4b8..3a2ea9e68f 100644
--- a/lily/lyric-hyphen.cc
+++ b/lily/lyric-hyphen.cc
@@ -11,7 +11,7 @@
 #include "box.hh"
 #include "lookup.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-column.hh"
 #include "spanner.hh"
 #include "item.hh"
diff --git a/lily/main.cc b/lily/main.cc
index a3b89c6020..c8811fdc04 100644
--- a/lily/main.cc
+++ b/lily/main.cc
@@ -27,9 +27,8 @@
 #include "lily-guile.hh"
 #include "lily-version.hh"
 #include "main.hh"
-#include "midi-def.hh"
 #include "misc.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "string.hh"
 #include "warn.hh"
 
diff --git a/lily/measure-grouping-spanner.cc b/lily/measure-grouping-spanner.cc
index 62c7c287ab..7d160ac8e4 100644
--- a/lily/measure-grouping-spanner.cc
+++ b/lily/measure-grouping-spanner.cc
@@ -7,7 +7,7 @@
 
  */
 
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "spanner.hh"
 #include "measure-grouping-spanner.hh"
 #include "lookup.hh" 
diff --git a/lily/mensural-ligature-engraver.cc b/lily/mensural-ligature-engraver.cc
index 4d6493fec8..8252e5a569 100644
--- a/lily/mensural-ligature-engraver.cc
+++ b/lily/mensural-ligature-engraver.cc
@@ -18,7 +18,7 @@
 #include "rhythmic-head.hh"
 #include "note-head.hh"
 #include "staff-symbol-referencer.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 
 /*
diff --git a/lily/mensural-ligature.cc b/lily/mensural-ligature.cc
index 2035745173..c9cab99eb4 100644
--- a/lily/mensural-ligature.cc
+++ b/lily/mensural-ligature.cc
@@ -14,7 +14,7 @@
 #include "lookup.hh"
 #include "staff-symbol-referencer.hh"
 #include "note-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 
 /*
diff --git a/lily/midi-def.cc b/lily/midi-def.cc
index 234ebeb2aa..d30e94e599 100644
--- a/lily/midi-def.cc
+++ b/lily/midi-def.cc
@@ -1,5 +1,5 @@
 /*
-  midi-def.cc -- implement Midi_def
+  midi-def.cc -- implement midi output def functions
 
   source file of the GNU LilyPond music typesetter
 
@@ -7,23 +7,21 @@
 
 */
 #include <math.h>
+
 #include "misc.hh"
-#include "midi-def.hh"
-#include "performance.hh"
+#include "output-def.hh"
+#include "moment.hh"
 #include "warn.hh"
 #include "scm-hash.hh"
 
-Midi_def::Midi_def ()
-{
-  // ugh
-  set_tempo (Moment (Rational (1, 4)), 60);
-}
+
 
 int
-Midi_def::get_tempo (Moment one_beat_mom)
+get_tempo (Output_def * def,
+	   Moment one_beat_mom)
 {
   SCM wis  = ly_symbol2scm ("whole-in-seconds");
-  Moment *w = unsmob_moment (lookup_variable (wis));
+  Moment *w = unsmob_moment (def->lookup_variable (wis));
 
   Moment wholes_per_min = Moment (60);
   if (!w)
@@ -41,11 +39,13 @@ Midi_def::get_tempo (Moment one_beat_mom)
 }
 
 void
-Midi_def::set_tempo (Moment one_beat_mom, int beats_per_minute_i)
+set_tempo (Output_def * def,
+	   Moment one_beat_mom,
+	   int beats_per_minute_i)
 {
   Moment beats_per_second = Moment (beats_per_minute_i) / Moment (60);
 
   Moment m = Moment (1)/Moment (beats_per_second * one_beat_mom);
-  set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
+  def->set_variable (ly_symbol2scm ("whole-in-seconds"), m.smobbed_copy ());
 }
 
diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc
index 61bbf1f84d..49b6c7b631 100644
--- a/lily/multi-measure-rest.cc
+++ b/lily/multi-measure-rest.cc
@@ -9,7 +9,7 @@
 
 #include "multi-measure-rest.hh"
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-column.hh" // urg
 #include "font-interface.hh"
 #include "rest.hh"
diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc
index e22549f502..95ca709533 100644
--- a/lily/music-output-def.cc
+++ b/lily/music-output-def.cc
@@ -1,39 +1,42 @@
 /*
-  music-output-def.cc -- implement Music_output_def
+  music-output-def.cc -- implement Output_def
 
   source file of the GNU LilyPond music typesetter
 
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "scm-hash.hh"
+#include "book-paper-def.hh"
 #include "context-def.hh"
 #include "file-path.hh"
 #include "global-context.hh"
 #include "lily-guile.hh"
 #include "ly-module.hh"
 #include "main.hh"
-#include "music-output-def.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
+#include "output-def.hh"
+#include "scm-hash.hh"
 #include "warn.hh"
 
 #include "ly-smobs.icc"
 
-Music_output_def::Music_output_def ()
+Output_def::Output_def ()
 {
   scope_ = SCM_EOL;
+  parent_ = 0;
   smobify_self ();
 
   scope_ = ly_make_anonymous_module (false);
 }
 
-Music_output_def::~Music_output_def ()
+Output_def::~Output_def ()
 {
 }
 
-Music_output_def::Music_output_def (Music_output_def const &s)
+Output_def::Output_def (Output_def const &s)
 {
   scope_ = SCM_EOL;
+  parent_ = 0;
   smobify_self ();
 
   scope_= ly_make_anonymous_module (false);
@@ -42,30 +45,32 @@ Music_output_def::Music_output_def (Music_output_def const &s)
 }
 
 
-IMPLEMENT_SMOBS (Music_output_def);
-IMPLEMENT_DEFAULT_EQUAL_P (Music_output_def);
+IMPLEMENT_SMOBS (Output_def);
+IMPLEMENT_DEFAULT_EQUAL_P (Output_def);
 
-#include "paper-def.hh"
-#include "book-paper-def.hh"
 
 SCM
-Music_output_def::mark_smob (SCM m)
+Output_def::mark_smob (SCM m)
 {
-  Music_output_def * mo = (Music_output_def*) SCM_CELL_WORD_1 (m);
+  Output_def * mo = (Output_def*) SCM_CELL_WORD_1 (m);
 
   /*
     FIXME: why is this necessary?
     all bookpaper_ should be protected by themselves.
   */
-  Paper_def *pd  = dynamic_cast<Paper_def*>(mo);
-  if (pd && pd->bookpaper_)
-    scm_gc_mark (pd->bookpaper_->self_scm ());
+  if (mo->parent_)
+    scm_gc_mark (mo->parent_->self_scm ());
   
+
+  mo->derived_mark ();
   return mo->scope_;
 }
 
 void
-Music_output_def::assign_context_def (SCM transdef)
+Output_def::derived_mark () {}
+
+void
+assign_context_def (Output_def * m, SCM transdef)
 {
   Context_def *tp = unsmob_context_def (transdef);
   assert (tp);
@@ -73,7 +78,7 @@ Music_output_def::assign_context_def (SCM transdef)
   if (tp)
     {
       SCM sym = tp->get_context_name ();
-      scm_module_define (scope_, sym, transdef);
+      scm_module_define (m->scope_, sym, transdef);
     }  
 }
 
@@ -81,24 +86,16 @@ Music_output_def::assign_context_def (SCM transdef)
   find the translator for NAME. NAME must be a symbol.
 */
 SCM
-Music_output_def::find_context_def (SCM name) const
+find_context_def (Output_def const *m, SCM name)
 {  
-  SCM var = ly_module_lookup (scope_, name);
-
-  if (var != SCM_BOOL_F)
-    {
-      var = scm_variable_ref (var);
-      Context_def *cd = (unsmob_context_def (var));
-      return cd ? cd->self_scm () : SCM_EOL;
-    }
-  else
-    return SCM_EOL;
+  Context_def *cd = unsmob_context_def (m->lookup_variable (name));
+  return cd ? cd->self_scm () : SCM_EOL;
 }
 
 int
-Music_output_def::print_smob (SCM s, SCM p, scm_print_state *)
+Output_def::print_smob (SCM s, SCM p, scm_print_state *)
 {
-  Music_output_def * def = unsmob_music_output_def (s);
+  Output_def * def = unsmob_output_def (s);
   scm_puts ("#< ", p);
   scm_puts (classname (def), p);
   
@@ -107,56 +104,76 @@ Music_output_def::print_smob (SCM s, SCM p, scm_print_state *)
   return 1;
 }
 
+Real
+Output_def::get_dimension (SCM s) const
+{
+  SCM val = lookup_variable (s);
+  return ly_scm2double (val);
+}
+
+
 SCM
-Music_output_def::lookup_variable (SCM sym) const
+Output_def::lookup_variable (SCM sym) const
 {
   SCM var = ly_module_lookup (scope_, sym);
-
-  return scm_variable_ref (var);
+  if (SCM_VARIABLEP (var))
+    return SCM_VARIABLE_REF (var);
+  
+  if (parent_)
+    return parent_->lookup_variable (sym);
+  
+  return SCM_EOL;
 }
 
 SCM
-Music_output_def::c_variable (String s) const
+Output_def::c_variable (String s) const
 {
   return lookup_variable (ly_symbol2scm (s.to_str0 ()));
 }
 
 void
-Music_output_def::set_variable (SCM sym, SCM val)
+Output_def::set_variable (SCM sym, SCM val)
 {
   scm_module_define (scope_, sym, val);
 }
 
-LY_DEFINE (ly_paper_lookup, "ly:paper-lookup",
-	   2, 0,0, (SCM pap, SCM sym),
+LY_DEFINE (ly_paper_lookup, "ly:output-def-lookup",
+	   2, 0, 0, (SCM pap, SCM sym),
 	   "Lookup @var{sym} in @var{pap}. "
 	   "Return the value or @code{'()} if undefined.")
 {
-  Music_output_def *op = unsmob_music_output_def (pap);
-  SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Paper");
+  Output_def *op = unsmob_output_def (pap);
+  SCM_ASSERT_TYPE (op, pap, SCM_ARG1, __FUNCTION__, "Output_def");
   SCM_ASSERT_TYPE (ly_c_symbol_p (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
 
-  SCM var = ly_module_lookup (op->scope_, sym);
-  if (SCM_VARIABLEP (var))
-    return SCM_VARIABLE_REF (var);
-  else
-    return SCM_EOL;
+  return op->lookup_variable (sym);
 }
 
 LY_DEFINE (ly_output_def_scope, "ly:output-def-scope",
 	   1, 0,0, (SCM def),
 	   "Get the variable scope inside @var{def}.")
 {
-  Music_output_def *op = unsmob_music_output_def (def);
+  Output_def *op = unsmob_output_def (def);
   SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
   return op->scope_;
 }
 
+
+LY_DEFINE (ly_output_def_parent, "ly:output-def-parent",
+	   1, 0, 0, (SCM def),
+	   "Get the parent output-def of @var{def}.")
+{
+  Output_def *op = unsmob_output_def (def);
+  SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
+  return op->parent_ ? op->parent_->self_scm () : SCM_EOL;
+}
+
+
 LY_DEFINE (ly_output_def_clone, "ly:output-def-clone",
 	   1, 0, 0, (SCM def),
 	   "Clone @var{def}.")
 {
-  Music_output_def *op = unsmob_music_output_def (def);
+  Output_def *op = unsmob_output_def (def);
   SCM_ASSERT_TYPE (op, def, SCM_ARG1, __FUNCTION__, "Output definition");
   SCM s = op->clone ()->self_scm ();
   scm_gc_unprotect_object (s);
@@ -168,7 +185,7 @@ LY_DEFINE(ly_output_description, "ly:output-description",
 	  (SCM output_def),
 	  "Return the description of translators in @var{output-def}.")
 {
-  Music_output_def *id = unsmob_music_output_def (output_def);
+  Output_def *id = unsmob_output_def (output_def);
   
   SCM al =ly_module_to_alist (id->scope_);
 
@@ -187,3 +204,23 @@ LY_DEFINE(ly_output_description, "ly:output-description",
 }
   
 
+
+#include "interval.hh"
+
+/* FIXME.  This is broken until we have a generic way of
+   putting lists inside the \paper block.  */
+Interval
+line_dimensions_int (Output_def *def, int n)
+{
+  Real lw =  def->get_dimension (ly_symbol2scm ("linewidth"));
+  Real ind = n ? 0.0 : def->get_dimension (ly_symbol2scm ("indent"));
+
+  return Interval (ind, lw);
+}
+
+LY_DEFINE (ly_paper_def_p, "ly:paper-def?",
+	   1, 0, 0, (SCM def),
+	   "Is @var{def} a paper definition?")
+{
+  return ly_bool2scm (unsmob_output_def (def));
+}
diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc
index 88661b346d..8d9fcb93de 100644
--- a/lily/my-lily-lexer.cc
+++ b/lily/my-lily-lexer.cc
@@ -178,17 +178,26 @@ My_lily_lexer::start_main_input ()
 void
 My_lily_lexer::set_identifier (SCM name, SCM s)
 {
-  assert (ly_c_string_p (name));
+  SCM sym = name;
+  if (ly_c_string_p (name))
+    sym =  scm_string_to_symbol (name);
   
-  if (lookup_keyword (ly_scm2string (name)) >= 0)
+  if (ly_c_symbol_p (sym))
     {
-      warning (_f ("Identifier name is a keyword: `%s'", SCM_STRING_CHARS (name)));
-    }
+      if (lookup_keyword (ly_symbol2string (sym)) >= 0)
+	{
+	  warning (_f ("Identifier name is a keyword: `%s'", SCM_SYMBOL_CHARS (sym)));
+	}
 
-  SCM sym = scm_string_to_symbol (name);
-  SCM mod = ly_car (scopes_);
+      SCM mod = ly_car (scopes_);
 
-  scm_module_define (mod, sym, s);
+      scm_module_define (mod, sym, s);
+    }
+  
+  else
+    {
+      programming_error ("Identifier is not a symbol.");
+    }
 }
 
 My_lily_lexer::~My_lily_lexer ()
diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc
index 018d4b0e8a..c6bdec50c3 100644
--- a/lily/my-lily-parser.cc
+++ b/lily/my-lily-parser.cc
@@ -17,7 +17,7 @@
 #include "main.hh"
 #include "my-lily-lexer.hh"
 #include "my-lily-parser.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "parray.hh"
 #include "parser.hh"
 #include "scm-hash.hh"
@@ -371,21 +371,37 @@ LY_DEFINE (ly_parser_parse_string, "ly:parser-parse-string",
   return SCM_UNSPECIFIED;
 }
 
-Music_output_def*
+Output_def*
 get_paper (My_lily_parser *parser)
 {
   SCM id = parser->lexer_->lookup_identifier ("$defaultpaper");
-  Music_output_def *paper = unsmob_music_output_def (id);
-  return paper ? paper->clone () : new Paper_def;
+  Output_def *paper = unsmob_output_def (id);
+  paper = paper ? paper->clone () : new Output_def;
+  paper->set_variable (ly_symbol2scm ("is-paper"), SCM_BOOL_T);
+  return paper;
 }
 
 
-Book_paper_def*
+Output_def*
+get_midi (My_lily_parser *parser)
+{
+  SCM id = parser->lexer_->lookup_identifier ("$defaultmidi");
+  Output_def *paper = unsmob_output_def (id);
+  paper = paper ? paper->clone () : new Output_def;
+  paper->set_variable (ly_symbol2scm ("is-midi"), SCM_BOOL_T);
+  return paper;
+}
+
+
+Book_output_def*
 get_bookpaper (My_lily_parser *parser)
 {
   SCM id = parser->lexer_->lookup_identifier ("$defaultbookpaper");
-  Book_paper_def *paper = unsmob_book_paper_def (id);
-  return paper->clone ();
+  Book_output_def *paper = unsmob_book_output_def (id);
+
+  paper = paper ? dynamic_cast<Book_output_def*> (paper->clone ()) : new Book_output_def;
+  paper->set_variable (ly_symbol2scm ("is-bookpaper"), SCM_BOOL_T);
+  return paper;
 }
 
 
@@ -421,7 +437,7 @@ LY_DEFINE (ly_parser_print_score, "ly:parser-print-score",
 
   if (score->defs_.is_empty ())
     {
-      Music_output_def *paper = get_paper (parser);
+      Output_def *paper = get_paper (parser);
       default_rendering (score->music_, paper->self_scm (),
 			 get_bookpaper (parser)->self_scm (),
 			 header, os);
@@ -437,7 +453,7 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book",
 {
   My_lily_parser *parser = unsmob_my_lily_parser (parser_smob);
   Book *book = unsmob_book (book_smob);
-  Book_paper_def *bp = unsmob_book_paper_def (parser->lexer_->lookup_identifier ("$defaultbookpaper"));
+  Book_output_def *bp = unsmob_book_output_def (parser->lexer_->lookup_identifier ("$defaultbookpaper"));
   
   SCM_ASSERT_TYPE (parser, parser_smob, SCM_ARG1, __FUNCTION__, "Lilypond parser");
   SCM_ASSERT_TYPE (book, book_smob, SCM_ARG2, __FUNCTION__, "Book");
@@ -451,7 +467,7 @@ LY_DEFINE (ly_parser_print_book, "ly:parser-print-book",
   if (*c)
     outname.base_ += "-" + to_string (*c);
   (*c)++;
-  Music_output_def *paper = get_paper (parser);
+  Output_def *paper = get_paper (parser);
   book->process (outname.to_string (), paper, header);
   scm_gc_unprotect_object (paper->self_scm ());
   return SCM_UNDEFINED;
diff --git a/lily/note-collision.cc b/lily/note-collision.cc
index 2d7c595cf1..ee3f53c888 100644
--- a/lily/note-collision.cc
+++ b/lily/note-collision.cc
@@ -13,7 +13,7 @@
 #include "note-column.hh"
 #include "note-head.hh"
 #include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "axis-group-interface.hh"
 #include "item.hh"
 #include "stem.hh"
diff --git a/lily/note-column.cc b/lily/note-column.cc
index 2edd774257..75117699b4 100644
--- a/lily/note-column.cc
+++ b/lily/note-column.cc
@@ -11,7 +11,7 @@
 #include "note-column.hh"
 #include "stem.hh"
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "rest.hh"
diff --git a/lily/note-head.cc b/lily/note-head.cc
index 39f57e848c..dfe20fbf52 100644
--- a/lily/note-head.cc
+++ b/lily/note-head.cc
@@ -19,7 +19,7 @@
 #include "rhythmic-head.hh"
 #include "staff-symbol-referencer.hh"
 #include "lookup.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 /*
   Note_head contains the code for printing note heads.
diff --git a/lily/note-heads-engraver.cc b/lily/note-heads-engraver.cc
index 12398fc068..7898b85ec3 100644
--- a/lily/note-heads-engraver.cc
+++ b/lily/note-heads-engraver.cc
@@ -6,7 +6,7 @@
 #include <ctype.h>
 
 #include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "event.hh"
 #include "dots.hh"
 #include "dot-column.hh"
diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc
index a3b94a5749..3a9d904e28 100644
--- a/lily/note-spacing.cc
+++ b/lily/note-spacing.cc
@@ -18,7 +18,7 @@
 #include "separation-item.hh"
 #include "staff-spacing.hh"
 #include "accidental-placement.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 
 /*
diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc
index c877f2ce59..8f86a03eff 100644
--- a/lily/ottava-bracket.cc
+++ b/lily/ottava-bracket.cc
@@ -14,7 +14,7 @@
 #include "spanner.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 #include "paper-column.hh"
 #include "staff-symbol-referencer.hh"
@@ -49,7 +49,7 @@ Ottava_bracket::print (SCM smob)
   Interval span_points;
   
   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
-  Paper_def * paper = me->get_paper ();
+  Output_def * paper = me->get_paper ();
 
   
   Drul_array<bool> broken;
diff --git a/lily/page.cc b/lily/page.cc
index 3eeba7a5d9..104f0052f9 100644
--- a/lily/page.cc
+++ b/lily/page.cc
@@ -9,7 +9,7 @@
 #include "dimensions.hh"
 #include "ly-module.hh"
 #include "page.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-outputter.hh"
 #include "paper-line.hh"
 #include "stencil.hh"
@@ -19,13 +19,13 @@
 int Page::page_count_ = 0;
 Real Page::MIN_COVERAGE_ = 0.66;
 
-Book_paper_def *
+Book_output_def *
 Page::bookpaper () const
 {
-  return paper_->bookpaper_;
+  return dynamic_cast<Book_output_def*> ( paper_->parent_);
 }
 
-Page::Page (Paper_def *paper, int number)
+Page::Page (Output_def *paper, int number)
 {
   copyright_ = SCM_EOL;
   footer_ = SCM_EOL;
diff --git a/lily/paper-book.cc b/lily/paper-book.cc
index c4cc819c96..b95b614c3e 100644
--- a/lily/paper-book.cc
+++ b/lily/paper-book.cc
@@ -10,7 +10,7 @@
 #include "main.hh"
 #include "page.hh"
 #include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-outputter.hh"
 #include "paper-line.hh"
 #include "paper-score.hh"
@@ -90,10 +90,11 @@ Paper_book::output (String outname)
   /* Generate all stencils to trigger font loads.  */
   SCM pages = this->pages ();
 
-  Paper_def *paper = score_lines_[0].paper_;
-  Paper_outputter *out = paper->get_paper_outputter (outname);
+  Output_def *paper = score_lines_[0].paper_;
+  Paper_outputter *out = get_paper_outputter (outname);
   int page_count = scm_ilength (pages);
-  out->output_header (paper->bookpaper_, scopes (0), page_count, false);
+
+  out->output_header (paper->parent_, scopes (0), page_count, false);
 
   for (SCM s = pages; s != SCM_EOL; s = ly_cdr (s))
     {
@@ -144,9 +145,13 @@ void
 Paper_book::classic_output (String outname)
 {
   int count = score_lines_.size ();
-  Paper_def * p = score_lines_.top ().paper_;
-  Paper_outputter *out = p->get_paper_outputter (outname);
-  out->output_header (p->bookpaper_, scopes (count - 1), 0, true);
+  Paper_outputter *out = get_paper_outputter (outname);
+
+  Output_def * p = score_lines_.top ().paper_;
+  while (p && p->parent_)
+    p = p->parent_;
+  
+  out->output_header (p, scopes (count - 1), 0, true);
 
   SCM top_lines = score_lines_.top ().lines_;
   Paper_line *first = unsmob_paper_line (scm_vector_ref (top_lines,
@@ -195,7 +200,7 @@ Paper_book::init ()
 	}
     }
 
-  Paper_def *paper = score_lines_[0].paper_;
+  Output_def *paper = score_lines_[0].paper_;
   SCM scopes = this->scopes (0);
 
   SCM make_tagline = paper->c_variable ("make-tagline");
@@ -238,7 +243,7 @@ Paper_book::pages ()
 {
   init ();
   Page::page_count_ = 0;
-  Paper_def *paper = score_lines_[0].paper_;
+  Output_def *paper = score_lines_[0].paper_;
   Page *page = new Page (paper, 1);
 
   Real text_height = page->text_height ();
diff --git a/lily/paper-column.cc b/lily/paper-column.cc
index 0c06555920..6f52171db1 100644
--- a/lily/paper-column.cc
+++ b/lily/paper-column.cc
@@ -16,7 +16,7 @@
 #include "text-item.hh"
 #include "lookup.hh"
 #include "font-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 
 
diff --git a/lily/paper-def.cc b/lily/paper-def.cc
index 388235ab7d..e69de29bb2 100644
--- a/lily/paper-def.cc
+++ b/lily/paper-def.cc
@@ -1,89 +0,0 @@
-/*
-  paper-def.cc -- implement Paper_def
-
-  source file of the GNU LilyPond music typesetter
-
-  (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-*/
-
-
-#include <math.h>
-
-#include "book-paper-def.hh"
-#include "virtual-font-metric.hh"
-#include "all-font-metrics.hh"
-#include "string.hh"
-#include "misc.hh"
-#include "paper-def.hh"
-#include "warn.hh"
-#include "scaled-font-metric.hh"
-#include "main.hh"
-#include "scm-hash.hh"
-#include "paper-outputter.hh"
-#include "ly-module.hh"
-
-/*
-  This is an almost empty thing. The only substantial thing this class
-  handles is scaling up and down to real-world dimensions (internally
-  dimensions are against global staff-space.)
- */
-
-Paper_def::Paper_def ()
-{
-  bookpaper_ = 0;
-}
-
-Paper_def::Paper_def (Paper_def const&src)
-  : Music_output_def (src)
-{
-  /* Do not remove this statement, scm_make_hash_table may trigger GC.  */
-  bookpaper_ = 0;
-}
-
-Paper_def::~Paper_def ()
-{
-}
-
-Real
-Paper_def::get_dimension (SCM s) const
-{
-  SCM val = lookup_variable (s);
-  return ly_scm2double (val);
-}
-
-/* FIXME.  This is broken until we have a generic way of
-   putting lists inside the \paper block.  */
-Interval
-Paper_def::line_dimensions_int (int n) const
-{
-  Real lw =  get_dimension (ly_symbol2scm ("linewidth"));
-  Real ind = n? 0.0:get_dimension (ly_symbol2scm ("indent"));
-
-  return Interval (ind, lw);
-}
-
-Paper_outputter*
-Paper_def::get_paper_outputter (String outname) const
-{
-  progress_indication (_f ("paper output to `%s'...",
-			   outname == "-" ? String ("<stdout>") : outname));
-  return new Paper_outputter (outname);
-
-}
-
-Paper_def* 
-unsmob_paper (SCM x)
-{
-  return dynamic_cast<Paper_def*> (unsmob_music_output_def (x));
-}
-  
-
-LY_DEFINE (ly_paper_def_p, "ly:paper-def?",
-	   1, 0, 0, (SCM def),
-	   "Is @var{def} a paper definition?")
-{
-  Paper_def *op = dynamic_cast<Paper_def*> (unsmob_music_output_def (def));
-
-  bool pap = op;
-  return ly_bool2scm (pap);
-}
diff --git a/lily/paper-outputter.cc b/lily/paper-outputter.cc
index 318784259e..310ce23830 100644
--- a/lily/paper-outputter.cc
+++ b/lily/paper-outputter.cc
@@ -21,7 +21,7 @@
 #include "main.hh"
 #include "page.hh"
 #include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-line.hh"
 #include "paper-outputter.hh"
 #include "file-name.hh"
@@ -56,7 +56,7 @@ Paper_outputter::output_scheme (SCM scm)
 }
 
 void
-Paper_outputter::output_metadata (Book_paper_def *paper, SCM scopes)
+Paper_outputter::output_metadata (Output_def *paper, SCM scopes)
 {
   SCM fields = SCM_EOL;
   for (int i = dump_header_fieldnames_global.size (); i--; )
@@ -76,8 +76,7 @@ Paper_outputter::output_metadata (Book_paper_def *paper, SCM scopes)
 }
 
 void
-Paper_outputter::output_header (Book_paper_def * bookpaper,
-				
+Paper_outputter::output_header (Output_def * bookpaper,
 				SCM scopes,
 				int page_count,
 				bool is_classic)
@@ -146,7 +145,7 @@ Paper_outputter::output_page (Page *p, bool is_last)
 }
 
 void
-Paper_outputter::output_music_output_def (Music_output_def *odef)
+Paper_outputter::output_music_output_def (Output_def *odef)
 {
   output_scheme (scm_list_2 (ly_symbol2scm ("output-paper-def"),
 			      odef->self_scm ()));
@@ -168,3 +167,11 @@ Paper_outputter::output_stencil (Stencil stil)
 			  (void*) this, Offset (0,0));
 }
 
+Paper_outputter*
+get_paper_outputter (String outname) 
+{
+  progress_indication (_f ("paper output to `%s'...",
+			   outname == "-" ? String ("<stdout>") : outname));
+  return new Paper_outputter (outname);
+
+}
diff --git a/lily/paper-score.cc b/lily/paper-score.cc
index 430cd52c57..9d4024b18a 100644
--- a/lily/paper-score.cc
+++ b/lily/paper-score.cc
@@ -11,7 +11,7 @@
 #include "warn.hh"
 #include "font-metric.hh"
 #include "spanner.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "system.hh"
 #include "paper-column.hh"
 #include "paper-score.hh"
diff --git a/lily/parser.yy b/lily/parser.yy
index 3820640b2d..915449be0f 100644
--- a/lily/parser.yy
+++ b/lily/parser.yy
@@ -37,14 +37,13 @@ TODO:
 #include "lilypond-input-version.hh"
 #include "ly-module.hh"
 #include "main.hh"
-#include "midi-def.hh"
 #include "misc.hh"
 #include "music-list.hh"
 #include "music-sequence.hh"
 #include "my-lily-lexer.hh"
 #include "my-lily-parser.hh"
 #include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "scm-hash.hh"
 #include "scm-option.hh"
 #include "score.hh"
@@ -194,8 +193,8 @@ of the parse stack onto the heap. */
 
 %union {
 	Book *book;
-	Book_paper_def *bookpaper;
-	Music_output_def *outputdef;
+	Book_output_def *bookpaper;
+	Output_def *outputdef;
 	SCM scm;
 	String *string;
  	Music *music;
@@ -474,15 +473,18 @@ toplevel_expression:
 	}
 	| output_def {
 		SCM id = SCM_EOL;
-		if (dynamic_cast<Paper_def*> ($1))
-			id = scm_makfrom0str ("$defaultpaper");
-		else if (dynamic_cast<Midi_def*> ($1))
-			id = scm_makfrom0str ("$defaultmidi");
+		if ($1->c_variable ("is-paper") == SCM_BOOL_T)
+			id = ly_symbol2scm ("$defaultpaper");
+		else if ($1->c_variable ("is-midi") == SCM_BOOL_T)
+			id = ly_symbol2scm ("$defaultmidi");
+		else if ($1->c_variable ("is-book-paper") == SCM_BOOL_T)
+			id = ly_symbol2scm ("$defaultbookpaper");
+
 		THIS->lexer_->set_identifier (id, $1->self_scm ());
 		scm_gc_unprotect_object ($1->self_scm ());
 	}
 	| book_paper_block {
-		THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultbookpaper"), $1->self_scm ());
+		THIS->lexer_->set_identifier (ly_symbol2scm ("$defaultbookpaper"), $1->self_scm ());
 		scm_gc_unprotect_object ($1->self_scm ());
 	}
 	;
@@ -622,7 +624,7 @@ book_paper_block:
 	;
 book_paper_head:
 	BOOKPAPER '{' {
-		$$ = unsmob_book_paper_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone ();
+		$$ = get_bookpaper (THIS);
 		THIS->lexer_->add_scope ($$->scope_);
 	}
 	;
@@ -651,7 +653,7 @@ book_body:
 	{
 		$$ = new Book;
 		$$->set_spot (THIS->here_input ());
-		$$->bookpaper_ = unsmob_book_paper_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone ();
+		$$->bookpaper_ = dynamic_cast<Book_output_def*> (unsmob_book_output_def (THIS->lexer_->lookup_identifier ("$defaultbookpaper"))->clone ());
 		scm_gc_unprotect_object ($$->bookpaper_->self_scm ());
 	}
 	| book_body book_paper_block {
@@ -735,25 +737,13 @@ output_def:
 
 music_output_def_head:
 	MIDI    {
-		Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultmidi"));
-
-
-		Midi_def *p = 0;
-		if (id)
-			p = dynamic_cast<Midi_def*> (id->clone ());
-		else
-			p = new Midi_def;
-
+		Output_def *p = get_midi (THIS);
 		$$ = p;
 		THIS->lexer_->add_scope (p->scope_);
 	}
 	| PAPER 	{
-		Music_output_def *id = unsmob_music_output_def (THIS->lexer_->lookup_identifier ("$defaultpaper"));
-		  Paper_def *p = 0;
-		if (id)
-			p = dynamic_cast<Paper_def*> (id->clone ());
-		else
-			p = new Paper_def;
+		Output_def* p = get_paper (THIS);
+
 
 		THIS->lexer_->add_scope (p->scope_);
 		$$ = p;
@@ -769,7 +759,7 @@ music_output_def_body:
 	}
 	| music_output_def_head '{' MUSIC_OUTPUT_DEF_IDENTIFIER 	{
 		scm_gc_unprotect_object ($1->self_scm ());
-		Music_output_def *o = unsmob_music_output_def ($3);
+		Output_def *o = unsmob_output_def ($3);
 		o->input_origin_.set_spot (THIS->here_input ());
 		$$ = o;
 		THIS->lexer_->remove_scope ();
@@ -780,18 +770,16 @@ music_output_def_body:
 
 	}
 	| music_output_def_body context_def_spec_block	{
-		$$->assign_context_def ($2);
+		assign_context_def ($$, $2);
 	}
 	| music_output_def_body tempo_event  {
 		/*
 			junk this ? there already is tempo stuff in
 			music.
 		*/
-		int m = ly_scm2int ( $2->get_property ("metronome-count"));
+		int m = ly_scm2int ($2->get_property ("metronome-count"));
 		Duration *d = unsmob_duration ($2->get_property ("tempo-unit"));
-		Midi_def *md = dynamic_cast<Midi_def*> ($$);
-		if (md)
-			md->set_tempo (d->get_length (), m);
+		set_tempo ($$, d->get_length (), m);
 		scm_gc_unprotect_object ($2->self_scm ());
 	}
 	| music_output_def_body error {
@@ -2478,7 +2466,7 @@ markup:
  		Book *book = new Book;
 		book->scores_.push (score);
 			
-		Music_output_def *paper = get_paper (THIS);
+		Output_def *paper = get_paper (THIS);
 		book->bookpaper_ = get_bookpaper (THIS);
 
 		SCM s = book->to_stencil (paper, THIS->header_);
@@ -2583,8 +2571,8 @@ My_lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
 	} else if (unsmob_duration (sid)) {
 		*destination = unsmob_duration (sid)->smobbed_copy ();
 		return DURATION_IDENTIFIER;
-	} else if (unsmob_music_output_def (sid)) {
-		Music_output_def *p = unsmob_music_output_def (sid);
+	} else if (unsmob_output_def (sid)) {
+		Output_def *p = unsmob_output_def (sid);
 		p = p->clone ();
 
 		*destination = p->self_scm ();
diff --git a/lily/performance.cc b/lily/performance.cc
index 5bb074307f..379e024793 100644
--- a/lily/performance.cc
+++ b/lily/performance.cc
@@ -14,7 +14,6 @@
 #include "file-name.hh"
 #include "lily-version.hh"
 #include "main.hh"
-#include "midi-def.hh"
 #include "midi-item.hh"
 #include "midi-stream.hh"
 #include "performance.hh"
diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc
index 9f0aeef0cb..83354c3a50 100644
--- a/lily/rest-collision.cc
+++ b/lily/rest-collision.cc
@@ -13,7 +13,7 @@
 #include "note-column.hh"
 #include "stem.hh"
 #include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "rest.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
diff --git a/lily/rest.cc b/lily/rest.cc
index fc1f7e2782..63b8e55d54 100644
--- a/lily/rest.cc
+++ b/lily/rest.cc
@@ -7,7 +7,7 @@
 */
 
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "rest.hh"
 #include "dots.hh"
diff --git a/lily/score-engraver.cc b/lily/score-engraver.cc
index 27c7d52038..9321423219 100644
--- a/lily/score-engraver.cc
+++ b/lily/score-engraver.cc
@@ -15,7 +15,7 @@
 #include "score-engraver.hh"
 #include "paper-score.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "axis-group-interface.hh"
 #include "context-def.hh"
 #include "staff-spacing.hh"
@@ -105,7 +105,7 @@ Score_engraver::initialize ()
    
 
   pscore_ = new Paper_score;
-  pscore_->paper_ = dynamic_cast<Paper_def*> (get_output_def ());
+  pscore_->paper_ = dynamic_cast<Output_def*> (get_output_def ());
 
   SCM props = updated_grob_properties (context (), ly_symbol2scm ("System"));
 
diff --git a/lily/score-performer.cc b/lily/score-performer.cc
index f1aa576917..4d231ff63a 100644
--- a/lily/score-performer.cc
+++ b/lily/score-performer.cc
@@ -7,7 +7,6 @@
  */
 
 #include "score-performer.hh"
-#include "midi-def.hh"
 #include "audio-column.hh"
 #include "audio-item.hh"
 #include "performance.hh"
@@ -15,6 +14,7 @@
 #include "string-convert.hh"
 #include "warn.hh"
 #include "context-def.hh"
+#include "output-def.hh"
 
 
 
@@ -78,7 +78,7 @@ Score_performer::one_time_step ()
 int
 Score_performer::get_tempo () const
 {
-  return performance_->midi_->get_tempo (Moment (Rational (1, 4)));
+  return ::get_tempo (performance_->midi_, Moment (Rational (1, 4)));
 }
 
 
@@ -94,7 +94,7 @@ void
 Score_performer::initialize ()
 {
   performance_ = new Performance;
-  performance_->midi_ = dynamic_cast<Midi_def*> (get_output_def ());
+  performance_->midi_ = get_output_def ();
 
   Translator_group::initialize ();
 }
diff --git a/lily/score.cc b/lily/score.cc
index 58f4e97e39..aa66207b9d 100644
--- a/lily/score.cc
+++ b/lily/score.cc
@@ -16,11 +16,11 @@
 #include "ly-smobs.icc"
 #include "main.hh"
 #include "music-iterator.hh"
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "music-output.hh"
 #include "music.hh"
 #include "paper-book.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-score.hh"
 #include "scm-hash.hh"
 #include "score.hh"
@@ -99,7 +99,7 @@ LY_DEFINE (ly_run_translator, "ly:run-translator",
 	   "and @var{mus} is interpreted with it.  "
 	   "The context is returned in its final state.")
 {
-  Music_output_def *odef = unsmob_music_output_def (output_def);
+  Output_def *odef = unsmob_output_def (output_def);
   Music *music = unsmob_music (mus);
 
   SCM_ASSERT_TYPE (music, mus, SCM_ARG1, __FUNCTION__, "Music");
@@ -160,10 +160,10 @@ default_rendering (SCM music, SCM outdef,
 		   SCM book_outputdef,
 		   SCM header, SCM outname)
 {
-  Book_paper_def *bpd = unsmob_book_paper_def (book_outputdef);
-  if (bpd && unsmob_paper (outdef))
+  Book_output_def *bpd = unsmob_book_output_def (book_outputdef);
+  if (bpd && unsmob_output_def (outdef))
     /* FIXME:  memory leak */
-    outdef = bpd->scale_paper (unsmob_paper (outdef))->self_scm ();
+    outdef = bpd->scale_paper (unsmob_output_def (outdef))->self_scm ();
   
   SCM context = ly_run_translator (music, outdef);
 
@@ -193,22 +193,22 @@ default_rendering (SCM music, SCM outdef,
  
 SCM
 Score::book_rendering (String outname,
-		       Book_paper_def* paperbook,
-		       Music_output_def *default_def,
-		       Paper_def **paper)
+		       Book_output_def* paperbook,
+		       Output_def *default_def,
+		       Output_def **paper)
 {
   SCM out = scm_makfrom0str (outname.to_str0 ());
   SCM systems = SCM_EOL;
   int outdef_count = defs_.size ();
   for (int i = 0; !i || i < outdef_count; i++)
     {
-      Music_output_def *def = outdef_count ? defs_[i] : default_def;
-      if (Paper_def * pd = dynamic_cast<Paper_def*> (def))
+      Output_def *def = outdef_count ? defs_[i] : default_def;
+      if (Output_def * pd = dynamic_cast<Output_def*> (def))
 	{
 	  def = paperbook->scale_paper (pd);
 	}
       
-      if (!(no_paper_global_b && dynamic_cast<Paper_def*> (def)))
+      if (!(no_paper_global_b && dynamic_cast<Output_def*> (def)))
 	{
 	  SCM context = ly_run_translator (music_, def->self_scm ());
 	  if (Global_context *g = dynamic_cast<Global_context*>
diff --git a/lily/script.cc b/lily/script.cc
index d314e976a8..910c240a6a 100644
--- a/lily/script.cc
+++ b/lily/script.cc
@@ -12,7 +12,7 @@
 #include "script.hh"
 #include "font-interface.hh"
 #include "side-position-interface.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "item.hh"
 #include "stencil.hh"
 #include "lookup.hh"
diff --git a/lily/separating-group-spanner.cc b/lily/separating-group-spanner.cc
index 0ca1a16471..250fcade92 100644
--- a/lily/separating-group-spanner.cc
+++ b/lily/separating-group-spanner.cc
@@ -10,7 +10,7 @@
 #include "separating-group-spanner.hh"
 #include "separation-item.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "dimensions.hh"
 #include "group-interface.hh"
 
diff --git a/lily/separating-line-group-engraver.cc b/lily/separating-line-group-engraver.cc
index 5b7054f1ee..acaf1920b4 100644
--- a/lily/separating-line-group-engraver.cc
+++ b/lily/separating-line-group-engraver.cc
@@ -10,7 +10,7 @@
 #include "separating-group-spanner.hh"
 #include "separation-item.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "engraver.hh"
 #include "axis-group-interface.hh"
 #include "note-spacing.hh"
diff --git a/lily/slur-bezier-bow.cc b/lily/slur-bezier-bow.cc
index 45d599399e..380435befb 100644
--- a/lily/slur-bezier-bow.cc
+++ b/lily/slur-bezier-bow.cc
@@ -7,7 +7,7 @@
 */
 
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "slur-bezier-bow.hh"
 
 Slur_bezier_bow::Slur_bezier_bow (Array<Offset> encompass, Direction dir,
diff --git a/lily/slur.cc b/lily/slur.cc
index 3759cc75d5..0363945cc4 100644
--- a/lily/slur.cc
+++ b/lily/slur.cc
@@ -25,7 +25,7 @@
 #include "group-interface.hh"
 #include "slur.hh"
 #include "lookup.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "note-column.hh"
 #include "stem.hh"
 #include "paper-column.hh"
diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc
index deedd461a6..bdb3212023 100644
--- a/lily/spacing-spanner.cc
+++ b/lily/spacing-spanner.cc
@@ -13,7 +13,7 @@
 #include "main.hh"
 #include "system.hh"
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-score.hh"
 #include "paper-column.hh"
 #include "item.hh"
diff --git a/lily/span-bar.cc b/lily/span-bar.cc
index b54e4a74d5..b49bde8aa3 100644
--- a/lily/span-bar.cc
+++ b/lily/span-bar.cc
@@ -9,7 +9,7 @@
 #include "span-bar.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "stencil.hh"
 #include "warn.hh"
 #include "axis-group-interface.hh"
diff --git a/lily/staff-symbol-engraver.cc b/lily/staff-symbol-engraver.cc
index 49be8930e3..fe813adc0a 100644
--- a/lily/staff-symbol-engraver.cc
+++ b/lily/staff-symbol-engraver.cc
@@ -9,7 +9,7 @@
 
 #include "score.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "side-position-interface.hh"
 #include "engraver.hh"
 #include "moment.hh"
diff --git a/lily/staff-symbol-referencer.cc b/lily/staff-symbol-referencer.cc
index 354c402f79..160576caae 100644
--- a/lily/staff-symbol-referencer.cc
+++ b/lily/staff-symbol-referencer.cc
@@ -10,7 +10,7 @@
 
 #include "staff-symbol-referencer.hh"
 #include "staff-symbol.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "libc-extension.hh"
 
 
diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc
index 46de293510..695ebb201c 100644
--- a/lily/staff-symbol.cc
+++ b/lily/staff-symbol.cc
@@ -8,7 +8,7 @@
 
 #include "lookup.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "stencil.hh"
 #include "warn.hh"
 #include "item.hh"
diff --git a/lily/stem-tremolo.cc b/lily/stem-tremolo.cc
index 7f08717622..1ac44ca61e 100644
--- a/lily/stem-tremolo.cc
+++ b/lily/stem-tremolo.cc
@@ -11,7 +11,7 @@
 #include "directional-element-interface.hh"
 #include "item.hh"
 #include "lookup.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "staff-symbol-referencer.hh"
 #include "stem-tremolo.hh"
 #include "stem.hh"
diff --git a/lily/stem.cc b/lily/stem.cc
index 437a316f70..e359efb9eb 100644
--- a/lily/stem.cc
+++ b/lily/stem.cc
@@ -20,7 +20,7 @@
 #include "note-head.hh"
 #include "stem.hh"
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "rhythmic-head.hh"
 #include "font-interface.hh"
 #include "stencil.hh"
diff --git a/lily/system-start-delimiter-engraver.cc b/lily/system-start-delimiter-engraver.cc
index 81dd379dae..719a5ed17d 100644
--- a/lily/system-start-delimiter-engraver.cc
+++ b/lily/system-start-delimiter-engraver.cc
@@ -12,7 +12,7 @@
 #include "staff-symbol.hh"
 #include "group-interface.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "spanner.hh"
 
 class System_start_delimiter_engraver : public Engraver
diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc
index 4dff002c81..4977fa0ddc 100644
--- a/lily/system-start-delimiter.cc
+++ b/lily/system-start-delimiter.cc
@@ -10,7 +10,7 @@
 
 #include "axis-group-interface.hh"
 #include "system-start-delimiter.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "stencil.hh"
 #include "font-interface.hh"
 #include "all-font-metrics.hh"
diff --git a/lily/system.cc b/lily/system.cc
index fed4dfd792..48f7034236 100644
--- a/lily/system.cc
+++ b/lily/system.cc
@@ -13,7 +13,7 @@
 #include "system.hh"
 #include "main.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-outputter.hh"
 #include "paper-score.hh"
 #include "string.hh"
diff --git a/lily/tab-note-heads-engraver.cc b/lily/tab-note-heads-engraver.cc
index af1450d692..e4caf6835b 100644
--- a/lily/tab-note-heads-engraver.cc
+++ b/lily/tab-note-heads-engraver.cc
@@ -7,7 +7,7 @@
 #include <stdio.h>
 
 #include "rhythmic-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "event.hh"
 #include "dots.hh"
 #include "dot-column.hh"
diff --git a/lily/text-item.cc b/lily/text-item.cc
index 782cd4d1c1..b03027b965 100644
--- a/lily/text-item.cc
+++ b/lily/text-item.cc
@@ -13,14 +13,14 @@
 #include "text-item.hh"
 #include "font-interface.hh"
 #include "virtual-font-metric.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "scaled-font-metric.hh"
 
 MAKE_SCHEME_CALLBACK (Text_item, interpret_string, 4)
 SCM
 Text_item::interpret_string (SCM paper, SCM props, SCM encoding, SCM markup)
 {
-  Paper_def *pap = unsmob_paper (paper);
+  Output_def *pap = unsmob_output_def (paper);
   
   SCM_ASSERT_TYPE(pap, paper, SCM_ARG1, __FUNCTION__, "Paper definition");
   SCM_ASSERT_TYPE(ly_c_string_p (markup), markup, SCM_ARG3, __FUNCTION__, "string");
diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc
index 6f07666a68..b2254b1451 100644
--- a/lily/text-spanner.cc
+++ b/lily/text-spanner.cc
@@ -15,7 +15,7 @@
 #include "spanner.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 #include "paper-column.hh"
 #include "staff-symbol-referencer.hh"
@@ -42,7 +42,7 @@ Text_spanner::print (SCM smob)
   /* Ugh, must be same as Hairpin::print.  */
 
   Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
-  Paper_def * paper = me->get_paper ();
+  Output_def * paper = me->get_paper ();
 
   SCM flare = me->get_property ("bracket-flare");
   SCM shorten = me->get_property ("shorten-pair");
diff --git a/lily/tie.cc b/lily/tie.cc
index 0ac50e5e85..c13f97f354 100644
--- a/lily/tie.cc
+++ b/lily/tie.cc
@@ -10,7 +10,7 @@
 
 #include "spanner.hh"
 #include "lookup.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "tie.hh"
 #include "rhythmic-head.hh"
 #include "bezier.hh"
diff --git a/lily/time-signature.cc b/lily/time-signature.cc
index 7cb072fa00..d6e3b16f3e 100644
--- a/lily/time-signature.cc
+++ b/lily/time-signature.cc
@@ -11,7 +11,7 @@
 #include "stencil.hh"
 #include "text-item.hh"
 #include "time-signature.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "font-interface.hh"
 #include "warn.hh"
 #include "staff-symbol-referencer.hh"
diff --git a/lily/translator-group.cc b/lily/translator-group.cc
index 85e9d43b62..8038323786 100644
--- a/lily/translator-group.cc
+++ b/lily/translator-group.cc
@@ -6,7 +6,7 @@
   (c) 1997--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
-#include "music-output-def.hh"
+#include "output-def.hh"
 #include "translator-group.hh"
 #include "translator.hh"
 #include "warn.hh"
diff --git a/lily/translator.cc b/lily/translator.cc
index 62846fb3cd..485e22b29a 100644
--- a/lily/translator.cc
+++ b/lily/translator.cc
@@ -64,7 +64,7 @@ Translator::now_mom () const
   return daddy_context_->now_mom ();
 }
 
-Music_output_def *
+Output_def *
 Translator::get_output_def () const
 {
   return daddy_context_->get_output_def ();
diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc
index 2c87802a08..7a56f9c5d4 100644
--- a/lily/tuplet-bracket.cc
+++ b/lily/tuplet-bracket.cc
@@ -31,7 +31,7 @@
 #include "warn.hh"
 #include "font-interface.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "text-item.hh"
 #include "tuplet-bracket.hh"
 #include "stem.hh"
@@ -168,7 +168,7 @@ Tuplet_bracket::print (SCM smob)
   
   SCM number = me->get_property ("text");
 
-  Paper_def *pap = me->get_paper ();
+  Output_def *pap = me->get_paper ();
   Stencil num;
  if (ly_c_string_p (number) && number_visibility)
     {
diff --git a/lily/vaticana-ligature-engraver.cc b/lily/vaticana-ligature-engraver.cc
index b6d6e5b6b8..94cccf6f08 100644
--- a/lily/vaticana-ligature-engraver.cc
+++ b/lily/vaticana-ligature-engraver.cc
@@ -14,7 +14,7 @@
 #include "staff-symbol-referencer.hh"
 #include "font-interface.hh"
 #include "warn.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "paper-column.hh"
 
 /*
diff --git a/lily/vaticana-ligature.cc b/lily/vaticana-ligature.cc
index ea1d4d447e..2528586aa1 100644
--- a/lily/vaticana-ligature.cc
+++ b/lily/vaticana-ligature.cc
@@ -14,7 +14,7 @@
 #include "lookup.hh"
 #include "staff-symbol-referencer.hh"
 #include "note-head.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "bezier.hh"
 #include "warn.hh"
 
diff --git a/lily/virtual-font-metric.cc b/lily/virtual-font-metric.cc
index 065a9a5436..d63d8b74a0 100644
--- a/lily/virtual-font-metric.cc
+++ b/lily/virtual-font-metric.cc
@@ -11,7 +11,7 @@ source file of the GNU LilyPond music typesetter
 #include "virtual-font-metric.hh"
 #include "all-font-metrics.hh"
 #include "stencil.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 
 
 /*
diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc
index 1309e98837..9f4d8a505f 100644
--- a/lily/volta-bracket.cc
+++ b/lily/volta-bracket.cc
@@ -14,7 +14,7 @@
 #include "line-interface.hh"
 #include "stencil.hh"
 #include "paper-column.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "text-item.hh"
 #include "volta-bracket.hh"
 #include "group-interface.hh"
@@ -66,7 +66,7 @@ Volta_bracket_interface::print (SCM smob)
     (strcmp (cs,":|")!=0 && strcmp (cs,"|:")!=0 && strcmp (cs,"|.")!=0
      && strcmp (cs,":|:")!=0 && strcmp (cs,".|")!=0);
 
-  Paper_def * paper =me->get_paper ();
+  Output_def * paper =me->get_paper ();
   Real half_space = 0.5;
 
   Item * bound = dynamic_cast<Spanner*> (me)->get_bound (LEFT);
diff --git a/ly/book-paper-defaults.ly b/ly/book-paper-defaults.ly
index bb344e921e..6ba340e714 100644
--- a/ly/book-paper-defaults.ly
+++ b/ly/book-paper-defaults.ly
@@ -1,5 +1,7 @@
 \version "2.3.2"
+
 \bookpaper {
+#(define-public is-bookpaper #t)
     
 #(define-public (book-title paper scopes)
   "Generate book title from header strings."
diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly
index b710b6f82c..6dfa049e5d 100644
--- a/ly/declarations-init.ly
+++ b/ly/declarations-init.ly
@@ -91,7 +91,7 @@ melismaEnd = #(make-span-event 'ManualMelismaEvent STOP)
 %
 
 #(define-public $defaultbookpaper (ly:make-bookpaper 1.7573))
-  
+
 \include "book-paper-defaults.ly"
 
 #(set-default-paper-size "a4")
diff --git a/scm/output-lib.scm b/scm/output-lib.scm
index 943cf4c390..eba247bc61 100644
--- a/scm/output-lib.scm
+++ b/scm/output-lib.scm
@@ -42,7 +42,7 @@
 	   (paper (ly:grob-paper grob))
 	   (text (interpret-markup
 		  paper
-		  (ly:grob-alist-chain grob (ly:paper-lookup paper 'text-font-defaults))
+		  (ly:grob-alist-chain grob (ly:output-def-lookup paper 'text-font-defaults))
 		  letter)))
     
       (let ((x (/ (- (cdr (ly:stencil-extent slur 0)) 
diff --git a/scm/output-ps.scm b/scm/output-ps.scm
index 4cc714fdec..537b5f0330 100644
--- a/scm/output-ps.scm
+++ b/scm/output-ps.scm
@@ -206,7 +206,7 @@
 	   (plain (font-command font #f))
 	   (designsize (ly:font-design-size font))
 	   (magnification (* (ly:font-magnification font)))
-	   (ops (ly:paper-lookup paper 'outputscale))
+	   (ops (ly:output-def-lookup paper 'outputscale))
 	   (scaling (* ops magnification designsize)))
 
       (string-append
@@ -275,7 +275,7 @@
    "%%Creator: " creator " " time-stamp "\n"
    "%%Pages: " (number->string page-count) "\n"
    "%%PageOrder: Ascend\n"
-   "%%DocumentPaperSizes: " (ly:paper-lookup paper 'papersize) "\n"
+   "%%DocumentPaperSizes: " (ly:output-def-lookup paper 'papersize) "\n"
    ;;(string-append "GNU LilyPond (" (lilypond-version) "), ")
    ;;	   (strftime "%c" (localtime (current-time))))
    ;; FIXME: duplicated in every backend
diff --git a/scm/page-layout.scm b/scm/page-layout.scm
index 5d22f14c00..aa1f847dc0 100644
--- a/scm/page-layout.scm
+++ b/scm/page-layout.scm
@@ -8,7 +8,7 @@
 (define-public (page-properties paper)
   (list (append `((linewidth . ,(ly:paper-get-number
 				 paper 'linewidth)))
-		(ly:paper-lookup paper 'text-font-defaults))))
+		(ly:output-def-lookup paper 'text-font-defaults))))
 
 (define-public (plain-header paper page-number)
   (let ((props (page-properties paper) ))
diff --git a/scm/paper.scm b/scm/paper.scm
index b6ab3761a5..41fa80f54c 100644
--- a/scm/paper.scm
+++ b/scm/paper.scm
@@ -109,13 +109,13 @@
   (let*
       ((scale (ly:bookpaper-outputscale bookpap))
        (new-pap (ly:output-def-clone pap))
-       (dim-vars (ly:paper-lookup pap 'dimension-variables))
+       (dim-vars (ly:output-def-lookup pap 'dimension-variables))
        (scope (ly:output-def-scope new-pap)))
 
     (for-each
      (lambda (v)
        (module-define! scope v
-		       (/ (ly:paper-lookup pap v) scale)))
+		       (/ (ly:output-def-lookup pap v) scale)))
      
      dim-vars)
 
diff --git a/scm/safe-lily.scm b/scm/safe-lily.scm
index ea9215c5d1..bcd9a41fa4 100644
--- a/scm/safe-lily.scm
+++ b/scm/safe-lily.scm
@@ -100,7 +100,7 @@
      ly:paper-line-number
      ly:paper-line-stencil
      ly:paper-line?
-     ly:paper-lookup
+     ly:output-def-lookup
      ly:parse-string
      ly:parser-parse-string
      ly:parser-print-book
diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py
index 22ffd43048..83035a911a 100644
--- a/scripts/convert-ly.py
+++ b/scripts/convert-ly.py
@@ -2097,7 +2097,10 @@ def conv (str):
 		else:
 			return m.group (0)
 		
-	return re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
+	str = re.sub (r'\\([a-zA-Z]+)Context\b', func, str)
+
+	str = re.sub ('ly:paper-lookup', 'ly:output-def-lookup', str)
+	return str
 
 conversions.append (((2, 3, 2), conv,
 		     '''\\FooContext -> \\Foo'''))
diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py
index 73670333a4..1da2f27ff7 100644
--- a/scripts/lilypond-book.py
+++ b/scripts/lilypond-book.py
@@ -204,7 +204,7 @@ ly_options = {
     indent = 0.0\mm''',
 	NOTIME : r'''
     \context {
-        \StaffContext
+        \Staff
         \remove Time_signature_engraver
     }''',
 	QUOTE : r'''