-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support require
ing modules located within the script folder
#37
base: master
Are you sure you want to change the base?
Conversation
…pport the use of "require" for scripts in the script folder.
Enable scripts_<etc> = "filename.lua" Reduces the noise around script definitions, helps with supporting the disablement of "greedy loading" of "open" scripts.
…ipts_window_open' 'scripts_window_open' being defined disables "greedy loading" to enable 'require' in user scripts. Defined is: * A table with filename entries (as other script defs). * An empty table definition. * A single string, empty or not.
...and the call to g_build_path, since the same stuff was being done in a few places. Also followed clangs advice and added some const to args.
Re-arrange slightly and modify to explain: * Changes to support single file definition * scripts_window_open addition and significance * Explain "require"ing modules re: the previous/default behaviour.
...and more consistent/predictable for other files and the config. The Lua VM is re-loaded if a module or any other file has changed, or if the config does, as any changes can render any global variables or state invalid.
Safe to just wait for the next edit and change event to load a valid config
src/config.c
Outdated
script_folder, | ||
current_file, | ||
NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent with tabs, align with spaces; and if your text editor ever replaces the spaces with tabs, it's broken because doing so will break the alignment for others who use a different tab width.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 571795e
src/config.c
Outdated
script_folder, | ||
oneFileString, | ||
NULL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 tabs to indent then 36 spaces (not 9 tabs == 72 spaces) to align.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was fixed/changed in a later commit, which was part of the original push: 2e711f8#diff-18680f57f5d32607a3b196afffe0d6ecb250af6c0a994b304b88fc91231250bfR135
Remove unneeded indentaion left over from placement in inner loop, fix formatting of assignment.
What was intended to be a fairly small PR, to include the script folder in Lua's package search path, ended up getting a little more involved:
This PR resolves this by:
scripts_window_open
variable.scripts...
variables to be assigned a single string, referencing a single file.In support of the above changes I also:
add_lua_file_to_list
to accept the script folder path and include the call tog_build_path
since the same thing was being done in a few places.refresh_config_and_script
).load_config
.Why not other implementations?
scripts_window_open
, anyway, and have 2 things to add to config when 1 would do the same job.script_...
tables. Would also require more processing to end up with, basically, the same "window open" list anyway. Also begs a question of would it only apply to the "open" list, or all?@dsalt This is one of a total of 5 PRs so I'm sorry for the github spam!
If you decide to accept them and would rather I group them into 1 larger PR, just let me know.
Thanks!