X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=common%2Fcontent%2Fautocommands.js;fp=common%2Fcontent%2Fautocommands.js;h=31c3ad90826bcae04fddd387b0c39182311fb596;hb=9044153cb63835e39b9de8ec4ade237c03e3888a;hp=beb8fc52e2a199bd5fefab0ed1fa3f1e2d452679;hpb=70740024f9c028c1fd63e1a1850ab062ff956054;p=dactyl.git diff --git a/common/content/autocommands.js b/common/content/autocommands.js index beb8fc5..31c3ad9 100644 --- a/common/content/autocommands.js +++ b/common/content/autocommands.js @@ -4,16 +4,16 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -"use strict"; +/* use strict */ /** @scope modules */ var AutoCommand = Struct("event", "filter", "command"); update(AutoCommand.prototype, { - eventName: Class.memoize(function () this.event.toLowerCase()), + eventName: Class.Memoize(function () this.event.toLowerCase()), match: function (event, pattern) { - return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === pattern); + return (!event || this.eventName == event.toLowerCase()) && (!pattern || String(this.filter) === String(pattern)); } }); @@ -43,24 +43,26 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, { }, /** - * Returns all autocommands with a matching *event* and *regexp*. + * Returns all autocommands with a matching *event* and *filter*. * * @param {string} event The event name filter. - * @param {string} pattern The URL pattern filter. + * @param {string} filter The URL pattern filter. * @returns {[AutoCommand]} */ - get: function (event, pattern) { - return this._store.filter(function (autoCmd) autoCmd.match(event, regexp)); + get: function (event, filter) { + filter = filter && String(Group.compileFilter(filter)); + return this._store.filter(function (autoCmd) autoCmd.match(event, filter)); }, /** - * Deletes all autocommands with a matching *event* and *regexp*. + * Deletes all autocommands with a matching *event* and *filter*. * * @param {string} event The event name filter. - * @param {string} regexp The URL pattern filter. + * @param {string} filter The URL pattern filter. */ - remove: function (event, regexp) { - this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, regexp)); + remove: function (event, filter) { + filter = filter && String(Group.compileFilter(filter)); + this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, filter)); }, }); @@ -69,12 +71,6 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, { */ var AutoCommands = Module("autocommands", { init: function () { - update(this, { - hives: contexts.Hives("autocmd", AutoCmdHive), - user: contexts.hives.autocmd.user, - allHives: contexts.allGroups.autocmd, - matchingHives: function matchingHives(uri, doc) contexts.matchingGroups(uri, doc).autocmd - }); }, get activeHives() contexts.allGroups.autocmd.filter(function (h) h._store.length), @@ -107,6 +103,7 @@ var AutoCommands = Module("autocommands", { return cmds; } + XML.prettyPrinting = XML.ignoreWhitespace = false; commandline.commandOutput(
{hive.name} | +|||
{hive.name} + {hive.filter} | |||
{i == 0 ? event : ""} | +{i == 0 ? event : ""} | {item.filter.toXML ? item.filter.toXML() : item.filter} | {item.command} |