* found it is sourced. Only the first file found (per specified path) is
* sourced unless *all* is specified, then all found files are sourced.
*
- * @param {string[]} paths An array of relative paths to source.
+ * @param {[string]} paths An array of relative paths to source.
* @param {boolean} all Whether all found files should be sourced.
*/
sourceFromRuntimePath: function sourceFromRuntimePath(paths, all) {
outer:
for (let dir in values(dirs)) {
- for (let [,path] in Iterator(paths)) {
+ for (let [, path] in Iterator(paths)) {
let file = dir.child(path);
dactyl.echomsg(_("io.searchingFor", file.path.quote()), 3);
this._scriptNames.push(file.path);
dactyl.echomsg(_("io.sourcingEnd", filename.quote()), 2);
+ dactyl.log(_("dactyl.sourced", filename), 3);
- dactyl.log("Sourced: " + filename, 3);
return context;
}
catch (e) {
dactyl.reportError(e);
- let message = "Sourcing file: " + (e.echoerr || file.path + ": " + e);
+ let message = _("io.sourcingError", e.echoerr || (file ? file.path : filename) + ": " + e);
if (!params.silent)
dactyl.echoerr(message);
}
defineModule.loadLog.push("done sourcing " + filename + ": " + (Date.now() - time) + "ms");
}
}, this);
- },
+ }
}),
// TODO: there seems to be no way, short of a new component, to change
*/
listJar: function listJar(file, path) {
file = util.getFile(file);
- if (file) {
+ if (file && file.exists() && file.isFile() && file.isReadable()) {
// let jar = services.zipReader.getZip(file); Crashes.
let jar = services.ZipReader(file);
try {
yield entry;
}
finally {
- jar.close();
+ if (jar)
+ jar.close();
}
}
},
* Runs an external program.
*
* @param {File|string} program The program to run.
- * @param {string[]} args An array of arguments to pass to *program*.
+ * @param {[string]} args An array of arguments to pass to *program*.
*/
run: function (program, args, blocking) {
args = args || [];
// go directly to an absolute path or look for a relative path
// match in 'cdpath'
- // TODO: handle ../ and ./ paths
if (File.isAbsolutePath(arg)) {
io.cwd = arg;
dactyl.echomsg(io.cwd.path);
dactyl.assert(!file.exists() || args.bang, _("io.exists", file.path.quote()));
// TODO: Use a set/specifiable list here:
- let lines = [cmd.serialize().map(commands.commandToString, cmd) for (cmd in commands.iterator(true)) if (cmd.serialize)];
+ let lines = [cmd.serialize().map(commands.commandToString, cmd) for (cmd in commands.iterator()) if (cmd.serialize)];
lines = array.flatten(lines);
lines.unshift('"' + config.version + "\n");
file.write(lines.join("\n"));
}
catch (e) {
- dactyl.echoerr(_("io.notWriteable"), file.path.quote());
- dactyl.log("Could not write to " + file.path + ": " + e.message); // XXX
+ dactyl.echoerr(_("io.notWriteable", file.path.quote()));
+ dactyl.log(_("error.notWriteable", file.path, e.message)); // XXX
}
}, {
argCount: "*", // FIXME: should be "?" but kludged for proper error message
if (file.exists() && file.isDirectory() || args[0] && /\/$/.test(args[0]))
file.append(config.name + ".vim");
- dactyl.assert(!file.exists() || args.bang, "File exists");
+ dactyl.assert(!file.exists() || args.bang, _("io.exists"));
let template = util.compileMacro(<![CDATA[
" Vim syntax file
syn match <name>Notation "<[0-9A-Za-z-]\+>"
-syn match <name>Comment +".*$+ contains=<name>Todo,@Spell
syn keyword <name>Todo FIXME NOTE TODO XXX contained
syn region <name>String start="\z(["']\)" end="\z1" skip="\\\\\|\\\z1" oneline
-syn match <name>LineComment +^\s*".*$+ contains=<name>Todo,@Spell
+syn match <name>Comment +^\s*".*$+ contains=<name>Todo,@Spell
" NOTE: match vim.vim highlighting group names
hi def link <name>AutoCmd <name>Command
hi def link <name>AutoEvent Type
hi def link <name>Command Statement
-hi def link <name>Comment Comment
hi def link <name>JavaScriptDelimiter Delimiter
hi def link <name>CssDelimiter Delimiter
hi def link <name>Notation Special
-hi def link <name>LineComment Comment
+hi def link <name>Comment Comment
hi def link <name>Option PreProc
hi def link <name>SetMod <name>Option
hi def link <name>String String
commands.add(["scrip[tnames]"],
"List all sourced script names",
function () {
- modules.commandline.commandOutput(
- template.tabular(["<SNR>", "Filename"], ["text-align: right; padding-right: 1em;"],
- ([i + 1, file] for ([i, file] in Iterator(io._scriptNames))))); // TODO: add colon and remove column titles for pedantic Vim compatibility?
+ if (!io._scriptNames.length)
+ dactyl.echomsg(_("command.scriptnames.none"));
+ else
+ modules.commandline.commandOutput(
+ template.tabular(["<SNR>", "Filename"], ["text-align: right; padding-right: 1em;"],
+ ([i + 1, file] for ([i, file] in Iterator(io._scriptNames)))));
+
},
{ argCount: "0" });
commands.add(["so[urce]"],
- "Read Ex commands from a file",
+ "Read Ex commands, JavaScript or CSS from a file",
function (args) {
if (args.length > 1)
dactyl.echoerr(_("io.oneFileAllowed"));
if (modules.options["banghist"]) {
// replaceable bang and no previous command?
dactyl.assert(!/((^|[^\\])(\\\\)*)!/.test(arg) || io._lastRunCommand,
- "E34: No previous command");
+ _("command.run.noPrevious"));
arg = arg.replace(/(\\)*!/g,
function (m) /^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!") : m.replace("!", io._lastRunCommand)
let result = io.system(arg);
if (result.returnValue != 0)
- result.output += "\nshell returned " + result.returnValue;
+ result.output += "\n" + _("io.shellReturn", result.returnValue);
- modules.commandline.command = "!" + arg;
+ modules.commandline.command = args.commandName.replace("run", "$& ") + arg;
modules.commandline.commandOutput(<span highlight="CmdOutput">{result.output}</span>);
modules.autocommands.trigger("ShellCmdPost", {});
}, {
- argCount: "?", // TODO: "1" - probably not worth supporting weird Vim edge cases. The dream is dead. --djk
+ argCount: "?",
bang: true,
// This is abominably slow.
// completer: function (context) completion.shellCommand(context),
};
completion.file = function file(context, full, dir) {
+ if (/^jar:[^!]*$/.test(context.filter))
+ context.advance(4);
+
// dir == "" is expanded inside readDirectory to the current dir
function getDir(str) str.match(/^(?:.*[\/\\])?/)[0];
dir = getDir(dir || context.filter);
};
context.compare = function (a, b) b.isdir - a.isdir || String.localeCompare(a.text, b.text);
- if (modules.options["wildignore"]) {
- let wig = modules.options.get("wildignore");
- context.filters.push(function (item) item.isdir || !wig.getKey(this.name));
- }
+ if (modules.options["wildignore"])
+ context.filters.push(function (item) !modules.options.get("wildignore").getKey(item.path));
// context.background = true;
context.key = dir;
context.key = match.prefix;
context.advance(match.prefix.length + 1);
context.generate = function () iter({
- content: "Chrome content",
- locale: "Locale-specific content",
- skin: "Theme-specific content"
+ content: /*L*/"Chrome content",
+ locale: /*L*/"Locale-specific content",
+ skin: /*L*/"Theme-specific content"
});
}
}
if (!match || match.scheme === "resource" && match.path)
- if (/^(\.{0,2}|~)\/|^file:/.test(context.filter) || util.getFile(context.filter) || io.isJarURL(context.filter))
+ if (/^(\.{0,2}|~)\/|^file:/.test(context.filter)
+ || util.OS.isWindows && /^[a-z]:/i.test(context.filter)
+ || util.getFile(context.filter)
+ || io.isJarURL(context.filter))
completion.file(context, full);
});
},
options["shellcmdflag"];
options.add(["wildignore", "wig"],
- "List of file patterns to ignore when completing file names",
+ "List of path name patterns to ignore when completing files and directories",
"regexplist", "");
}
});