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

fix :command so that it respects the special version and doesn't always output

the "command already exists" error message
This commit is contained in:
Doug Kearns
2008-05-27 16:53:38 +00:00
parent 9cb7ae4f36
commit 13d0eeaa1e

View File

@@ -435,6 +435,18 @@ liberator.Commands = function () //{{{
return matches;
}
function removeUserCommand(name)
{
for (var i = 0; i < exCommands.length; i++)
{
if (exCommands[i].isUserCommand && exCommands[i].name == name)
{
exCommands.splice(i, 1);
break;
}
}
}
/////////////////////////////////////////////////////////////////////////////}}}
////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{
@@ -501,11 +513,16 @@ liberator.Commands = function () //{{{
if (exCommands[i].name == command.name)
{
if (!replace)
{
return false;
}
else
{
removeUserCommand(command.name);
break;
}
}
}
exCommands.push(command);
return true;
@@ -589,8 +606,8 @@ liberator.Commands = function () //{{{
{
if (!liberator.commands.addUserCommand([cmd],
"User defined command",
function (args, special, count, modifiers) { eval(rep) }),
special);
function (args, special, count, modifiers) { eval(rep) },
null, special))
{
liberator.echoerr("E174: Command already exists: add ! to replace it");
}