diff --git a/common/content/commands.js b/common/content/commands.js index 32d193e6..63df6d03 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -296,6 +296,7 @@ const Command = Class("Command", { * invocation which should be restored on subsequent @dactyl startups. */ serialize: null, + serialGroup: 50, /** * @property {number} If this command takes another ex command as an * argument, the index of that argument. Used in determining whether to @@ -447,7 +448,7 @@ const Commands = Module("commands", { /** @property {Iterator(Command)} @private */ __iterator__: function () { - let sorted = this._exCommands.sort(function (a, b) a.name > b.name); + let sorted = this._exCommands.sort(function (a, b) a.serialGroup - b.serialGroup || a.name > b.name); return array.iterValues(sorted); }, diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e0440bc7..7690f32f 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -818,12 +818,16 @@ const Dactyl = Module("dactyl", { function globalVariables() this._globalVariables) }), - loadPlugins: function () { + loadPlugins: function (args) { function sourceDirectory(dir) { dactyl.assert(dir.isReadable(), "E484: Can't open file " + dir.path); dactyl.log("Sourcing plugin directory: " + dir.path + "...", 3); + let loadplugins = options.get("loadplugins"); + if (args) + loadplugins = { __proto__: loadplugins, value: args.map(Option.parseRegexp) } + dir.readDirectory(true).forEach(function (file) { if (file.isFile() && loadplugins.getKey(file.path) && !(file.path in dactyl.pluginFiles)) { try { @@ -1786,8 +1790,20 @@ const Dactyl = Module("dactyl", { commands.add(["loadplugins", "lpl"], "Load all plugins immediately", - function () { dactyl.loadPlugins(); }, - { argCount: "0" }); + function (args) { + dactyl.loadPlugins(args.length ? args : null); + }, + { + argCount: "*", + keepQuotes: true, + serialGroup: 10, + serialize: function () [ + { + command: this.name, + literalArg: options["loadplugins"].join(" ") + } + ] + }); commands.add(["norm[al]"], "Execute Normal mode commands", diff --git a/common/content/events.js b/common/content/events.js index b84f7463..05d095a0 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1031,7 +1031,7 @@ const Events = Module("events", { dactyl.trapErrors(commandline.onEvent, commandline, event); } - // Unconsumed events + // Reprocess unconsumed events for (let event in values(res.slice(1))) if (!event.skipmap) if (event.originalTarget) @@ -1056,9 +1056,8 @@ const Events = Module("events", { const self = this; let key = events.toString(event); - let inputStr = this.buffer + key; - let countStr = inputStr.match(/^[1-9][0-9]*|/)[0]; - let candidateCommand = inputStr.substr(countStr.length); + let [, countStr, candidateCommand] = /^((?:[1-9][0-9]*)?)(.*)/.exec(this.buffer + key); + let map = mappings[event.noremap ? "getDefault" : "get"](this.main, candidateCommand); function execute(map) { @@ -1104,9 +1103,8 @@ const Events = Module("events", { if (isNaN(this[count])) this[count] = null; - this.buffer = ""; if (map.arg) { - this.buffer = inputStr; + this.append(event); this.pendingArgMap = map; } else if (this.pendingMotionMap) { @@ -1114,9 +1112,10 @@ const Events = Module("events", { execute(this.pendingMotionMap, candidateCommand, this.motionCount || this.count, null); return true; } - // no count support for these commands yet - else if (map.motion) + else if (map.motion) { + this.buffer = ""; this.pendingMotionMap = map; + } else { if (modes.isReplaying && !this.waitForPageLoad()) return true; @@ -1126,8 +1125,8 @@ const Events = Module("events", { } } else if (mappings.getCandidates(this.main, candidateCommand).length > 0 && !event.skipmap) { - this.pendingMap = map; this.append(event); + this.pendingMap = map; } else { this.append(event); diff --git a/common/content/options.js b/common/content/options.js index 6bb33ba0..9ce791a3 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -391,6 +391,9 @@ const Option = Class("Option", { }, parseRegexp: function (value, result, flags) { + if (isArray(flags)) // Called by map + result = flags = undefined; + let [, bang, val] = /^(!?)(.*)/.exec(value); let re = RegExp(Option.dequote(val), flags); re.bang = bang; diff --git a/common/locale/en-US/repeat.xml b/common/locale/en-US/repeat.xml index 4067bb8e..6b2dce26 100644 --- a/common/locale/en-US/repeat.xml +++ b/common/locale/en-US/repeat.xml @@ -183,7 +183,7 @@ :lpl :loadplugins - :loadplugins + :loadplugins pattern

Immediately load all plugins which have yet to be loaded. Because @@ -194,6 +194,10 @@ newly installed plugins to be easily loaded without restarting &dactyl.appName;. See also loadplugins.

+

+ If patterns are provided, the given regular expressions are + used as filters rather than those in loadplugins. +