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