Re: Setting paper for bookpart
Thomas Morleywrites: > Hi David, > > to continue on this [...] > I meanwhile did some experiments: > > Both of > \book { \bookpart { { r1 } } } > \book { \bookpart { \paper {} { r1 } } } > succeed without problems. > > While for > bk-fail = \book { \bookpart { { r1 } } } %% no paper in bookpart!! > bk-ok = \book { \bookpart { \paper {} { r1 } } } > \bk-fail > \bk-ok > > bk-fail returns: > /home/harm/lilydevel/usr/share/lilypond/current/scm/lily-library.scm:253:5: > In procedure ly:book-process in expression (process-procedure book > paper ...): > /home/harm/lilydevel/usr/share/lilypond/current/scm/lily-library.scm:253:5: > Wrong type (expecting real number): # [...] > Which all looks fine. > So I'm at a loss here. That's my current state as well... -ddebug-parser does not offer any compelling insight either. I suspect this to be a scoping problem of some kind but have no good idea just what is involved here. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
Hi David, to continue on this 2017-08-02 23:26 GMT+02:00 David Kastrup: > Thomas Morley writes: > >> 2017-08-02 22:38 GMT+02:00 David Kastrup : >> >>> I think that part of the problem is that looking at the functions in >>> >>> lily/book-scheme.cc >>> >>> it seems like bookparts were never intended to have paper blocks. Now >>> after actually checking it would appear that at least several bookparts >>> cannot appear on the same page: so at least the paper dimensions likely >>> don't clash. >>> >>> So what is supposed to be the actual difference between bookparts and >>> books? >>> >>> I actually don't know how to tell, and it shows by the parser not >>> knowing how to know that >>> >>> \xxx >>> >>> is not a book when xxx has been defined as \bookpart { \paper {...} ...}. >>> >>> I really don't have an idea what the distinction is supposed to be about. >> >> Thanks for your findings and thoughts. >> >> At least one distinction can be seen here: >> >> foo = \book { } >> #(format #t "paper present? ~a" (ly:book-paper foo)) >> >> bar = \bookpart { } >> #(format #t "paper present? ~a" (ly:book-paper bar)) > > Yes, books and bookparts can be told apart when specified _without_ > paper block. Once a paper block intervenes, it's getting impossible. > >> The latter displays #f, which is inline with what you said above: >> "bookparts were never intended to have paper blocks" >> Otoh, paper in bookpart _is_ supported, at least nowadays ... > > The Scheme code for creating a Book has a constructor _including_ a > paper block from the moment a book is created, and it would appear that > after creation, there is no real accessor for changing it. > > The Scheme code for creating a Bookpart. Actually, there is no such > thing. The Scheme functions creating a Book that have "book-part" in > their name set the paper block to #f. > > That's it from the Scheme side. The parser, however, assigns to the > internal paper_ field bypassing any accessor functions. > > That looks fishy. I meanwhile did some experiments: Both of \book { \bookpart { { r1 } } } \book { \bookpart { \paper {} { r1 } } } succeed without problems. While for bk-fail = \book { \bookpart { { r1 } } } %% no paper in bookpart!! bk-ok = \book { \bookpart { \paper {} { r1 } } } \bk-fail \bk-ok bk-fail returns: /home/harm/lilydevel/usr/share/lilypond/current/scm/lily-library.scm:253:5: In procedure ly:book-process in expression (process-procedure book paper ...): /home/harm/lilydevel/usr/share/lilypond/current/scm/lily-library.scm:253:5: Wrong type (expecting real number): # After changing 'print-book-with' from lily-library.scm (where the message points to) to get some debugging output: (define (print-book-with book process-procedure) (let* ((paper (ly:parser-lookup '$defaultpaper)) (layout (ly:parser-lookup '$defaultlayout)) (outfile-name (get-outfile-name book))) (format #t "\n\tbook:\t\t ~a" book) (format #t "\n\tbookparts:\t ~a" (ly:book-book-parts book)) (format #t "\n\tpaper:\t\t ~a" paper) (format #t "\n\tis-paper?:\t ~a" (module-ref (ly:output-def-scope paper) 'is-paper)) (format #t "\n\tlayout:\t\t ~a" layout) (format #t "\n\tis-layout?:\t ~a" (module-ref (ly:output-def-scope layout) 'is-layout)) (format #t "\n\toutfile-name:\t ~a" outfile-name) (format #t "\n\tprocess-procedure: ~a\n" process-procedure) (process-procedure book paper layout outfile-name))) I get in terminal: book: # bookparts: (#) paper: #< Output_def> is-paper?: #t layout: #< Output_def> is-layout?: #t outfile-name: atest-63 process-procedure: # Which all looks fine. So I'm at a loss here. > In many cases of LilyPond's strangenesses I've been able to work out a > nice theory and manufacture principles useful for ironing out the > strangenesses and make the result appear to reflect a design that was > not really all that apparent from the start. > > But I'm really sort-of adrift about what should and what should not be > possible here, and how. Need to stall on this (and the other > discussion) until after the weekend as I am visiting accordionists in > Klingenthal. Really need to start packing. I hope you enjoyed your weekend. Best, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
Thomas Morleywrites: > 2017-08-02 22:38 GMT+02:00 David Kastrup : > >> I think that part of the problem is that looking at the functions in >> >> lily/book-scheme.cc >> >> it seems like bookparts were never intended to have paper blocks. Now >> after actually checking it would appear that at least several bookparts >> cannot appear on the same page: so at least the paper dimensions likely >> don't clash. >> >> So what is supposed to be the actual difference between bookparts and >> books? >> >> I actually don't know how to tell, and it shows by the parser not >> knowing how to know that >> >> \xxx >> >> is not a book when xxx has been defined as \bookpart { \paper {...} ...}. >> >> I really don't have an idea what the distinction is supposed to be about. > > Thanks for your findings and thoughts. > > At least one distinction can be seen here: > > foo = \book { } > #(format #t "paper present? ~a" (ly:book-paper foo)) > > bar = \bookpart { } > #(format #t "paper present? ~a" (ly:book-paper bar)) Yes, books and bookparts can be told apart when specified _without_ paper block. Once a paper block intervenes, it's getting impossible. > The latter displays #f, which is inline with what you said above: > "bookparts were never intended to have paper blocks" > Otoh, paper in bookpart _is_ supported, at least nowadays ... The Scheme code for creating a Book has a constructor _including_ a paper block from the moment a book is created, and it would appear that after creation, there is no real accessor for changing it. The Scheme code for creating a Bookpart. Actually, there is no such thing. The Scheme functions creating a Book that have "book-part" in their name set the paper block to #f. That's it from the Scheme side. The parser, however, assigns to the internal paper_ field bypassing any accessor functions. That looks fishy. In many cases of LilyPond's strangenesses I've been able to work out a nice theory and manufacture principles useful for ironing out the strangenesses and make the result appear to reflect a design that was not really all that apparent from the start. But I'm really sort-of adrift about what should and what should not be possible here, and how. Need to stall on this (and the other discussion) until after the weekend as I am visiting accordionists in Klingenthal. Really need to start packing. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
2017-08-02 22:38 GMT+02:00 David Kastrup: > Thomas Morley writes: > >> 2017-08-02 18:27 GMT+02:00 David Kastrup : >>> Thomas Morley writes: >>> 2017-08-02 15:46 GMT+02:00 David Kastrup : > #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) This works fine, but only if the bookpart already has \paper >>> >>> So use the LilyPond syntax variant instead? >>> >>> What are you currently after? Getting some task done or working out >>> where LilyPond's Scheme interfaces are having holes and getting them >>> filled? >>> >>> Of course approaches differ then. >> >> This thread was triggered by a request in the german forum >> https://lilypondforum.de/index.php/topic,105.msg686.html >> While I think there is a working sollution over there, I now try to >> explore whether LilyPond could be improved with regard to this topic. >> >> I can fill an empty bookpart with a header using ly:book-set-header! >> I can fill an empty bookpart with scores using ly:book-add-score! >> But obviously there's no possibility to get a paper into an empty >> bookpart. Otherwise the answer would have been dropped hours ago. >> >> What's needed to have/get/code such a function? > > I think that part of the problem is that looking at the functions in > > lily/book-scheme.cc > > it seems like bookparts were never intended to have paper blocks. Now > after actually checking it would appear that at least several bookparts > cannot appear on the same page: so at least the paper dimensions likely > don't clash. > > So what is supposed to be the actual difference between bookparts and > books? > > I actually don't know how to tell, and it shows by the parser not > knowing how to know that > > \xxx > > is not a book when xxx has been defined as \bookpart { \paper {...} ...}. > > I really don't have an idea what the distinction is supposed to be about. > > -- > David Kastrup Thanks for your findings and thoughts. At least one distinction can be seen here: foo = \book { } #(format #t "paper present? ~a" (ly:book-paper foo)) bar = \bookpart { } #(format #t "paper present? ~a" (ly:book-paper bar)) The latter displays #f, which is inline with what you said above: "bookparts were never intended to have paper blocks" Otoh, paper in bookpart _is_ supported, at least nowadays ... Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
Thomas Morleywrites: > 2017-08-02 18:27 GMT+02:00 David Kastrup : >> Thomas Morley writes: >> >>> 2017-08-02 15:46 GMT+02:00 David Kastrup : >>> #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) >>> >>> This works fine, but only if the bookpart already has \paper >> >> So use the LilyPond syntax variant instead? >> >> What are you currently after? Getting some task done or working out >> where LilyPond's Scheme interfaces are having holes and getting them >> filled? >> >> Of course approaches differ then. > > This thread was triggered by a request in the german forum > https://lilypondforum.de/index.php/topic,105.msg686.html > While I think there is a working sollution over there, I now try to > explore whether LilyPond could be improved with regard to this topic. > > I can fill an empty bookpart with a header using ly:book-set-header! > I can fill an empty bookpart with scores using ly:book-add-score! > But obviously there's no possibility to get a paper into an empty > bookpart. Otherwise the answer would have been dropped hours ago. > > What's needed to have/get/code such a function? I think that part of the problem is that looking at the functions in lily/book-scheme.cc it seems like bookparts were never intended to have paper blocks. Now after actually checking it would appear that at least several bookparts cannot appear on the same page: so at least the paper dimensions likely don't clash. So what is supposed to be the actual difference between bookparts and books? I actually don't know how to tell, and it shows by the parser not knowing how to know that \xxx is not a book when xxx has been defined as \bookpart { \paper {...} ...}. I really don't have an idea what the distinction is supposed to be about. -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
2017-08-02 18:27 GMT+02:00 David Kastrup: > Thomas Morley writes: > >> 2017-08-02 15:46 GMT+02:00 David Kastrup : >> >>> #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) >> >> This works fine, but only if the bookpart already has \paper > > So use the LilyPond syntax variant instead? > > What are you currently after? Getting some task done or working out > where LilyPond's Scheme interfaces are having holes and getting them > filled? > > Of course approaches differ then. This thread was triggered by a request in the german forum https://lilypondforum.de/index.php/topic,105.msg686.html While I think there is a working sollution over there, I now try to explore whether LilyPond could be improved with regard to this topic. I can fill an empty bookpart with a header using ly:book-set-header! I can fill an empty bookpart with scores using ly:book-add-score! But obviously there's no possibility to get a paper into an empty bookpart. Otherwise the answer would have been dropped hours ago. What's needed to have/get/code such a function? Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
2017-08-02 19:09 GMT+02:00 Timothy Lanfear: > On 02/08/17 16:29, Thomas Morley wrote: >> >> 2017-08-02 15:46 GMT+02:00 David Kastrup : >> >>> #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) >> >> This works fine, but only if the bookpart already has \paper >> >> In the following example, I start with an empty bookpart and fill it >> with a header and a score. >> And I want to do the same with the paper. >> >> > > How about creating a book with paper and adding the bookpart? Hi Timothy, thanks for your reply and code. Though, it's exactly not what I'm after. I'd like to create bookparts with _different_ paper-settings. > I think the > book is implicitly created when using LilyPond syntax if it is not there > explicitly. > > > foo = #(define-void-function() () > (let* ((paper#{ \paper {} #}) > (header #{ \header {} #}) > (score#{ \score { r1 } #}) > (bookpart (ly:make-book-part (list score))) > (book (ly:make-book paper header))) > > (module-define! header 'title "Second Title") > (ly:output-def-set-variable! paper 'ragged-right #f) > (ly:book-add-bookpart! book bookpart) > (ly:book-process book paper $defaultlayout "tmp"))) > > \foo Thanks, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
On 02/08/17 16:29, Thomas Morley wrote: 2017-08-02 15:46 GMT+02:00 David Kastrup: #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) This works fine, but only if the bookpart already has \paper In the following example, I start with an empty bookpart and fill it with a header and a score. And I want to do the same with the paper. How about creating a book with paper and adding the bookpart? I think the book is implicitly created when using LilyPond syntax if it is not there explicitly. foo = #(define-void-function() () (let* ((paper#{ \paper {} #}) (header #{ \header {} #}) (score#{ \score { r1 } #}) (bookpart (ly:make-book-part (list score))) (book (ly:make-book paper header))) (module-define! header 'title "Second Title") (ly:output-def-set-variable! paper 'ragged-right #f) (ly:book-add-bookpart! book bookpart) (ly:book-process book paper $defaultlayout "tmp"))) \foo -- Timothy Lanfear, Bristol, UK. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
Thomas Morleywrites: > 2017-08-02 15:46 GMT+02:00 David Kastrup : > >> #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) > > This works fine, but only if the bookpart already has \paper So use the LilyPond syntax variant instead? What are you currently after? Getting some task done or working out where LilyPond's Scheme interfaces are having holes and getting them filled? Of course approaches differ then. > In the following example, I start with an empty bookpart and fill it > with a header and a score. > And I want to do the same with the paper. > > But how? > The last command returns (not surprisingly): > > error: GUILE signaled an error for the expression beginning here > # > (ly:output-def-set-variable! (ly:book-paper bkIII) 'ragged-right #f) > Wrong type argument in position 1 (expecting Output_def): #f > > > myHeader = \header { title = "TITLE III" } > myScore = \score { { cis'1 } } > myPaper = \paper { ragged-right = ##f } > bkIII = \bookpart {} > > #(ly:book-set-header! bkIII myHeader) > #(ly:book-add-score! bkIII myScore) % Now insert bkIII = \bookpart { \bkIII \paper {} } % and continue... % I think you don't need to test for preexisting \paper but to be % honest, I'm not sure and haven't tried. > #(ly:output-def-set-variable! (ly:book-paper bkIII) 'ragged-right #f) > > \bkIII -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
2017-08-02 15:46 GMT+02:00 David Kastrup: > #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) This works fine, but only if the bookpart already has \paper In the following example, I start with an empty bookpart and fill it with a header and a score. And I want to do the same with the paper. But how? The last command returns (not surprisingly): error: GUILE signaled an error for the expression beginning here # (ly:output-def-set-variable! (ly:book-paper bkIII) 'ragged-right #f) Wrong type argument in position 1 (expecting Output_def): #f myHeader = \header { title = "TITLE III" } myScore = \score { { cis'1 } } myPaper = \paper { ragged-right = ##f } bkIII = \bookpart {} #(ly:book-set-header! bkIII myHeader) #(ly:book-add-score! bkIII myScore) #(ly:output-def-set-variable! (ly:book-paper bkIII) 'ragged-right #f) \bkIII Thanks, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Setting paper for bookpart
Thomas Morleywrites: > Hi all, > > consider the following code, setting a header to a bookpart: > > bkI = \bookpart { { r1 } } > #(ly:book-set-header! bkI #{ \header { title = "TITLE" } #}) > #(collect-bookpart-for-book bkI) > > All fine, but how to do with a bookpart-paper? > If I'm not mstaken we don't have something like ly:book-set-paper! > Currently I use sort of a workaround: > > pap = \paper { } > #(ly:output-def-set-variable! pap 'ragged-right #f) > bkII = \bookpart { $pap { r1 } } bkII = \bookpart { \bkII \paper { ragged-right = ##f } } Or just: #(ly:output-def-set-variable! (ly:book-paper bkII) 'ragged-right #f) > #(ly:book-set-header! bkII #{ \header { title = "SECOND-TITLE" } #}) > #(collect-bookpart-for-book bkII) > > Any better way? > > > Thanks, > Harm -- David Kastrup ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Setting paper for bookpart
Hi all, consider the following code, setting a header to a bookpart: bkI = \bookpart { { r1 } } #(ly:book-set-header! bkI #{ \header { title = "TITLE" } #}) #(collect-bookpart-for-book bkI) All fine, but how to do with a bookpart-paper? If I'm not mstaken we don't have something like ly:book-set-paper! Currently I use sort of a workaround: pap = \paper { } #(ly:output-def-set-variable! pap 'ragged-right #f) bkII = \bookpart { $pap { r1 } } #(ly:book-set-header! bkII #{ \header { title = "SECOND-TITLE" } #}) #(collect-bookpart-for-book bkII) Any better way? Thanks, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user