1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-07 19:04:11 +01:00

Better :qmark completion.

This commit is contained in:
Kris Maglione
2010-10-09 13:21:00 -04:00
parent 15df81361d
commit 8fb31f7696

View File

@@ -46,6 +46,14 @@ const QuickMarks = Module("quickmarks", {
return res;
},
/**
* Returns the URL of the given QuickMark, or null if none exists.
*
* @param {string} mark The mark to find.
* @returns {string} The mark's URL.
*/
get: function (mark) this._qmarks.get(mark) || null,
/**
* Deletes the specified quickmarks. The <b>filter</b> is a list of
* quickmarks and ranges are supported. Eg. "ab c d e-k".
@@ -77,7 +85,7 @@ const QuickMarks = Module("quickmarks", {
* URL. See {@link Dactyl#open}.
*/
jumpTo: function jumpTo(qmark, where) {
let url = this._qmarks.get(qmark);
let url = this.get(qmark);
if (url)
dactyl.open(url, where);
@@ -148,8 +156,17 @@ const QuickMarks = Module("quickmarks", {
{
argCount: "+",
completer: function (context, args) {
if (args.length == 2)
return completion.url(context);
if (args.length == 1)
return completion.quickmark(context);
if (args.length == 2) {
context.fork("current", 0, this, function (context) {
context.title = ["Extra Completions"];
context.completions = [
[quickmarks.get(args[0]), "Current Value"]
].filter(function ([k, v]) k);
});
context.fork("url", 0, completion, "url");
}
},
literal: 1
});
@@ -168,6 +185,12 @@ const QuickMarks = Module("quickmarks", {
literal: 0
});
},
completion: function () {
completion.quickmark = function (context) {
context.title = ["QuickMark", "URL"];
context.generate = function () Iterator(quickmarks._qmarks);
}
},
mappings: function () {
var myModes = config.browserModes;