Skip to content
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

Be explicit about ordering when autoloading #3021

Closed
wants to merge 2 commits into from
Closed

Be explicit about ordering when autoloading #3021

wants to merge 2 commits into from

Conversation

winged
Copy link

@winged winged commented Jul 15, 2019

Some autoloads may depend on another. Right now, the autoload ordering depends on the filesystem, so the ordering may change depending on what happens on the file system (find does not list the files in any given order).

This sorts the files before sourceing them, thus making the ordering explicit.

winged and others added 2 commits July 15, 2019 16:45
Some autoloads may depend on another. Right now, the autoload ordering
depends on the filesystem, so the ordering may change depending on what
happens on the file system (`find` does not list the files in any given
order).

This sorts the files before `source`ing them, thus making the ordering
explicit.
I dedicate any and all copyright interest in this software to the
public domain.  I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors.  I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
@Screwtapello
Copy link
Contributor

If Kakoune didn't have any way to declare that one module depends on another, this would be a good way to make autoloads more consistent and reliable.

As it is, though, we have the provide-module and require-module commands so modules can guarantee they load in the correct order, and the ModuleLoaded hook so modules can be loaded as lazily as possible. Kakoune will be faster the more people use those features; if shuf were a standard POSIX command, I'd propose we shuffle the output of find so we could find implicit dependencies more quickly and convert them to explicit dependencies.

@winged
Copy link
Author

winged commented Jul 16, 2019

Fair enough, I even kind of like the explicit shuffling idea :)

I was using the autoload folder to load my configs, and as such was depending on a certain order to get things right (They're not modules, so the provide/require-module mechanism can't be used).

After your comment I've now changed my config to a custom loader that /does/ the ordering withing my .config/kak, so I guess this can be dropped (unless someone steps in and wants to merge despite your objections :) )

@andreyorst
Copy link
Contributor

simple sorting makes little sense anyway. Breadth-first sorting would be more appropriate way. But unfortunately there's no builtin way to do such sorting with find. I wrote this piece of code to do this kind of sorting when sourcing plugins before require-module was introduced: https://github.com/andreyorst/plug.kak/blob/e7582a5a9c39b8b7f9d699400492889a39e1b6be/rc/plug.kak#L214-L218

@mawww
Copy link
Owner

mawww commented Jul 21, 2019

Yes, we should try to make module dependencies explicit rather than trying to enforce a sourcing order.

@mawww mawww closed this Jul 21, 2019
@winged winged deleted the patch-1 branch August 6, 2019 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants