mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 08:27:59 +01:00
Revert 102689d248aa
Args is command completion specific. --HG-- extra : rebase_source : 230320207a8c1fd9732e406fd217e36736982c27
This commit is contained in:
@@ -215,6 +215,7 @@ const Abbreviations = Module("abbreviations", {
|
|||||||
}, {
|
}, {
|
||||||
}, {
|
}, {
|
||||||
completion: function () {
|
completion: function () {
|
||||||
|
// TODO: shouldn't all of these have a standard signature (context, args, ...)? --djk
|
||||||
completion.abbreviation = function abbreviation(context, args, modes) {
|
completion.abbreviation = function abbreviation(context, args, modes) {
|
||||||
if (args.completeArg == 0) {
|
if (args.completeArg == 0) {
|
||||||
let abbrevs = abbreviations.merged.filter(function (abbr) abbr.inModes(modes));
|
let abbrevs = abbreviations.merged.filter(function (abbr) abbr.inModes(modes));
|
||||||
|
|||||||
@@ -385,7 +385,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
for ([, win] in Iterator(frames))];
|
for ([, win] in Iterator(frames))];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
completion.bookmark(context, args, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||||
},
|
},
|
||||||
options: [keyword, title, tags, post]
|
options: [keyword, title, tags, post]
|
||||||
});
|
});
|
||||||
@@ -400,7 +400,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
bang: true,
|
bang: true,
|
||||||
completer: function completer(context, args) {
|
completer: function completer(context, args) {
|
||||||
context.filter = args.join(" ");
|
context.filter = args.join(" ");
|
||||||
completion.bookmark(context, args, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||||
},
|
},
|
||||||
options: [tags, keyword, title,
|
options: [tags, keyword, title,
|
||||||
{
|
{
|
||||||
@@ -442,7 +442,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function completer(context, args)
|
completer: function completer(context, args)
|
||||||
completion.bookmark(context, args, args["-tags"], { keyword: args["-keyword"], title: args["-title"] }),
|
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] }),
|
||||||
domains: function (args) array.compact(args.map(util.getHost)),
|
domains: function (args) array.compact(args.map(util.getHost)),
|
||||||
literal: 0,
|
literal: 0,
|
||||||
options: [tags, title, keyword],
|
options: [tags, title, keyword],
|
||||||
@@ -487,8 +487,8 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
"Set the default search engine",
|
"Set the default search engine",
|
||||||
"string", "google",
|
"string", "google",
|
||||||
{
|
{
|
||||||
completer: function completer(context, args) {
|
completer: function completer(context) {
|
||||||
completion.search(context, args, true);
|
completion.search(context, true);
|
||||||
context.completions = [["", "Don't perform searches by default"]].concat(context.completions);
|
context.completions = [["", "Don't perform searches by default"]].concat(context.completions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -497,12 +497,12 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
"Engine Alias which has a feature of suggest",
|
"Engine Alias which has a feature of suggest",
|
||||||
"stringlist", "google",
|
"stringlist", "google",
|
||||||
{
|
{
|
||||||
completer: function completer(context, args) completion.searchEngine(context, args, true),
|
completer: function completer(context) completion.searchEngine(context, true),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
completion: function () {
|
completion: function () {
|
||||||
completion.bookmark = function bookmark(context, args, tags, extra) {
|
completion.bookmark = function bookmark(context, tags, extra) {
|
||||||
context.title = ["Bookmark", "Title"];
|
context.title = ["Bookmark", "Title"];
|
||||||
context.format = bookmarks.format;
|
context.format = bookmarks.format;
|
||||||
forEach(iter(extra || {}), function ([k, v]) {
|
forEach(iter(extra || {}), function ([k, v]) {
|
||||||
@@ -510,10 +510,10 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k]));
|
context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k]));
|
||||||
});
|
});
|
||||||
context.generate = function () values(bookmarkcache.bookmarks);
|
context.generate = function () values(bookmarkcache.bookmarks);
|
||||||
completion.urls(context, args, tags);
|
completion.urls(context, tags);
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.search = function search(context, args, noSuggest) {
|
completion.search = function search(context, noSuggest) {
|
||||||
let [, keyword, space, args] = context.filter.match(/^\s*(\S*)(\s*)(.*)$/);
|
let [, keyword, space, args] = context.filter.match(/^\s*(\S*)(\s*)(.*)$/);
|
||||||
let keywords = bookmarks.getKeywords();
|
let keywords = bookmarks.getKeywords();
|
||||||
let engines = bookmarks.getSearchEngines();
|
let engines = bookmarks.getSearchEngines();
|
||||||
@@ -553,7 +553,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.searchEngine = function searchEngine(context, args, suggest) {
|
completion.searchEngine = function searchEngine(context, suggest) {
|
||||||
let engines = services.get("browserSearch").getEngines({});
|
let engines = services.get("browserSearch").getEngines({});
|
||||||
if (suggest)
|
if (suggest)
|
||||||
engines = engines.filter(function (e) e.supportsResponseType("application/x-suggestions+json"));
|
engines = engines.filter(function (e) e.supportsResponseType("application/x-suggestions+json"));
|
||||||
@@ -562,7 +562,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
context.completions = engines.map(function (e) [e.alias, e.description]);
|
context.completions = engines.map(function (e) [e.alias, e.description]);
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.searchEngineSuggest = function searchEngineSuggest(context, args, engineAliases, kludge) {
|
completion.searchEngineSuggest = function searchEngineSuggest(context, engineAliases, kludge) {
|
||||||
if (!context.filter)
|
if (!context.filter)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1259,7 +1259,7 @@ const Buffer = Module("buffer", {
|
|||||||
{
|
{
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
completer: function (context) {
|
completer: function (context) {
|
||||||
completion.optionValue(context, args, "pageinfo", "+", "");
|
completion.optionValue(context, "pageinfo", "+", "");
|
||||||
context.title = ["Page Info"];
|
context.title = ["Page Info"];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1374,7 +1374,7 @@ const Buffer = Module("buffer", {
|
|||||||
{
|
{
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context, args) completion.url(context, args, "bhf")
|
completer: function (context) completion.url(context, "bhf")
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["zo[om]"],
|
commands.add(["zo[om]"],
|
||||||
|
|||||||
@@ -765,7 +765,7 @@ const Completion = Module("completion", {
|
|||||||
// may consist of search engines, filenames, bookmarks and history,
|
// may consist of search engines, filenames, bookmarks and history,
|
||||||
// depending on the 'complete' option
|
// depending on the 'complete' option
|
||||||
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option
|
// if the 'complete' argument is passed like "h", it temporarily overrides the complete option
|
||||||
url: function url(context, args, complete) {
|
url: function url(context, complete) {
|
||||||
let numLocationCompletions = 0; // how many async completions did we already return to the caller?
|
let numLocationCompletions = 0; // how many async completions did we already return to the caller?
|
||||||
let start = 0;
|
let start = 0;
|
||||||
let skip = 0;
|
let skip = 0;
|
||||||
@@ -794,7 +794,7 @@ const Completion = Module("completion", {
|
|||||||
this.urlCompleters[opt] = completer;
|
this.urlCompleters[opt] = completer;
|
||||||
},
|
},
|
||||||
|
|
||||||
urls: function (context, args, tags) {
|
urls: function (context, tags) {
|
||||||
let compare = String.localeCompare;
|
let compare = String.localeCompare;
|
||||||
let contains = String.indexOf;
|
let contains = String.indexOf;
|
||||||
if (context.ignoreCase) {
|
if (context.ignoreCase) {
|
||||||
|
|||||||
@@ -1685,7 +1685,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
}, {
|
}, {
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context, args) completion.help(context, args, unchunked),
|
completer: function (context) completion.help(context, unchunked),
|
||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1937,7 +1937,7 @@ const Dactyl = Module("dactyl", {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.help = function help(context, args, unchunked) {
|
completion.help = function help(context, unchunked) {
|
||||||
dactyl.initHelp();
|
dactyl.initHelp();
|
||||||
context.title = ["Help"];
|
context.title = ["Help"];
|
||||||
context.anchored = false;
|
context.anchored = false;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ const History = Module("history", {
|
|||||||
].slice(2);
|
].slice(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.history = function _history(context, args, maxItems) {
|
completion.history = function _history(context, maxItems) {
|
||||||
context.format = history.format;
|
context.format = history.format;
|
||||||
context.title = ["History"];
|
context.title = ["History"];
|
||||||
context.compare = CompletionContext.Sort.unsorted;
|
context.compare = CompletionContext.Sort.unsorted;
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ lookup:
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
argCount: "?",
|
argCount: "?",
|
||||||
completer: function (context) completion.directory(context, args, true),
|
completer: function (context) completion.directory(context, true),
|
||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -550,7 +550,7 @@ lookup:
|
|||||||
}, {
|
}, {
|
||||||
argCount: "*", // FIXME: should be "?" but kludged for proper error message
|
argCount: "*", // FIXME: should be "?" but kludged for proper error message
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) completion.file(context, args, true)
|
completer: function (context) completion.file(context, true)
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["runt[ime]"],
|
commands.add(["runt[ime]"],
|
||||||
@@ -582,7 +582,7 @@ lookup:
|
|||||||
}, {
|
}, {
|
||||||
argCount: "+", // FIXME: should be "1" but kludged for proper error message
|
argCount: "+", // FIXME: should be "1" but kludged for proper error message
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function (context) completion.file(context, args, true)
|
completer: function (context) completion.file(context, true)
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["!", "run"],
|
commands.add(["!", "run"],
|
||||||
@@ -635,8 +635,8 @@ lookup:
|
|||||||
context.generate = function () iter(services.get("charset").getDecoderList());
|
context.generate = function () iter(services.get("charset").getDecoderList());
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.directory = function directory(context, args, full) {
|
completion.directory = function directory(context, full) {
|
||||||
this.file(context, args, full);
|
this.file(context, full);
|
||||||
context.filters.push(function ({ item }) item.isDirectory());
|
context.filters.push(function ({ item }) item.isDirectory());
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -649,7 +649,7 @@ lookup:
|
|||||||
context.generate = function () lines.map(function (line) (line.match(/([^=]+)=(.+)/) || []).slice(1));
|
context.generate = function () lines.map(function (line) (line.match(/([^=]+)=(.+)/) || []).slice(1));
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.file = function file(context, args, full, dir) {
|
completion.file = function file(context, full, dir) {
|
||||||
// dir == "" is expanded inside readDirectory to the current dir
|
// dir == "" is expanded inside readDirectory to the current dir
|
||||||
[dir] = (dir || context.filter).match(/^(?:.*[\/\\])?/);
|
[dir] = (dir || context.filter).match(/^(?:.*[\/\\])?/);
|
||||||
|
|
||||||
@@ -687,7 +687,7 @@ lookup:
|
|||||||
for (let [, dir] in Iterator(options["runtimepath"]))
|
for (let [, dir] in Iterator(options["runtimepath"]))
|
||||||
context.fork(dir, 0, this, function (context) {
|
context.fork(dir, 0, this, function (context) {
|
||||||
dir = dir.replace("/+$", "") + "/";
|
dir = dir.replace("/+$", "") + "/";
|
||||||
completion.file(context, args, true, dir + context.filter);
|
completion.file(context, true, dir + context.filter);
|
||||||
context.title[0] = dir;
|
context.title[0] = dir;
|
||||||
context.keys.text = function (f) f.path.substr(dir.length);
|
context.keys.text = function (f) f.path.substr(dir.length);
|
||||||
});
|
});
|
||||||
@@ -711,16 +711,16 @@ lookup:
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.addUrlCompleter("f", "Local files", function (context, args, full) {
|
completion.addUrlCompleter("f", "Local files", function (context, full) {
|
||||||
if (/^(\.{0,2}|~)\/|^file:/.test(context.filter))
|
if (/^(\.{0,2}|~)\/|^file:/.test(context.filter))
|
||||||
completion.file(context, args, full);
|
completion.file(context, full);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
javascript: function () {
|
javascript: function () {
|
||||||
JavaScript.setCompleter([File, File.expandPath],
|
JavaScript.setCompleter([File, File.expandPath],
|
||||||
[function (context, obj, args) {
|
[function (context, obj, args) {
|
||||||
context.quote[2] = "";
|
context.quote[2] = "";
|
||||||
completion.file(context, args, true);
|
completion.file(context, true);
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -939,7 +939,7 @@ const Options = Module("options", {
|
|||||||
if (context.filter.indexOf("=") == -1) {
|
if (context.filter.indexOf("=") == -1) {
|
||||||
if (false && prefix)
|
if (false && prefix)
|
||||||
context.filters.push(function ({ item }) item.type == "boolean" || prefix == "inv" && isArray(item.values));
|
context.filters.push(function ({ item }) item.type == "boolean" || prefix == "inv" && isArray(item.values));
|
||||||
return completion.option(context, args, opt.scope, prefix);
|
return completion.option(context, opt.scope, prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
let option = opt.option;
|
let option = opt.option;
|
||||||
@@ -965,7 +965,7 @@ const Options = Module("options", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let optcontext = context.fork("values");
|
let optcontext = context.fork("values");
|
||||||
completion.optionValue(optcontext, args, opt.name, opt.operator);
|
completion.optionValue(optcontext, opt.name, opt.operator);
|
||||||
|
|
||||||
// Fill in the current values if we're removing
|
// Fill in the current values if we're removing
|
||||||
if (opt.operator == "-" && isArray(opt.values)) {
|
if (opt.operator == "-" && isArray(opt.values)) {
|
||||||
@@ -975,7 +975,7 @@ const Options = Module("options", {
|
|||||||
context.maxItems = optcontext.maxItems;
|
context.maxItems = optcontext.maxItems;
|
||||||
|
|
||||||
context.filters.push(function (i) !set.has(have, i.text));
|
context.filters.push(function (i) !set.has(have, i.text));
|
||||||
completion.optionValue(context, args, opt.name, opt.operator, null,
|
completion.optionValue(context, opt.name, opt.operator, null,
|
||||||
function (context) {
|
function (context) {
|
||||||
context.generate = function () option.value.map(function (o) [o, ""]);
|
context.generate = function () option.value.map(function (o) [o, ""]);
|
||||||
});
|
});
|
||||||
@@ -1136,7 +1136,7 @@ const Options = Module("options", {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
completion: function () {
|
completion: function () {
|
||||||
completion.option = function option(context, args, scope, prefix) {
|
completion.option = function option(context, scope, prefix) {
|
||||||
context.title = ["Option"];
|
context.title = ["Option"];
|
||||||
context.keys = { text: "names", description: "description" };
|
context.keys = { text: "names", description: "description" };
|
||||||
context.completions = options;
|
context.completions = options;
|
||||||
@@ -1148,7 +1148,7 @@ const Options = Module("options", {
|
|||||||
context.filters.push(function ({ item }) item.scope & scope);
|
context.filters.push(function ({ item }) item.scope & scope);
|
||||||
};
|
};
|
||||||
|
|
||||||
completion.optionValue = function (context, args, name, op, curValue, completer) {
|
completion.optionValue = function (context, name, op, curValue, completer) {
|
||||||
let opt = options.get(name);
|
let opt = options.get(name);
|
||||||
completer = completer || opt.completer;
|
completer = completer || opt.completer;
|
||||||
if (!completer || !opt)
|
if (!completer || !opt)
|
||||||
|
|||||||
Reference in New Issue
Block a user