mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-22 06:47:58 +01:00
minor refactoring of :command action
This commit is contained in:
committed by
Kris Maglione
parent
d277dd5c1c
commit
39d6542e80
@@ -759,19 +759,20 @@ function Commands() //{{{
|
|||||||
{
|
{
|
||||||
if (/^custom,/.test(completeOpt))
|
if (/^custom,/.test(completeOpt))
|
||||||
{
|
{
|
||||||
|
completeOpt = completeOpt.substr(7);
|
||||||
completeFunc = function ()
|
completeFunc = function ()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var completer = liberator.eval(completeOpt.substr(7));
|
var completer = liberator.eval(completeOpt);
|
||||||
|
|
||||||
if (!(completer instanceof Function))
|
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)
|
catch (e)
|
||||||
{
|
{
|
||||||
// FIXME: should be pushed to the MOW
|
// FIXME: should be pushed to the MOW
|
||||||
liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7));
|
liberator.echoerr("E117: Unknown function: " + completeOpt);
|
||||||
liberator.log(e);
|
liberator.log(e);
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@@ -784,8 +785,7 @@ function Commands() //{{{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!commands.addUserCommand(
|
let added = commands.addUserCommand([cmd],
|
||||||
[cmd],
|
|
||||||
"User defined command",
|
"User defined command",
|
||||||
userCommand,
|
userCommand,
|
||||||
{
|
{
|
||||||
@@ -798,13 +798,11 @@ function Commands() //{{{
|
|||||||
return completeFunc(context, args)
|
return completeFunc(context, args)
|
||||||
},
|
},
|
||||||
replacementText: args.literalArg
|
replacementText: args.literalArg
|
||||||
},
|
}, args.bang);
|
||||||
args.bang)
|
|
||||||
)
|
if (!added)
|
||||||
{
|
|
||||||
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
liberator.echoerr("E174: Command already exists: add ! to replace it");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
function completerToString(completer)
|
function completerToString(completer)
|
||||||
|
|||||||
Reference in New Issue
Block a user