mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-04 10:25:48 +01:00
Fix :delbmarks -k, -tags completion, etc.
This commit is contained in:
@@ -243,7 +243,7 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// if openItems is true, open the matching bookmarks items in tabs rather than display
|
// if openItems is true, open the matching bookmarks items in tabs rather than display
|
||||||
list: function list(filter, tags, openItems, maxItems) {
|
list: function list(filter, tags, openItems, maxItems, extra) {
|
||||||
// FIXME: returning here doesn't make sense
|
// FIXME: returning here doesn't make sense
|
||||||
// Why the hell doesn't it make sense? --Kris
|
// Why the hell doesn't it make sense? --Kris
|
||||||
// Because it unconditionally bypasses the final error message
|
// Because it unconditionally bypasses the final error message
|
||||||
@@ -251,8 +251,8 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
// short it breaks the :bmarks command which doesn't make much
|
// short it breaks the :bmarks command which doesn't make much
|
||||||
// sense to me but I'm old-fashioned. --djk
|
// sense to me but I'm old-fashioned. --djk
|
||||||
if (!openItems)
|
if (!openItems)
|
||||||
return completion.listCompleter("bookmark", filter, maxItems, tags);
|
return completion.listCompleter("bookmark", filter, maxItems, tags, extra);
|
||||||
let items = completion.runCompleter("bookmark", filter, maxItems, tags);
|
let items = completion.runCompleter("bookmark", filter, maxItems, tags, extra);
|
||||||
|
|
||||||
if (items.length)
|
if (items.length)
|
||||||
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
|
return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
|
||||||
@@ -290,8 +290,9 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
args.completeFilter = have.pop();
|
args.completeFilter = have.pop();
|
||||||
|
|
||||||
let prefix = filter.substr(0, filter.length - args.completeFilter.length);
|
let prefix = filter.substr(0, filter.length - args.completeFilter.length);
|
||||||
let tags = array.uniq(array.flatten([b.tags for ([k, b] in Iterator(bookmarkcache.bookmarks))]));
|
let tags = array.uniq(array.flatten([b.tags for ([k, b] in Iterator(bookmarkcache.bookmarks)) if (b.tags)]));
|
||||||
|
|
||||||
|
context.keys = { text: 0, description: 1 };
|
||||||
return [[prefix + tag, tag] for ([i, tag] in Iterator(tags)) if (have.indexOf(tag) < 0)];
|
return [[prefix + tag, tag] for ([i, tag] in Iterator(tags)) if (have.indexOf(tag) < 0)];
|
||||||
},
|
},
|
||||||
type: CommandOption.LIST
|
type: CommandOption.LIST
|
||||||
@@ -314,8 +315,6 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
names: ["-keyword", "-k"],
|
names: ["-keyword", "-k"],
|
||||||
description: "Keyword by which this bookmark may be opened (:open {keyword})",
|
description: "Keyword by which this bookmark may be opened (:open {keyword})",
|
||||||
completer: function keyword(context, args) {
|
completer: function keyword(context, args) {
|
||||||
if (!args.bang)
|
|
||||||
return [];
|
|
||||||
context.keys.text = "keyword";
|
context.keys.text = "keyword";
|
||||||
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: context.filter, title: args["-title"] });
|
return bookmarks.get(args.join(" "), args["-tags"], null, { keyword: context.filter, title: args["-title"] });
|
||||||
},
|
},
|
||||||
@@ -355,16 +354,17 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
commands.add(["bmarks"],
|
commands.add(["bmarks"],
|
||||||
"List or open multiple bookmarks",
|
"List or open multiple bookmarks",
|
||||||
function (args) {
|
function (args) {
|
||||||
bookmarks.list(args.join(" "), args["-tags"] || [], args.bang, args["-max"]);
|
bookmarks.list(args.join(" "), args["-tags"] || [], args.bang, args["-max"],
|
||||||
|
{ keyword: args["-keyword"], title: args["-title"] });
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
bang: true,
|
bang: true,
|
||||||
completer: function completer(context, args) {
|
completer: function completer(context, args) {
|
||||||
context.quote = null;
|
context.quote = null;
|
||||||
context.filter = args.join(" ");
|
context.filter = args.join(" ");
|
||||||
completion.bookmark(context, args["-tags"]);
|
completion.bookmark(context, args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
|
||||||
},
|
},
|
||||||
options: [tags,
|
options: [tags, keyword, title,
|
||||||
{
|
{
|
||||||
names: ["-max", "-m"],
|
names: ["-max", "-m"],
|
||||||
description: "The maximum number of items to list or open",
|
description: "The maximum number of items to list or open",
|
||||||
@@ -472,8 +472,8 @@ const Bookmarks = Module("bookmarks", {
|
|||||||
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]) {
|
||||||
if (v)
|
if (v != null)
|
||||||
context.filters.push(function (item) this.matchString(v, item[k]));
|
context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k]));
|
||||||
});
|
});
|
||||||
context.completions = bookmarkcache.bookmarks;
|
context.completions = bookmarkcache.bookmarks;
|
||||||
completion.urls(context, tags);
|
completion.urls(context, tags);
|
||||||
|
|||||||
Reference in New Issue
Block a user