1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 04:57:59 +01:00

minor refactoring of :command action

This commit is contained in:
Doug Kearns
2008-12-19 23:50:12 +11:00
committed by Kris Maglione
parent d277dd5c1c
commit 39d6542e80

View File

@@ -759,19 +759,20 @@ function Commands() //{{{
{
if (/^custom,/.test(completeOpt))
{
completeOpt = completeOpt.substr(7);
completeFunc = function ()
{
try
{
var completer = liberator.eval(completeOpt.substr(7));
var completer = liberator.eval(completeOpt);
if (!(completer instanceof Function))
throw new TypeError("User-defined custom completer '" + completeOpt.substr(7) + "' is not a function");
throw new TypeError("User-defined custom completer '" + completeOpt + "' is not a function");
}
catch (e)
{
// FIXME: should be pushed to the MOW
liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7));
liberator.echoerr("E117: Unknown function: " + completeOpt);
liberator.log(e);
return undefined;
}
@@ -784,8 +785,7 @@ function Commands() //{{{
}
}
if (!commands.addUserCommand(
[cmd],
let added = commands.addUserCommand([cmd],
"User defined command",
userCommand,
{
@@ -798,13 +798,11 @@ function Commands() //{{{
return completeFunc(context, args)
},
replacementText: args.literalArg
},
args.bang)
)
{
}, args.bang);
if (!added)
liberator.echoerr("E174: Command already exists: add ! to replace it");
}
}
else
{
function completerToString(completer)