1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 10:57:58 +01:00

More completion stuff

This commit is contained in:
Kris Maglione
2008-11-22 23:42:59 +00:00
parent d3449c2f50
commit 77dca6413f
5 changed files with 82 additions and 70 deletions

View File

@@ -280,8 +280,15 @@ function Bookmarks() //{{{
},
{ argCount: "0" });
function tags() util.Array.uniq(util.Array.flatten([b.tags for ([k, b] in Iterator(cache.bookmarks))]))
.map(function (tag) [tag, tag]);
function tags(context, args)
{
let filter = args.completeFilter;
let have = filter.split(",");
args.completeFilter = have.pop();
let prefix = filter.substr(0, filter.length - args.completeFilter.length);
let tags = util.Array.uniq(util.Array.flatten([b.tags for ([k, b] in Iterator(cache.bookmarks))]));
return [[prefix + tag, tag] for ([i, tag] in Iterator(tags)) if (have.indexOf(tag) < 0)];
}
commands.add(["bma[rk]"],
"Add a bookmark",
@@ -318,13 +325,7 @@ function Bookmarks() //{{{
},
{
bang: true,
completer: function (context, args)
{
if (args.completeOpt)
return;
context.advance(args.completeStart); // TODO: Move this to completion.ex?
completion.url(context, "b");
},
completer: function (context, args) completion.url(context, "b"),
options: [[["-tags", "-T"], commands.OPTION_LIST, null, tags]]
});