mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-04 07:44:10 +01:00
Replace :abc, :comc, :mapc with :unab!, :delc!, :unmap!. Add bang to :styt, :delsty, ...
This commit is contained in:
@@ -296,25 +296,19 @@ var Abbreviations = Module("abbreviations", {
|
|||||||
commands.add([ch + "una[bbreviate]"],
|
commands.add([ch + "una[bbreviate]"],
|
||||||
"Remove an abbreviation" + modeDescription,
|
"Remove an abbreviation" + modeDescription,
|
||||||
function (args) {
|
function (args) {
|
||||||
let lhs = args.literalArg;
|
util.assert(args.bang ^ !!args[0], "Argument or ! required");
|
||||||
if (!lhs)
|
|
||||||
return dactyl.echoerr("E474: Invalid argument");
|
if (args.bang)
|
||||||
if (!args["-group"].remove(modes, lhs))
|
args["-group"].clear(modes);
|
||||||
|
else if (!args["-group"].remove(modes, lhs))
|
||||||
return dactyl.echoerr("E24: No such abbreviation");
|
return dactyl.echoerr("E24: No such abbreviation");
|
||||||
}, {
|
}, {
|
||||||
argCount: "1",
|
argCount: "?",
|
||||||
|
bang: true,
|
||||||
completer: function (context) completion.abbreviation(context, modes, args["-group"]),
|
completer: function (context) completion.abbreviation(context, modes, args["-group"]),
|
||||||
literal: 0,
|
literal: 0,
|
||||||
options: [contexts.GroupFlag("abbrevs")]
|
options: [contexts.GroupFlag("abbrevs")]
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add([ch + "abc[lear]"],
|
|
||||||
"Remove all abbreviations" + modeDescription,
|
|
||||||
function (args) { args["-group"].clear(modes); },
|
|
||||||
{
|
|
||||||
argCount: "0",
|
|
||||||
options: [contexts.GroupFlag("abbrevs")]
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addAbbreviationCommands([modes.INSERT, modes.COMMAND_LINE], "", "");
|
addAbbreviationCommands([modes.INSERT, modes.COMMAND_LINE], "", "");
|
||||||
|
|||||||
@@ -575,50 +575,31 @@ var Mappings = Module("mappings", {
|
|||||||
function (args) { map(args, true); },
|
function (args) { map(args, true); },
|
||||||
opts);
|
opts);
|
||||||
|
|
||||||
commands.add([ch + "mapc[lear]"],
|
|
||||||
"Remove all mappings" + modeDescription,
|
|
||||||
function (args) {
|
|
||||||
util.assert(args["-group"].modifiable,
|
|
||||||
"Cannot change mappings in the builtin group");
|
|
||||||
|
|
||||||
let mapmodes = array.uniq(args["-modes"].map(findMode));
|
|
||||||
mapmodes.forEach(function (mode) {
|
|
||||||
args["-group"].clear(mode);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
{
|
|
||||||
argCount: "0",
|
|
||||||
options: [
|
|
||||||
contexts.GroupFlag("mappings"),
|
|
||||||
update({}, modeFlag, {
|
|
||||||
names: ["-modes", "-mode", "-m"],
|
|
||||||
type: CommandOption.LIST,
|
|
||||||
description: "Remove all mappings from the given modes",
|
|
||||||
default: mapmodes || ["n", "v"]
|
|
||||||
})
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
commands.add([ch + "unm[ap]"],
|
commands.add([ch + "unm[ap]"],
|
||||||
"Remove a mapping" + modeDescription,
|
"Remove a mapping" + modeDescription,
|
||||||
function (args) {
|
function (args) {
|
||||||
util.assert(args["-group"].modifiable,
|
util.assert(args["-group"].modifiable,
|
||||||
"Cannot change mappings in the builtin group");
|
"Cannot change mappings in the builtin group");
|
||||||
|
|
||||||
|
util.assert(args.bang ^ !!args[0], "Argument or ! required");
|
||||||
|
|
||||||
let mapmodes = array.uniq(args["-modes"].map(findMode));
|
let mapmodes = array.uniq(args["-modes"].map(findMode));
|
||||||
|
|
||||||
let found = false;
|
let found = 0;
|
||||||
for (let [, mode] in Iterator(mapmodes)) {
|
for (let mode in values(mapmodes))
|
||||||
if (args["-group"].has(mode, args[0])) {
|
if (args.bang)
|
||||||
|
args["-group"].clear(mode);
|
||||||
|
else if (args["-group"].has(mode, args[0])) {
|
||||||
args["-group"].remove(mode, args[0]);
|
args["-group"].remove(mode, args[0]);
|
||||||
found = true;
|
found++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!found)
|
if (!found && !args.bang)
|
||||||
dactyl.echoerr("E31: No such mapping");
|
dactyl.echoerr("E31: No such mapping");
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
argCount: "1",
|
argCount: "?",
|
||||||
|
bang: true,
|
||||||
completer: opts.completer,
|
completer: opts.completer,
|
||||||
options: [
|
options: [
|
||||||
contexts.GroupFlag("mappings"),
|
contexts.GroupFlag("mappings"),
|
||||||
|
|||||||
@@ -622,6 +622,7 @@ var Commands = Module("commands", {
|
|||||||
* Displays a list of user-defined commands.
|
* Displays a list of user-defined commands.
|
||||||
*/
|
*/
|
||||||
list: function list() {
|
list: function list() {
|
||||||
|
const { commandline, completion } = this.modules;
|
||||||
function completerToString(completer) {
|
function completerToString(completer) {
|
||||||
if (completer)
|
if (completer)
|
||||||
return [k for ([k, v] in Iterator(config.completers)) if (completer == completion.closure[v])][0] || "custom";
|
return [k for ([k, v] in Iterator(config.completers)) if (completer == completion.closure[v])][0] || "custom";
|
||||||
@@ -631,7 +632,7 @@ var Commands = Module("commands", {
|
|||||||
if (!this.userHives.some(function (h) h._list.length))
|
if (!this.userHives.some(function (h) h._list.length))
|
||||||
dactyl.echomsg("No user-defined commands found");
|
dactyl.echomsg("No user-defined commands found");
|
||||||
else
|
else
|
||||||
modules.commandline.commandOutput(
|
commandline.commandOutput(
|
||||||
<table>
|
<table>
|
||||||
<tr highlight="Title">
|
<tr highlight="Title">
|
||||||
<td/>
|
<td/>
|
||||||
@@ -1487,13 +1488,22 @@ var Commands = Module("commands", {
|
|||||||
.flatten().array
|
.flatten().array
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["comc[lear]"],
|
commands.add(["delc[ommand]"],
|
||||||
"Delete all user-defined commands",
|
"Delete the specified user-defined command",
|
||||||
function (args) {
|
function (args) {
|
||||||
args["-group"].clear();
|
util.assert(args.bang ^ !!args[0], "Argument or ! required");
|
||||||
},
|
let name = args[0];
|
||||||
{
|
|
||||||
argCount: "0",
|
if (args.bang)
|
||||||
|
args["-group"].clear();
|
||||||
|
else if (args["-group"].get(name))
|
||||||
|
args["-group"].remove(name);
|
||||||
|
else
|
||||||
|
dactyl.echoerr("E184: No such user-defined command: " + name);
|
||||||
|
}, {
|
||||||
|
argCount: "?",
|
||||||
|
bang: true,
|
||||||
|
completer: function (context, args) modules.completion.userCommand(context, args["-group"]),
|
||||||
options: [contexts.GroupFlag("commands")]
|
options: [contexts.GroupFlag("commands")]
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1506,21 +1516,6 @@ var Commands = Module("commands", {
|
|||||||
literal: 0
|
literal: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
commands.add(["delc[ommand]"],
|
|
||||||
"Delete the specified user-defined command",
|
|
||||||
function (args) {
|
|
||||||
let name = args[0];
|
|
||||||
|
|
||||||
if (args["-group"].get(name))
|
|
||||||
args["-group"].remove(name);
|
|
||||||
else
|
|
||||||
dactyl.echoerr("E184: No such user-defined command: " + name);
|
|
||||||
}, {
|
|
||||||
argCount: "1",
|
|
||||||
completer: function (context, args) modules.completion.userCommand(context, args["-group"]),
|
|
||||||
options: [contexts.GroupFlag("commands")]
|
|
||||||
});
|
|
||||||
|
|
||||||
dactyl.addUsageCommand({
|
dactyl.addUsageCommand({
|
||||||
name: ["listc[ommands]", "lc"],
|
name: ["listc[ommands]", "lc"],
|
||||||
description: "List all Ex commands along with their short descriptions",
|
description: "List all Ex commands along with their short descriptions",
|
||||||
|
|||||||
@@ -636,14 +636,18 @@ var Styles = Module("Styles", {
|
|||||||
{
|
{
|
||||||
name: ["dels[tyle]"],
|
name: ["dels[tyle]"],
|
||||||
desc: "Remove a user style sheet",
|
desc: "Remove a user style sheet",
|
||||||
action: function (sheet) sheet.remove()
|
action: function (sheet) sheet.remove(),
|
||||||
}
|
}
|
||||||
].forEach(function (cmd) {
|
].forEach(function (cmd) {
|
||||||
commands.add(cmd.name, cmd.desc,
|
commands.add(cmd.name, cmd.desc,
|
||||||
function (args) {
|
function (args) {
|
||||||
|
dactyl.assert(args.bang ^ !!(args[0] || args[1] || args["-name"] || args["-index"]),
|
||||||
|
"Argument or ! required");
|
||||||
|
|
||||||
args["-group"].find(args["-name"], args[0], args.literalArg, args["-index"])
|
args["-group"].find(args["-name"], args[0], args.literalArg, args["-index"])
|
||||||
.forEach(cmd.action);
|
.forEach(cmd.action);
|
||||||
}, {
|
}, {
|
||||||
|
bang: true,
|
||||||
completer: function (context, args) {
|
completer: function (context, args) {
|
||||||
let uris = util.visibleURIs(window.content);
|
let uris = util.visibleURIs(window.content);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user