1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:38:00 +01:00

Search recursively for plugins in liberator.loadPlugins.

This commit is contained in:
Doug Kearns
2008-12-30 19:04:54 +11:00
parent a1dcfa4e02
commit 2828b47b65
3 changed files with 37 additions and 33 deletions

View File

@@ -588,7 +588,6 @@ function Events() //{{{
// load all macros inside ~/.vimperator/macros/
// setTimeout needed since io. is loaded after events.
setTimeout (function () {
// FIXME: largely duplicated for loading plugins
try
{
let dirs = io.getRuntimeDirectories("macros");

View File

@@ -988,27 +988,17 @@ const liberator = (function () //{{{
loadPlugins: function ()
{
// FIXME: largely duplicated for loading macros
try
function sourceDirectory(dir)
{
let dirs = io.getRuntimeDirectories("plugin");
if (dirs.length == 0)
if (!dir.isReadable())
{
liberator.log("No user plugin directory found", 3);
liberator.echoerr("E484: Can't open file " + dir.path);
return;
}
for (let [,dir] in Iterator(dirs))
{
// TODO: search plugins/**/* for plugins
liberator.echomsg('Searching for "plugin/*.{js,vimp}" in ' + dir.path.quote(), 2);
liberator.log("Sourcing plugin directory: " + dir.path + "...", 3);
let files = io.readDirectory(dir.path, true);
files.forEach(function (file) {
if (!file.isDirectory() && /\.(js|vimp)$/i.test(file.path) && !(file.path in liberator.pluginFiles))
io.readDirectory(dir.path, true).forEach(function (file) {
if (file.isFile() && /\.(js|vimp)$/i.test(file.path) && !(file.path in liberator.pluginFiles))
{
try
{
@@ -1020,14 +1010,28 @@ const liberator = (function () //{{{
liberator.reportError(e);
}
}
else if (file.isDirectory())
{
sourceDirectory(file);
}
});
}
}
catch (e)
let dirs = io.getRuntimeDirectories("plugin");
if (dirs.length == 0)
{
// thrown if directory does not exist
liberator.log("Error sourcing plugin directory: " + e, 9);
liberator.log("No user plugin directory found", 3);
return;
}
liberator.echomsg('Searching for "plugin/**/*.{js,vimp}" in '
+ [dir.path.replace(/.plugin$/, "") for each (dir in dirs)].join(",").quote(), 2);
dirs.forEach(function (dir) {
liberator.echomsg("Searching for " + (dir.path + "/**/*.{js,vimp}").quote(), 3);
sourceDirectory(dir);
});
},
// logs a message to the javascript error console

View File

@@ -21,8 +21,9 @@ If 'exrc' is set then any RC file in the current directory is also sourced.
The plugin directory can be in any of the directories in 'runtimepath'.
All directories in 'runtimepath' are searched for plugins and they are are all
loaded.
All directories in 'runtimepath' are searched for a "plugin" subdirectory and
all are loaded. For each plugin directory all *.\{js,vimp} files (including
those in further subdirectories) are sourced alphabetically.
Plugins will not be sourced if 'noloadplugins' is set.