diff --git a/common/content/commands.js b/common/content/commands.js index 6d2e3098..f7e3f8f9 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -36,7 +36,7 @@ * @property {string} description A description of the option */ -const CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description"); +const CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description", "default"); CommandOption.defaultValue("description", function () ""); CommandOption.defaultValue("type", function () CommandOption.NOARG); CommandOption.defaultValue("multiple", function () false); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 86473575..3b04aeb0 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -642,16 +642,7 @@ const Dactyl = Module("dactyl", { let br = <> ; - if (obj.completer) - var completions = let (br = br + <> ) <> -
{ br + - template.map( - completion._runCompleter(obj.completer, "", null, args).items, - function (i) <>
{i.text}
{i.description}
, - br) } -
; - - return <> + let res =
{link(obj.name)}
{obj.description ? obj.description.replace(/\.$/, "") : ""}
{template.map(obj.names, tag, " ")} @@ -662,10 +653,34 @@ const Dactyl = Module("dactyl", { { obj.description ? br+

{obj.description.replace(/\.?$/, ".")}

: "" }{ extraHelp ? br+extraHelp : "" }{ - !(extraHelp || obj.description) ? br+

Sorry, no help available.

: "" }{ - completions ? br + completions : "" } + !(extraHelp || obj.description) ? br+

Sorry, no help available.

: "" }
-
.toXMLString().replace(/^ {12}/gm, ""); +
; + + function add(ary) { + res.item.description.* += br + + let (br = br + <> ) + <>
{ br + template.map(ary, function ([a, b]) <>
{a}
{b}
, br) } +
+ ; + } + + if (obj.completer) + add(completion._runCompleter(obj.completer, "", null, args).items + .map(function (i) [i.text, i.description])); + + if (obj.options && obj.options.some(function (o) o.description)) + add(obj.options.filter(function (o) o.description) + .map(function (o) [ + o.names[0], + <>{o.description}{ + o.names.length == 1 ? "" : + <> (short name: { + template.map(o.names.slice(1), function (n) {n}, <>, ) + }) + } + ])); + return res.*.toXMLString().replace(/^ {12}/gm, "");; }, /** diff --git a/common/content/history.js b/common/content/history.js index aa4a6f3e..ecc4644c 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -195,11 +195,11 @@ const History = Module("history", { commands.add(["hist[ory]", "hs"], "Show recently visited URLs", - function (args) { history.list(args.join(" "), args.bang, args["-max"] || 1000); }, { + function (args) { history.list(args.join(" "), args.bang, args["-max"]); }, { bang: true, completer: function (context) { context.quote = null; completion.history(context); }, // completer: function (filter) completion.history(filter) - options: [{ names: ["-max", "-m"], description: "The maximum number of items to list", type: CommandOption.INT }], + options: [{ names: ["-max", "-m"], description: "The maximum number of items to list", default: 1000, type: CommandOption.INT }], privateData: true }); }, diff --git a/common/content/mappings.js b/common/content/mappings.js index 6768a97a..bbcef4b5 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -351,7 +351,7 @@ const Mappings = Module("mappings", { // 1 arg -> list the maps starting with args // 2 args -> map arg1 to arg* function map(args, mapmodes, noremap) { - mapmodes = getModes(args, mapmodes); + mapmodes = getModes(args); if (!args.length) { mappings.list(mapmodes); return; @@ -394,8 +394,8 @@ const Mappings = Module("mappings", { return mode.mask; return null; } - function getModes(args, def) - array.uniq((args["-modes"] || def || ["n", "v"]).map(findMode)); + function getModes(args) + array.uniq(args["-modes"].map(findMode)); function uniqueModes(modes) { modes = modes.map(modules.modes.closure.getMode); let chars = [k for ([k, v] in Iterator(modules.modes.modeChars)) @@ -442,6 +442,7 @@ const Mappings = Module("mappings", { names: ["-modes", "-mode", "-m"], type: CommandOption.LIST, description: "Create this mapping in the given modes", + default: mapmodes || ["n", "v"], validator: function (list) !list || list.every(findMode), completer: function () [[array.compact([mode.name.toLowerCase(), mode.char]), mode.disp] for (mode in modes.mainModes)], diff --git a/common/modules/base.jsm b/common/modules/base.jsm index f27b2fac..126ab13f 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -213,6 +213,8 @@ function debuggerProperties(obj) { * @returns {Generator} */ function prototype(obj) + // Temporary hack: + typeof obj === "xml" || obj.__proto__ !== obj.__proto__ ? null : obj.__proto__ || Object.getPrototypeOf(obj) || XPCNativeWrapper.unwrap(obj).__proto__ || Object.getPrototypeOf(XPCNativeWrapper.unwrap(obj));