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

refactor :delcommand action

This commit is contained in:
Doug Kearns
2008-11-10 13:24:51 +00:00
parent 1de3210214
commit c6ad5faf9c

View File

@@ -682,16 +682,10 @@ function Commands() //{{{
removeUserCommand: function (name)
{
for (let i = 0; i < exCommands.length; i++)
{
if (exCommands[i].isUserCommand && exCommands[i].hasName(name))
{
exCommands.splice(i, 1);
break;
}
}
exCommands = exCommands.filter(function (cmd) !(cmd.isUserCommand && cmd.hasName(name)));
},
// FIXME: still belong here? Also used for autocommand parameters
replaceTokens: function replaceTokens(str, tokens)
{
return str.replace(/<((?:q-)?)([a-zA-Z]+)?>/g, function (match, quote, token)
@@ -824,18 +818,11 @@ function Commands() //{{{
"Delete the specified user-defined command",
function (args)
{
var name = args.arguments[0];
var cmdlist = commands.getUserCommands();
let name = args.arguments[0];
for (let i = 0; i < cmdlist.length; i++)
{
if (cmdlist[i].name == name)
{
if (commands.get(name))
commands.removeUserCommand(name);
return;
}
}
else
liberator.echoerr("E184: No such user-defined command: " + name);
},
{