lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Move \RemoveEmptyStaves to new file for context modifications (issue #17


From: n . puttock
Subject: Move \RemoveEmptyStaves to new file for context modifications (issue #1760) (issue4664076)
Date: Tue, 12 Jul 2011 22:28:51 +0000

Reviewers: ,

Message:
Here's a patch which implements my proposal for a separate context
modifications init file
(http://lists.gnu.org/archive/html/lilypond-devel/2010-07/msg00359.html).

Description:
Move \RemoveEmptyStaves to new file for context modifications.

This allows \RemoveEmptyStaves to be invoked outside \layout blocks,
i.e.,
directly following a context instantiation:

\new Staff \RemoveEmptyStaves { ... }

or

\new Staff \with { \RemoveEmptyStaves } { ... }

* ly/context-mods-init.ly:

  new file for context modification identifiers

* ly/declarations-init.ly:

  include context-mods-init.ly; placed before engraver-init.ly to ensure
  \RemoveEmptyStaves is accessible for deprecated
\RemoveEmptyStaffContext
  and analogues

* ly/engraver-init.ly:

  remove \RemoveEmptyStaves declaration

Please review this at http://codereview.appspot.com/4664076/

Affected files:
  A input/regression/remove-empty-context-mod.ly
  A ly/context-mods-init.ly
  M ly/declarations-init.ly
  M ly/engraver-init.ly


Index: input/regression/remove-empty-context-mod.ly
diff --git a/input/regression/remove-empty-context-mod.ly b/input/regression/remove-empty-context-mod.ly
new file mode 100644
index 0000000000000000000000000000000000000000..f1c96ffd7ee9bc66894665ddac3341e2601526ea
--- /dev/null
+++ b/input/regression/remove-empty-context-mod.ly
@@ -0,0 +1,15 @@
+\version "2.15.5"
+
+\header {
+  texidoc = "@code{\\RemoveEmptyStaves} is defined separately from
+context definitions so it can be used outside of @code{\\layout} blocks."
+}
+
+\paper {
+  ragged-right = ##t
+}
+
+\new Staff \RemoveEmptyStaves {
+  c'1 \break
+  r1
+}
Index: ly/context-mods-init.ly
diff --git a/ly/context-mods-init.ly b/ly/context-mods-init.ly
new file mode 100644
index 0000000000000000000000000000000000000000..db07600b485cd8aa95f0c93fd5a786ff47a5fbc1
--- /dev/null
+++ b/ly/context-mods-init.ly
@@ -0,0 +1,29 @@
+%%%% This file is part of LilyPond, the GNU music typesetter.
+%%%%
+%%%% Copyright (C) 2011 Han-Wen Nienhuys <address@hidden>
+%%%%                    Jan Nieuwenhuizen <address@hidden>
+%%%%
+%%%% 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/>.
+
+RemoveEmptyStaves = \with {
+  \remove "Axis_group_engraver"
+  % If RemoveEmptyStaves is called twice, two
+  % Hara_kiri_engravers would be added, which leads to a
+  % warning.
+  % This code makes sure that no previous Hara_kiri_engraver
+  % is left before adding a new one.
+  \remove "Hara_kiri_engraver"
+  \consists "Hara_kiri_engraver"
+  \override VerticalAxisGroup #'remove-empty = ##t
+}
Index: ly/declarations-init.ly
diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly
index 268ecaee7eff6de6d34472ced100bbdebb3f3008..8907b789ad674b676cf7af1096bcf9ebf0d2e157 100644
--- a/ly/declarations-init.ly
+++ b/ly/declarations-init.ly
@@ -122,31 +122,29 @@ repeatTie = #(make-music 'RepeatTieEvent)
 \include "grace-init.ly"
 \include "midi-init.ly"
 \include "paper-defaults-init.ly"
+\include "context-mods-init.ly"

 \layout {
-    mm = #(ly:output-def-lookup $defaultpaper 'mm)
-    unit = #(ly:output-def-lookup $defaultpaper 'unit)
+  mm = #(ly:output-def-lookup $defaultpaper 'mm)
+  unit = #(ly:output-def-lookup $defaultpaper 'unit)

-    in = #(* 25.4 mm)
-    pt = #(/  in 72.27)
-    cm = #(* 10 mm)
+  in = #(* 25.4 mm)
+  pt = #(/ in 72.27)
+  cm = #(* 10 mm)

-    \include "engraver-init.ly"
+  \include "engraver-init.ly"

-    #(set-paper-dimension-variables (current-module))
+  #(set-paper-dimension-variables (current-module))
 }

 #(set-default-paper-size (ly:get-option 'paper-size))
 partCombineListener = \layout {
-    \context {
-       \Score
-       skipTypesetting = ##t
-       ignoreBarChecks = ##t
-       \alias "Timing"
-    }
+  \context {
+    \Score
+    skipTypesetting = ##t
+    ignoreBarChecks = ##t
+    \alias "Timing"
+  }
 }

 setDefaultDurationToQuarter = { c4 }
-
-
-
Index: ly/engraver-init.ly
diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly
index d28b8be51b947e1c1391fd37ee7b774be47b8c2c..badb701e08579e8aa7bb4f70ec8b027eaaae0380 100644
--- a/ly/engraver-init.ly
+++ b/ly/engraver-init.ly
@@ -498,20 +498,6 @@ printing of a single line of lyrics."
   \override VerticalAxisGroup #'nonstaff-nonstaff-spacing #'padding = #0.5
 }

-
-RemoveEmptyStaves = \with {
-  \remove "Axis_group_engraver"
-    % If RemoveEmptyStaves is called twice, two
-    % Hara_kiri_engravers would be added, which leads to a
-    % warning.
-    % This code makes sure that no previous Hara_kiri_engraver
-    % is left before adding a new one.
-  \remove "Hara_kiri_engraver"
-  \consists "Hara_kiri_engraver"
-  \override VerticalAxisGroup #'remove-empty = ##t
-}
-
-
 \context {
   \type "Score_engraver"
   \name "Score"
@@ -1052,7 +1038,6 @@ 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]