mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-28 18:42:28 +01:00
Replace expression closures (command/option/mapping definitions).
Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
@@ -365,15 +365,16 @@ var Addons = Module("addons", {
|
||||
|
||||
if (modules.commandline.savingOutput)
|
||||
util.waitFor(() => addons.ready);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
options: [
|
||||
{
|
||||
names: ["-types", "-type", "-t"],
|
||||
description: "The add-on types to list",
|
||||
default: ["extension"],
|
||||
completer: function (context) completion.addonType(context),
|
||||
completer: function (context) {
|
||||
completion.addonType(context);
|
||||
},
|
||||
type: CommandOption.LIST
|
||||
}
|
||||
]
|
||||
@@ -450,7 +451,9 @@ var Addons = Module("addons", {
|
||||
names: ["-types", "-type", "-t"],
|
||||
description: "The add-on types to operate on",
|
||||
default: ["extension"],
|
||||
completer: function (context) completion.addonType(context),
|
||||
completer: function (context) {
|
||||
completion.addonType(context);
|
||||
},
|
||||
type: CommandOption.LIST
|
||||
}
|
||||
]
|
||||
|
||||
@@ -815,7 +815,9 @@ var Buffer = Module("Buffer", {
|
||||
self.saveURI({ uri: uri, file: file, context: elem });
|
||||
},
|
||||
|
||||
completer: function (context) completion.savePage(context, elem)
|
||||
completer: function (context) {
|
||||
completion.savePage(context, elem);
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
catch (e) {
|
||||
@@ -1891,8 +1893,7 @@ var Buffer = Module("Buffer", {
|
||||
.getInterface(Ci.nsIWebBrowserPrint).print(settings, null);
|
||||
|
||||
dactyl.echomsg(_("print.sent"));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
@@ -1911,8 +1912,7 @@ var Buffer = Module("Buffer", {
|
||||
dactyl.assert(!arg || opt.validator(opt.parse(arg)),
|
||||
_("error.invalidArgument", arg));
|
||||
buffer.showPageInfo(true, arg);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
completer: function (context) {
|
||||
modules.completion.optionValue(context, "pageinfo", "+", "");
|
||||
@@ -1934,10 +1934,11 @@ var Buffer = Module("Buffer", {
|
||||
options["usermode"] = false;
|
||||
|
||||
window.stylesheetSwitchAll(buffer.focusedFrame, arg);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
completer: function (context) modules.completion.alternateStyleSheet(context),
|
||||
completer: function (context) {
|
||||
modules.completion.alternateStyleSheet(context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -2016,8 +2017,7 @@ var Buffer = Module("Buffer", {
|
||||
doc.contentType, false, null, chosenData,
|
||||
doc.referrer ? window.makeURI(doc.referrer) : null,
|
||||
doc, true);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) {
|
||||
@@ -2041,11 +2041,14 @@ var Buffer = Module("Buffer", {
|
||||
|
||||
commands.add(["vie[wsource]"],
|
||||
"View source code of current document",
|
||||
function (args) { buffer.viewSource(args[0], args.bang); },
|
||||
{
|
||||
function (args) {
|
||||
buffer.viewSource(args[0], args.bang);
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) modules.completion.url(context, "bhf")
|
||||
completer: function (context) {
|
||||
modules.completion.url(context, "bhf");
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["zo[om]"],
|
||||
@@ -2475,7 +2478,9 @@ var Buffer = Module("Buffer", {
|
||||
"string", "UTF-8",
|
||||
{
|
||||
scope: Option.SCOPE_LOCAL,
|
||||
getter: function () buffer.docShell.QueryInterface(Ci.nsIDocCharset).charset,
|
||||
getter: function () {
|
||||
return buffer.docShell.QueryInterface(Ci.nsIDocCharset).charset;
|
||||
},
|
||||
setter: function (val) {
|
||||
if (options["encoding"] == val)
|
||||
return val;
|
||||
@@ -2491,7 +2496,9 @@ var Buffer = Module("Buffer", {
|
||||
});
|
||||
return null;
|
||||
},
|
||||
completer: function (context) completion.charset(context)
|
||||
completer: function (context) {
|
||||
completion.charset(context);
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["iskeyword", "isk"],
|
||||
@@ -2502,7 +2509,7 @@ var Buffer = Module("Buffer", {
|
||||
this.regexp = util.regexp(value);
|
||||
return value;
|
||||
},
|
||||
validator: function (value) RegExp(value)
|
||||
validator: function (value) { return RegExp(value); }
|
||||
});
|
||||
|
||||
options.add(["jumptags", "jt"],
|
||||
@@ -2518,8 +2525,10 @@ var Buffer = Module("Buffer", {
|
||||
vals[k] = update(new String(v), { matcher: DOM.compileMatcher(Option.splitList(v)) });
|
||||
return vals;
|
||||
},
|
||||
validator: function (value) DOM.validateMatcher.call(this, value)
|
||||
&& Object.keys(value).every(v => v.length == 1)
|
||||
validator: function (value) {
|
||||
return DOM.validateMatcher.call(this, value) &&
|
||||
Object.keys(value).every(v => v.length == 1);
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["linenumbers", "ln"],
|
||||
@@ -2591,7 +2600,7 @@ var Buffer = Module("Buffer", {
|
||||
options.add(["scroll", "scr"],
|
||||
"Number of lines to scroll with <C-u> and <C-d> commands",
|
||||
"number", 0,
|
||||
{ validator: function (value) value >= 0 });
|
||||
{ validator: function (value) { return value >= 0; } });
|
||||
|
||||
options.add(["showstatuslinks", "ssli"],
|
||||
"Where to show the destination of the link under the cursor",
|
||||
@@ -2616,7 +2625,9 @@ var Buffer = Module("Buffer", {
|
||||
|
||||
initValue: function () {},
|
||||
|
||||
getter: function getter(value) !prefs.get(this.PREF) ? 1 : value,
|
||||
getter: function getter(value) {
|
||||
return !prefs.get(this.PREF) ? 1 : value;
|
||||
},
|
||||
|
||||
setter: function setter(value) {
|
||||
prefs.set(this.PREF, value > 1);
|
||||
@@ -2624,15 +2635,19 @@ var Buffer = Module("Buffer", {
|
||||
return value;
|
||||
},
|
||||
|
||||
validator: function (value) value > 0
|
||||
validator: function (value) { return value > 0; }
|
||||
});
|
||||
|
||||
options.add(["usermode", "um"],
|
||||
"Show current website without styling defined by the author",
|
||||
"boolean", false,
|
||||
{
|
||||
setter: function (value) buffer.contentViewer.authorStyleDisabled = value,
|
||||
getter: function () buffer.contentViewer.authorStyleDisabled
|
||||
setter: function (value) {
|
||||
return buffer.contentViewer.authorStyleDisabled = value;
|
||||
},
|
||||
getter: function () {
|
||||
return buffer.contentViewer.authorStyleDisabled;
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["yankshort", "ys"],
|
||||
|
||||
@@ -1676,9 +1676,13 @@ var Commands = Module("commands", {
|
||||
// TODO: "E180: invalid complete value: " + arg
|
||||
names: ["-complete", "-C"],
|
||||
description: "The argument completion function",
|
||||
completer: function (context) [[k, ""] for ([k, v] of iter(config.completers))],
|
||||
completer: function (context) {
|
||||
return [[k, ""] for ([k, v] of iter(config.completers))];
|
||||
},
|
||||
type: CommandOption.STRING,
|
||||
validator: function (arg) arg in config.completers || /^custom,/.test(arg)
|
||||
validator: function (arg) {
|
||||
return arg in config.completers || /^custom,/.test(arg);
|
||||
}
|
||||
},
|
||||
{
|
||||
names: ["-description", "-desc", "-d"],
|
||||
@@ -1715,28 +1719,30 @@ var Commands = Module("commands", {
|
||||
],
|
||||
literal: 1,
|
||||
|
||||
serialize: function () Ary(commands.userHives)
|
||||
.filter(h => h.persist)
|
||||
.map(hive => [
|
||||
{
|
||||
command: this.name,
|
||||
bang: true,
|
||||
options: iter([v, typeof cmd[k] == "boolean" ? null : cmd[k]]
|
||||
// FIXME: this map is expressed multiple times
|
||||
for ([k, v] of iter({
|
||||
argCount: "-nargs",
|
||||
bang: "-bang",
|
||||
count: "-count",
|
||||
description: "-description"
|
||||
}))
|
||||
if (cmd[k])).toObject(),
|
||||
arguments: [cmd.name],
|
||||
literalArg: cmd.action,
|
||||
ignoreDefaults: true
|
||||
}
|
||||
for (cmd of hive) if (cmd.persist)
|
||||
])
|
||||
.flatten().array
|
||||
serialize: function () {
|
||||
return Ary(commands.userHives)
|
||||
.filter(h => h.persist)
|
||||
.map(hive => [
|
||||
{
|
||||
command: this.name,
|
||||
bang: true,
|
||||
options: iter([v, typeof cmd[k] == "boolean" ? null : cmd[k]]
|
||||
// FIXME: this map is expressed multiple times
|
||||
for ([k, v] of iter({
|
||||
argCount: "-nargs",
|
||||
bang: "-bang",
|
||||
count: "-count",
|
||||
description: "-description"
|
||||
}))
|
||||
if (cmd[k])).toObject(),
|
||||
arguments: [cmd.name],
|
||||
literalArg: cmd.action,
|
||||
ignoreDefaults: true
|
||||
}
|
||||
for (cmd of hive) if (cmd.persist)
|
||||
])
|
||||
.flatten().array;
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["delc[ommand]"],
|
||||
@@ -1754,16 +1760,21 @@ var Commands = Module("commands", {
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context, args) modules.completion.userCommand(context, args["-group"]),
|
||||
completer: function (context, args) {
|
||||
modules.completion.userCommand(context, args["-group"]);
|
||||
},
|
||||
options: [contexts.GroupFlag("commands")]
|
||||
});
|
||||
|
||||
commands.add(["comp[letions]"],
|
||||
"List the completion results for a given command substring",
|
||||
function (args) { modules.completion.listCompleter("ex", args[0]); },
|
||||
{
|
||||
function (args) {
|
||||
modules.completion.listCompleter("ex", args[0]);
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context, args) modules.completion.ex(context),
|
||||
completer: function (context) {
|
||||
modules.completion.ex(context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -1801,10 +1812,11 @@ var Commands = Module("commands", {
|
||||
|
||||
let lines = res.split("\n").length;
|
||||
dactyl.echomsg(_("command.yank.yankedLine" + (lines == 1 ? "" : "s"), lines));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) modules.completion[/^:/.test(context.filter) ? "ex" : "javascript"](context),
|
||||
completer: function (context) {
|
||||
modules.completion[/^:/.test(context.filter) ? "ex" : "javascript"](context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
},
|
||||
|
||||
@@ -1224,8 +1224,7 @@ var Completion = Module("completion", {
|
||||
function m(item) {
|
||||
return template.completionRow(item, "CompItem");
|
||||
})]);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "*",
|
||||
completer: function (context) {
|
||||
let PREFIX = "/ex/contexts";
|
||||
@@ -1303,7 +1302,9 @@ var Completion = Module("completion", {
|
||||
return values;
|
||||
},
|
||||
|
||||
validator: function validator(values) validator.supercall(this, this.setter(values))
|
||||
validator: function validator(values) {
|
||||
return validator.supercall(this, this.setter(values));
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["wildanchor", "wia"],
|
||||
|
||||
@@ -152,7 +152,9 @@ var Contexts = Module("contexts", {
|
||||
contexts.user)[this.name];
|
||||
},
|
||||
|
||||
completer: function (context) modules.completion.group(context)
|
||||
completer: function (context) {
|
||||
modules.completion.group(context);
|
||||
}
|
||||
});
|
||||
|
||||
memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, false]));
|
||||
@@ -685,8 +687,7 @@ var Contexts = Module("contexts", {
|
||||
!["-description", "-locations", "-nopersist"]
|
||||
.some(hasOwnProperty.bind(null, args.explicitOpts)),
|
||||
_("group.cantModifyBuiltin"));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
@@ -718,24 +719,26 @@ var Contexts = Module("contexts", {
|
||||
}
|
||||
],
|
||||
serialGroup: 20,
|
||||
serialize: function () [
|
||||
{
|
||||
command: this.name,
|
||||
bang: true,
|
||||
options: iter([v, typeof group[k] == "boolean" ? null : group[k]]
|
||||
// FIXME: this map is expressed multiple times
|
||||
for ([k, v] of iter({
|
||||
args: "-args",
|
||||
description: "-description",
|
||||
filter: "-locations"
|
||||
}))
|
||||
if (group[k])).toObject(),
|
||||
arguments: [group.name],
|
||||
ignoreDefaults: true
|
||||
}
|
||||
for (group of contexts.initializedGroups())
|
||||
if (!group.builtin && group.persist)
|
||||
].concat([{ command: this.name, arguments: ["user"] }])
|
||||
serialize: function () {
|
||||
return [
|
||||
{
|
||||
command: this.name,
|
||||
bang: true,
|
||||
options: iter([v, typeof group[k] == "boolean" ? null : group[k]]
|
||||
// FIXME: this map is expressed multiple times
|
||||
for ([k, v] of iter({
|
||||
args: "-args",
|
||||
description: "-description",
|
||||
filter: "-locations"
|
||||
}))
|
||||
if (group[k])).toObject(),
|
||||
arguments: [group.name],
|
||||
ignoreDefaults: true
|
||||
}
|
||||
for (group of contexts.initializedGroups())
|
||||
if (!group.builtin && group.persist)
|
||||
].concat([{ command: this.name, arguments: ["user"] }]);
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["delg[roup]"],
|
||||
@@ -749,8 +752,7 @@ var Contexts = Module("contexts", {
|
||||
util.assert(contexts.getGroup(args[0]), _("group.noSuch", args[0]));
|
||||
contexts.removeGroup(args[0]);
|
||||
}
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
|
||||
@@ -481,8 +481,7 @@ var Downloads_ = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
|
||||
function (args) {
|
||||
let downloads = DownloadList(modules, args[0], args["-sort"]);
|
||||
modules.commandline.echo(downloads);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
options: [
|
||||
{
|
||||
@@ -492,8 +491,12 @@ var Downloads_ = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
|
||||
get default() {
|
||||
return modules.options["downloadsort"];
|
||||
},
|
||||
completer: function (context, args) modules.options.get("downloadsort").completer(context, { values: args["-sort"] }),
|
||||
validator: function (value) modules.options.get("downloadsort").validator(value)
|
||||
completer: function (context, args) {
|
||||
modules.options.get("downloadsort").completer(context, { values: args["-sort"] });
|
||||
},
|
||||
validator: function (value) {
|
||||
return modules.options.get("downloadsort").validator(value);
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -546,7 +549,9 @@ var Downloads_ = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
|
||||
.flatten().array;
|
||||
},
|
||||
|
||||
has: function () Array.some(arguments, val => this.value.some(v => v.substr(1) == val)),
|
||||
has: function () {
|
||||
return Array.some(arguments, val => this.value.some(v => v.substr(1) == val));
|
||||
},
|
||||
|
||||
validator: function (value) {
|
||||
let seen = new RealSet();
|
||||
|
||||
@@ -429,7 +429,9 @@ var Help = Module("Help", {
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) completion.help(context, consolidated),
|
||||
completer: function (context) {
|
||||
completion.help(context, consolidated);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
});
|
||||
|
||||
@@ -332,10 +332,11 @@ var Highlights = Module("Highlight", {
|
||||
dactyl.assert(lastScheme, _("command.colorscheme.notFound", scheme));
|
||||
}
|
||||
autocommands.trigger("ColorScheme", { name: scheme });
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.colorScheme(context)
|
||||
completer: function (context) {
|
||||
completion.colorScheme(context);
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["hi[ghlight]"],
|
||||
@@ -381,8 +382,7 @@ var Highlights = Module("Highlight", {
|
||||
highlight.set(key, css, clear, "-append" in args, args["-link"]);
|
||||
else
|
||||
util.assert(false, _("error.invalidArgument"));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
// TODO: add this as a standard highlight completion function?
|
||||
completer: function (context, args) {
|
||||
// Complete a highlight group on :hi clear ...
|
||||
@@ -420,18 +420,20 @@ var Highlights = Module("Highlight", {
|
||||
}
|
||||
}
|
||||
],
|
||||
serialize: function () [
|
||||
{
|
||||
command: this.name,
|
||||
arguments: [v.class],
|
||||
literalArg: v.value,
|
||||
options: {
|
||||
"-link": v.extends.length ? v.extends : undefined
|
||||
serialize: function () {
|
||||
return [
|
||||
{
|
||||
command: this.name,
|
||||
arguments: [v.class],
|
||||
literalArg: v.value,
|
||||
options: {
|
||||
"-link": v.extends.length ? v.extends : undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
for (v of highlight)
|
||||
if (v.value != v.defaultValue)
|
||||
]
|
||||
for (v of highlight)
|
||||
if (v.value != v.defaultValue)
|
||||
];
|
||||
}
|
||||
});
|
||||
},
|
||||
completion: function initCompletion(dactyl, modules) {
|
||||
|
||||
@@ -650,7 +650,9 @@ var IO = Module("io", {
|
||||
}
|
||||
}, {
|
||||
argCount: "?",
|
||||
completer: function (context) completion.directory(context, true),
|
||||
completer: function (context) {
|
||||
completion.directory(context, true);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -689,7 +691,9 @@ var IO = Module("io", {
|
||||
}, {
|
||||
argCount: "*", // FIXME: should be "?" but kludged for proper error message
|
||||
bang: true,
|
||||
completer: function (context) completion.file(context, true)
|
||||
completer: function (context) {
|
||||
completion.file(context, true);
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["mkv[imruntime]"],
|
||||
@@ -889,17 +893,22 @@ unlet s:cpo_save
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) completion.directory(context, true),
|
||||
completer: function (context) {
|
||||
completion.directory(context, true);
|
||||
},
|
||||
literal: 1
|
||||
});
|
||||
|
||||
commands.add(["runt[ime]"],
|
||||
"Source the specified file from each directory in 'runtimepath'",
|
||||
function (args) { io.sourceFromRuntimePath(args, args.bang); },
|
||||
{
|
||||
function (args) {
|
||||
io.sourceFromRuntimePath(args, args.bang);
|
||||
}, {
|
||||
argCount: "+",
|
||||
bang: true,
|
||||
completer: function (context) completion.runtime(context)
|
||||
completer: function (context) {
|
||||
completion.runtime(context);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -927,7 +936,9 @@ unlet s:cpo_save
|
||||
}, {
|
||||
argCount: "+", // FIXME: should be "1" but kludged for proper error message
|
||||
bang: true,
|
||||
completer: function (context) completion.file(context, true)
|
||||
completer: function (context) {
|
||||
completion.file(context, true);
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["!", "run"],
|
||||
@@ -969,7 +980,9 @@ unlet s:cpo_save
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
// This is abominably slow.
|
||||
// completer: function (context) completion.shellCommand(context),
|
||||
//completer: function (context) {
|
||||
// completion.shellCommand(context);
|
||||
//},
|
||||
literal: 0
|
||||
});
|
||||
},
|
||||
@@ -1156,10 +1169,15 @@ unlet s:cpo_save
|
||||
|
||||
options.add(["fileencoding", "fenc"],
|
||||
"The character encoding used when reading and writing files",
|
||||
"string", "UTF-8", {
|
||||
completer: function (context) completion.charset(context),
|
||||
getter: function () File.defaultEncoding,
|
||||
setter: function (value) (File.defaultEncoding = value)
|
||||
"string", "UTF-8",
|
||||
{
|
||||
completer: function (context) {
|
||||
completion.charset(context);
|
||||
},
|
||||
getter: function () { return File.defaultEncoding; },
|
||||
setter: function (value) {
|
||||
return File.defaultEncoding = value;
|
||||
}
|
||||
});
|
||||
options.add(["cdpath", "cd"],
|
||||
"List of directories searched when executing :cd",
|
||||
@@ -1169,7 +1187,9 @@ unlet s:cpo_save
|
||||
return this.value.map(path => File(path, modules.io.cwd))
|
||||
.filter(dir => dir.exists());
|
||||
},
|
||||
setter: function (value) File.expandPathList(value)
|
||||
setter: function (value) {
|
||||
return File.expandPathList(value);
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["runtimepath", "rtp"],
|
||||
@@ -1185,7 +1205,7 @@ unlet s:cpo_save
|
||||
options.add(["shell", "sh"],
|
||||
"Shell to use for executing external commands with :! and :run",
|
||||
"string", shell,
|
||||
{ validator: function (val) io.pathSearch(val) });
|
||||
{ validator: function (val) { return io.pathSearch(val); } });
|
||||
|
||||
options.add(["shellcmdflag", "shcf"],
|
||||
"Flag passed to shell when executing external commands with :! and :run",
|
||||
|
||||
@@ -860,7 +860,9 @@ var JavaScript = Module("javascript", {
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) modules.completion.javascript(context),
|
||||
completer: function (context) {
|
||||
modules.completion.javascript(context);
|
||||
},
|
||||
hereDoc: true,
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -1418,15 +1418,17 @@ var Options = Module("options", {
|
||||
description: "Set an option",
|
||||
modifiers: {},
|
||||
extra: {
|
||||
serialize: function () [
|
||||
{
|
||||
command: this.name,
|
||||
literalArg: [opt.type == "boolean" ? (opt.value ? "" : "no") + opt.name
|
||||
: opt.name + "=" + opt.stringValue]
|
||||
}
|
||||
for (opt of modules.options)
|
||||
if (!opt.getter && !opt.isDefault && (opt.scope & Option.SCOPE_GLOBAL))
|
||||
]
|
||||
serialize: function () {
|
||||
return [
|
||||
{
|
||||
command: this.name,
|
||||
literalArg: [opt.type == "boolean" ? (opt.value ? "" : "no") + opt.name
|
||||
: opt.name + "=" + opt.stringValue]
|
||||
}
|
||||
for (opt of modules.options)
|
||||
if (!opt.getter && !opt.isDefault && (opt.scope & Option.SCOPE_GLOBAL))
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
].forEach(function (params) {
|
||||
|
||||
@@ -507,15 +507,14 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
else
|
||||
sanitize(items);
|
||||
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "*", // FIXME: should be + and 0
|
||||
bang: true,
|
||||
completer: function (context) {
|
||||
context.title = ["Privacy Item", "Description"];
|
||||
context.completions = modules.options.get("sanitizeitems").values;
|
||||
},
|
||||
domains: function (args) args["-host"] || [],
|
||||
domains: function (args) { return args["-host"] || []; },
|
||||
options: [
|
||||
{
|
||||
names: ["-host", "-h"],
|
||||
@@ -533,9 +532,13 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
}, {
|
||||
names: ["-timespan", "-t"],
|
||||
description: "Timespan for which to sanitize items",
|
||||
completer: function (context) modules.options.get("sanitizetimespan").completer(context),
|
||||
completer: function (context) {
|
||||
modules.options.get("sanitizetimespan").completer(context);
|
||||
},
|
||||
type: modules.CommandOption.STRING,
|
||||
validator: function (arg) modules.options.get("sanitizetimespan").validator(arg)
|
||||
validator: function (arg) {
|
||||
return modules.options.get("sanitizetimespan").validator(arg);
|
||||
}
|
||||
}
|
||||
],
|
||||
privateData: true
|
||||
@@ -645,8 +648,10 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
return res && !/^!/.test(res);
|
||||
},
|
||||
|
||||
validator: function (values) values.length &&
|
||||
values.every(val => (val === "all" || hasOwnProperty(sanitizer.itemMap, val.replace(/^!/, ""))))
|
||||
validator: function (values) {
|
||||
return values.length &&
|
||||
values.every(val => (val === "all" || hasOwnProperty(sanitizer.itemMap, val.replace(/^!/, ""))));
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["sanitizeshutdown", "ss"],
|
||||
@@ -712,7 +717,9 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
["none", "Accept no cookies"],
|
||||
["visited", "Accept cookies from visited sites"]
|
||||
],
|
||||
getter: function () (this.values[prefs.get(this.PREF)] || ["all"])[0],
|
||||
getter: function () {
|
||||
return (this.values[prefs.get(this.PREF)] || ["all"])[0];
|
||||
},
|
||||
setter: function (val) {
|
||||
prefs.set(this.PREF, this.values.map(i => i[0]).indexOf(val));
|
||||
return val;
|
||||
@@ -731,7 +738,9 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
["prompt", "Always prompt for a lifetime"],
|
||||
["session", "The current session"]
|
||||
],
|
||||
getter: function () (this.values[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0],
|
||||
getter: function () {
|
||||
return (this.values[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0];
|
||||
},
|
||||
setter: function (value) {
|
||||
let val = this.values.map(i => i[0]).indexOf(value);
|
||||
if (val > -1)
|
||||
@@ -743,7 +752,10 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
|
||||
},
|
||||
initialValue: true,
|
||||
persist: false,
|
||||
validator: function validator(val) parseInt(val) == val || validator.superapply(this, arguments)
|
||||
validator: function validator(val) {
|
||||
return parseInt(val) == val ||
|
||||
validator.superapply(this, arguments);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -628,8 +628,7 @@ var Styles = Module("Styles", {
|
||||
if (args["-nopersist"] || !args["-append"] || style.persist === undefined)
|
||||
style.persist = !args["-nopersist"];
|
||||
}
|
||||
},
|
||||
{
|
||||
}, {
|
||||
completer: function (context, args) {
|
||||
let sheet = args["-group"].get(args["-name"]);
|
||||
if (args.completeArg == 0) {
|
||||
@@ -654,8 +653,8 @@ var Styles = Module("Styles", {
|
||||
nameFlag(),
|
||||
{ names: ["-nopersist", "-N"], description: "Do not save this style to an auto-generated RC file" }
|
||||
],
|
||||
serialize: function ()
|
||||
Ary(styles.hives)
|
||||
serialize: function () {
|
||||
return Ary(styles.hives)
|
||||
.filter(hive => hive.persist)
|
||||
.map(hive =>
|
||||
hive.sheets.filter(style => style.persist)
|
||||
@@ -670,7 +669,8 @@ var Styles = Module("Styles", {
|
||||
"-name": style.name || undefined
|
||||
}
|
||||
})))
|
||||
.flatten().array
|
||||
.flatten().array;
|
||||
}
|
||||
});
|
||||
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user