From 1944bed400adcc889f718e900f216c12d9fa2e48 Mon Sep 17 00:00:00 2001
From: Kris Maglione
Date: Mon, 27 Sep 2010 09:05:28 -0400
Subject: [PATCH] Add -keywords, -tags, -title to :delbmarks.
---
common/content/bookmarks.js | 37 +++++++++++++++++++++++------------
common/locale/en-US/marks.xml | 12 +++++++++++-
pentadactyl/NEWS | 1 +
pentadactyl/TODO | 1 -
4 files changed, 37 insertions(+), 14 deletions(-)
diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js
index 8d8a1772..70677a64 100644
--- a/common/content/bookmarks.js
+++ b/common/content/bookmarks.js
@@ -96,10 +96,14 @@ const Bookmarks = Module("bookmarks", {
// returns number of deleted bookmarks
remove: function remove(url) {
try {
- let uri = util.newURI(url);
- let bmarks = services.get("bookmarks")
- .getBookmarkIdsForURI(uri, {})
- .filter(bookmarkcache.closure.isRegularBookmark);
+ if (isArray(url))
+ var bmarks = url;
+ else {
+ let uri = util.newURI(url);
+ var bmarks = services.get("bookmarks")
+ .getBookmarkIdsForURI(uri, {})
+ .filter(bookmarkcache.closure.isRegularBookmark);
+ }
bmarks.forEach(services.get("bookmarks").removeItem);
return bmarks.length;
}
@@ -382,10 +386,16 @@ const Bookmarks = Module("bookmarks", {
}
});
else {
- let url = args[0] || buffer.URL;
- let deletedCount = bookmarks.remove(url);
+ if (!(args.length || args["-tags"] || args["-keyword"] || args["-title"]))
+ var deletedCount = bookmarks.remove(buffer.URL);
+ else {
+ let context = CompletionContext(args.join(" "));
+ context.fork("bookmark", 0, completion, "bookmark",
+ args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
+ var deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
+ }
- dactyl.echomsg({ domains: [util.getHost(url)], message: deletedCount + " bookmark(s) with url " + url.quote() + " deleted" },
+ dactyl.echomsg({ message: deletedCount + " bookmark(s) deleted" },
1, commandline.FORCE_SINGLELINE);
}
@@ -393,8 +403,12 @@ const Bookmarks = Module("bookmarks", {
{
argCount: "?",
bang: true,
- completer: function completer(context) completion.bookmark(context),
- literal: 0
+ completer: function completer(context)
+ 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],
+ privateData: true
});
},
mappings: function () {
@@ -457,11 +471,10 @@ const Bookmarks = Module("bookmarks", {
completion.bookmark = function bookmark(context, tags, extra) {
context.title = ["Bookmark", "Title"];
context.format = bookmarks.format;
- for (let val in Iterator(extra || [])) {
- let [k, v] = val; // Need block scope here for the closure
+ forEach(iter(extra || {}), function ([k, v]) {
if (v)
context.filters.push(function (item) this.matchString(v, item[k]));
- }
+ });
context.completions = bookmarkcache.bookmarks;
completion.urls(context, tags);
};
diff --git a/common/locale/en-US/marks.xml b/common/locale/en-US/marks.xml
index e83039f1..84f09bdd 100644
--- a/common/locale/en-US/marks.xml
+++ b/common/locale/en-US/marks.xml
@@ -120,11 +120,19 @@
The bookmarks may also be filtered via the following options,
- - -tag
+ - -keyword
+ -
+ The bookmark's keyword (short name -k).
+
+ - -tags
-
A comma-separated list of tags, all of which must be
present for a match (short name -T).
+ - -title
+ -
+ The title of the bookmark (short name -t).
+
- -max
-
The maximum number of items to list or open
@@ -145,6 +153,8 @@
current buffer.
+ Accepts the same options as :bmarks.
+
If ! is specified then all bookmarks will be deleted.
diff --git a/pentadactyl/NEWS b/pentadactyl/NEWS
index c6c492f8..fa039399 100644
--- a/pentadactyl/NEWS
+++ b/pentadactyl/NEWS
@@ -41,6 +41,7 @@
* Added 'autocomplete' option for specifying which completion
groups should be auto-completed.
* Added 'banghist' option.
+ * Added -keyword, -tags, -title to :delbmarks
* Added 'hintkeys' option.
* Replaced 'focuscontent' with 'strictfocus'.
* Added 'wildanchor' option.
diff --git a/pentadactyl/TODO b/pentadactyl/TODO
index 7a5e89af..8e61ac82 100644
--- a/pentadactyl/TODO
+++ b/pentadactyl/TODO
@@ -34,7 +34,6 @@ BUGS:
FEATURES:
9 Add quoting help tag
-9 Support multiple bookmarks, -keyword, -tags in :delbmarks
8 Document Caret and Visual modes.
8 finish :help TODOs
8 fix local options