From 1e25799ef1b96362ba7fd20f9c5e67cd1c6aa529 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 31 Dec 2008 15:56:00 +1100 Subject: [PATCH] Use a Struct for autocommands. This is marginally clearer and will be helpful for autocommand groups etc. --- common/content/events.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/common/content/events.js b/common/content/events.js index 13f57339..33cb4380 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -37,12 +37,12 @@ function AutoCommands() //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ + const AutoCommand = new Struct("event", "pattern", "command"); var store = []; function matchAutoCmd(autoCmd, event, regex) { - return (!event || autoCmd.event == event) && - (!regex || autoCmd.pattern.source == regex); + return (!event || autoCmd.event == event) && (!regex || autoCmd.pattern.source == regex); } /////////////////////////////////////////////////////////////////////////////}}} @@ -71,6 +71,7 @@ function AutoCommands() //{{{ { let [event, regex, cmd] = args; let events = null; + if (event) { // NOTE: event can only be a comma separated list for |:au {event} {pat} {cmd}| @@ -95,6 +96,7 @@ function AutoCommands() //{{{ { if (event == "*") event = null; + if (args.bang) { // TODO: "*" only appears to work in Vim when there is a {group} specified @@ -187,8 +189,9 @@ function AutoCommands() //{{{ events = events.split(","); liberator.log("DEPRECATED: the events list arg to autocommands.add() should be an array of event names"); } - events.forEach(function (event) - store.push({ event: event, pattern: RegExp(regex), command: cmd })); + events.forEach(function (event) { + store.push(new AutoCommand(event, RegExp(regex), cmd)); + }); }, get: function (event, regex)