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:
@@ -423,7 +423,7 @@ liberator.Commands = function () //{{{
|
|||||||
{
|
{
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
if (exCommands[i].name.match("^"+name))
|
if (exCommands[i].name.match("^" + name))
|
||||||
matches.push(exCommands[i]);
|
matches.push(exCommands[i]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -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");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user