1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-03-15 15:03:32 +01:00

Add -modes argument to :unmap, :mapclear.

This commit is contained in:
Kris Maglione
2010-12-23 12:07:10 -05:00
parent 02a95a0e35
commit 702b4ff340

View File

@@ -386,6 +386,7 @@ const Mappings = Module("mappings", {
const opts = { const opts = {
completer: function (context, args) { completer: function (context, args) {
let mapmodes = array.uniq(args["-modes"].map(findMode));
if (args.length == 1) if (args.length == 1)
return completion.userMapping(context, mapmodes); return completion.userMapping(context, mapmodes);
if (args.length == 2) { if (args.length == 2) {
@@ -475,17 +476,26 @@ const Mappings = Module("mappings", {
commands.add([ch + "mapc[lear]"], commands.add([ch + "mapc[lear]"],
"Remove all mappings" + modeDescription, "Remove all mappings" + modeDescription,
function () { mapmodes.forEach(function (mode) { mappings.removeAll(mode); }); }, function () { mapmodes.forEach(function (mode) { mappings.removeAll(mode); }); },
{ argCount: "0" }); {
argCount: "0",
options: [ update({}, modeFlag, {
names: ["-modes", "-mode", "-m"],
type: CommandOption.LIST,
description: "Clear 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) {
args = args[0]; let mapmodes = array.uniq(args["-modes"].map(findMode));
let found = false; let found = false;
for (let [, mode] in Iterator(mapmodes)) { for (let [, mode] in Iterator(mapmodes)) {
if (mappings.hasMap(mode, args)) { if (mappings.hasMap(mode, args[0])) {
mappings.remove(mode, args); mappings.remove(mode, args[0]);
found = true; found = true;
} }
} }
@@ -494,7 +504,14 @@ const Mappings = Module("mappings", {
}, },
{ {
argCount: "1", argCount: "1",
completer: function (context) completion.userMapping(context, mapmodes) completer: opts.completer,
options: [ update({}, modeFlag, {
names: ["-modes", "-mode", "-m"],
type: CommandOption.LIST,
description: "Remove mapping from the given modes",
default: mapmodes || ["n", "v"],
}),
]
}); });
} }