]> git.donarmstrong.com Git - lilypond.git/commitdiff
Context mods stored in variable, can be inserted into \with or \context
authorReinhold Kainhofer <reinhold@eeepc.(none)>
Wed, 10 Mar 2010 14:40:00 +0000 (15:40 +0100)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Sat, 3 Apr 2010 11:29:23 +0000 (13:29 +0200)
-) Context-Modifications: create C++ class to store them
-) context modifications lists are stored in a dedicated simple scheme object
     (C++ class Context_mod)
-) Changes to the parser:
  -) \with blocks no longer return a simple list, but a Context_mod object
  -) 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
 \RESC 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
-) Add convert-ly rule (\RemoveEmpty*StaffContext -> \*Staff \RemoveEmptyStaves)
-) Add scheme interface to extract context mods and add context mods with Scheme
-) Add changelog entry

16 files changed:
Documentation/changes.tely
input/regression/context-mod-context.ly [new file with mode: 0644]
input/regression/context-mod-with.ly [new file with mode: 0644]
input/regression/hara-kiri-drumstaff.ly
input/regression/hara-kiri-keep-previous-settings.ly [new file with mode: 0644]
input/regression/hara-kiri-percent-repeat.ly
input/regression/hara-kiri-pianostaff.ly
input/regression/hara-kiri-rhythmicstaff.ly
input/regression/hara-kiri-tabstaff.ly
lily/context-mod-scheme.cc [new file with mode: 0644]
lily/context-mod.cc [new file with mode: 0644]
lily/include/context-mod.hh [new file with mode: 0644]
lily/include/lily-proto.hh
lily/parser.yy
ly/engraver-init.ly
python/convertrules.py

index 62e625974bf13f1bd92908b06de88fc5a3281ea4..8569dbf56f67004badce4e245c04aaf92d26058c 100644 (file)
@@ -62,6 +62,24 @@ which scares away people.
 
 @end ignore
 
