1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 10:08:00 +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*.