1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-25 23:45:45 +01:00

Add -keywords, -tags, -title to :delbmarks.

This commit is contained in:
Kris Maglione
2010-09-27 09:05:28 -04:00
parent bed08a3455
commit 1944bed400
4 changed files with 37 additions and 14 deletions

View File

@@ -96,10 +96,14 @@ const Bookmarks = Module("bookmarks", {
// returns number of deleted bookmarks // returns number of deleted bookmarks
remove: function remove(url) { remove: function remove(url) {
try { try {
let uri = util.newURI(url); if (isArray(url))
let bmarks = services.get("bookmarks") var bmarks = url;
.getBookmarkIdsForURI(uri, {}) else {
.filter(bookmarkcache.closure.isRegularBookmark); let uri = util.newURI(url);
var bmarks = services.get("bookmarks")
.getBookmarkIdsForURI(uri, {})
.filter(bookmarkcache.closure.isRegularBookmark);
}
bmarks.forEach(services.get("bookmarks").removeItem); bmarks.forEach(services.get("bookmarks").removeItem);
return bmarks.length; return bmarks.length;
} }
@@ -382,10 +386,16 @@ const Bookmarks = Module("bookmarks", {
} }
}); });
else { else {
let url = args[0] || buffer.URL; if (!(args.length || args["-tags"] || args["-keyword"] || args["-title"]))
let deletedCount = bookmarks.remove(url); 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); 1, commandline.FORCE_SINGLELINE);
} }
@@ -393,8 +403,12 @@ const Bookmarks = Module("bookmarks", {
{ {
argCount: "?", argCount: "?",
bang: true, bang: true,
completer: function completer(context) completion.bookmark(context), completer: function completer(context)
literal: 0 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 () { mappings: function () {
@@ -457,11 +471,10 @@ const Bookmarks = Module("bookmarks", {
completion.bookmark = function bookmark(context, 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;
for (let val in Iterator(extra || [])) { forEach(iter(extra || {}), function ([k, v]) {
let [k, v] = val; // Need block scope here for the closure
if (v) if (v)
context.filters.push(function (item) this.matchString(v, item[k])); context.filters.push(function (item) this.matchString(v, item[k]));
} });
context.completions = bookmarkcache.bookmarks; context.completions = bookmarkcache.bookmarks;
completion.urls(context, tags); completion.urls(context, tags);
}; };

View File

@@ -120,11 +120,19 @@
<p>The bookmarks may also be filtered via the following options,</p> <p>The bookmarks may also be filtered via the following options,</p>
<dl> <dl>
<dt>-tag</dt> <dt>-keyword</dt>
<dd>
The bookmark's keyword (short name <em>-k</em>).
</dd>
<dt>-tags</dt>
<dd> <dd>
A comma-separated list of tags, all of which must be A comma-separated list of tags, all of which must be
present for a match (short name <em>-T</em>). present for a match (short name <em>-T</em>).
</dd> </dd>
<dt>-title</dt>
<dd>
The title of the bookmark (short name <em>-t</em>).
</dd>
<dt>-max</dt> <dt>-max</dt>
<dd> <dd>
The maximum number of items to list or open The maximum number of items to list or open
@@ -145,6 +153,8 @@
current buffer. current buffer.
</p> </p>
<p>Accepts the same options as :bmarks.</p>
<p>If <oa>!</oa> is specified then all bookmarks will be deleted.</p> <p>If <oa>!</oa> is specified then all bookmarks will be deleted.</p>
</description> </description>
</item> </item>

View File

@@ -41,6 +41,7 @@
* Added 'autocomplete' option for specifying which completion * Added 'autocomplete' option for specifying which completion
groups should be auto-completed. groups should be auto-completed.
* Added 'banghist' option. * Added 'banghist' option.
* Added -keyword, -tags, -title to :delbmarks
* Added 'hintkeys' option. * Added 'hintkeys' option.
* Replaced 'focuscontent' with 'strictfocus'. * Replaced 'focuscontent' with 'strictfocus'.
* Added 'wildanchor' option. * Added 'wildanchor' option.

View File

@@ -34,7 +34,6 @@ BUGS:
FEATURES: FEATURES:
9 Add quoting help tag 9 Add quoting help tag
9 Support multiple bookmarks, -keyword, -tags in :delbmarks
8 Document Caret and Visual modes. 8 Document Caret and Visual modes.
8 finish :help TODOs 8 finish :help TODOs
8 fix local options 8 fix local options