+#(let ((book-handler (if (defined? 'default-toplevel-book-handler)
+ default-toplevel-book-handler
+ toplevel-book-handler)))
+ (cond ((pair? toplevel-bookparts)
+ (let ((book (ly:make-book $defaultpaper $defaultheader)))
+ (for-each (lambda (part)
+ (ly:book-add-bookpart! book part))
+ (reverse! toplevel-bookparts))
+ (set! toplevel-bookparts (list))
+ ;; if scores have been defined after the last explicit \bookpart:
+ (if (pair? toplevel-scores)
+ (for-each (lambda (score)
+ (ly:book-add-score! book score))
+ (reverse! toplevel-scores)))
+ (set! toplevel-scores (list))
+ (book-handler book)))
+ ((or (pair? toplevel-scores) output-empty-score-list)
+ (let ((book (apply ly:make-book $defaultpaper
+ $defaultheader toplevel-scores)))
+ (set! toplevel-scores (list))
+ (book-handler book)))))