1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 13:52:26 +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; 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 ////////////////////////////////////////// ////////////////////// PUBLIC SECTION //////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
@@ -501,11 +513,16 @@ liberator.Commands = function () //{{{
if (exCommands[i].name == command.name) if (exCommands[i].name == command.name)
{ {
if (!replace) if (!replace)
{
return false; return false;
}
else else
{
removeUserCommand(command.name);
break; break;
} }
} }
}
exCommands.push(command); exCommands.push(command);
return true; return true;
@@ -589,8 +606,8 @@ liberator.Commands = function () //{{{
{ {
if (!liberator.commands.addUserCommand([cmd], if (!liberator.commands.addUserCommand([cmd],
"User defined command", "User defined command",
function (args, special, count, modifiers) { eval(rep) }), function (args, special, count, modifiers) { eval(rep) },
special); null, special))
{ {
liberator.echoerr("E174: Command already exists: add ! to replace it"); liberator.echoerr("E174: Command already exists: add ! to replace it");
} }