|
From: | Mats Bengtsson |
Subject: | Re: [PATCH]: Allow context modifications to be stored in a variable and inserted into \context or \with |
Date: | Fri, 12 Mar 2010 15:06:09 +0100 |
User-agent: | Thunderbird 2.0.0.23 (X11/20090817) |
Reinhold Kainhofer wrote:
Our problems with \RemoveEmptyStaffContext resetting previous context modifications highlights one problem we have: So far, it was not possible to store a bunch of context modifications into a variable and apply them later on.
Right!
Another incarnation of this problem is that it is not possible to collect some modifications and use them in a \with block. So far, the contents of the \with block had to be explicitly written out. I had the problem that in a full score I needed several staves to be smaller (since they are optional), but I couldn't use a global definition of the settings (defining my own Staff- derived context was also not possible, because in the instrumental part, I need a normal Staff, so all \override Staff.... would break in one or the other case).
No, that's not a problem, as long as you include a \alias "Staff" line in the definition of your new context.
So, here is a patch against current origin/master: http://codereview.appspot.com/475041It modifies the parser so that context mods can be stored in variables and can be inserted into \with or \context blocks:-) context modifications lists are stored in a dedicated simple scheme object (C++ class Context_mod) -) Changes to the parser: -) context_modifications objects (stored in variables) are now also allowed with \with clauses -) context_modifications objects are also allowed inside \context -) this allows us to rewrite \RemoveEmptyStaffContext (unfortunately with a little different syntax, since we no longer store \Staff inside the new \RemoveEmptyStaves command) so that it no longer erases previous settings to the Staff context. Now, instead of \context { \RemoveEmptyStaffContext } one can do \context { \Staff \RemoveEmptyStaves } with the same effect and preserve previous changes to the Staff context. (The same applies of course to \DrumStaff, \RhythmicStaff, etc. as well) -) Adjusted engraver-init.ly and the regtests accordingly; Also added regtest that checks for RESC not discarding previous settings to the Staff context
Without looking at the actual patch, it looks like a very good thing.The next step would be to somehow also be able to handle music functions and/or Scheme functions in \with and \context blocks, so that you could do a setting like
\overrideBeamSettings ... or #(set-accidental-style ...)in such a block, so you can better separate layout settings from the actual music. Of course, such a change is probably much more difficult than your current patch.
/Mats
[Prev in Thread] | Current Thread | [Next in Thread] |