+void
+Book::set_parent (Book *parent)
+{
+ if (!paper_)
+ {
+ paper_ = new Output_def ();
+ paper_->unprotect ();
+ }
+ paper_->parent_ = parent->paper_;
+ /* If this part is the first child of parent, copy its header */
+ if (ly_is_module (parent->header_) && (scm_is_null (parent->bookparts_)))
+ {
+ SCM tmp_header = ly_make_anonymous_module (false);
+ ly_module_copy (tmp_header, parent->header_);
+ if (ly_is_module (header_))
+ ly_module_copy (tmp_header, header_);
+ header_ = tmp_header;
+ }
+}
+
+/* Before an explicit \bookpart is encountered, scores are added to the book.
+ * But once a bookpart is added, the previous scores shall be collected into
+ * a new bookpart.
+ */
+void
+Book::add_scores_to_bookpart ()
+{
+ if (scm_is_pair (scores_))
+ {
+ /* If scores have been added to this book, add them to a child
+ * book part */
+ Book *part = new Book;
+ part->set_parent (this);
+ part->scores_ = scores_;
+ bookparts_ = scm_cons (part->self_scm (), bookparts_);
+ part->unprotect ();
+ scores_ = SCM_EOL;
+ }
+}
+
+void
+Book::add_bookpart (SCM b)
+{
+ add_scores_to_bookpart ();
+ Book *part = unsmob_book (b);
+ part->set_parent (this);
+ bookparts_ = scm_cons (b, bookparts_);
+}
+
+bool
+Book::error_found ()
+{
+ for (SCM s = scores_; scm_is_pair (s); s = scm_cdr (s))
+ if (Score *score = unsmob_score (scm_car (s)))
+ if (score->error_found_)
+ return true;