diff --git a/common/content/commands.js b/common/content/commands.js index efd02ed4..cc1e060a 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -373,9 +373,8 @@ const Command = Class("Command", { // Prototype. const ex = { - __noSuchMethod__: function (meth, args) { - let cmd = commands.get(meth); - dactyl.assert(cmd, "No such command"); + _args: function (cmd, args) { + args = Array.slice(args); let res = cmd.newArgs(); if (isObject(args[0])) @@ -393,11 +392,31 @@ const ex = { } for (let [i, val] in array.iterItems(args)) res[i] = String(val); + return res; + }, - res.verify(); + _complete: function (cmd) + function _complete(context, func, obj, args) { + args = ex._args(cmd, args); + args.completeArg = args.length - 1; + if (cmd.completer && args.length) + return cmd.completer(context, args); + }, - return cmd.execute(res); - } + _run: function (name) { + let cmd = commands.get(name); + dactyl.assert(cmd, "No such command"); + + return update(function exCommand(options) { + let args = this._args(cmd, arguments); + args.verify(); + return cmd.execute(args); + }, { + dactylCompleter: this._complete(cmd) + }); + }, + + __noSuchMethod__: function (meth, args) this._run(meth).apply(this, args) }; /** @@ -439,9 +458,11 @@ const Commands = Module("commands", { if (!replace || !(args[3] && args[3].user)) dactyl.assert(!names.some(function (name) name in this._exMap, this), "Not replacing command " + args[0]); - for (let name in values(names)) + for (let name in values(names)) { + ex.__defineGetter__(name, function () this._run(name)); if (name in this._exMap) commands.removeUserCommand(name); + } let name = names[0]; let closure = function () commands._exMap[name]; diff --git a/pentadactyl/TODO b/pentadactyl/TODO index e7808e24..016ebc85 100644 --- a/pentadactyl/TODO +++ b/pentadactyl/TODO @@ -25,6 +25,7 @@ BUGS: (recent Mercurial regressions): FEATURES: +8 registers 8 Document Caret and Visual modes. 8 replace global variables with plugin scoped user options 8 fix local options @@ -53,9 +54,6 @@ FEATURES: 7 :grep support (needs location list) 6 :mksession 6 add [count] support to :b* and :tab* commands where missing -6 registers - Here, unlike Vim, y and "*y would be equivalent. That is, the pasteboard would - always be the default register. --Ted 6 check/correct spellings in insert mode with some mappings 6 add more autocommands (TabClose, TabOpen, TabChanged etc) 6 Use ctrl-w+j/k/w to switch between sidebar, content, preview window