1
0
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:
Doug Kearns
2010-11-09 00:05:26 +11:00
parent f004a80d55
commit fd9ca1487d
8 changed files with 34 additions and 33 deletions

View File

@@ -215,6 +215,7 @@ const Abbreviations = Module("abbreviations", {
}, {
}, {
completion: function () {
// TODO: shouldn't all of these have a standard signature (context, args, ...)? --djk
completion.abbreviation = function abbreviation(context, args, modes) {
if (args.completeArg == 0) {
let abbrevs = abbreviations.merged.filter(function (abbr) abbr.inModes(modes));

View File

@@ -385,7 +385,7 @@ const Bookmarks = Module("bookmarks", {
for ([, win] in Iterator(frames))];
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]
});
@@ -400,7 +400,7 @@ const Bookmarks = Module("bookmarks", {
bang: true,
completer: function completer(context, args) {
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,
{
@@ -442,7 +442,7 @@ const Bookmarks = Module("bookmarks", {
argCount: "?",
bang: true,
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)),
literal: 0,
options: [tags, title, keyword],
@@ -487,8 +487,8 @@ const Bookmarks = Module("bookmarks", {
"Set the default search engine",
"string", "google",
{
completer: function completer(context, args) {
completion.search(context, args, true);
completer: function completer(context) {
completion.search(context, true);
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",
"stringlist", "google",
{
completer: function completer(context, args) completion.searchEngine(context, args, true),
completer: function completer(context) completion.searchEngine(context, true),
});
},
completion: function () {
completion.bookmark = function bookmark(context, args, tags, extra) {
completion.bookmark = function bookmark(context, tags, extra) {
context.title = ["Bookmark", "Title"];
context.format = bookmarks.format;
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.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 keywords = bookmarks.getKeywords();
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({});
if (suggest)
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]);
};
completion.searchEngineSuggest = function searchEngineSuggest(context, args, engineAliases, kludge) {
completion.searchEngineSuggest = function searchEngineSuggest(context, engineAliases, kludge) {
if (!context.filter)
return;

View File

@@ -1259,7 +1259,7 @@ const Buffer = Module("buffer", {
{
argCount: "?",
completer: function (context) {
completion.optionValue(context, args, "pageinfo", "+", "");
completion.optionValue(context, "pageinfo", "+", "");
context.title = ["Page Info"];
}
});
@@ -1374,7 +1374,7 @@ const Buffer = Module("buffer", {
{
argCount: "?",
bang: true,
completer: function (context, args) completion.url(context, args, "bhf")
completer: function (context) completion.url(context, "bhf")
});
commands.add(["zo[om]"],

View File

@@ -765,7 +765,7 @@ const Completion = Module("completion", {
// may consist of search engines, filenames, bookmarks and history,
// depending on 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 start = 0;
let skip = 0;
@@ -794,7 +794,7 @@ const Completion = Module("completion", {
this.urlCompleters[opt] = completer;
},
urls: function (context, args, tags) {
urls: function (context, tags) {
let compare = String.localeCompare;
let contains = String.indexOf;
if (context.ignoreCase) {

View File

@@ -1685,7 +1685,7 @@ const Dactyl = Module("dactyl", {
}, {
argCount: "?",
bang: true,
completer: function (context, args) completion.help(context, args, unchunked),
completer: function (context) completion.help(context, unchunked),
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();
context.title = ["Help"];
context.anchored = false;

View File

@@ -218,7 +218,7 @@ const History = Module("history", {
].slice(2);
};
completion.history = function _history(context, args, maxItems) {
completion.history = function _history(context, maxItems) {
context.format = history.format;
context.title = ["History"];
context.compare = CompletionContext.Sort.unsorted;

View File

@@ -504,7 +504,7 @@ lookup:
}
}, {
argCount: "?",
completer: function (context) completion.directory(context, args, true),
completer: function (context) completion.directory(context, true),
literal: 0
});
@@ -550,7 +550,7 @@ lookup:
}, {
argCount: "*", // FIXME: should be "?" but kludged for proper error message
bang: true,
completer: function (context) completion.file(context, args, true)
completer: function (context) completion.file(context, true)
});
commands.add(["runt[ime]"],
@@ -582,7 +582,7 @@ lookup:
}, {
argCount: "+", // FIXME: should be "1" but kludged for proper error message
bang: true,
completer: function (context) completion.file(context, args, true)
completer: function (context) completion.file(context, true)
});
commands.add(["!", "run"],
@@ -635,8 +635,8 @@ lookup:
context.generate = function () iter(services.get("charset").getDecoderList());
};
completion.directory = function directory(context, args, full) {
this.file(context, args, full);
completion.directory = function directory(context, full) {
this.file(context, full);
context.filters.push(function ({ item }) item.isDirectory());
};
@@ -649,7 +649,7 @@ lookup:
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] = (dir || context.filter).match(/^(?:.*[\/\\])?/);
@@ -687,7 +687,7 @@ lookup:
for (let [, dir] in Iterator(options["runtimepath"]))
context.fork(dir, 0, this, function (context) {
dir = dir.replace("/+$", "") + "/";
completion.file(context, args, true, dir + context.filter);
completion.file(context, true, dir + context.filter);
context.title[0] = dir;
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))
completion.file(context, args, full);
completion.file(context, full);
});
},
javascript: function () {
JavaScript.setCompleter([File, File.expandPath],
[function (context, obj, args) {
context.quote[2] = "";
completion.file(context, args, true);
completion.file(context, true);
}]);
},

View File

@@ -939,7 +939,7 @@ const Options = Module("options", {
if (context.filter.indexOf("=") == -1) {
if (false && prefix)
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;
@@ -965,7 +965,7 @@ const Options = Module("options", {
}
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
if (opt.operator == "-" && isArray(opt.values)) {
@@ -975,7 +975,7 @@ const Options = Module("options", {
context.maxItems = optcontext.maxItems;
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) {
context.generate = function () option.value.map(function (o) [o, ""]);
});
@@ -1136,7 +1136,7 @@ const Options = Module("options", {
});
},
completion: function () {
completion.option = function option(context, args, scope, prefix) {
completion.option = function option(context, scope, prefix) {
context.title = ["Option"];
context.keys = { text: "names", description: "description" };
context.completions = options;
@@ -1148,7 +1148,7 @@ const Options = Module("options", {
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);
completer = completer || opt.completer;
if (!completer || !opt)