You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
loadModule first tries to load a module and then applies the options to it.
In some cases it may be preferrable to have the options already set when loading the module. For example: scholarly.annotate consist/s the engraver to all bottom contexts upon loading. It would be good to have an option that chooses which contexts to use or avoid. But this works only when the options have already been set.
Idea (implementation is clear, but I'm not 100% sure if it's good design):
Look for a config.ily file in the module directory. if that is present:
load the config
set options if given in the \with {} block
Load the module
if no config was present set the options now
Possible problems:
feels somewhat fragile and hard-to-document-clearly
Prohibits any code in config.ily to depend on the module itself.
Slightly less invasive:
check if a pre-config.ily file is present.
set all options before loading the module that are already present in the module's option leaf.
Problem: maybe even more unclear?
The text was updated successfully, but these errors were encountered:
Reported by a user (this is related and shows that the problem is the same on package level):
I'm currently having an apparently simple problem dealing with options.
The option I set on the loadPackage or loadModule "\with" does not take
precedence over the value used in register the options.
Eg:
%%% file: local/package.ily\include"oll-core/package.ily"\registerOption local.option "A"#(display (getOption '(local option)))
%%% end%%% file: whatever/project.ly\include"oll-core/package.ily"\loadPackage\with {
option ="B"
} local
%%% end
-- Outputs: "A"
I've came up with a workaround, but then I tought that is most likely I just
don't know how to proper handle it. "\registerDefaultOpt" is a simple
function that only register the value if the option is unregistered.
%%% file: local/package.ily\include"oll-core/package.ily"\registerDefaultOpt local.option "A"#(display (getOption '(local option)))
%%% end%%% file: whatever/project.ly\include"oll-core/package.ily"\registerOption local.option "B"\loadPackage local
%%% end
-- Outputs: "B"
I think the following alternative approach is cleaner. (\loadModule should be considered synonymous to \loadPackage here):
\loadModule stores any given options in a global place like \setOption options.current-module-loading ...
A function, say \applyModuleOptions, is added that reads these global "current" options and sets them
This makes it possible for a module to first register its options with default values and then (if the specific module wants to do so) take the options given by the user to override the defaults. These user-provided values are then available during the loading of the module/package.
loadModule
first tries to load a module and then applies the options to it.In some cases it may be preferrable to have the options already set when loading the module. For example:
scholarly.annotate
consist/s the engraver to all bottom contexts upon loading. It would be good to have an option that chooses which contexts to use or avoid. But this works only when the options have already been set.Idea (implementation is clear, but I'm not 100% sure if it's good design):
config.ily
file in the module directory. if that is present:Possible problems:
Slightly less invasive:
pre-config.ily
file is present.Problem: maybe even more unclear?
The text was updated successfully, but these errors were encountered: