Hi David & all, 2014-07-25 21:34 GMT+02:00 David Kastrup <d...@gnu.org>: > > Janek Warchoł <janek.lilyp...@gmail.com> writes: >> 2) i didn't manage to get midi stuff done inside the same function as >> the layout stuff - but i think that i'll be able to solve that if i >> have a solution to 1). > > You basically need to collect just the context definitions and apply > those (a context definition is applied by looking up its \name and > overwriting the variable with that name). > > Frankly, I am tempted to create something like > #{ > \output { > \context ... > xxx = 3\cm > } > #} > > that will either execute a number of assignments or alternatively return > an anonymous lambda or define-void-function doing the same so that you > can easily splice it into different output definitions. > > Something like that would apparently serve a need.
Ok, i reread what you wrote and now i understand that this is indeed what i need :) So if you could write a function like this, i would be very grateful (and i would happily increase your bounty!). My own (_very_ naive) attempt at removing code duplication failed: \version "2.19.10" % Create a new xxxStaff and xxxVoice contexts with specified settings, % derived from specified yyyStaff and yyyVoice contexts. newInstrument = #(define-scheme-function (parser location name parent-name group-name staff-settings voice-settings) (string? string? string? ly:context-mod? ly:context-mod?) (let* ((staff-name (string-append name "Staff")) (voice-name (string-append name "Voice")) (parent-name (if (string=? parent-name "default") "" parent-name)) (parent-staff-name (string-append parent-name "Staff")) (parent-voice-name (string-append parent-name "Voice")) (common #{ \context { $(module-ref (current-module) (string->symbol group-name)) \accepts #staff-name } \context { $(module-ref (current-module) (string->symbol parent-staff-name)) \name #staff-name \alias #parent-staff-name % is it possible to make it accept Voices of derived instruments? \accepts #voice-name \defaultchild #voice-name #staff-settings } \context { $(module-ref (current-module) (string->symbol parent-voice-name)) \name #voice-name \alias #parent-voice-name #voice-settings } #})) (ly:parser-define! parser '$defaultlayout #{ \layout #common #}) (ly:parser-define! parser '$defaultmidi #{ \midi #common #}))) thanks again for your help! Janek _______________________________________________ lilypond-devel mailing list lilypond-devel@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-devel