diff --git a/common/content/commands.js b/common/content/commands.js index 749cdf36..0bd57a01 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -269,6 +269,7 @@ var Command = Class("Command", { { __iterator__: function () array.iterItems(this), command: this, + explicitOpts: Class.memoize(function () ({})), get literalArg() this.command.literal != null && this[this.command.literal] || "", // TODO: string: Class.memoize(function () { ... }), verify: function verify() { @@ -396,7 +397,8 @@ var ex = { let val = opt.type && opt.type.parse(v); dactyl.assert(val != null && (typeof val !== "number" || !isNaN(val)), "No such option: " + k); - res[opt.names[0]] = val; + Class.replaceProperty(args, opt.names[0], val); + args.explicitOpts[opt.names[0]] = val; } for (let [i, val] in array.iterItems(args)) res[i] = String(val); @@ -921,6 +923,8 @@ var Commands = Module("commands", { else Class.replaceProperty(args, opt.names[0], opt.type == CommandOption.NOARG || arg); + args.explicitOpts[opt.names[0]] = args[opt.names[0]]; + i += optname.length + count; if (i == str.length) break outer; diff --git a/common/content/mappings.js b/common/content/mappings.js index fce82cf7..e72b2651 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -276,6 +276,8 @@ var Mappings = Module("mappings", { hives: Class.memoize(function () array(this.allHives.filter(function (h) h.filter(buffer.uri)))), + get userHives() this.allHives.filter(function (h) h !== this.builtinHive, this), + _addMap: function (map, hive) { map.definedAt = commands.getCaller(Components.stack.caller.caller); map.hive = hive; @@ -398,30 +400,40 @@ var Mappings = Module("mappings", { * @param {number[]} modes An array of modes to search. * @param {string} filter The filter string to match. */ - list: function (modes, filter) { + list: function (modes, filter, hives) { + hives = hives || mappings.userHives; + let modeSign = ""; + modes.filter(function (m) m.char).forEach(function (m) { modeSign += m.char; }); + modes.filter(function (m) !m.char).forEach(function (m) { modeSign += " " + m.name; }); + modeSign = modeSign.replace(/^ /, ""); - // TODO: Vim hides "nv" in a :map and "v" and "n" in :vmap and - // :nmap respectively if the map is not exclusive. - modes.forEach(function (mode) { - for (let m in modules.modes.mainModes) - if (mode == m.mask && modeSign.indexOf(m.char) == -1) - modeSign += m.char; - }); - - let maps = this.userHive.iterate(modes); - if (filter) - maps = [map for (map in maps) if (map.names[0] == filter)]; + function maps(hive) { + let maps = hive.iterate(modes); + if (filter) + maps = [map for (map in maps) if (map.names[0] == filter)]; + return maps; + } let list =
| + | Mode | +Command | +Action | +
| {modeSign} {name} | -{map.noremap ? "*" : " "} | -{map.rhs || map.action.toSource()} | -|
| {!i++ ? hive.name : ""} | +{modeSign} | +{name} | +{map.rhs || map.action.toSource()} | +