1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 09:48:00 +01:00

delay user-command custom completer evaluation until call time

This commit is contained in:
Doug Kearns
2008-12-17 17:26:15 +11:00
parent acb556d111
commit 58514ffd4f
2 changed files with 18 additions and 11 deletions

View File

@@ -757,14 +757,10 @@ function Commands() //{{{
if (completeOpt)
{
// TODO: Should we catch any eval error? It'll be reported anyway.
if (/^custom,/.test(completeOpt))
completeFunc = liberator.eval(completeOpt.substr(7));
completeFunc = completeOpt.substr(7);
else
completeFunc = completion[completeOptionMap[completeOpt]];
if (completeFunc == null)
return liberator.echoerr("No such completion function");
completeFunc = "completion." + completeOptionMap[completeOpt];
}
if (!commands.addUserCommand(
@@ -775,9 +771,20 @@ function Commands() //{{{
argCount: nargsOpt,
bang: bangOpt,
count: countOpt,
// TODO: handle missing function
//completer: completeFunc,
completer: function (context, args) eval(completeFunc(context, args)),
completer: function (context, args) {
if (completeFunc)
{
try
{
liberator.eval(completeFunc).call(completion, context, args)
}
catch (e)
{
// FIXME: should be pushed to the MOW
liberator.echoerr("E117: Unknown function: " + completeFunc);
}
}
},
replacementText: args.literalArg
},
args.bang)