From 704b06c2bbaebd2ce83e7c04481c12e8fbdf9363 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Mon, 26 Jul 2010 14:09:18 +0200 Subject: [PATCH] Add include-settings cmd line option to include a custom settings This allows the user to apply the same set of options to different files, or to apply different settings to the same score without modifying the score itself. In particular, lilypond -dinclude-settings=myinclude.ily file.ly will compile file.ly, but read and execute myinclude.ily before file.ly is processed. That way, e.g. global paper changes can be easily done, and a file can be run several times, each time with a different include-settings file containing different settings. This feature is similar to the --init=DATEI feature, except that --init will replace the whole init sequence (thus your init file will need to copy all of lilypond's init.ly), while -dinclude-settings will only add some definitions to the normal init sequence in init.ly (i.e. the file is included in init.ly, so the normal init sequence takes place). Unfortunately, it is not possible to add lilypond variable definitions for use in the score... This is probably due to the way the init sequence works. --- Documentation/changes.tely | 8 ++++++++ ly/init.ly | 5 +++++ scm/lily.scm | 2 ++ 3 files changed, 15 insertions(+) diff --git a/Documentation/changes.tely b/Documentation/changes.tely index 76ba8b56d1..7941e85c27 100644 --- a/Documentation/changes.tely +++ b/Documentation/changes.tely @@ -66,6 +66,14 @@ which scares away people. @end ignore +@item +New option @code{-dinclude-settings=INCLUDEFILE.ly}, which causes lilypond +to include the given file before the score is processed. This allows the +user to change global settings without the need to change the score itself. +That way, several different editions/version (e.g. different page sizes) +can be generated from a file without having to modify the score for each +version. + @item The autobeaming settings syntax has been changed. beatLength, beatGrouping, beamSettings, and measureGrouping have all been eliminated. diff --git a/ly/init.ly b/ly/init.ly index 20416624c2..fa1dbe5993 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -22,6 +22,11 @@ #(define book-filename #f) #(define book-output-suffix #f) #(use-modules (scm clip-region)) + +#(if (ly:get-option 'include-settings) + (ly:parser-include-string parser + (format "\\include \"~a\"" (ly:get-option 'include-settings)))) + \maininput %% there is a problem at the end of the input file diff --git a/scm/lily.scm b/scm/lily.scm index 515ff2e02c..4a00ab66e4 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -104,6 +104,8 @@ a log file.") "Include book titles in preview images.") (include-eps-fonts #t "Include fonts in separate-system EPS files.") + (include-settings #f +"Include file for global settings, included before the score is processed.") (job-count #f "Process in parallel, using the given number of jobs.") -- 2.39.2