+@item
+Context modifications (@code{\with} blocks) can be stored in variables and
+inserted into contexts or other @code{\with} blocks:
+@lilypond[quote,verbatim]
+coloredheads = \with { \override NoteHead #'color = #red }
+noclef = \with { \remove "Clef_engraver" }
+\score {
+  \new Staff {
+    \new Voice \with { \coloredheads } \relative c' { c4 e g c }
+  }
+  \layout {
+    \context { \Staff
+      \noclef
+    }
+  }
+}
+@end lilypond
+
 @item
 A half-open articulation was added:
 @lilypond[quote,relative=2]
diff --git a/input/regression/context-mod-context.ly b/input/regression/context-mod-context.ly
new file mode 100644 (file)
index 0000000..020db8c
--- /dev/null
@@ -0,0 +1,43 @@
+\version "2.13.18"
+
+\header  {
+texidoc = "Context modifications can be stored into a variable as a
+\with object. They can be later inserted directly into a context definition."
+}
+
+% Some sample modifications to be inserted into a \with block later on
+ctxmod = \with {
+  \remove "Time_signature_engraver"
+  \consists "Ambitus_engraver"
+  \override StaffSymbol #'line-count = 4
+}
+
+music = \relative c'' { \key fis \minor c1 d e }
+
+\score { <<
+    \new Staff { \music}
+  >>
+  \layout {
+    \context { \Staff
+      \ctxmod
+      \override NoteHead #'style = #'petrucci
+    }
+  }
+}
+
+
+\score { <<
+    \new Staff { \music}
+  >>
+  \layout {
+    \context { \Staff
+      \override StaffSymbol #'line-count = 3
+      \override NoteHead #'style = #'petrucci
+    }
+    % Should override the above definitions, but not reset others
+    \context { \Staff
+      \ctxmod
+    }
+  }
+}
+
diff --git a/input/regression/context-mod-with.ly b/input/regression/context-mod-with.ly
new file mode 100644 (file)
index 0000000..377d3ef
--- /dev/null
@@ -0,0 +1,45 @@
+\version "2.13.18"
+
+\header  {
+texidoc = "Context modifications can be stored into a variable as a
+\with object. They can be later inserted into another \with block."
+}
+
+% Some sample modifications to be inserted into a \with block later on
+ctxmod = \with {
+  \remove "Time_signature_engraver"
+  \consists "Ambitus_engraver"
+  \override StaffSymbol #'line-count = 4
+}
+
+music = \relative c'' { \key fis \minor c1 d e }
+
+\score { <<
+  % No modifications:
+  \new Staff { \music }
+  % Some context modifications manually written in a \with block
+  \new Staff \with {
+    \remove "Time_signature_engraver"
+    \consists "Ambitus_engraver"
+    \override StaffSymbol #'line-count = 4
+  } { \music }
+  % The same mods as direct value of \with
+  \new Staff \with \ctxmod { \music }
+  % Mods as part of a \with block
+  \new Staff \with { \ctxmod } { \music }
+  % Mods before a context mod in a with block are working:
+  \new Staff \with {
+    \remove "Clef_engraver"
+    \ctxmod
+  } { \music }
+  % Mods before and after a context mod in a with block are working:
+  \new Staff \with {
+    \remove "Clef_engraver"
+    \ctxmod
+    \remove "Key_engraver"
+  } { \music }
+  % Mods can be inserted instead of a \with block (i.e. \with is not required)
+  \new Staff \ctxmod { \music }
+  \new Staff { \music }
+>>
+}
index 478d23e69552187a95e85643e1c5e6762a2c4b98..ada43ebcb28c538202c636414def02557bed6f2c 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.13.10"
+\version "2.13.18"
 \header {
   texidoc =
 
@@ -18,7 +18,8 @@ and no staff case.
 \layout {
   ragged-right = ##t
   \context {
-    \RemoveEmptyDrumStaffContext
+    \DrumStaff
+    \RemoveEmptyStaves
   }
 }
 
diff --git a/input/regression/hara-kiri-keep-previous-settings.ly b/input/regression/hara-kiri-keep-previous-settings.ly
new file mode 100644 (file)
index 0000000..818376c
--- /dev/null
@@ -0,0 +1,43 @@
+\version "2.13.18"
+
+\header { texidoc =
+
+         "Inserting the harakiri settings globally into the Staff context should
+not erase previous settings to the Staff context.
+"
+
+}
+
+\layout {
+  ragged-right= ##t
+  \context {
+    \Staff
+    \override StaffSymbol #'line-count = 4
+    \consists "Ambitus_engraver"
+    \remove "Clef_engraver"
+  }
+}
+
+% Old \RemoveEmptyStaffContext: Will erase previous settings...
+\score {
+  <<
+    \new Staff \relative c'' {  c4 c c c \break s1 \break c4 c c c \break c c c c}
+    \new Staff \relative c'' {  d4 d d d        s1        s1              s1 }
+    \new Staff \relative c'' {  e4 e e e        s1        e4 e e e        s1 }
+  >>
+  \layout {
+    \context { \RemoveEmptyStaffContext }
+  }
+}
+
+% New \RemoveEmptyStaves settings: Preserves previous settings...
+\score {
+  <<
+    \new Staff \relative c'' {  c4 c c c \break s1 \break c4 c c c \break c c c c}
+    \new Staff \relative c'' {  d4 d d d        s1        s1              s1 }
+    \new Staff \relative c'' {  e4 e e e        s1        e4 e e e        s1 }
+  >>
+  \layout {
+    \context { \Staff \RemoveEmptyStaves }
+  }
+}
index 847e93c688f0045a735b9af0ebea3f93ae2f584d..fdc5338d348c12a335c0cf2722ea444ca0ca7f66 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.13.10"
+\version "2.13.18"
 
 \header {
   texidoc = "Staves, RhythmicStaves, TabStaves and DrumStaves
   \new TabStaff \repeat  percent 4 { c1 }
   \new DrumStaff \drummode { \repeat percent 4 { hh1 } }
   \new RhythmicStaff \repeat percent 4 { c'1 }
->>                          
+>>
 
 \layout {
-  \context { \RemoveEmptyStaffContext }
-  \context { \RemoveEmptyRhythmicStaffContext }
-  \context { \RemoveEmptyDrumStaffContext }
-  \context { \RemoveEmptyTabStaffContext }
-  }
-
+  \context { \Staff \RemoveEmptyStaves }
+  \context { \RhythmicStaff \RemoveEmptyStaves }
+  \context { \DrumStaff \RemoveEmptyStaves }
+  \context { \TabStaff \RemoveEmptyStaves }
+}
index e347ad20293ef3ae2d8cef931a9e16c03038e864..e19aa4fd823747a064f771383aba4b8c3e7efe7f 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.12.0"
+\version "2.13.18"
 
 \header { texidoc =
 
@@ -21,7 +21,8 @@ alignment; this should not confuse the mechanism.
 \layout {
   ragged-right= ##t
   \context {
-    \RemoveEmptyStaffContext
+    \Staff
+    \RemoveEmptyStaves
   }
 }
 
index fd6ccbdd5b488741126cab562d306914da68d675..a554dd2c1afa980112604ea58d75944a6cb57c0f 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.13.10"
+\version "2.13.18"
 \header {
   texidoc =
 
@@ -18,7 +18,8 @@ and no staff case.
 \layout {
   ragged-right= ##t
   \context {
-    \RemoveEmptyRhythmicStaffContext
+    \RhythmicStaff
+    \RemoveEmptyStaves
   }
 }
 
index e5738ab8760e06863f48e93c76b7b099a040d4d4..a692385fc9ccfddafaba5652c3ae9333015cd916 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.13.10"
+\version "2.13.18"
 
 \header {
   texidoc =
@@ -18,7 +18,8 @@ and no staff case."
 \layout {
   ragged-right= ##t
   \context {
-    \RemoveEmptyTabStaffContext
+    \TabStaff
+    \RemoveEmptyStaves
   }
 }
 
diff --git a/lily/context-mod-scheme.cc b/lily/context-mod-scheme.cc
new file mode 100644 (file)
index 0000000..2457496
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2010 Jan Nieuwenhuizen <janneke@gnu.org>
+  Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "context.hh"
+#include "context-mod.hh"
+
+LY_DEFINE (ly_get_context_mods,
+          "ly:get-context-mods",
+          1, 0, 0, (SCM contextmod),
+          "Returns the list of context modifications stored in @var{contextmod}.")
+{
+  Context_mod *tr = unsmob_context_mod (contextmod);
+  LY_ASSERT_SMOB (Context_mod, contextmod, 1);
+  return tr->get_mods ();
+}
+
+LY_DEFINE (ly_add_context_mod,
+          "ly:add-context-mod",
+          2, 0, 0, (SCM contextmods, SCM modification),
+          "Adds the given context @var{modification} to the list @var{contextmods} of context modifications.")
+{
+  Context_mod *ctxmod = unsmob_context_mod (contextmods);
+  LY_ASSERT_SMOB (Context_mod, contextmods, 1);
+  ctxmod->add_context_mod (modification);
+  return SCM_UNSPECIFIED;
+}
+
diff --git a/lily/context-mod.cc b/lily/context-mod.cc
new file mode 100644 (file)
index 0000000..691f296
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2010 Reinhold Kainhofer <reinhold@kainhofer.com>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "context-mod.hh"
+
+Context_mod::Context_mod ()
+{
+  mods_ = SCM_EOL;
+}
+
+Context_mod::Context_mod (Context_mod const &s)
+{
+  mods_ = s.mods_;
+}
+
+#include "ly-smobs.icc"
+IMPLEMENT_SIMPLE_SMOBS (Context_mod);
+IMPLEMENT_DEFAULT_EQUAL_P (Context_mod);
+
+int
+Context_mod::print_smob (SCM smob, SCM port, scm_print_state*)
+{
+  Context_mod *me = (Context_mod *) SCM_CELL_WORD_1 (smob);
+
+  scm_puts ("#<Context_mod ", port);
+  scm_display (me->mods_, port);
+  scm_puts (">", port);
+  return 1;
+}
+
+SCM
+Context_mod::mark_smob (SCM smob)
+{
+  ASSERT_LIVE_IS_ALLOWED ();
+
+  Context_mod *me = (Context_mod *) SCM_CELL_WORD_1 (smob);
+
+  scm_gc_mark (me->mods_);
+  return me->mods_;
+}
+
+void
+Context_mod::add_context_mod (SCM mod)
+{
+  mods_ = scm_cons (mod, mods_);
+}
+
+void
+Context_mod::add_context_mods (SCM mods)
+{
+  for (SCM m = mods; scm_is_pair (m); m = scm_cdr (m))
+    add_context_mod (scm_car (m));
+}
+
+SCM
+Context_mod::get_mods () const
+{
+  return scm_reverse (mods_);
+}
+
diff --git a/lily/include/context-mod.hh b/lily/include/context-mod.hh
new file mode 100644 (file)
index 0000000..babb864
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+  This file is part of LilyPond, the GNU music typesetter.
+
+  Copyright (C) 2010 Reinhold Kainhofer <reinhold@kainhofer.com>
+
+  LilyPond is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 3 of the License, or
+  (at your option) any later version.
+
+  LilyPond is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/**
+ * context-mod.hh
+ * Implement a structure to store context modifications to be inserted
+ * at some later point
+ */
+
+#ifndef CONTEXT_MOD_HH
+#define CONTEXT_MOD_HH
+
+#include "lily-proto.hh"
+#include "smobs.hh"
+#include "virtual-methods.hh"
+
+
+/*
+  Modifications for an interpretation context as given in the
+  input.
+*/
+struct Context_mod
+{
+private:
+  SCM mods_;
+public:
+  void add_context_mod (SCM);
+  void add_context_mods (SCM);
+
+  VIRTUAL_COPY_CONSTRUCTOR (Context_mod, Context_mod);
+
+  SCM get_mods () const;
+
+  Context_mod ();
+  Context_mod (Context_mod const &);
+  DECLARE_SIMPLE_SMOBS (Context_mod);
+};
+
+DECLARE_UNSMOB (Context_mod, context_mod);
+
+#endif /* CONTEXT_MOD_HH */
+
index d9ede2a7657805c9a17c985ef7f59d9ac6e62ac3..04b9b23d53c12b2ecd6b4290c0a1de1438f1214d 100644 (file)
@@ -54,6 +54,7 @@ class Cluster_engraver;
 class Column_x_positions;
 class Context;
 class Context_def;
+class Context_mod;
 class Context_specced_music;
 class Dispatcher;
 class Dot_column;
index 5f18eef53191b046830953038da9a8c2561233ed..1ec5e11aa2b7e787168e114e76c3d5cc880d52e9 100644 (file)
@@ -84,6 +84,7 @@ using namespace std;
 
 #include "book.hh"
 #include "context-def.hh"
+#include "context-mod.hh"
 #include "dimensions.hh"
 #include "file-path.hh"
 #include "input.hh"
@@ -279,6 +280,7 @@ If we give names, Bison complains.
 %token <scm> CHORD_MODIFIER
 %token <scm> CHORD_REPETITION
 %token <scm> CONTEXT_DEF_IDENTIFIER
+%token <scm> CONTEXT_MOD_IDENTIFIER
 %token <scm> DRUM_PITCH
 %token <scm> DURATION_IDENTIFIER
 %token <scm> EVENT_IDENTIFIER
@@ -346,6 +348,7 @@ If we give names, Bison complains.
 %type <scm> chord_body_element
 %type <scm> command_element
 %type <scm> command_event
+%type <scm> context_modification
 %type <scm> context_change
 %type <scm> direction_less_event
 %type <scm> direction_reqd_event
@@ -631,6 +634,9 @@ identifier_init:
        | DIGIT {
                $$ = scm_from_int ($1);
        }
+        | context_modification {
+                $$ = $1;
+        }
        ;
 
 context_def_spec_block:
@@ -663,6 +669,13 @@ context_def_spec_body:
        | context_def_spec_body context_mod {
                unsmob_context_def ($$)->add_context_mod ($2);
        }
+       | context_def_spec_body context_modification {
+                Context_def *td = unsmob_context_def ($$);
+                SCM new_mods = unsmob_context_mod ($2)->get_mods ();
+                for (SCM m = new_mods; scm_is_pair (m); m = scm_cdr (m)) {
+                    td->add_context_mod (scm_car (m));
+                }
+       }
        ;
 
 
@@ -1023,22 +1036,45 @@ simple_music:
        | context_change
        ;
 
+context_modification:
+        WITH { PARSER->lexer_->push_initial_state (); } '{' context_mod_list '}'
+        {
+                PARSER->lexer_->pop_state ();
+                $$ = $4;
+        }
+        | WITH CONTEXT_MOD_IDENTIFIER
+        {
+                $$ = $2;
+        }
+        | CONTEXT_MOD_IDENTIFIER
+        {
+                $$ = $1;
+        }
+        ;
+
 optional_context_mod:
-       /**/ { $$ = SCM_EOL; }
-       | WITH { PARSER->lexer_->push_initial_state (); }
-       '{' context_mod_list '}'
-       {
-               PARSER->lexer_->pop_state ();
-               $$ = $4;
-       }
-       ;
+        /**/ {
+            $$ = SCM_EOL;
+        }
+        | context_modification
+        {
+              $$ = $1;
+        }
+        ;
 
 context_mod_list:
-       /* */  { $$ = SCM_EOL; }
-       | context_mod_list context_mod  {
-                $$ = scm_cons ($2, $1);
-       }
-       ;
+        /**/ {
+            $$ = Context_mod ().smobbed_copy ();
+        }
+        | context_mod_list context_mod  {
+                 unsmob_context_mod ($1)->add_context_mod ($2);
+        }
+        | context_mod_list CONTEXT_MOD_IDENTIFIER {
+                 Context_mod *md = unsmob_context_mod ($2);
+                 if (md)
+                     unsmob_context_mod ($1)->add_context_mods (md->get_mods ());
+        }
+        ;
 
 composite_music:
        prefix_composite_music { $$ = $1; }
@@ -1120,10 +1156,18 @@ prefix_composite_music:
                $$ = run_music_function (PARSER, $1);
        }
        | CONTEXT simple_string optional_id optional_context_mod music {
-               $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, $4, SCM_BOOL_F);
+                Context_mod *ctxmod = unsmob_context_mod ($4);
+                SCM mods = SCM_EOL;
+                if (ctxmod)
+                        mods = ctxmod->get_mods ();
+               $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, mods, SCM_BOOL_F);
        }
        | NEWCONTEXT simple_string optional_id optional_context_mod music {
-               $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, $4, SCM_BOOL_T);
+                Context_mod *ctxmod = unsmob_context_mod ($4);
+                SCM mods = SCM_EOL;
+                if (ctxmod)
+                        mods = ctxmod->get_mods ();
+               $$ = MAKE_SYNTAX ("context-specification", @$, $2, $3, $5, mods, SCM_BOOL_T);
        }
 
        | TIMES fraction music {
@@ -1148,7 +1192,11 @@ prefix_composite_music:
                PARSER->lexer_->pop_state ();
        }
        | mode_changing_head_with_context optional_context_mod grouped_music_list {
-               $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, $3, $2, SCM_BOOL_T);
+                Context_mod *ctxmod = unsmob_context_mod ($2);
+                SCM mods = SCM_EOL;
+                if (ctxmod)
+                        mods = ctxmod->get_mods ();
+               $$ = MAKE_SYNTAX ("context-specification", @$, $1, SCM_EOL, $3, mods, SCM_BOOL_T);
                if ($1 == ly_symbol2scm ("ChordNames"))
                {
                  $$ = MAKE_SYNTAX ("unrelativable-music", @$, $$);
@@ -2556,13 +2604,17 @@ Lily_lexer::try_special_identifiers (SCM *destination, SCM sid)
        } else if (scm_is_number (sid)) {
                *destination = sid;
                return NUMBER_IDENTIFIER;
-       } else if (unsmob_context_def (sid)) {
-               Context_def *def= unsmob_context_def (sid)->clone ();
+        } else if (unsmob_context_def (sid)) {
+                Context_def *def= unsmob_context_def (sid)->clone ();
+
+                *destination = def->self_scm ();
+                def->unprotect ();
 
-               *destination = def->self_scm ();
-               def->unprotect ();
+                return CONTEXT_DEF_IDENTIFIER;
+        } else if (unsmob_context_mod (sid)) {
+                *destination = unsmob_context_mod (sid)->smobbed_copy ();
 
-               return CONTEXT_DEF_IDENTIFIER;
+                return CONTEXT_MOD_IDENTIFIER;
        } else if (unsmob_score (sid)) {
                Score *score = new Score (*unsmob_score (sid));
                *destination = score->self_scm ();
index 6d4b656dd7e0cb68a21d1a1f84e41cb84f77ce2c..ee723dc0e1e67947316f5e725543263897b8f1b1 100644 (file)
@@ -451,22 +451,13 @@ printing of a single line of lyrics."
 }
 
 
-RemoveEmptyStaffContext = \context {
-  \Staff
+RemoveEmptyStaves = \with {
   \remove "Axis_group_engraver"
   \consists "Hara_kiri_engraver"
   \override Beam #'auto-knee-gap = #'()
   \override VerticalAxisGroup #'remove-empty = ##t
 }
 
-AncientRemoveEmptyStaffContext = \context {
-%% why not add by default?
-
-  \RemoveEmptyStaffContext
-  \accepts "VaticanaVoice"
-  \accepts "GregorianTranscriptionVoice"
-  \accepts "MensuralVoice"
-}
 
 \context {
   \type "Score_engraver"
@@ -980,24 +971,35 @@ accommodated for typesetting a piece in mensural style."
   printKeyCancellation = ##f
 }
 
+
+%% Keep the old definitions in here for compatibility (they erase previous
+%% settings to the corresponding context!).
+%% For new scores, one should simply insert the \RemoveEmptyStaves settings
+%% into the desired context. That's just as easy, requires only one line more
+%% (the \*Staff), but preserves previous context mods.
+%% TODO: DEPRECATED_2.13.17, remove at some point in the future
+RemoveEmptyStaffContext = \context {
+  \Staff
+  \RemoveEmptyStaves
+}
+
+AncientRemoveEmptyStaffContext = \context {
+  \VaticanaStaff
+  \RemoveEmptyStaves
+}
+
 RemoveEmptyDrumStaffContext = \context {
   \DrumStaff
-  \remove "Axis_group_engraver"
-  \override VerticalAxisGroup #'remove-empty = ##t
-  \consists "Hara_kiri_engraver"
+  \RemoveEmptyStaves
 }
 
 RemoveEmptyRhythmicStaffContext = \context {
   \RhythmicStaff
-  \remove "Axis_group_engraver"
-  \override VerticalAxisGroup #'remove-empty = ##t
-  \consists "Hara_kiri_engraver"
+  \RemoveEmptyStaves
 }
 
 RemoveEmptyTabStaffContext = \context {
   \TabStaff
-  \remove "Axis_group_engraver"
-  \override VerticalAxisGroup #'remove-empty = ##t
-  \consists "Hara_kiri_engraver"
+  \RemoveEmptyStaves
 }
 
index 2f0409eb3c03d63d575242938a535d7d082b6de2..8de43822e04df37e3831eba8101d142ed898c459 100644 (file)
@@ -2987,7 +2987,18 @@ def conv(str):
        _ ("Unify fetaNumber and fetaDynamic encodings"))
 def conv(str):
     return re.sub(r'\bfeta(Number|Dynamic)', 'fetaText', str)
-    
+
+@rule ((2, 13, 18),
+       _ ("\RemoveEmpty*StaffContext -> \*Staff \RemoveEmptyStaves"))
+def conv(str):
+    str = re.sub (r"\\RemoveEmpty(|Drum|Rhythmic|Tab)StaffContext",
+                  r"\\\1Staff \\RemoveEmptyStaves",
+                  str);
+    str = re.sub (r"\\AncientRemoveEmptyStaffContext",
+                  r"\\VaticanaStaff \\RemoveEmptyStaves",
+                  str);
+    return str
+
 # Guidelines to write rules (please keep this at the end of this file)
 #
 # - keep at most one rule per version; if several conversions should be done,