Hello David, hello lists,

now, when we have a book-predicate, we are dealing with books in scheme. And 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

On 27.02.2012 10:10, David Kastrup wrote:
Jan-Peter Voigt<[email protected]>  writes:

Am 24.02.2012 um 16:24 schrieb:

Jan-Peter Voigt<[email protected]>  writes:

Hello list,

when I use books or bookparts for (scheme-)function arguments, I
haven't found the predicate for it.
paper-book? is something else, or am I missing something?
Well, you can always use scheme? and file a feature request in the mean
time.
Thank you David,

the scheme?-solution is what I do right now. I will send a feature
request next days.
Don't bother.

commit 09814b549186893c265bcdf835edbe242f6354cf
Author: David Kastrup<[email protected]>
Date:   Sun Feb 26 11:23:39 2012 +0100

     Implement ly:book? and ly:context-def? predicates

Note that a bookpart _is_ a book as well, usually without a paper block
of its own.


>From 40a1419a051402ee4bac6d8f7fa65e5b8353b815 Mon Sep 17 00:00:00 2001
From: Jan-Peter Voigt <[email protected]>
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-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to