From a0335cb437fa1ad55a2aa314f530847fc02e4bf7 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 8 Dec 2010 14:56:11 -0500 Subject: [PATCH] Fix :noremap. (Probably) Fixes issue #168. --- common/content/mappings.js | 22 +++++----------------- common/modules/util.jsm | 3 +++ 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/common/content/mappings.js b/common/content/mappings.js index 592ac8e3..5885b197 100644 --- a/common/content/mappings.js +++ b/common/content/mappings.js @@ -354,11 +354,8 @@ const Mappings = Module("mappings", { }, { commands: function () { function addMapCommands(ch, mapmodes, modeDescription) { - // 0 args -> list all maps - // 1 arg -> list the maps starting with args - // 2 args -> map arg1 to arg* - function map(args, mapmodes, noremap) { - mapmodes = getModes(args); + function map(args, noremap) { + let mapmodes = array.uniq(args["-modes"].map(findMode)); if (!args.length) { mappings.list(mapmodes); return; @@ -386,23 +383,14 @@ const Mappings = Module("mappings", { modeDescription = modeDescription ? " in " + modeDescription + " mode" : ""; - // :map, :noremap => NORMAL + VISUAL modes - function isMultiMode(map, cmd) { - return map.modes.indexOf(modules.modes.NORMAL) >= 0 - && map.modes.indexOf(modules.modes.VISUAL) >= 0 - && /^[nv](nore)?map$/.test(cmd); - } - function findMode(name) { - if (typeof name == "number") + if (isinstance(name, Number)) return name; for (let mode in modes.mainModes) if (name == mode.char || name == mode.name.toLowerCase()) return mode.mask; return null; } - function getModes(args) - array.uniq(args["-modes"].map(findMode)); function uniqueModes(modes) { modes = modes.map(modules.modes.closure.getMode); let chars = [k for ([k, v] in Iterator(modules.modes.modeChars)) @@ -492,12 +480,12 @@ const Mappings = Module("mappings", { commands.add([ch ? ch + "m[ap]" : "map"], "Map a key sequence" + modeDescription, - function (args) { map(args, mapmodes, false); }, + function (args) { map(args, false); }, opts); commands.add([ch + "no[remap]"], "Map a key sequence without remapping keys" + modeDescription, - function (args) { map(args, mapmodes, true); }, + function (args) { map(args, true); }, opts); commands.add([ch + "mapc[lear]"], diff --git a/common/modules/util.jsm b/common/modules/util.jsm index e0b58b5f..91094487 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -134,6 +134,9 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]) */ compareIgnoreCase: function compareIgnoreCase(a, b) String.localeCompare(a.toLowerCase(), b.toLowerCase()), + compileFormat: function compileFormat(format) { + }, + /** * Returns an object representing a Node's computed CSS style. *