Hello list,

sorry for resending this, it might get lost, because I simply answered to another thread with another subject.

now, we have a book-predicate and we are dealing with books in scheme. Then we might want to set a header after creating a book. There is a function ly:score-set-header!, which I copied and adapted for the Book-class.
This patch compiled and works with the following snippet.

--snip--
\version "2.15.32"

bk = \book {
  \score {
    \relative c' {
      c4 e g b
    }
  }
}

#(let ((bh (eval-string "(define-module (a b))")))
     (eval '(define title "Hallo") bh)
     (ly:book-set-header! bk bh))

\book { \bk }
--snip--

Is this helpful for lily-devel?
And is there another (better) way of creating a module (for header generation) on the fly in scheme?

Cheers,
Jan-Peter
>From 40a1419a051402ee4bac6d8f7fa65e5b8353b815 Mon Sep 17 00:00:00 2001
From: Jan-Peter Voigt <jp.vo...@gmx.de>
Date: Fri, 2 Mar 2012 09:54:20 +0100
Subject: [PATCH] add ly:book-set-header!

Add a scheme function ly:book-set-header! like ly:score-set-header!

Function is copied from score-scheme.cc to book-scheme.cc,
setting public member var header_ in class Book.
---
 lily/book-scheme.cc |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/lily/book-scheme.cc b/lily/book-scheme.cc
index 7f1026a..ae505af 100644
--- a/lily/book-scheme.cc
+++ b/lily/book-scheme.cc
@@ -156,6 +156,19 @@ LY_DEFINE (ly_book_header, "ly:book-header",
   return b->header_ ? b->header_ : SCM_BOOL_F;
 }
 
+LY_DEFINE (ly_book_set_header_x, "ly:book-set-header!",
+           2, 0, 0, (SCM book, SCM module),
+           "Set the book header.")
+{
+  LY_ASSERT_SMOB (Book, book, 1);
+  SCM_ASSERT_TYPE (ly_is_module (module), module, SCM_ARG2, __FUNCTION__,
+                   "module");
+
+  Book *b = unsmob_book (book);
+  b->header_ = (module);
+  return SCM_UNSPECIFIED;
+}
+
 LY_DEFINE (ly_book_scores, "ly:book-scores",
            1, 0, 0, (SCM book),
            "Return scores in @var{book}.")
-- 
1.7.0.4

_______________________________________________
lilypond-devel mailing list
lilypond-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-devel

Reply via email to