1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-02 18:24:11 +01:00

Do something sensible for items defined from :map/:com/... in :*usage!.

This commit is contained in:
Kris Maglione
2010-12-09 22:25:20 -05:00
parent 4c9e73949c
commit 75342f09ec
4 changed files with 29 additions and 8 deletions

View File

@@ -453,7 +453,7 @@ const Commands = Module("commands", {
_addCommand: function (args, replace) {
if (!args[3])
args[3] = {};
args[3].definedAt = Components.stack.caller.caller;
args[3].definedAt = commands.getCaller(Components.stack.caller.caller);
let names = array.flatten(Command.parseSpecs(args[0]));
dactyl.assert(!names.some(function (name) name in this._exMap && !this._exMap[name].user, this),
@@ -636,6 +636,22 @@ const Commands = Module("commands", {
return this._exCommands.filter(function (cmd) cmd.user);
},
/**
* Returns a frame object describing the currently executing
* command, if applicable, otherwise returns the passed frame.
*
* @param {nsIStackFrame} frame
*/
getCaller: function (frame) {
if (io.sourcing)
return {
__proto__: frame,
filename: services.io.newFileURI(File(io.sourcing.file)).spec,
lineNumber: io.sourcing.line
};
return frame;
},
/**
* Returns true if a command invocation contains a URL referring to the
* domain *host*.

View File

@@ -140,7 +140,7 @@ const Mappings = Module("mappings", {
_addMap: function (map) {
let where = map.user ? this._user : this._main;
map.definedAt = Components.stack.caller.caller;
map.definedAt = commands.getCaller(Components.stack.caller.caller);
map.modes.forEach(function (mode) {
if (!(mode in where))
where[mode] = [];

View File

@@ -642,7 +642,7 @@ const Options = Module("options", {
if (!extraInfo)
extraInfo = {};
extraInfo.definedAt = Components.stack.caller;
extraInfo.definedAt = commands.getCaller(Components.stack.caller);
let name = names[0];
if (name in this._optionMap) {