Am 05.08.2016 um 18:23 schrieb Thomas Morley: > 2016-08-04 22:50 GMT+02:00 Urs Liska <u...@openlilylib.org>: >> Hi again, >> >> I have the problem that I (seem to) have to "merge" an unknown number of >> \layout {} blocks. >> >> I create several such block independently in different included files (e.g. >> one for part generation and one global for the edition project as a whole). >> And as everthing is working within one Scheme function and the actual >> engraving is done with ly:book-process I can't write the \layout blocks as >> top-level expressions. >> >> I thought I'm clever and use the #@ construct to output them as a list but >> (of course) this results in *two* layout blocks being present in the \score >> block - and consequently the score being printed twice. >> >> I think the attached example is a correct reduction of my actual set-up to a >> MWE. >> >> AFAICS I need one out of two solutions: >> >> "merging" several \layout {} blocks so there is only one left in the \score >> block >> somehow apply \layout blocks independently as top-level expressions, but >> from within a Scheme function. >> >> Any ideas? >> >> Best >> Urs >> > > Hi Urs, > > maybe the code below. Though, it's more a proof of concept...
Hi Harm, thank you for the "proof-of-concept". I think I roughly understand what you do and try figuring out how to integrate it in my real-world use case. Best Urs > > \version "2.19.45" > > #(define (get-output-def-diff-alist output-def-1 output-def-2) > " Returns an alist of type: > ((TabStaff . #<Context_def TabStaff merge-layouts-02.ly:47:5>) > (Staff . #<Context_def Staff merge-layouts-02.ly:39:5>) > (TabVoice . #<Context_def TabVoice merge-layouts-02.ly:43:5>)) > " > (lset-difference > equal? > (ly:output-find-context-def output-def-1) > (ly:output-find-context-def output-def-2))) > > engrave = > #(define-void-function (layouts music)(list? ly:music?) > "Takes a list of output-defs and some music. The music becomes a score with > the > merged output-defs. Finally a book is returns." > (let* ((my-layout (ly:output-def-clone $defaultlayout)) > ;; get the diffs of custom-layouts to default > (diffs > (append-map > (lambda (output-def) > (get-output-def-diff-alist output-def my-layout)) > layouts)) > ;; make a score from `music' > (my-score (scorify-music music))) > > ;; apply `diff' to the default > (for-each > (lambda (x) > (ly:output-def-set-variable! my-layout (car x) (cdr x))) > diffs) > > ;; add `my-layout' to `my-score' > (ly:score-add-output-def! my-score my-layout) > > (ly:book-process > #{ \book { $my-score } #} > #{ \paper {} #} ; non-functional, placeholder > #{ \layout {} #} ; non-functional, placeholder > (ly:parser-output-name)))) > > layoutI = > \layout { > \context { > \Staff > \override TimeSignature.color = #blue > } > \context { > \TabVoice > \override TabNoteHead.color = #cyan > } > \context { > \TabStaff > \override Clef.color = #green > } > } > > layoutII = > \layout { > \context { > \Voice { > \override NoteHead.color = #red > } > } > } > > \engrave > #(list layoutI layoutII) > << > \new Staff { c' } > \new TabStaff { c' } > >> > > > Cheers, > Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user