From cf2da187b5b99e963346e5944311bb77e2e52ff1 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Sun, 17 Jul 2011 22:58:19 +0100 Subject: [PATCH] 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 } { ... } * input/regression/remove-empty-context-mod.ly new regtest * 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 --- input/regression/remove-empty-context-mod.ly | 15 ++++++++++ ly/context-mods-init.ly | 29 +++++++++++++++++++ ly/declarations-init.ly | 30 +++++++++----------- ly/engraver-init.ly | 15 ---------- 4 files changed, 58 insertions(+), 31 deletions(-) create mode 100644 input/regression/remove-empty-context-mod.ly create mode 100644 ly/context-mods-init.ly diff --git a/input/regression/remove-empty-context-mod.ly b/input/regression/remove-empty-context-mod.ly new file mode 100644 index 0000000000..b6cc56193a --- /dev/null +++ b/input/regression/remove-empty-context-mod.ly @@ -0,0 +1,15 @@ +\version "2.15.6" + +\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 +} diff --git a/ly/context-mods-init.ly b/ly/context-mods-init.ly new file mode 100644 index 0000000000..db07600b48 --- /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 +%%%% Jan Nieuwenhuizen +%%%% +%%%% 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 . + +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 +} diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index 268ecaee7e..8907b789ad 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 } - - - diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index d28b8be51b..badb701e08 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 -- 2.39.5