mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-03 12:44:10 +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:
@@ -341,9 +341,9 @@ var Abbreviations = Module("abbreviations", {
|
||||
identifier: "abbreviate",
|
||||
completer: function (context, args) {
|
||||
if (args.length == 1)
|
||||
return completion.abbreviation(context, modes, args["-group"]);
|
||||
completion.abbreviation(context, modes, args["-group"]);
|
||||
else if (args["-javascript"])
|
||||
return completion.javascript(context);
|
||||
completion.javascript(context);
|
||||
},
|
||||
hereDoc: true,
|
||||
literal: 1,
|
||||
@@ -354,22 +354,24 @@ var Abbreviations = Module("abbreviations", {
|
||||
description: "Expand this abbreviation by evaluating its right-hand-side as JavaScript"
|
||||
}
|
||||
],
|
||||
serialize: function () Ary(abbreviations.userHives)
|
||||
.filter(h => h.persist)
|
||||
.map(hive => [
|
||||
{
|
||||
command: this.name,
|
||||
arguments: [abbr.lhs],
|
||||
literalArg: abbr.rhs,
|
||||
options: {
|
||||
"-group": hive.name == "user" ? undefined : hive.name,
|
||||
"-javascript": callable(abbr.rhs) ? null : undefined
|
||||
serialize: function () {
|
||||
return Ary(abbreviations.userHives)
|
||||
.filter(h => h.persist)
|
||||
.map(hive => [
|
||||
{
|
||||
command: this.name,
|
||||
arguments: [abbr.lhs],
|
||||
literalArg: abbr.rhs,
|
||||
options: {
|
||||
"-group": hive.name == "user" ? undefined : hive.name,
|
||||
"-javascript": callable(abbr.rhs) ? null : undefined
|
||||
}
|
||||
}
|
||||
}
|
||||
for (abbr of hive.merged)
|
||||
if (abbr.modesEqual(modes))
|
||||
]).
|
||||
flatten().array
|
||||
for (abbr of hive.merged)
|
||||
if (abbr.modesEqual(modes))
|
||||
]).
|
||||
flatten().array;
|
||||
}
|
||||
});
|
||||
|
||||
commands.add([ch + "una[bbreviate]"],
|
||||
@@ -384,7 +386,9 @@ var Abbreviations = Module("abbreviations", {
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context, args) completion.abbreviation(context, modes, args["-group"]),
|
||||
completer: function (context, args) {
|
||||
completion.abbreviation(context, modes, args["-group"]);
|
||||
},
|
||||
literal: 0,
|
||||
options: [contexts.GroupFlag("abbrevs")]
|
||||
});
|
||||
|
||||
@@ -213,9 +213,9 @@ var AutoCommands = Module("autocommands", {
|
||||
bang: true,
|
||||
completer: function (context, args) {
|
||||
if (args.length == 1)
|
||||
return completion.autocmdEvent(context);
|
||||
if (args.length == 3)
|
||||
return args["-javascript"] ? completion.javascript(context) : completion.ex(context);
|
||||
completion.autocmdEvent(context);
|
||||
else if (args.length == 3)
|
||||
args["-javascript"] ? completion.javascript(context) : completion.ex(context);
|
||||
},
|
||||
hereDoc: true,
|
||||
keepQuotes: true,
|
||||
@@ -273,7 +273,9 @@ var AutoCommands = Module("autocommands", {
|
||||
autocommands.trigger(event, { url: uri.spec });
|
||||
}, {
|
||||
argCount: "*", // FIXME: kludged for proper error message should be "1".
|
||||
completer: function (context) completion.autocmdEvent(context),
|
||||
completer: function (context) {
|
||||
completion.autocmdEvent(context);
|
||||
},
|
||||
keepQuotes: true
|
||||
});
|
||||
});
|
||||
|
||||
@@ -516,16 +516,18 @@ var Bookmarks = Module("bookmarks", {
|
||||
context.completions = [
|
||||
[win.document.documentURI, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.document.title]
|
||||
for (win of frames)];
|
||||
return;
|
||||
}
|
||||
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||
else
|
||||
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||
},
|
||||
options: [keyword, title, tags, post,
|
||||
{
|
||||
names: ["-charset", "-c"],
|
||||
description: "The character encoding of the bookmark",
|
||||
type: CommandOption.STRING,
|
||||
completer: function (context) completion.charset(context),
|
||||
completer: function (context) {
|
||||
completion.charset(context);
|
||||
},
|
||||
validator: io.bound.validateCharset
|
||||
},
|
||||
{
|
||||
@@ -541,8 +543,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
function (args) {
|
||||
bookmarks.list(args.join(" "), args["-tags"] || [], args.bang, args["-max"],
|
||||
{ keyword: args["-keyword"], title: args["-title"] });
|
||||
},
|
||||
{
|
||||
}, {
|
||||
bang: true,
|
||||
completer: function completer(context, args) {
|
||||
context.filter = args.join(" ");
|
||||
@@ -584,13 +585,15 @@ var Bookmarks = Module("bookmarks", {
|
||||
dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) });
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function completer(context, args)
|
||||
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] }),
|
||||
domains: function (args) Ary.compact(args.map(util.getHost)),
|
||||
completer: function completer(context, args) {
|
||||
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||
},
|
||||
domains: function (args) {
|
||||
return Ary.compact(args.map(util.getHost));
|
||||
},
|
||||
literal: 0,
|
||||
options: [tags, title, keyword],
|
||||
privateData: true
|
||||
@@ -643,14 +646,21 @@ var Bookmarks = Module("bookmarks", {
|
||||
{
|
||||
completer: function completer(context) {
|
||||
completion.search(context, true);
|
||||
context.completions = [{ keyword: "", title: "Don't perform searches by default" }].concat(context.completions);
|
||||
context.completions = [{
|
||||
keyword: "",
|
||||
title: "Don't perform searches by default"
|
||||
}].concat(context.completions);
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["suggestengines"],
|
||||
"Search engines used for search suggestions",
|
||||
"stringlist", "google",
|
||||
{ completer: function completer(context) completion.searchEngine(context, true) });
|
||||
{
|
||||
completer: function completer(context) {
|
||||
completion.searchEngine(context, true);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
completion: function initCompletion() {
|
||||
|
||||
@@ -208,11 +208,14 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
|
||||
commands: function initCommands(dactyl, modules, window) {
|
||||
commands.add(["o[pen]"],
|
||||
"Open one or more URLs in the current tab",
|
||||
function (args) { dactyl.open(args[0] || "about:blank"); },
|
||||
{
|
||||
completer: function (context) completion.url(context),
|
||||
domains: function (args) Ary.compact(dactyl.parseURLs(args[0] || "")
|
||||
.map(url => util.getHost(url))),
|
||||
function (args) {
|
||||
dactyl.open(args[0] || "about:blank");
|
||||
}, {
|
||||
completer: function (context) { completion.url(context); },
|
||||
domains: function (args) {
|
||||
return Ary.compact(dactyl.parseURLs(args[0] || "")
|
||||
.map(url => util.getHost(url)));
|
||||
},
|
||||
literal: 0,
|
||||
privateData: true
|
||||
});
|
||||
|
||||
@@ -1690,7 +1690,9 @@ var CommandLine = Module("commandline", {
|
||||
function (args) {
|
||||
command.action(CommandLine.echoArgumentToString(args[0] || "", true));
|
||||
}, {
|
||||
completer: function (context) completion.javascript(context),
|
||||
completer: function (context) {
|
||||
completion.javascript(context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
});
|
||||
@@ -1723,7 +1725,7 @@ var CommandLine = Module("commandline", {
|
||||
function (args) {
|
||||
commandline.runSilently(() => { commands.execute(args[0] || "", null, true); });
|
||||
}, {
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
});
|
||||
@@ -1884,17 +1886,17 @@ var CommandLine = Module("commandline", {
|
||||
options.add(["history", "hi"],
|
||||
"Number of Ex commands and search patterns to store in the command-line history",
|
||||
"number", 500,
|
||||
{ validator: function (value) value >= 0 });
|
||||
{ validator: function (value) { return value >= 0; } });
|
||||
|
||||
options.add(["maxitems"],
|
||||
"Maximum number of completion items to display at once",
|
||||
"number", 20,
|
||||
{ validator: function (value) value >= 1 });
|
||||
{ validator: function (value) { return value >= 1; } });
|
||||
|
||||
options.add(["messages", "msgs"],
|
||||
"Number of messages to store in the :messages history",
|
||||
"number", 100,
|
||||
{ validator: function (value) value >= 0 });
|
||||
{ validator: function (value) { return value >= 0; } });
|
||||
},
|
||||
sanitizer: function initSanitizer() {
|
||||
sanitizer.addItem("commandline", {
|
||||
|
||||
@@ -252,8 +252,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
|
||||
commandline.commandOutput(
|
||||
template.usage(results, params.format));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "*",
|
||||
completer: function (context, args) {
|
||||
context.keys.text = identity;
|
||||
@@ -1332,8 +1331,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
options.add(["fullscreen", "fs"],
|
||||
"Show the current window fullscreen",
|
||||
"boolean", false, {
|
||||
setter: function (value) window.fullScreen = value,
|
||||
getter: function () window.fullScreen
|
||||
setter: function (value) { return window.fullScreen = value; },
|
||||
getter: function () { return window.fullScreen; }
|
||||
});
|
||||
|
||||
const groups = [
|
||||
@@ -1382,8 +1381,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
prefs.safeSet("layout.scrollbar.side", opts.indexOf("l") >= 0 ? 3 : 2,
|
||||
_("option.guioptions.safeSet"));
|
||||
},
|
||||
validator: function (opts) Option.validIf(!(opts.indexOf("l") >= 0 && opts.indexOf("r") >= 0),
|
||||
UTF8("Only one of ‘l’ or ‘r’ allowed"))
|
||||
validator: function (opts) {
|
||||
return Option.validIf(!(opts.indexOf("l") >= 0 && opts.indexOf("r") >= 0),
|
||||
UTF8("Only one of ‘l’ or ‘r’ allowed"));
|
||||
}
|
||||
},
|
||||
{
|
||||
feature: "tabs",
|
||||
@@ -1421,8 +1422,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
events.checkFocus();
|
||||
return value;
|
||||
},
|
||||
validator: function (val) Option.validateCompleter.call(this, val)
|
||||
&& groups.every(g => !g.validator || g.validator(val))
|
||||
validator: function (val) {
|
||||
return Option.validateCompleter.call(this, val) &&
|
||||
groups.every(g => !g.validator || g.validator(val));
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["loadplugins", "lpl"],
|
||||
@@ -1466,13 +1469,17 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
options.add(["urlseparator", "urlsep", "us"],
|
||||
"The regular expression used to separate multiple URLs in :open and friends",
|
||||
"string", " \\| ",
|
||||
{ validator: function (value) RegExp(value) });
|
||||
{ validator: function (value) { return RegExp(value); } });
|
||||
|
||||
options.add(["verbose", "vbs"],
|
||||
"Define which info messages are displayed",
|
||||
"number", 1,
|
||||
{ validator: function (value) Option.validIf(value >= 0 && value <= 15,
|
||||
"Value must be between 0 and 15") });
|
||||
{
|
||||
validator: function (value) {
|
||||
return Option.validIf(value >= 0 && value <= 15,
|
||||
"Value must be between 0 and 15");
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["visualbell", "vb"],
|
||||
"Use visual bell instead of beeping on errors",
|
||||
@@ -1538,7 +1545,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
}
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.menuItem(context),
|
||||
completer: function (context) {
|
||||
completion.menuItem(context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -1553,7 +1562,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
dactyl.echoerr(e);
|
||||
}
|
||||
}, {
|
||||
completer: function (context) completion.javascript(context),
|
||||
completer: function (context) {
|
||||
completion.javascript(context);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -1561,18 +1572,17 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"Load all or matching plugins",
|
||||
function (args) {
|
||||
dactyl.loadPlugins(args.length ? args : null, args.bang);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "*",
|
||||
bang: true,
|
||||
keepQuotes: true,
|
||||
serialGroup: 10,
|
||||
serialize: function () [
|
||||
{
|
||||
serialize: function () {
|
||||
return [{
|
||||
command: this.name,
|
||||
literalArg: options["loadplugins"].join(" ")
|
||||
}
|
||||
]
|
||||
}];
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["norm[al]"],
|
||||
@@ -1593,7 +1603,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
});
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
privateData: "never-save",
|
||||
subCommand: 0
|
||||
@@ -1799,9 +1809,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
bang: true,
|
||||
completer: function (context) {
|
||||
if (/^:/.test(context.filter))
|
||||
return completion.ex(context);
|
||||
completion.ex(context);
|
||||
else
|
||||
return completion.javascript(context);
|
||||
completion.javascript(context);
|
||||
},
|
||||
count: true,
|
||||
hereDoc: true,
|
||||
@@ -1827,7 +1837,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
}
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
count: true,
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
|
||||
@@ -1382,7 +1382,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
args.push(obj["file"]);
|
||||
return args;
|
||||
},
|
||||
has: function (key) util.compileMacro(this.value).seen.has(key),
|
||||
has: function (key) {
|
||||
return util.compileMacro(this.value).seen.has(key);
|
||||
},
|
||||
validator: function (value) {
|
||||
this.format({}, value);
|
||||
let allowed = new RealSet(["column", "file", "line"]);
|
||||
|
||||
@@ -1033,15 +1033,17 @@ var Events = Module("events", {
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) completion.macro(context),
|
||||
completer: function (context) { completion.macro(context); },
|
||||
literal: 0
|
||||
});
|
||||
|
||||
commands.add(["mac[ros]"],
|
||||
"List all macros",
|
||||
function (args) { completion.listCompleter("macro", args[0]); }, {
|
||||
function (args) {
|
||||
completion.listCompleter("macro", args[0]);
|
||||
}, {
|
||||
argCount: "?",
|
||||
completer: function (context) completion.macro(context)
|
||||
completer: function (context) { completion.macro(context); }
|
||||
});
|
||||
},
|
||||
completion: function initCompletion() {
|
||||
@@ -1168,7 +1170,10 @@ var Events = Module("events", {
|
||||
});
|
||||
},
|
||||
|
||||
has: function (key) this.pass.has(key) || hasOwnProperty(this.commandHive.stack.mappings, key),
|
||||
has: function (key) {
|
||||
return this.pass.has(key) ||
|
||||
hasOwnProperty(this.commandHive.stack.mappings, key);
|
||||
},
|
||||
|
||||
get pass() { this.flush(); return this.pass; },
|
||||
|
||||
|
||||
@@ -1381,7 +1381,7 @@ var Hints = Module("hints", {
|
||||
options.add(["hinttimeout", "hto"],
|
||||
"Timeout before automatically following a non-unique numerical hint",
|
||||
"number", 0,
|
||||
{ validator: function (value) value >= 0 });
|
||||
{ validator: function (value) { return value >= 0; } });
|
||||
|
||||
options.add(["followhints", "fh"],
|
||||
"Define the conditions under which selected hints are followed",
|
||||
@@ -1404,15 +1404,17 @@ var Hints = Module("hints", {
|
||||
"wordstartswith": "The typed characters are split on whitespace. The resulting groups must all match the beginnings of words, in order.",
|
||||
"transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., é ⇒ e)")
|
||||
},
|
||||
validator: function (values) Option.validateCompleter.call(this, values) &&
|
||||
1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0),
|
||||
0)
|
||||
validator: function (values) {
|
||||
return Option.validateCompleter.call(this, values) &&
|
||||
1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0),
|
||||
0);
|
||||
}
|
||||
});
|
||||
|
||||
options.add(["wordseparators", "wsp"],
|
||||
"Regular expression defining which characters separate words when matching hints",
|
||||
"string", '[.,!?:;/"^$%&?()[\\]{}<>#*+|=~ _-]',
|
||||
{ validator: function (value) RegExp(value) });
|
||||
{ validator: function (value) { return RegExp(value); } });
|
||||
|
||||
options.add(["hintinputs", "hin"],
|
||||
"Which text is used to filter hints for input elements",
|
||||
|
||||
@@ -200,8 +200,7 @@ var History = Module("history", {
|
||||
history.stepTo(-Math.max(args.count, 1));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function completer(context) {
|
||||
@@ -211,9 +210,13 @@ var History = Module("history", {
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.filters = [CompletionContext.Filter.textDescription];
|
||||
context.completions = sh.slice(0, sh.index).reverse();
|
||||
context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec,
|
||||
description: "title",
|
||||
icon: "icon" };
|
||||
context.keys = {
|
||||
text: function (item) {
|
||||
return (sh.index - item.index) + ": " + item.URI.spec;
|
||||
},
|
||||
description: "title",
|
||||
icon: "icon"
|
||||
};
|
||||
},
|
||||
count: true,
|
||||
literal: 0,
|
||||
@@ -242,8 +245,7 @@ var History = Module("history", {
|
||||
history.stepTo(Math.max(args.count, 1));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function completer(context) {
|
||||
@@ -253,9 +255,13 @@ var History = Module("history", {
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.filters = [CompletionContext.Filter.textDescription];
|
||||
context.completions = sh.slice(sh.index + 1);
|
||||
context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec,
|
||||
description: "title",
|
||||
icon: "icon" };
|
||||
context.keys = {
|
||||
text: function (item) {
|
||||
return (item.index - sh.index) + ": " + item.URI.spec;
|
||||
},
|
||||
description: "title",
|
||||
icon: "icon"
|
||||
};
|
||||
},
|
||||
count: true,
|
||||
literal: 0,
|
||||
@@ -264,9 +270,13 @@ var History = Module("history", {
|
||||
|
||||
commands.add(["hist[ory]", "hs"],
|
||||
"Show recently visited URLs",
|
||||
function (args) { history.list(args.join(" "), args.bang, args["-max"], args["-sort"]); }, {
|
||||
function (args) {
|
||||
history.list(args.join(" "), args.bang, args["-max"], args["-sort"]);
|
||||
}, {
|
||||
bang: true,
|
||||
completer: function (context, args) completion.history(context, args["-max"], args["-sort"]),
|
||||
completer: function (context, args) {
|
||||
completion.history(context, args["-max"], args["-sort"]);
|
||||
},
|
||||
options: [
|
||||
{
|
||||
names: ["-max", "-m"],
|
||||
|
||||
@@ -575,12 +575,12 @@ var Mappings = Module("mappings", {
|
||||
completer: function (context, args) {
|
||||
let mapmodes = Ary.uniq(args["-modes"].map(findMode));
|
||||
if (args.length == 1)
|
||||
return completion.userMapping(context, mapmodes, args["-group"]);
|
||||
if (args.length == 2) {
|
||||
completion.userMapping(context, mapmodes, args["-group"]);
|
||||
else if (args.length == 2) {
|
||||
if (args["-javascript"])
|
||||
return completion.javascript(context);
|
||||
if (args["-ex"])
|
||||
return completion.ex(context);
|
||||
completion.javascript(context);
|
||||
else if (args["-ex"])
|
||||
completion.ex(context);
|
||||
}
|
||||
},
|
||||
hereDoc: true,
|
||||
@@ -629,8 +629,10 @@ var Mappings = Module("mappings", {
|
||||
}
|
||||
],
|
||||
serialize: function () {
|
||||
return this.name != "map" ? [] :
|
||||
Ary(mappings.userHives)
|
||||
if (this.name != "map")
|
||||
return [];
|
||||
else
|
||||
return Ary(mappings.userHives)
|
||||
.filter(h => h.persist)
|
||||
.map(hive => [
|
||||
{
|
||||
@@ -691,8 +693,7 @@ var Mappings = Module("mappings", {
|
||||
|
||||
if (!found && !args.bang)
|
||||
dactyl.echoerr(_("map.noSuch", args[0]));
|
||||
},
|
||||
{
|
||||
}, {
|
||||
identifier: "unmap",
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
@@ -712,10 +713,14 @@ var Mappings = Module("mappings", {
|
||||
let modeFlag = {
|
||||
names: ["-mode", "-m"],
|
||||
type: CommandOption.STRING,
|
||||
validator: function (value) Array.concat(value).every(findMode),
|
||||
completer: function () [[Ary.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.description]
|
||||
for (mode of modes.all)
|
||||
if (!mode.hidden)]
|
||||
validator: function (value) {
|
||||
return Array.concat(value).every(findMode);
|
||||
},
|
||||
completer: function () {
|
||||
return [[Ary.compact([mode.name.toLowerCase().replace(/_/g, "-"), mode.char]), mode.description]
|
||||
for (mode of modes.all)
|
||||
if (!mode.hidden)];
|
||||
}
|
||||
};
|
||||
|
||||
function findMode(name) {
|
||||
|
||||
@@ -349,10 +349,9 @@ var Marks = Module("marks", {
|
||||
dactyl.assert(!special || !arg, _("error.invalidArgument"));
|
||||
|
||||
marks.remove(arg, special);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
bang: true,
|
||||
completer: function (context) completion.mark(context),
|
||||
completer: function (context) { completion.mark(context); },
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -372,7 +371,7 @@ var Marks = Module("marks", {
|
||||
function (args) {
|
||||
marks.list(args[0] || "");
|
||||
}, {
|
||||
completer: function (context) completion.mark(context),
|
||||
completer: function (context) { completion.mark(context); },
|
||||
literal: 0
|
||||
});
|
||||
},
|
||||
|
||||
@@ -659,8 +659,10 @@ var Modes = Module("modes", {
|
||||
return vals;
|
||||
},
|
||||
|
||||
validator: function validator(vals) vals.map(v => v.replace(/^!/, ""))
|
||||
.every(k => hasOwnProperty(this.values, k)),
|
||||
validator: function validator(vals) {
|
||||
return vals.map(v => v.replace(/^!/, ""))
|
||||
.every(k => hasOwnProperty(this.values, k));
|
||||
},
|
||||
|
||||
get values() {
|
||||
return Ary.toObject([[m.name.toLowerCase(), m.description]
|
||||
|
||||
@@ -131,11 +131,12 @@ var QuickMarks = Module("quickmarks", {
|
||||
quickmarks.removeAll();
|
||||
else
|
||||
quickmarks.remove(args[0]);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
completer: function (context) completion.quickmark(context)
|
||||
completer: function (context) {
|
||||
completion.quickmark(context);
|
||||
}
|
||||
});
|
||||
|
||||
commands.add(["qma[rk]"],
|
||||
@@ -147,13 +148,12 @@ var QuickMarks = Module("quickmarks", {
|
||||
quickmarks.add(args[0], buffer.uri.spec);
|
||||
else
|
||||
quickmarks.add(args[0], args[1]);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "+",
|
||||
completer: function (context, args) {
|
||||
if (args.length == 1)
|
||||
return completion.quickmark(context);
|
||||
if (args.length == 2) {
|
||||
completion.quickmark(context);
|
||||
else if (args.length == 2) {
|
||||
context.fork("current", 0, this, context => {
|
||||
context.title = ["Extra Completions"];
|
||||
context.completions = [
|
||||
@@ -172,7 +172,9 @@ var QuickMarks = Module("quickmarks", {
|
||||
quickmarks.list(args[0] || "");
|
||||
}, {
|
||||
argCount: "?",
|
||||
completer: function (context) completion.quickmark(context)
|
||||
completer: function (context) {
|
||||
completion.quickmark(context);
|
||||
}
|
||||
});
|
||||
},
|
||||
completion: function initCompletion() {
|
||||
|
||||
@@ -650,7 +650,9 @@ var Tabs = Module("tabs", {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
count: true,
|
||||
completer: function (context) completion.buffer(context),
|
||||
completer: function (context) {
|
||||
completion.buffer(context);
|
||||
},
|
||||
literal: 0,
|
||||
privateData: true
|
||||
});
|
||||
@@ -661,8 +663,7 @@ var Tabs = Module("tabs", {
|
||||
function (args) {
|
||||
for (let tab of tabs.match(args[0], args.count))
|
||||
config.browser[!args.bang || !tab.pinned ? "pinTab" : "unpinTab"](tab);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
count: true,
|
||||
@@ -678,8 +679,7 @@ var Tabs = Module("tabs", {
|
||||
function (args) {
|
||||
for (let tab of tabs.match(args[0], args.count))
|
||||
config.browser.unpinTab(tab);
|
||||
},
|
||||
{
|
||||
}, {
|
||||
argCount: "?",
|
||||
count: true,
|
||||
completer: function (context) {
|
||||
@@ -699,7 +699,7 @@ var Tabs = Module("tabs", {
|
||||
}
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
});
|
||||
@@ -713,7 +713,7 @@ var Tabs = Module("tabs", {
|
||||
});
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
});
|
||||
@@ -727,7 +727,7 @@ var Tabs = Module("tabs", {
|
||||
});
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
});
|
||||
@@ -741,7 +741,7 @@ var Tabs = Module("tabs", {
|
||||
}
|
||||
}, {
|
||||
argCount: "1",
|
||||
completer: function (context) completion.ex(context),
|
||||
completer: function (context) { completion.ex(context); },
|
||||
literal: 0,
|
||||
subCommand: 0
|
||||
});
|
||||
@@ -821,7 +821,9 @@ var Tabs = Module("tabs", {
|
||||
argCount: "?",
|
||||
bang: true,
|
||||
count: true,
|
||||
completer: function (context) completion.buffer(context),
|
||||
completer: function (context) {
|
||||
completion.buffer(context);
|
||||
},
|
||||
literal: 0,
|
||||
privateData: true
|
||||
});
|
||||
@@ -866,7 +868,9 @@ var Tabs = Module("tabs", {
|
||||
}, {
|
||||
argCount: "1",
|
||||
bang: true,
|
||||
completer: function (context) completion.buffer(context, true),
|
||||
completer: function (context) {
|
||||
completion.buffer(context, true);
|
||||
},
|
||||
literal: 0
|
||||
});
|
||||
|
||||
@@ -882,8 +886,12 @@ var Tabs = Module("tabs", {
|
||||
{ from: "tabopen", where: dactyl.NEW_TAB, background: args.bang });
|
||||
}, {
|
||||
bang: true,
|
||||
completer: function (context) completion.url(context),
|
||||
domains: function (args) commands.get("open").domains(args),
|
||||
completer: function (context) {
|
||||
completion.url(context);
|
||||
},
|
||||
domains: function (args) {
|
||||
return commands.get("open").domains(args);
|
||||
},
|
||||
literal: 0,
|
||||
privateData: true
|
||||
});
|
||||
@@ -1012,9 +1020,13 @@ var Tabs = Module("tabs", {
|
||||
context.anchored = false;
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.filters = [CompletionContext.Filter.textDescription];
|
||||
context.keys = { text: function ([i, { state: s }]) (i + 1) + ": " + s.entries[s.index - 1].url,
|
||||
description: "[1].title",
|
||||
icon: "[1].image" };
|
||||
context.keys = {
|
||||
text: function ([i, { state: s }]) {
|
||||
return (i + 1) + ": " + s.entries[s.index - 1].url;
|
||||
},
|
||||
description: "[1].title",
|
||||
icon: "[1].image"
|
||||
};
|
||||
context.completions = tabs.closedTabs.entries();
|
||||
},
|
||||
count: true,
|
||||
|
||||
Reference in New Issue
Block a user