1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 15:07:57 +01:00
This commit is contained in:
Kris Maglione
2008-12-18 18:21:01 -05:00
parent ac0b476988
commit c094a2dd2b
6 changed files with 87 additions and 35 deletions

View File

@@ -758,9 +758,30 @@ function Commands() //{{{
if (completeOpt)
{
if (/^custom,/.test(completeOpt))
completeFunc = completeOpt.substr(7);
else
completeFunc = "completion." + completeOptionMap[completeOpt];
{
completeFunc = function ()
{
try
{
var completer = liberator.eval(completeOpt.substr(7));
if (!(completer instanceof Function))
throw new TypeError("User-defined custom completer '" + completeOpt.substr(7) + "' is not a function");
}
catch (e)
{
// FIXME: should be pushed to the MOW
liberator.echoerr("E117: Unknown function: " + completeOpt.substr(7));
liberator.log(e);
return undefined;
}
return completer.apply(this, Array.slice(arguments));
}
}
else
{
completeFunc = function () completion[completeOptionMap[completeOpt]].apply(this, Array.slice(arguments));
}
}
if (!commands.addUserCommand(
@@ -773,24 +794,7 @@ function Commands() //{{{
count: countOpt,
completer: function (context, args) {
if (completeFunc)
{
try
{
var completer = liberator.eval(completeFunc);
if (!(completer instanceof Function))
throw new TypeError("User-defined custom completer '" + completeFunc + "' is not a function");
}
catch (e)
{
// FIXME: should be pushed to the MOW
liberator.echoerr("E117: Unknown function: " + completeFunc);
liberator.log(e);
return;
}
completer.call(completion, context, args)
}
return completeFunc(context, args)
},
replacementText: args.literalArg
},