mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 14:12:27 +01:00
refactor :delcommand action
This commit is contained in:
@@ -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,19 +818,12 @@ 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))
|
||||||
{
|
commands.removeUserCommand(name);
|
||||||
if (cmdlist[i].name == name)
|
else
|
||||||
{
|
liberator.echoerr("E184: No such user-defined command: " + name);
|
||||||
commands.removeUserCommand(name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
liberator.echoerr("E184: No such user-defined command: " + name);
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "1",
|
||||||
|
|||||||
Reference in New Issue
Block a user