diff --git a/content/io.js b/content/io.js index d1a8630a..a5d7a0df 100644 --- a/content/io.js +++ b/content/io.js @@ -268,41 +268,7 @@ function IO() //{{{ commands.add(["runt[ime]"], "Source the specified file from each directory in 'runtimepath'", - function (args, special) - { - // TODO: support backslash escaped whitespace in filenames - // : wildcards/regexp - // : unify with startup sourcing loop - let paths = args.arguments; - let runtimeDirs = options["runtimepath"].split(","); - let found = false; - - // FIXME: should use original arg string - liberator.echomsg("Searching for \"" + paths.join(" ") + "\" in \"" + options["runtimepath"] + "\"", 2); - - outer: - for (let [,runtimeDir] in Iterator(runtimeDirs)) - { - for (let [,path] in Iterator(paths)) - { - let file = io.getFile(joinPaths(runtimeDir, path)); - - liberator.echomsg("Searching for \"" + file.path + "\" in \"", 3); - - if (file.exists() && file.isReadable() && !file.isDirectory()) // XXX - { - found = true; - io.source(file.path, false); - - if (!special) - break outer; - } - } - } - - if (!found) - liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string - }, + function (args, special) { io.sourceFromRuntimePath(args.arguments, special); }, { argCount: "+", bang: true @@ -746,6 +712,41 @@ lookup: return output; }, + // FIXME: multiple paths? + sourceFromRuntimePath: function (paths, all) + { + let runtimeDirs = options["runtimepath"].split(","); + let found = false; + + // FIXME: should use original arg string + liberator.echomsg("Searching for \"" + paths.join(" ") + "\" in \"" + options["runtimepath"] + "\"", 2); + + outer: + for (let [,runtimeDir] in Iterator(runtimeDirs)) + { + for (let [,path] in Iterator(paths)) + { + let file = io.getFile(joinPaths(runtimeDir, path)); + + liberator.echomsg("Searching for \"" + file.path, 3); + + if (file.exists() && file.isReadable() && !file.isDirectory()) // XXX + { + found = true; + io.source(file.path, false); + + if (!all) + break outer; + } + } + } + + if (!found) + liberator.echomsg("not found in 'runtimepath': \"" + paths.join(" ") + "\"", 1); // FIXME: should use original arg string + + return found; + }, + // files which end in .js are sourced as pure javascript files, // no need (actually forbidden) to add: js <