From c223ce0c494250178a9751de9e7a058aa3370fea Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Mon, 9 Mar 2015 16:09:29 +0100 Subject: [PATCH 01/36] oll: Improve initialization code --- ly/_internal/init-openlilylib.ily | 14 +++++++------- ly/openlilylib | 1 - 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ly/_internal/init-openlilylib.ily b/ly/_internal/init-openlilylib.ily index 63a4f014..c593b066 100644 --- a/ly/_internal/init-openlilylib.ily +++ b/ly/_internal/init-openlilylib.ily @@ -67,15 +67,15 @@ % Set the root path of openLilyLib % - for oll module inclusion % - for Scheme module inclusion -% This must be called from the main openlilylib file -% because that's inside the desired root directory setRootPath = #(define-void-function (parser location)() - (let* ((path (location-extract-path location))) - #{ \registerOption global.root-path #path #} - (if (not (member path %load-path)) - (set! %load-path `(,path ,@%load-path))))) - + (let* ((path + (normalize-path + (string-append + (location-extract-path location) + "/..")))) + #{ \registerOption global.root-path #path #})) +\setRootPath % Functionality to load and manage modules \include "module-handling.ily" diff --git a/ly/openlilylib b/ly/openlilylib index e777d366..5dafd7b3 100644 --- a/ly/openlilylib +++ b/ly/openlilylib @@ -28,4 +28,3 @@ initOpenLilyLib = (ly:parser-include-string parser "\\include \"_internal/init-openlilylib.ily\"")))) \initOpenLilyLib -\setRootPath From 86f7762ddcf96cccdd8c7f5ef262a0eb5c741196 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Mon, 9 Mar 2015 16:49:43 +0100 Subject: [PATCH 02/36] oll: New command \useLibrary This is partially replacing \loadModule which didn't distinguish between libraries and modules. Having \useLibrary is slightly more verbose (as one needs two commands now, but also more explicit. The new thing is that \useLibrary can take options that are directly passed to the library. --- ly/_internal/module-handling.ily | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index f67a03eb..61204553 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -30,6 +30,57 @@ #(define oll-loaded-libraries '()) #(define oll-loaded-modules '()) +% Initialize a library before first use. +% This also serves as a kind of declaration of the intent of using it. +% If options are passed in a \with {} clause they are set after in +% initialization file has been loaded. If the initializiation did not +% register the options (in the form LIBRARY.OPTION) this will cause +% warnings about trying to set unregistered options. +useLibrary = +#(define-void-function (parser location options name) + ((ly:context-mod?) symbol? ) + "Load an openLilyLib library and initialize it" + (if (not (member name oll-loaded-libraries)) + ;; Determine paths to init and main files + (let* ((lib-dir + (string-append + #{ \getOption global.root-path #} + "/" (symbol->string name) "/")) + (init-file + (string-append lib-dir "__init__.ily")) + (main-file + (string-append lib-dir "__main__.ily"))) + + ;; Create a root option for the library + #{ \registerOption #(list name) #'() #} + + ;; Load initialization file if it exists + (if (file-exists? init-file) + (begin + (oll:log location "Initialize library \"~a\" ..." name) + (ly:parser-include-string parser (ly:gulp-file init-file)))) + + ;; If a \with clause has been given pass the options to the library. + ;; If the options have not been registered in the __init__ file this + ;; will trigger oll:warn messages but don't abort the job. + (if options + (for-each + (lambda (o) + (let ((opt-path (list name (cadr o))) + (opt-val (caddr o))) + #{ \setOption #opt-path #opt-val #})) + (ly:get-context-mods options))) + + ;; load the main file of the library or issue a warning if that isn't found. + (if (file-exists? main-file) + (begin + (ly:parser-include-string parser (ly:gulp-file main-file)) + (set! oll-loaded-libraries + (append oll-loaded-libraries + `(,name))) + (oll:log location "... completed.")) + (oll:warn location (format "Library main file \"~a\" not found" main-file)))))) + % Conditionally register and load a library when % for the first time a module from that library is requested. From 907102deafed8d130dddca718be1b250de2d0354 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Mon, 9 Mar 2015 16:59:08 +0100 Subject: [PATCH 03/36] oll: deprecate \loadModule for loading libraries For loading libraries \useLibrary is to be used now. This is more powerful and explicit/idiomatic. Commands to load individual items or collections from a library will be added later. --- ly/_internal/module-handling.ily | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 61204553..423cc97f 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -76,14 +76,18 @@ useLibrary = (begin (ly:parser-include-string parser (ly:gulp-file main-file)) (set! oll-loaded-libraries - (append oll-loaded-libraries - `(,name))) + (append oll-loaded-libraries + `(,name))) (oll:log location "... completed.")) (oll:warn location (format "Library main file \"~a\" not found" main-file)))))) % Conditionally register and load a library when % for the first time a module from that library is requested. + +%%% DEPRECATED !!! +%%% This is deprecated together with \loadModule +%%% registerLibrary = #(define-void-function (parser location lib) (string?) @@ -133,6 +137,15 @@ loadModule = #{ \getOption global.root-path #} "/" append-path))) + + ;; DEPRECATION !!! + ;; If used for loading a main library we should now use + ;; \useLibrary instead + (if (= 1 (length path-list)) + (oll:warn location +"\n\\loadModule is deprecated for loading libraries. +Please use the more idiomatic and powerful \\useLibrary now.")) + ;; try to load the file if it isn't already present (if (member load-path oll-loaded-modules) (oll:log "module ~a already loaded. Skipping." load-path) From b3683748bad7c8bfdb52cf283aaeb04c0c018177 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 10:41:30 +0100 Subject: [PATCH 04/36] oll: add \declareLibrary (WIP) Function that has to be used in a library's __init__ file. (Currently it is not enforced but \useLibrary will be updated to enforce that by performing checks for existing options). \declareLibrary is used to set a number of meta options for a library that can be used for documentation and versioning purposes --- ly/_internal/module-handling.ily | 83 ++++++++++++++++++- ly/_internal/utilities/general-predicates.ily | 7 ++ 2 files changed, 89 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 423cc97f..b3f4e11e 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -30,6 +30,87 @@ #(define oll-loaded-libraries '()) #(define oll-loaded-modules '()) + +% Alist with mandatory options for library declarations +% Each entry is a pair of option name symbol and type predicate +#(define oll-lib-mandatory-options + `((maintainers . ,string-or-alist?) + (dummy . ,pair?) + )) + + +% Declare a library, to be done in the __init__.ily file +% Arguments: +% - display-name: The official name of the library +% - name (optional): the directory name of the library +% This name must be 'symbol?' compatible, i.e. must consist of +% alphabetical characters and hyphens only. +% This argument can be omitted if the display-name is the same +% as the directory name with exception of capitalization. +% (e.g. when the display-name is "ScholarLY" the implicit 'name' +% is "scholarly"). +% - options: a \with {} clause with metadata options. +% some of them are mandatory, others can be used at the discretion +% of the library maintainers: +% Mandatory options: +% - maintainers (string-or-alist?) +% multiple maintainers can be maintained with name/email +% - TO-BE-CONTINUED +% Recognized options: +% - TO-BE-DISCUSSED +% +declareLibrary = +#(define-void-function (parser location display-name name options) + (string? (symbol?) ly:context-mod?) + (let* + ;; internal-name is either explicitly given + ;; or the lowercase version of display-name + ((internal-name + (or name (string-downcase display-name))) + ;; option path to the library's meta options + (meta-path `(,(string->symbol internal-name) meta)) + ;; retrieve options from context mods + (options + (map (lambda (o) + (cons (cadr o) (caddr o))) + (ly:get-context-mods options)))) + + ;; initialize library's meta option branch + #{ \registerOption #meta-path #'() #} + + ;; check if all mandatory options are present + (for-each + (lambda (o) + (let ((mand-opt (car o))) + (if (not (assoc-ref options mand-opt)) + (oll:error (format " + Missing option in library declaration! + Library: \"~a\" + Option: \"~a\"" display-name mand-opt) "")) + )) + oll-lib-mandatory-options) + + ;; process options, type-check mandatory options and store in meta + (for-each + (lambda (o) + (let* ((opt-name (car o)) + (opt-val (cdr o)) + (predicate? (assoc-ref oll-lib-mandatory-options opt-name))) + ;; check for type if there is a predicate (-> true for mandatory options) + (if (and predicate? + (not (predicate? opt-val))) + (oll:error (format " + Type check failed for mandatory option in library declaration! + Library: \"~a\" + Option: \"~a\" + Predicate: ~a" display-name opt-name predicate?) "")) + + ;; store option + #{ \setChildOption #meta-path #opt-name #opt-val #} + )) + options))) + + % Initialize a library before first use. % This also serves as a kind of declaration of the intent of using it. % If options are passed in a \with {} clause they are set after in @@ -143,7 +224,7 @@ loadModule = ;; \useLibrary instead (if (= 1 (length path-list)) (oll:warn location -"\n\\loadModule is deprecated for loading libraries. + "\n\\loadModule is deprecated for loading libraries. Please use the more idiomatic and powerful \\useLibrary now.")) ;; try to load the file if it isn't already present diff --git a/ly/_internal/utilities/general-predicates.ily b/ly/_internal/utilities/general-predicates.ily index 2c652c16..c4495a07 100644 --- a/ly/_internal/utilities/general-predicates.ily +++ b/ly/_internal/utilities/general-predicates.ily @@ -35,3 +35,10 @@ (and (list? obj) (every string? obj))) +% Returns true if obj is a string or a list of pairs (alist) +% (used for mandatory library options) +#(define (string-or-alist? obj) + (if (or (string? obj) + (and (list? obj) + (every pair? obj))) + #t #f)) From 20336bfede84e2638de3c488054cf79e09a667f9 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 11:19:11 +0100 Subject: [PATCH 05/36] oll: add oll-maintainers? predicate and use it The mandatory library option maintainers is now oll-maintainers? This is either a string of name or a list thereof. --- ly/_internal/module-handling.ily | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index b3f4e11e..9037d1e3 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -30,11 +30,25 @@ #(define oll-loaded-libraries '()) #(define oll-loaded-modules '()) +% Simple regex check for Name plus email address in angled brackets: +% "Ben Maintainer " +#(define (oll-maintainer? obj) + (let ((pat (make-regexp ".*<.*@.*>"))) + (if (and (string? obj) + (regexp-exec pat obj)) + #t #f))) + +% Returns true for one maintainer or a list of them +#(define (oll-maintainers? obj) + (or (oll-maintainer? obj) + (and (list? obj) + (every oll-maintainer? obj)))) + % Alist with mandatory options for library declarations % Each entry is a pair of option name symbol and type predicate #(define oll-lib-mandatory-options - `((maintainers . ,string-or-alist?) + `((maintainers . ,oll-maintainers?) (dummy . ,pair?) )) From 971b708d9aa80bb09fc9f8f85d879ed8b9302fab Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 11:38:32 +0100 Subject: [PATCH 06/36] oll: add 'version as mandatory library option version string with three integer elements --- ly/_internal/module-handling.ily | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 9037d1e3..0c23de4a 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -30,6 +30,9 @@ #(define oll-loaded-libraries '()) #(define oll-loaded-modules '()) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Predicates for type-checking of library options + % Simple regex check for Name plus email address in angled brackets: % "Ben Maintainer " #(define (oll-maintainer? obj) @@ -44,12 +47,22 @@ (and (list? obj) (every oll-maintainer? obj)))) +% Returns true if obj is a string representation of an integer +#(define (integer-string? obj) + (integer? (string->number obj))) + +% Returns true if a string is a three-element dot-joined list of integers +#(define (oll-version-string? obj) + (and (string? obj) + (let ((lst (string-split obj #\.))) + (and (= 3 (length lst)) + (every integer-string? lst))))) % Alist with mandatory options for library declarations % Each entry is a pair of option name symbol and type predicate #(define oll-lib-mandatory-options `((maintainers . ,oll-maintainers?) - (dummy . ,pair?) + (version . ,oll-version-string?) )) From bcc0fb5e785f81e9cefc5d375ca5a76396a0d3dd Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 11:41:57 +0100 Subject: [PATCH 07/36] oll: add 'short-description as mandatory option Short description (subheading) as \markup. --- ly/_internal/module-handling.ily | 1 + 1 file changed, 1 insertion(+) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 0c23de4a..95e000b2 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -63,6 +63,7 @@ #(define oll-lib-mandatory-options `((maintainers . ,oll-maintainers?) (version . ,oll-version-string?) + (short-description . ,markup?) )) From e0c959524fcaa2812ef919df1683043657f06f5d Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 14:14:29 +0100 Subject: [PATCH 08/36] oll: add descriptions as mandatory options 'short-description (as subheading) 'description (as introduction) Both as string options. --- ly/_internal/module-handling.ily | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 95e000b2..97bb14f0 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -63,7 +63,8 @@ #(define oll-lib-mandatory-options `((maintainers . ,oll-maintainers?) (version . ,oll-version-string?) - (short-description . ,markup?) + (short-description . ,string?) + (description . ,string?) )) From 88c7462896ebd0abb19d83d3cc1c9f7dc156832e Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 11:54:37 +0100 Subject: [PATCH 09/36] oll: Add type-checked known library options A list of known library options is used to type-check known options. The library can still add arbitrary options, but it is ensured that "known" options have a given type. That's necessary to be able to post-process them (e.g. in documentation generation).. --- ly/_internal/module-handling.ily | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 97bb14f0..e8464ef5 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -67,6 +67,13 @@ (description . ,string?) )) +% Alist with recognized options for library declarations +% If an option is in this list it is type-checked against the given predicate. +#(define oll-lib-known-options + `((lilypond-min-version . ,oll-version-string?) + (lilypond-max-version . ,oll-version-string?) + )) + % Declare a library, to be done in the __init__.ily file % Arguments: @@ -124,7 +131,8 @@ declareLibrary = (lambda (o) (let* ((opt-name (car o)) (opt-val (cdr o)) - (predicate? (assoc-ref oll-lib-mandatory-options opt-name))) + (predicate? (assoc-ref oll-lib-mandatory-options opt-name)) + (known-opt-pred? (assoc-ref oll-lib-known-options opt-name))) ;; check for type if there is a predicate (-> true for mandatory options) (if (and predicate? (not (predicate? opt-val))) @@ -133,6 +141,13 @@ declareLibrary = Library: \"~a\" Option: \"~a\" Predicate: ~a" display-name opt-name predicate?) "")) + (if (and known-opt-pred? + (not (known-opt-pred? opt-val))) + (oll:error (format " + Type check failed for known option in library declaration! + Library: \"~a\" + Option: \"~a\" + Predicate: ~a" display-name opt-name known-opt-pred?) "")) ;; store option #{ \setChildOption #meta-path #opt-name #opt-val #} From 66cd472923b597b6c8a70d1f9cf831f6225742da Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 11:57:21 +0100 Subject: [PATCH 10/36] oll: "declare" stylesheets library --- ly/stylesheets/__init__.ily | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ly/stylesheets/__init__.ily b/ly/stylesheets/__init__.ily index bf4afff2..9e44bff8 100644 --- a/ly/stylesheets/__init__.ily +++ b/ly/stylesheets/__init__.ily @@ -32,6 +32,18 @@ Initialization of the Stylesheets library %} +\declareLibrary "Stylesheets" \with { + maintainers = #'("Urs Liska " + "Abraham Lee " + "Kieren MacMillan ") + version = "0.1.0" + short-description = "Managing fonts and stylesheets with GNU LilyPond" + description = "Longer description, used as an introduction to the library." + % The following option is "unreal" and only used to demonstrate "known options" + lilypond-min-version = "2.18.2" +} + + % internal options for use in the font loading mechanism \registerOption stylesheets.font.name Emmentaler \registerOption stylesheets.font.use-name Emmentaler From f1ff7c1e5b48032d821c4b787e49c0aef59e250b Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 14:16:34 +0100 Subject: [PATCH 11/36] oll: Small comment polishing --- ly/_internal/module-handling.ily | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index e8464ef5..8b85ff23 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -88,12 +88,7 @@ % - options: a \with {} clause with metadata options. % some of them are mandatory, others can be used at the discretion % of the library maintainers: -% Mandatory options: -% - maintainers (string-or-alist?) -% multiple maintainers can be maintained with name/email -% - TO-BE-CONTINUED -% Recognized options: -% - TO-BE-DISCUSSED +% For possible mandatory and known options see the two lists above. % declareLibrary = #(define-void-function (parser location display-name name options) From a8cc3a8cc4bde0bb4a13a62397a3dcc9465f9781 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 14:34:20 +0100 Subject: [PATCH 12/36] comptools: \declareLibrary --- ly/comptools/__init__.ily | 13 +++++++++++++ ly/comptools/__main__.ily | 3 +++ ly/comptools/usage-examples/conditional-breaks.ly | 4 ++++ ly/comptools/usage-examples/partial-compilation.ly | 3 +++ 4 files changed, 23 insertions(+) create mode 100644 ly/comptools/__main__.ily diff --git a/ly/comptools/__init__.ily b/ly/comptools/__init__.ily index 7e853d09..d9ba2c46 100644 --- a/ly/comptools/__init__.ily +++ b/ly/comptools/__init__.ily @@ -1,5 +1,18 @@ + + +\declareLibrary CompTools \with { + maintainers = "Urs Liska " + version = "0.1.0" + + short-description = "Tools providing support for different compilation modes." + description = "This library supports ways to conditionally compile documents, +that is, it provides commands that affect the appearance of the score but that +don't belong to the musical content of the engraved piece. Rather it is at the +level of presentation or of authoring workflows." +} + % Shared variable that can hold any number of break sets. % Selecting one set to apply makes it possible to manage different % break sets, e.g. corresponding to different manuscripts diff --git a/ly/comptools/__main__.ily b/ly/comptools/__main__.ily new file mode 100644 index 00000000..7288cf98 --- /dev/null +++ b/ly/comptools/__main__.ily @@ -0,0 +1,3 @@ + + +% Stub diff --git a/ly/comptools/usage-examples/conditional-breaks.ly b/ly/comptools/usage-examples/conditional-breaks.ly index c1476d34..2acbc5c4 100644 --- a/ly/comptools/usage-examples/conditional-breaks.ly +++ b/ly/comptools/usage-examples/conditional-breaks.ly @@ -3,6 +3,10 @@ \version "2.18.0" \include "openlilylib" + +\setOption global.loglevel #oll-loglevel-log +\useLibrary comptools + %\loadModule "comptools/partial-compilation.ily" \registerOption documentation.include-file "comptools/conditional-breaks.ily" \loadModule "_internal/doc-include/usage-example.ily" diff --git a/ly/comptools/usage-examples/partial-compilation.ly b/ly/comptools/usage-examples/partial-compilation.ly index 55f0272c..bde3532f 100644 --- a/ly/comptools/usage-examples/partial-compilation.ly +++ b/ly/comptools/usage-examples/partial-compilation.ly @@ -3,6 +3,9 @@ \version "2.18.0" \include "openlilylib" +\setOption global.loglevel #oll-loglevel-log +\useLibrary comptools + \registerOption documentation.include-file "comptools/partial-compilation.ily" \loadModule "_internal/doc-include/usage-example.ily" From f9bf8d96ba16967e2ffbe913a3e4a3e8b0eaee20 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 14:40:25 +0100 Subject: [PATCH 13/36] scholarly: \declareLibrary --- ly/scholarly/__init__.ily | 12 ++++++++++++ ly/scholarly/usage-examples/annotate.ly | 3 +++ .../usage-examples/diplomatic-line-breaks.ly | 3 +++ 3 files changed, 18 insertions(+) diff --git a/ly/scholarly/__init__.ily b/ly/scholarly/__init__.ily index 8495c4da..f24fe78b 100644 --- a/ly/scholarly/__init__.ily +++ b/ly/scholarly/__init__.ily @@ -26,6 +26,18 @@ Initialization of the ScholarLY library %} +\declareLibrary ScholarLY \with { + maintainers = "Urs Liska " + version = "0.1.0" + short-description = "Toolkit for scholarly editing." + description = " +ScholarLY is intended to become a comprehensive toolkit for scholarly work with +GNU LilyPond. Currently its main content is the \annotate module, providing +commands to add annotations in the LilyPond sources. These annotations can be +printed or exported and post-processed, e.g. with critical reports in LaTeX +documents." +} + % By default coloring is turned on. % Only for publication one will want to turn it off \registerOption scholarly.colorize ##t diff --git a/ly/scholarly/usage-examples/annotate.ly b/ly/scholarly/usage-examples/annotate.ly index fa6e15a0..37b8a392 100644 --- a/ly/scholarly/usage-examples/annotate.ly +++ b/ly/scholarly/usage-examples/annotate.ly @@ -1,6 +1,9 @@ \version "2.18.0" \include "openlilylib" + +\useLibrary ScholarLY + \registerOption documentation.include-file "scholarly/annotate" \loadModule "_internal/doc-include/usage-example.ily" diff --git a/ly/scholarly/usage-examples/diplomatic-line-breaks.ly b/ly/scholarly/usage-examples/diplomatic-line-breaks.ly index a3ceb0cc..b3d5a24e 100644 --- a/ly/scholarly/usage-examples/diplomatic-line-breaks.ly +++ b/ly/scholarly/usage-examples/diplomatic-line-breaks.ly @@ -1,6 +1,9 @@ \version "2.17.10" \include "openlilylib" + +\useLibrary scholarly + \registerOption documentation.include-file "scholarly/diplomatic-line-breaks.ily" \loadModule "_internal/doc-include/usage-example.ily" From 65506fcd27cb35bf9e22bdfd979353d72810d4ce Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 15:10:45 +0100 Subject: [PATCH 14/36] oll: paths in os-path can also be symbol? paths Now all functions in os-path that take paths as arguments accept - strings (OS independent) - lists of strings - lists of symbols (strings and symbols could be mixed as they are converted one by one.) --- ly/_internal/utilities/os-path.scm | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/ly/_internal/utilities/os-path.scm b/ly/_internal/utilities/os-path.scm index 61a6f357..6912980b 100644 --- a/ly/_internal/utilities/os-path.scm +++ b/ly/_internal/utilities/os-path.scm @@ -54,18 +54,24 @@ Takes either a path string or a list. If 'path' is a string it is split respecting the OS dependent path separator, - if it is a list then simply the list is returned." + if it is a list then the list is returned, + while elements are converted from symbol to string if necessary." (if (string? path) (string-split path os-path-separator) - path)) + (map + (lambda (elt) + (if (string? elt) + elt + (symbol->string elt))) + path))) (define-public (join-unix-path path-list) - "Returns a Unix formatted path string from a list." - (string-join path-list "/")) + "Returns a Unix formatted path string from a (symbol?/string?) list." + (string-join (split-path path-list) "/")) (define-public (join-dot-path path) "Returns a string in dot-notation (to be displayed). - Takes a list with string elements or an + Takes a list with symbol?/string? elements or an OS independent path string." (let ((path-list (split-path path))) (string-join path-list "."))) @@ -76,7 +82,7 @@ (define-public (absolute-path? path) "Test if the given path is absolute. - Process either a string or a string list." + Process either a string or a symbol?/string? list." (let ((path-list (split-path path))) (if (and (> (length path-list) 0) ;; consider the path absolute if either the regex for windows volumes is matched From 0b417c00c922b1a78fd5d3aace5a2741daabf158 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 15:25:17 +0100 Subject: [PATCH 15/36] oll: factor out extract-options It is a common operation to extract the cadr and caddr from all elements of a ly:context-mod? argument. Therefore it is factored in a dedicated function. --- ly/_internal/module-handling.ily | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 8b85ff23..cd288a1b 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -30,6 +30,19 @@ #(define oll-loaded-libraries '()) #(define oll-loaded-modules '()) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Helper tools + +% Extract an options alist from a context-mods argument +% Return an empty list if no mods are passed. +#(define (extract-options ctx-mods) + (if ctx-mods + (map (lambda (o) + (cons (cadr o) (caddr o))) + (ly:get-context-mods ctx-mods)) + '())) + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Predicates for type-checking of library options @@ -101,10 +114,7 @@ declareLibrary = ;; option path to the library's meta options (meta-path `(,(string->symbol internal-name) meta)) ;; retrieve options from context mods - (options - (map (lambda (o) - (cons (cadr o) (caddr o))) - (ly:get-context-mods options)))) + (options (extract-options options))) ;; initialize library's meta option branch #{ \registerOption #meta-path #'() #} From b75dfcdb4b962529d5fcd636a0cc35a7fb32ec37 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 16:04:36 +0100 Subject: [PATCH 16/36] oll: use "\include" instead of (ly:gulp-file) It seems that when using gulp-file the location argument is not passed correctly. Therefore I change it to the "\include" idiom. --- ly/_internal/module-handling.ily | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index cd288a1b..557c527e 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -204,7 +204,9 @@ useLibrary = ;; load the main file of the library or issue a warning if that isn't found. (if (file-exists? main-file) (begin - (ly:parser-include-string parser (ly:gulp-file main-file)) + ; (ly:parser-include-string parser (ly:gulp-file main-file)) + (ly:parser-include-string parser + (format "\\include \"~a\"" main-file)) (set! oll-loaded-libraries (append oll-loaded-libraries `(,name))) From 947259978d9065e9cc40eba3ad8751eda1a14cc5 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 16:06:21 +0100 Subject: [PATCH 17/36] oll: add \useModule New interface to using modules, using a dot-symbol-path as argument. Throws a warning when the library hasn't been loaded already. Accepts an optional \with {} clause with options that are passed to the module. --- ly/_internal/module-handling.ily | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 557c527e..a21ca7b0 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -214,6 +214,73 @@ useLibrary = (oll:warn location (format "Library main file \"~a\" not found" main-file)))))) +% Load a module from within a library. +% A module is either a single .ily file or a __main__.ily file in a folder. +% It is adressed as a dotted path representing the directory structure +% leading to the file. The first element of the path is the library, the last one +% is the name of the module. +% It is looked for files path/to/NAME.ily or path/to/NAME/__main__.ily +% +% An optional \with {} clause can contain options that will be set +% after the module has been loaded. Such options must have been registered +% in the module definition file. + +useModule = +#(define-void-function (parser location options sym-path) + ((ly:context-mod?) list?) + (let ((dot-path (join-dot-path sym-path))) + ;; only do any work if the module isn't already loaded + (if (member dot-path oll-loaded-modules ) + (oll:warn location + (format "Module already loaded. Skipping \"~a\"" dot-path)) + (let* + ((library (car sym-path)) + (mod-path (cdr sym-path)) + ;; unix file path to the module (base) + (module-basename + (string-append + #{ \getOption global.root-path #} + "/" (join-unix-path sym-path))) + ;; Check if a valid file can be found for the module path + ;; #f if no file is found + (filename + (or (if (file-exists? (string-append module-basename ".ily")) + (string-append module-basename ".ily") #f) + (if (file-exists? (string-append module-basename "/__main__.ily")) + (string-append module-basename "/__main__.ily") #f))) + (opts (extract-options options))) + + ;; Load module if present + (if filename + ;; but only if the library is already loaded + (if (not (member library oll-loaded-libraries)) + (oll:warn location + (format "Library \"~a\" must be loaded before module \"~a\"" + library (join-dot-path mod-path))) + (begin + + ;; Include module file + (ly:parser-include-string parser + (format "\\include \"~a\"" filename)) + + ;; register module + (set! oll-loaded-modules + (append oll-loaded-modules (list dot-path))) + + ;; pass along options + (for-each + (lambda (o) + #{ \setChildOption #sym-path #(car o) #(cdr o) #}) + opts) + + ;; TODO: COntinue with setting options + )) + (oll:warn location + (format "No file found for module ~a" + (join-dot-path (append (list library) mod-path))))))))) + + + % Conditionally register and load a library when % for the first time a module from that library is requested. From 99265a17e8969da090b960ec0227e74d408c8dbd Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 16:42:46 +0100 Subject: [PATCH 18/36] oll: completely deprecate \loadModule \loadModule should not be used anymore. --- ly/_internal/module-handling.ily | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index a21ca7b0..25021236 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -320,6 +320,15 @@ registerLibrary = loadModule = #(define-void-function (parser location path)(string?) "Load an openLilyLib module if it has not been already loaded." + + ;; DEPRECATION !!! + (oll:warn location + "\n \\loadModule + is deprecated and will eventually be removed. + Please use the more idiomatic and powerful + \\useLibrary and + \\useModule now.") + (let* ((path-list (string-split path #\/)) (lib (first path-list)) @@ -337,14 +346,6 @@ loadModule = "/" append-path))) - ;; DEPRECATION !!! - ;; If used for loading a main library we should now use - ;; \useLibrary instead - (if (= 1 (length path-list)) - (oll:warn location - "\n\\loadModule is deprecated for loading libraries. -Please use the more idiomatic and powerful \\useLibrary now.")) - ;; try to load the file if it isn't already present (if (member load-path oll-loaded-modules) (oll:log "module ~a already loaded. Skipping." load-path) From 4b4fdcac51005c657b4fdbd48c549dc08be9b579 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 17:28:23 +0100 Subject: [PATCH 19/36] oll: ensure library name to be used as lowercase --- ly/_internal/module-handling.ily | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 25021236..c77d99a3 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -169,6 +169,10 @@ declareLibrary = useLibrary = #(define-void-function (parser location options name) ((ly:context-mod?) symbol? ) + (let* + ;; ensure the library name is lowercase + ((display-name name) + (name (string->symbol (string-downcase (symbol->string name))))) "Load an openLilyLib library and initialize it" (if (not (member name oll-loaded-libraries)) ;; Determine paths to init and main files @@ -187,7 +191,7 @@ useLibrary = ;; Load initialization file if it exists (if (file-exists? init-file) (begin - (oll:log location "Initialize library \"~a\" ..." name) + (oll:log location "Initialize library \"~a\" ..." display-name) (ly:parser-include-string parser (ly:gulp-file init-file)))) ;; If a \with clause has been given pass the options to the library. From aa2226a09a0ff7c1ff685aae31fc7199f739b04d Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 17:29:32 +0100 Subject: [PATCH 20/36] oll: include init file (if present) in \useModule --- ly/_internal/module-handling.ily | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index c77d99a3..3ab147ba 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -247,11 +247,20 @@ useModule = "/" (join-unix-path sym-path))) ;; Check if a valid file can be found for the module path ;; #f if no file is found - (filename + (ext (or (if (file-exists? (string-append module-basename ".ily")) - (string-append module-basename ".ily") #f) + ".ily" #f) (if (file-exists? (string-append module-basename "/__main__.ily")) - (string-append module-basename "/__main__.ily") #f))) + "/__main__.ily" #f))) + (filename + (if ext + (string-append module-basename ext) #f)) + (init-file + (and ext + (string=? "/__main__.ily" ext) + (let ((fname (string-append module-basename "/__init__.ily"))) + (if (file-exists? fname) + fname #f)))) (opts (extract-options options))) ;; Load module if present @@ -263,7 +272,13 @@ useModule = library (join-dot-path mod-path))) (begin - ;; Include module file + ;; include init-file if present + (if init-file + (ly:parser-include-string parser + (format "\\include \"~a\"" init-file))) + + + ;; include module file (ly:parser-include-string parser (format "\\include \"~a\"" filename)) From 370aac15e6d61b3d25550d909520a7685d5eb422 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 17:29:55 +0100 Subject: [PATCH 21/36] oll: once more use \include instead of gulp-file --- ly/_internal/module-handling.ily | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 3ab147ba..1af09ea2 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -192,7 +192,8 @@ useLibrary = (if (file-exists? init-file) (begin (oll:log location "Initialize library \"~a\" ..." display-name) - (ly:parser-include-string parser (ly:gulp-file init-file)))) + (ly:parser-include-string parser + (format "\\include \"~a\"" init-file)))) ;; If a \with clause has been given pass the options to the library. ;; If the options have not been registered in the __init__ file this @@ -215,7 +216,7 @@ useLibrary = (append oll-loaded-libraries `(,name))) (oll:log location "... completed.")) - (oll:warn location (format "Library main file \"~a\" not found" main-file)))))) + (oll:warn location (format "Library main file \"~a\" not found" main-file))))))) % Load a module from within a library. @@ -339,10 +340,10 @@ registerLibrary = loadModule = #(define-void-function (parser location path)(string?) "Load an openLilyLib module if it has not been already loaded." - - ;; DEPRECATION !!! - (oll:warn location - "\n \\loadModule + + ;; DEPRECATION !!! + (oll:warn location + "\n \\loadModule is deprecated and will eventually be removed. Please use the more idiomatic and powerful \\useLibrary and From ab5b618c03c79f18301d5b974843f2853d301785 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 17:30:58 +0100 Subject: [PATCH 22/36] utility: Add (empty) main and init files These are needed for the new loading mechanism --- ly/utility/__init__.ily | 1 + ly/utility/__main__.ily | 1 + 2 files changed, 2 insertions(+) create mode 100644 ly/utility/__init__.ily create mode 100644 ly/utility/__main__.ily diff --git a/ly/utility/__init__.ily b/ly/utility/__init__.ily new file mode 100644 index 00000000..1aa35e93 --- /dev/null +++ b/ly/utility/__init__.ily @@ -0,0 +1 @@ +% empty library init file for utility lib. \ No newline at end of file diff --git a/ly/utility/__main__.ily b/ly/utility/__main__.ily new file mode 100644 index 00000000..5ff7fab1 --- /dev/null +++ b/ly/utility/__main__.ily @@ -0,0 +1 @@ +% empty library file for utility lib. \ No newline at end of file From dc3feec6159924b33f355603b86e2d0c41241f77 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 10 Mar 2015 17:33:05 +0100 Subject: [PATCH 23/36] scholarly: Remove old module loading code --- ly/scholarly/__main__.ily | 2 +- ly/scholarly/annotate/__main__.ily | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ly/scholarly/__main__.ily b/ly/scholarly/__main__.ily index 790b2fe2..332f38fe 100644 --- a/ly/scholarly/__main__.ily +++ b/ly/scholarly/__main__.ily @@ -29,4 +29,4 @@ currently only the annotate module is implemented %} -\loadModule "scholarly/annotate" +\include "annotate/__main__.ily" diff --git a/ly/scholarly/annotate/__main__.ily b/ly/scholarly/annotate/__main__.ily index ac6dbd1f..a019e2ce 100644 --- a/ly/scholarly/annotate/__main__.ily +++ b/ly/scholarly/annotate/__main__.ily @@ -47,7 +47,8 @@ % Include factored out functionality \include "config.ily" -\loadModule "utility/rhythmic-location.ily" +\useLibrary utility +\useModule utility.rhythmic-location \include "sort.ily" \include "format.ily" \include "export.ily" From 5bbbb94ad36cd32c137d4fc408843e2167095414 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Wed, 11 Mar 2015 11:04:47 +0100 Subject: [PATCH 24/36] stylesheets: Replace gulp-file with \include --- ly/stylesheets/__main__.ily | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ly/stylesheets/__main__.ily b/ly/stylesheets/__main__.ily index 73aa8740..4b841b1d 100644 --- a/ly/stylesheets/__main__.ily +++ b/ly/stylesheets/__main__.ily @@ -166,7 +166,7 @@ useNotationFont = ; through Scheme (I suspect there are options in the paper ; related ly: functions but I didn't succeed to find a solution). (ly:parser-include-string parser - (ly:gulp-file + (format "\\include \"~a\"" (string-append #{ \getOption global.root-path #} "/stylesheets/load-font"))) @@ -180,6 +180,6 @@ useNotationFont = ;; if not "none". (if (not (string=? "none" style)) (ly:parser-include-string parser - (ly:gulp-file style-file))) + (format "\\include \"~a\"" style-file))) (oll:log location (format "Associated \"~a\" stylesheet loaded successfully" style)) )) From 827ee82df45466e8d6157446606c852f007d66d4 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:04:17 +0100 Subject: [PATCH 25/36] basic-example: Update to new calling syntax Now it works. However, there's one peculiar thing: When defining a variable in __init__.ily this isn't available in __main__.ily afterwards. --- ly/basic-example.ly | 15 ++++++++++----- ly/example/__init__.ily | 2 +- ly/example/__main__.ily | 11 +++++------ ly/example/load-test.ily | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/ly/basic-example.ly b/ly/basic-example.ly index e32c3ddb..4708461a 100644 --- a/ly/basic-example.ly +++ b/ly/basic-example.ly @@ -39,22 +39,27 @@ % Load the example library % Notice (on the console) that actually example/__main__.ily is loaded -\loadModule "example" +\useLibrary example #(ly:message "\nTry to load a module that is already loaded:") -\loadModule "example/load-test.ily" +\useModule example.load-test #(ly:message "\nTry to load a non-existent module:") -\loadModule "example/this/is/not/a/module.ily" - +\useModule example.this.is.not.any.module #(ly:message "Use a command defined in the loaded modules") \hello +#(ly:message "Display value defined in the init file:") +#(ly:message in-init) + + #(ly:message "\nOverwrite one option, keep default of another, try to set a non-existent option.") \setOption example.common.thickness 0.8 \setOption example.common.thin-thickness 0.5 #(ly:message (format "Default value of example.common.thick-thickness: ~a\n" #{ \getOption example.common.thick-thickness #})) -\displayOptions \ No newline at end of file +%} + +\displayOptions diff --git a/ly/example/__init__.ily b/ly/example/__init__.ily index d9e796c4..a568acae 100644 --- a/ly/example/__init__.ily +++ b/ly/example/__init__.ily @@ -39,8 +39,8 @@ #(ly:message "\nDefine variable \"in-init\" in initialization file") +#(define in-init "This is defined in init") -#(define in-init "defined in init") #(ly:message "\nRegister some options in the __init__ file") diff --git a/ly/example/__main__.ily b/ly/example/__main__.ily index b6e17e77..18dcb8ad 100644 --- a/ly/example/__main__.ily +++ b/ly/example/__main__.ily @@ -31,13 +31,12 @@ %} % Output a confirmation message that we are being parsed -#(ly:message "\nModule \"example\" loaded through openLilyLib!\n") +#(ly:message "\nModule \"example\" main file loaded through openLilyLib!\n") #(ly:message (format "I am ~a" #{ \thisFile #})) +#(ly:message "\nLoad a module from within the library main file:") +\useModule example.load-test -#(ly:message "\nLoad a file from within the module.\n") -\loadModule "example/load-test.ily" - -#(display - (format "Use variable in __main__ that was defined in __init__: ~a" in-init)) +%#(display +% (format "Use variable in __main__ that was defined in __init__: ~a" in-init)) diff --git a/ly/example/load-test.ily b/ly/example/load-test.ily index f09372bf..98db326f 100644 --- a/ly/example/load-test.ily +++ b/ly/example/load-test.ily @@ -34,4 +34,4 @@ hello = #(define-void-function (parser location)() (ly:message (format "\nHello,\nthis is printed by an included funtion -from file ~a\n" this-file))) \ No newline at end of file +from file ~a\n" this-file))) From cee7c879a16445b02b903ea89c5f12be8ede9209 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:04:43 +0100 Subject: [PATCH 26/36] oll: Minor output improvement in \useModule --- ly/_internal/module-handling.ily | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ly/_internal/module-handling.ily b/ly/_internal/module-handling.ily index 1af09ea2..89f53d87 100644 --- a/ly/_internal/module-handling.ily +++ b/ly/_internal/module-handling.ily @@ -215,7 +215,7 @@ useLibrary = (set! oll-loaded-libraries (append oll-loaded-libraries `(,name))) - (oll:log location "... completed.")) + (oll:log "... completed." "")) (oll:warn location (format "Library main file \"~a\" not found" main-file))))))) From 89cd692ac85fbccf48553dad6d7da93a83df6a34 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:29:31 +0100 Subject: [PATCH 27/36] scholarly: Update usage-examples to new syntax --- ly/scholarly/usage-examples/annotate.ly | 8 ++++++-- ly/scholarly/usage-examples/diplomatic-line-breaks.ly | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/ly/scholarly/usage-examples/annotate.ly b/ly/scholarly/usage-examples/annotate.ly index 37b8a392..ad44a434 100644 --- a/ly/scholarly/usage-examples/annotate.ly +++ b/ly/scholarly/usage-examples/annotate.ly @@ -4,8 +4,12 @@ \useLibrary ScholarLY -\registerOption documentation.include-file "scholarly/annotate" -\loadModule "_internal/doc-include/usage-example.ily" +\useModule scholarly.annotate + +#(display "loaded\n") + +%\registerOption documentation.include-file "scholarly/annotate" +%\loadModule "_internal/doc-include/usage-example.ily" \markup \vspace #1 diff --git a/ly/scholarly/usage-examples/diplomatic-line-breaks.ly b/ly/scholarly/usage-examples/diplomatic-line-breaks.ly index b3d5a24e..2164cf33 100644 --- a/ly/scholarly/usage-examples/diplomatic-line-breaks.ly +++ b/ly/scholarly/usage-examples/diplomatic-line-breaks.ly @@ -4,8 +4,13 @@ \useLibrary scholarly -\registerOption documentation.include-file "scholarly/diplomatic-line-breaks.ily" -\loadModule "_internal/doc-include/usage-example.ily" +%\registerOption documentation.include-file "scholarly/diplomatic-line-breaks.ily" +%\loadModule "_internal/doc-include/usage-example.ily" + +\useModule scholarly.diplomatic-line-breaks + +% The following is necessary because leaving it out would give lots of (strange) syntax errors +#(ly:message "loaded") \markup \vspace #1 { From d20149eb1829d4a3283588a9f3b5b6bb4049d3d0 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:39:01 +0100 Subject: [PATCH 28/36] gridly: Remove redundant includes from examples --- ly/gridly/usage-examples/multi-file/parts/alto-I.ily | 2 -- ly/gridly/usage-examples/multi-file/parts/basso-I.ily | 2 -- ly/gridly/usage-examples/multi-file/parts/soprano-I.ily | 2 -- ly/gridly/usage-examples/multi-file/parts/tenore-I.ily | 2 -- 4 files changed, 8 deletions(-) diff --git a/ly/gridly/usage-examples/multi-file/parts/alto-I.ily b/ly/gridly/usage-examples/multi-file/parts/alto-I.ily index 9a38cc76..3a8402d0 100644 --- a/ly/gridly/usage-examples/multi-file/parts/alto-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/alto-I.ily @@ -1,7 +1,5 @@ \version "2.18.2" -\include "../global.ily" - \gridPutMusic "alto" #1 \relative c' { e1 | diff --git a/ly/gridly/usage-examples/multi-file/parts/basso-I.ily b/ly/gridly/usage-examples/multi-file/parts/basso-I.ily index db898f15..3e9e1bb3 100644 --- a/ly/gridly/usage-examples/multi-file/parts/basso-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/basso-I.ily @@ -1,7 +1,5 @@ \version "2.18.2" -\include "../global.ily" - \gridPutMusic "basso" #1 \relative c { \clef "bass" diff --git a/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily b/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily index 41735e56..98297808 100644 --- a/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily @@ -1,7 +1,5 @@ \version "2.18.2" -\include "../global.ily" - \gridPutMusic "soprano" #1 \relative c'' { g1 | diff --git a/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily b/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily index 7955dbdf..074a304e 100644 --- a/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily @@ -1,7 +1,5 @@ \version "2.18.2" -\include "../global.ily" - \gridPutMusic "tenore" #1 \relative c' { \clef "violin_8" From 70022292d8bf3d695fe354d5a34f70b83f3ab159 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:51:23 +0100 Subject: [PATCH 29/36] gridly: Remove unnecessary test file It is no use exporting this to a separate file as the includes from all the different input files have been removed. --- ly/gridly/usage-examples/multi-file/global.ily | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 ly/gridly/usage-examples/multi-file/global.ily diff --git a/ly/gridly/usage-examples/multi-file/global.ily b/ly/gridly/usage-examples/multi-file/global.ily deleted file mode 100644 index 94e3e222..00000000 --- a/ly/gridly/usage-examples/multi-file/global.ily +++ /dev/null @@ -1,14 +0,0 @@ -\version "2.18.2" - -\include "openlilylib" -\loadModule "gridly" - -\gridInit #1 #'("marks" "soprano" "alto" "tenore" "basso") - -\gridSetSegmentTemplate #1 -\with { - lyrics = \lyricmode { Ooo } -} -\relative c { - s1 | -} From 533eacad2ca23b0c81c421f872b3d24a9328a2da Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:51:23 +0100 Subject: [PATCH 30/36] gridly: Update usage-examples to new syntax --- ly/gridly/usage-examples/example.ly | 2 +- ly/gridly/usage-examples/multi-file/main.ly | 24 +++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/ly/gridly/usage-examples/example.ly b/ly/gridly/usage-examples/example.ly index 95b757fd..661c978c 100644 --- a/ly/gridly/usage-examples/example.ly +++ b/ly/gridly/usage-examples/example.ly @@ -32,7 +32,7 @@ %%% First of all, you have to include the file that provides the %%% public interface \include "openlilylib" -\loadModule "gridly" +\useLibrary gridly %%% Grid initialization %%% ------------------- diff --git a/ly/gridly/usage-examples/multi-file/main.ly b/ly/gridly/usage-examples/multi-file/main.ly index a7e1b33e..071c94bf 100644 --- a/ly/gridly/usage-examples/multi-file/main.ly +++ b/ly/gridly/usage-examples/multi-file/main.ly @@ -1,7 +1,27 @@ \version "2.18.2" -\include "global.ily" -\loadModule "gridly/grid-templates.ily" +%\include "global.ily" + + +\include "openlilylib" +\useLibrary gridly + +\useModule gridly.grid-templates + +% Workaround for strange bug with \useModule, +% maybe due to the optional argument. +% (we need _something_ Scheme-ish before any LilyPond code) +#(display "") + +\gridInit #1 #'("marks" "soprano" "alto" "tenore" "basso") + +\gridSetSegmentTemplate #1 +\with { + lyrics = \lyricmode { Ooo } +} +\relative c { + s1 | +} \include "parts/soprano-I.ily" \include "parts/alto-I.ily" From 3378fdbf877b3303b1cc49e0abcdab626ff345ad Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:51:23 +0100 Subject: [PATCH 31/36] comptools: Update usage-examples to new syntax --- ly/comptools/usage-examples/conditional-breaks.ly | 10 +++++++--- ly/comptools/usage-examples/partial-compilation.ly | 11 ++++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/ly/comptools/usage-examples/conditional-breaks.ly b/ly/comptools/usage-examples/conditional-breaks.ly index 2acbc5c4..8559e79e 100644 --- a/ly/comptools/usage-examples/conditional-breaks.ly +++ b/ly/comptools/usage-examples/conditional-breaks.ly @@ -4,12 +4,16 @@ \include "openlilylib" -\setOption global.loglevel #oll-loglevel-log +%\setOption global.loglevel #oll-loglevel-log \useLibrary comptools %\loadModule "comptools/partial-compilation.ily" -\registerOption documentation.include-file "comptools/conditional-breaks.ily" -\loadModule "_internal/doc-include/usage-example.ily" +%\registerOption documentation.include-file "comptools/conditional-breaks.ily" +%\loadModule "_internal/doc-include/usage-example.ily" +\useModule comptools.conditional-breaks + +% Workaround for \useModule bug +#(display "") % Define a set with original breaks (barnumbers) % Entries can also be a list with barnumber and fraction diff --git a/ly/comptools/usage-examples/partial-compilation.ly b/ly/comptools/usage-examples/partial-compilation.ly index bde3532f..0255105b 100644 --- a/ly/comptools/usage-examples/partial-compilation.ly +++ b/ly/comptools/usage-examples/partial-compilation.ly @@ -3,11 +3,16 @@ \version "2.18.0" \include "openlilylib" -\setOption global.loglevel #oll-loglevel-log +%\setOption global.loglevel #oll-loglevel-log \useLibrary comptools -\registerOption documentation.include-file "comptools/partial-compilation.ily" -\loadModule "_internal/doc-include/usage-example.ily" +%\registerOption documentation.include-file "comptools/partial-compilation.ily" +%\loadModule "_internal/doc-include/usage-example.ily" + +\useModule comptools.partial-compilation + +% Workaround for \useModule bug +#(display "") \include "comptools-test-data.ily" From 2e9afcf57aae8781b69eab062194921d8d2135fa Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Thu, 19 Mar 2015 17:51:23 +0100 Subject: [PATCH 32/36] comptools: Update unit-tests to new syntax --- ly/comptools/unit-tests/partial-compilation-01.ly | 5 ++++- ly/comptools/unit-tests/partial-compilation-02.ly | 7 +++++-- ly/comptools/unit-tests/partial-compilation-03.ly | 5 ++++- ly/comptools/unit-tests/partial-compilation-04.ly | 5 ++++- ly/comptools/unit-tests/partial-compilation-05.ly | 5 ++++- ly/comptools/unit-tests/partial-compilation-06.ly | 5 ++++- ly/comptools/unit-tests/partial-compilation-07.ly | 5 ++++- 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ly/comptools/unit-tests/partial-compilation-01.ly b/ly/comptools/unit-tests/partial-compilation-01.ly index 06502333..63aea4a0 100644 --- a/ly/comptools/unit-tests/partial-compilation-01.ly +++ b/ly/comptools/unit-tests/partial-compilation-01.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" diff --git a/ly/comptools/unit-tests/partial-compilation-02.ly b/ly/comptools/unit-tests/partial-compilation-02.ly index 61606ed1..a40b49cc 100644 --- a/ly/comptools/unit-tests/partial-compilation-02.ly +++ b/ly/comptools/unit-tests/partial-compilation-02.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" @@ -15,7 +18,7 @@ %\setClipRegion 8 12 % Define a region beyond measure borders -\setClipRegion 198 #'(212 2/4) +\setClipRegion 15 #'(44 2/2) % Compile a single page %\setClipPage 5 diff --git a/ly/comptools/unit-tests/partial-compilation-03.ly b/ly/comptools/unit-tests/partial-compilation-03.ly index 0249108e..79c83f12 100644 --- a/ly/comptools/unit-tests/partial-compilation-03.ly +++ b/ly/comptools/unit-tests/partial-compilation-03.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" diff --git a/ly/comptools/unit-tests/partial-compilation-04.ly b/ly/comptools/unit-tests/partial-compilation-04.ly index 5fcbaeee..65ad4f82 100644 --- a/ly/comptools/unit-tests/partial-compilation-04.ly +++ b/ly/comptools/unit-tests/partial-compilation-04.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" diff --git a/ly/comptools/unit-tests/partial-compilation-05.ly b/ly/comptools/unit-tests/partial-compilation-05.ly index 1b371357..28504ecb 100644 --- a/ly/comptools/unit-tests/partial-compilation-05.ly +++ b/ly/comptools/unit-tests/partial-compilation-05.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" diff --git a/ly/comptools/unit-tests/partial-compilation-06.ly b/ly/comptools/unit-tests/partial-compilation-06.ly index e715f96a..e44153aa 100644 --- a/ly/comptools/unit-tests/partial-compilation-06.ly +++ b/ly/comptools/unit-tests/partial-compilation-06.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" diff --git a/ly/comptools/unit-tests/partial-compilation-07.ly b/ly/comptools/unit-tests/partial-compilation-07.ly index 91e2c8c6..18ff5e81 100644 --- a/ly/comptools/unit-tests/partial-compilation-07.ly +++ b/ly/comptools/unit-tests/partial-compilation-07.ly @@ -3,7 +3,10 @@ \version "2.18.0" \include "openlilylib" -\loadModule "comptools/partial-compilation.ily" +\useLibrary comptools +\useModule comptools.partial-compilation + +#(display "") \include "../usage-examples/comptools-test-data.ily" From 7ead7cb7c7f487e765d1a47b35bb9a10eda86acd Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Fri, 20 Mar 2015 18:37:45 +0100 Subject: [PATCH 33/36] Revert "gridly: Remove unnecessary test file" This reverts commit 70022292d8bf3d695fe354d5a34f70b83f3ab159. --- ly/gridly/usage-examples/multi-file/global.ily | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ly/gridly/usage-examples/multi-file/global.ily diff --git a/ly/gridly/usage-examples/multi-file/global.ily b/ly/gridly/usage-examples/multi-file/global.ily new file mode 100644 index 00000000..94e3e222 --- /dev/null +++ b/ly/gridly/usage-examples/multi-file/global.ily @@ -0,0 +1,14 @@ +\version "2.18.2" + +\include "openlilylib" +\loadModule "gridly" + +\gridInit #1 #'("marks" "soprano" "alto" "tenore" "basso") + +\gridSetSegmentTemplate #1 +\with { + lyrics = \lyricmode { Ooo } +} +\relative c { + s1 | +} From 897d4a283f93776c5ac1d00caa426499777b2869 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Fri, 20 Mar 2015 18:37:50 +0100 Subject: [PATCH 34/36] Revert "gridly: Remove redundant includes from examples" This reverts commit d20149eb1829d4a3283588a9f3b5b6bb4049d3d0. --- ly/gridly/usage-examples/multi-file/parts/alto-I.ily | 2 ++ ly/gridly/usage-examples/multi-file/parts/basso-I.ily | 2 ++ ly/gridly/usage-examples/multi-file/parts/soprano-I.ily | 2 ++ ly/gridly/usage-examples/multi-file/parts/tenore-I.ily | 2 ++ 4 files changed, 8 insertions(+) diff --git a/ly/gridly/usage-examples/multi-file/parts/alto-I.ily b/ly/gridly/usage-examples/multi-file/parts/alto-I.ily index 3a8402d0..9a38cc76 100644 --- a/ly/gridly/usage-examples/multi-file/parts/alto-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/alto-I.ily @@ -1,5 +1,7 @@ \version "2.18.2" +\include "../global.ily" + \gridPutMusic "alto" #1 \relative c' { e1 | diff --git a/ly/gridly/usage-examples/multi-file/parts/basso-I.ily b/ly/gridly/usage-examples/multi-file/parts/basso-I.ily index 3e9e1bb3..db898f15 100644 --- a/ly/gridly/usage-examples/multi-file/parts/basso-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/basso-I.ily @@ -1,5 +1,7 @@ \version "2.18.2" +\include "../global.ily" + \gridPutMusic "basso" #1 \relative c { \clef "bass" diff --git a/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily b/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily index 98297808..41735e56 100644 --- a/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/soprano-I.ily @@ -1,5 +1,7 @@ \version "2.18.2" +\include "../global.ily" + \gridPutMusic "soprano" #1 \relative c'' { g1 | diff --git a/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily b/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily index 074a304e..7955dbdf 100644 --- a/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily +++ b/ly/gridly/usage-examples/multi-file/parts/tenore-I.ily @@ -1,5 +1,7 @@ \version "2.18.2" +\include "../global.ily" + \gridPutMusic "tenore" #1 \relative c' { \clef "violin_8" From 377d6ac8e2a5ccbba99814fe90ca2494694d3b95 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Fri, 20 Mar 2015 18:39:21 +0100 Subject: [PATCH 35/36] gridly: But update syntax then Now that the two previous commits are reverted ones the syntax update has to be done. --- ly/gridly/usage-examples/multi-file/global.ily | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ly/gridly/usage-examples/multi-file/global.ily b/ly/gridly/usage-examples/multi-file/global.ily index 94e3e222..3cd78cc3 100644 --- a/ly/gridly/usage-examples/multi-file/global.ily +++ b/ly/gridly/usage-examples/multi-file/global.ily @@ -1,7 +1,7 @@ \version "2.18.2" \include "openlilylib" -\loadModule "gridly" +\useLibrary gridly \gridInit #1 #'("marks" "soprano" "alto" "tenore" "basso") From 95dfea4f24c37c07fd7b6a5bb072ffeafdf37955 Mon Sep 17 00:00:00 2001 From: Urs Liska Date: Tue, 24 Mar 2015 11:04:00 +0100 Subject: [PATCH 36/36] oll: rename dot-path->string to symbol-list->dot-path This is more general and better reflects what is actually done. --- ly/_internal/options.ily | 2 +- ly/_internal/utilities/alist-access.ily | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ly/_internal/options.ily b/ly/_internal/options.ily index d52f0a9d..ab6b6a55 100644 --- a/ly/_internal/options.ily +++ b/ly/_internal/options.ily @@ -82,7 +82,7 @@ setOption = #{ \setatree openlilylib-options #opt-path #val #} (oll:log location "Option set: ~a" (format "~a: ~a" - (dot-path->string opt-path) val))) + (symbol-list->dot-path opt-path) val))) ;; reject setting unknown options and report that (oll:warn location "Not a valid option path: ~a" (dot-path->string opt-path)))) diff --git a/ly/_internal/utilities/alist-access.ily b/ly/_internal/utilities/alist-access.ily index 8903e992..beb68440 100644 --- a/ly/_internal/utilities/alist-access.ily +++ b/ly/_internal/utilities/alist-access.ily @@ -44,7 +44,7 @@ % Convert a list to a dot-path notation string. % Can be used to print/log tree paths -#(define (dot-path->string path) +#(define (symbol-list->dot-path path) "output option path list as a dot-delimited string" (string-join (map