1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 09:48:00 +01:00

Normalise regex -> regexp.

This is what JS uses and using both is confusing.
This commit is contained in:
Doug Kearns
2010-10-22 12:03:03 +11:00
parent 5a42002243
commit 4f14857d66
14 changed files with 92 additions and 92 deletions

View File

@@ -22,52 +22,52 @@ const AutoCommands = Module("autocommands", {
/** /**
* Adds a new autocommand. *cmd* will be executed when one of the specified * Adds a new autocommand. *cmd* will be executed when one of the specified
* *events* occurs and the URL of the applicable buffer matches *regex*. * *events* occurs and the URL of the applicable buffer matches *regexp*.
* *
* @param {Array} events The array of event names for which this * @param {Array} events The array of event names for which this
* autocommand should be executed. * autocommand should be executed.
* @param {string} regex The URL pattern to match against the buffer URL. * @param {string} regexp The URL pattern to match against the buffer URL.
* @param {string} cmd The Ex command to run. * @param {string} cmd The Ex command to run.
*/ */
add: function (events, regex, cmd) { add: function (events, regexp, cmd) {
events.forEach(function (event) { events.forEach(function (event) {
this._store.push(AutoCommand(event, Option.parseRegex(regex), cmd)); this._store.push(AutoCommand(event, Option.parseRegexp(regexp), cmd));
}, this); }, this);
}, },
/** /**
* Returns all autocommands with a matching *event* and *regex*. * Returns all autocommands with a matching *event* and *regexp*.
* *
* @param {string} event The event name filter. * @param {string} event The event name filter.
* @param {string} regex The URL pattern filter. * @param {string} regexp The URL pattern filter.
* @returns {AutoCommand[]} * @returns {AutoCommand[]}
*/ */
get: function (event, regex) { get: function (event, regexp) {
return this._store.filter(function (autoCmd) AutoCommands.matchAutoCmd(autoCmd, event, regex)); return this._store.filter(function (autoCmd) AutoCommands.matchAutoCmd(autoCmd, event, regexp));
}, },
/** /**
* Deletes all autocommands with a matching *event* and *regex*. * Deletes all autocommands with a matching *event* and *regexp*.
* *
* @param {string} event The event name filter. * @param {string} event The event name filter.
* @param {string} regex The URL pattern filter. * @param {string} regexp The URL pattern filter.
*/ */
remove: function (event, regex) { remove: function (event, regexp) {
this._store = this._store.filter(function (autoCmd) !AutoCommands.matchAutoCmd(autoCmd, event, regex)); this._store = this._store.filter(function (autoCmd) !AutoCommands.matchAutoCmd(autoCmd, event, regexp));
}, },
/** /**
* Lists all autocommands with a matching *event* and *regex*. * Lists all autocommands with a matching *event* and *regexp*.
* *
* @param {string} event The event name filter. * @param {string} event The event name filter.
* @param {string} regex The URL pattern filter. * @param {string} regexp The URL pattern filter.
*/ */
list: function (event, regex) { list: function (event, regexp) {
let cmds = {}; let cmds = {};
// XXX // XXX
this._store.forEach(function (autoCmd) { this._store.forEach(function (autoCmd) {
if (AutoCommands.matchAutoCmd(autoCmd, event, regex)) { if (AutoCommands.matchAutoCmd(autoCmd, event, regexp)) {
cmds[autoCmd.event] = cmds[autoCmd.event] || []; cmds[autoCmd.event] = cmds[autoCmd.event] || [];
cmds[autoCmd.event].push(autoCmd); cmds[autoCmd.event].push(autoCmd);
} }
@@ -124,22 +124,22 @@ const AutoCommands = Module("autocommands", {
} }
} }
}, { }, {
matchAutoCmd: function (autoCmd, event, regex) { matchAutoCmd: function (autoCmd, event, regexp) {
return (!event || autoCmd.event == event) && (!regex || String(autoCmd.pattern) == regex); return (!event || autoCmd.event == event) && (!regexp || String(autoCmd.pattern) == regexp);
} }
}, { }, {
commands: function () { commands: function () {
commands.add(["au[tocmd]"], commands.add(["au[tocmd]"],
"Execute commands automatically on events", "Execute commands automatically on events",
function (args) { function (args) {
let [event, regex, cmd] = args; let [event, regexp, cmd] = args;
let events = []; let events = [];
try { try {
Option.parseRegex(regex); Option.parseRegexp(regexp);
} }
catch (e) { catch (e) {
dactyl.assert(false, "E475: Invalid argument: " + regex); dactyl.assert(false, "E475: Invalid argument: " + regexp);
} }
if (event) { if (event) {
@@ -154,7 +154,7 @@ const AutoCommands = Module("autocommands", {
if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern
if (args.bang) if (args.bang)
autocommands.remove(event, regex); autocommands.remove(event, regexp);
if (args["-javascript"]) { if (args["-javascript"]) {
cmd = dactyl.userFunc("args", "with(args) {" + cmd + "}"); cmd = dactyl.userFunc("args", "with(args) {" + cmd + "}");
cmd.toString = function toString() "-javascript " + cmd.source; cmd.toString = function toString() "-javascript " + cmd.source;
@@ -165,7 +165,7 @@ const AutoCommands = Module("autocommands", {
cmd.toString = function toString() cmd.source; cmd.toString = function toString() cmd.source;
} }
cmd.source = args[2]; cmd.source = args[2];
autocommands.add(events, regex, cmd); autocommands.add(events, regexp, cmd);
} }
else { else {
if (event == "*") if (event == "*")
@@ -174,10 +174,10 @@ const AutoCommands = Module("autocommands", {
if (args.bang) { if (args.bang) {
// TODO: "*" only appears to work in Vim when there is a {group} specified // TODO: "*" only appears to work in Vim when there is a {group} specified
if (args[0] != "*" || args.length > 1) if (args[0] != "*" || args.length > 1)
autocommands.remove(event, regex); // remove all autocommands.remove(event, regexp); // remove all
} }
else else
autocommands.list(event, regex); // list all autocommands.list(event, regexp); // list all
} }
}, { }, {
bang: true, bang: true,

View File

@@ -567,11 +567,11 @@ const Buffer = Module("buffer", {
yield elem; yield elem;
let res = util.evaluateXPath(path, frame.document); let res = util.evaluateXPath(path, frame.document);
for (let regex in values(regexps)) { for (let regexp in values(regexps)) {
for (let i in util.range(res.snapshotLength, 0, -1)) { for (let i in util.range(res.snapshotLength, 0, -1)) {
let elem = res.snapshotItem(i); let elem = res.snapshotItem(i);
if (regex.test(elem.textContent) === regex.result || regex.test(elem.title) === regex.result || if (regexp.test(elem.textContent) === regexp.result || regexp.test(elem.title) === regexp.result ||
Array.some(elem.childNodes, function (child) regex.test(child.alt) === regex.result)) Array.some(elem.childNodes, function (child) regexp.test(child.alt) === regexp.result))
yield elem; yield elem;
} }
} }
@@ -1745,13 +1745,13 @@ const Buffer = Module("buffer", {
options: function () { options: function () {
options.add(["nextpattern"], options.add(["nextpattern"],
"Patterns to use when guessing the 'next' page in a document sequence", "Patterns to use when guessing the 'next' page in a document sequence",
"regexlist", UTF8("'\\bnext\\b',^>$,^(>>|»)$,^(>|»),(>|»)$,'\\bmore\\b'"), "regexplist", UTF8("'\\bnext\\b',^>$,^(>>|»)$,^(>|»),(>|»)$,'\\bmore\\b'"),
{ regexFlags: "i" }); { regexpFlags: "i" });
options.add(["previouspattern"], options.add(["previouspattern"],
"Patterns to use when guessing the 'previous' page in a document sequence", "Patterns to use when guessing the 'previous' page in a document sequence",
"regexlist", UTF8("'\\bprev|previous\\b',^<$,^(<<|«)$,^(<|«),(<|«)$"), "regexplist", UTF8("'\\bprev|previous\\b',^<$,^(<<|«)$,^(<|«),(<|«)$"),
{ regexFlags: "i" }); { regexpFlags: "i" });
options.add(["pageinfo", "pa"], options.add(["pageinfo", "pa"],
"Desired info in the :pageinfo output", "Desired info in the :pageinfo output",

View File

@@ -1657,7 +1657,7 @@ const CommandLine = Module("commandline", {
// At the moment, adding "<Tab>" breaks tab completion. Adding // At the moment, adding "<Tab>" breaks tab completion. Adding
// "<CR>" has no effect. // "<CR>" has no effect.
// TODO: Make non-keyword recognition smarter so that there need not // TODO: Make non-keyword recognition smarter so that there need not
// be two lists of the same characters (one here and a regex in // be two lists of the same characters (one here and a regexp in
// mappings.js) // mappings.js)
mappings.add(myModes, mappings.add(myModes,
["<Space>", '"', "'"], "Expand command line abbreviation", ["<Space>", '"', "'"], "Expand command line abbreviation",

View File

@@ -833,7 +833,7 @@ const Completion = Module("completion", {
function (tok) contains(item.url, tok) || function (tok) contains(item.url, tok) ||
contains(item.title, tok))); contains(item.title, tok)));
let re = RegExp(tokens.filter(util.identity).map(util.escapeRegex).join("|"), "g"); let re = RegExp(tokens.filter(util.identity).map(util.escapeRegexp).join("|"), "g");
function highlight(item, text, i) process[i].call(this, item, template.highlightRegexp(text, re)); function highlight(item, text, i) process[i].call(this, item, template.highlightRegexp(text, re));
let process = context.process; let process = context.process;
context.process = [ context.process = [
@@ -895,7 +895,7 @@ const Completion = Module("completion", {
options.add(["autocomplete", "au"], options.add(["autocomplete", "au"],
"Automatically update the completion list on any key press", "Automatically update the completion list on any key press",
"regexlist", ".*"); "regexplist", ".*");
options.add(["complete", "cpt"], options.add(["complete", "cpt"],
"Items which are completed at the :open prompts", "Items which are completed at the :open prompts",
@@ -906,11 +906,11 @@ const Completion = Module("completion", {
options.add(["wildanchor", "wia"], options.add(["wildanchor", "wia"],
"Regexp list defining which contexts require matches anchored to the beginning of the result", "Regexp list defining which contexts require matches anchored to the beginning of the result",
"regexlist", "!/ex/(back|buffer|ext|forward|help|undo)"); "regexplist", "!/ex/(back|buffer|ext|forward|help|undo)");
options.add(["wildcase", "wic"], options.add(["wildcase", "wic"],
"Completion case matching mode", "Completion case matching mode",
"regexmap", ".?:smart", "regexpmap", ".?:smart",
{ {
completer: function () [ completer: function () [
["smart", "Case is significant when capital letters are typed"], ["smart", "Case is significant when capital letters are typed"],
@@ -926,7 +926,7 @@ const Completion = Module("completion", {
options.add(["wildsort", "wis"], options.add(["wildsort", "wis"],
"Regexp list of which contexts to sort", "Regexp list of which contexts to sort",
"regexlist", ".*"); "regexplist", ".*");
} }
}); });

View File

@@ -1211,8 +1211,8 @@ const Dactyl = Module("dactyl", {
"string", "intro"); "string", "intro");
options.add(["loadplugins", "lpl"], options.add(["loadplugins", "lpl"],
"A regex list that defines which plugins are loaded at startup and via :loadplugins", "A regexp list that defines which plugins are loaded at startup and via :loadplugins",
"regexlist", "'\\.(js|" + config.fileExtension + ")$'"); "regexplist", "'\\.(js|" + config.fileExtension + ")$'");
options.add(["titlestring"], options.add(["titlestring"],
"Change the title of the window", "Change the title of the window",
@@ -1221,7 +1221,7 @@ const Dactyl = Module("dactyl", {
setter: function (value) { setter: function (value) {
let win = document.documentElement; let win = document.documentElement;
function updateTitle(old, current) { function updateTitle(old, current) {
document.title = document.title.replace(RegExp("(.*)" + util.escapeRegex(old)), "$1" + current); document.title = document.title.replace(RegExp("(.*)" + util.escapeRegexp(old)), "$1" + current);
} }
// TODO: remove this FF3.5 test when we no longer support 3.0 // TODO: remove this FF3.5 test when we no longer support 3.0
@@ -1247,7 +1247,7 @@ const Dactyl = Module("dactyl", {
}); });
options.add(["urlseparator", "us"], options.add(["urlseparator", "us"],
"Set the separator regex used to separate multiple URL args", "Set the separator regexp used to separate multiple URL args",
"string", "\\|"); "string", "\\|");
options.add(["verbose", "vbs"], options.add(["verbose", "vbs"],

View File

@@ -27,7 +27,7 @@ const RangeFinder = Module("rangefinder", {
let highlighted = this.rangeFind && this.rangeFind.highlighted; let highlighted = this.rangeFind && this.rangeFind.highlighted;
let selections = this.rangeFind && this.rangeFind.selections; let selections = this.rangeFind && this.rangeFind.selections;
let regex = false; let regexp = false;
let matchCase = !(options["ignorecase"] || options["smartcase"] && !/[A-Z]/.test(str)); let matchCase = !(options["ignorecase"] || options["smartcase"] && !/[A-Z]/.test(str));
let linksOnly = options["linksearch"]; let linksOnly = options["linksearch"];
@@ -41,9 +41,9 @@ const RangeFinder = Module("rangefinder", {
else if (n1 == "L") else if (n1 == "L")
linksOnly = false; linksOnly = false;
else if (n1 == "r") else if (n1 == "r")
regex = true; regexp = true;
else if (n1 == "R") else if (n1 == "R")
regex = false; regexp = false;
else else
return m; return m;
return ""; return "";
@@ -54,13 +54,13 @@ const RangeFinder = Module("rangefinder", {
if (!this.rangeFind if (!this.rangeFind
|| this.rangeFind.window.get() != window || this.rangeFind.window.get() != window
|| linksOnly != !!this.rangeFind.elementPath || linksOnly != !!this.rangeFind.elementPath
|| regex != this.rangeFind.regex || regexp != this.rangeFind.regex
|| matchCase != this.rangeFind.matchCase || matchCase != this.rangeFind.matchCase
|| !!backward != this.rangeFind.reverse) { || !!backward != this.rangeFind.reverse) {
if (this.rangeFind) if (this.rangeFind)
this.rangeFind.cancel(); this.rangeFind.cancel();
this.rangeFind = RangeFind(matchCase, backward, linksOnly && options["hinttags"], regex); this.rangeFind = RangeFind(matchCase, backward, linksOnly && options["hinttags"], regexp);
this.rangeFind.highlighted = highlighted; this.rangeFind.highlighted = highlighted;
this.rangeFind.selections = selections; this.rangeFind.selections = selections;
} }
@@ -259,14 +259,14 @@ const RangeFinder = Module("rangefinder", {
* large amounts of data are concerned (e.g., for API documents). * large amounts of data are concerned (e.g., for API documents).
*/ */
const RangeFind = Class("RangeFind", { const RangeFind = Class("RangeFind", {
init: function (matchCase, backward, elementPath, regex) { init: function (matchCase, backward, elementPath, regexp) {
this.window = Cu.getWeakReference(window); this.window = Cu.getWeakReference(window);
this.elementPath = elementPath || null; this.elementPath = elementPath || null;
this.reverse = Boolean(backward); this.reverse = Boolean(backward);
this.finder = services.create("find"); this.finder = services.create("find");
this.matchCase = Boolean(matchCase); this.matchCase = Boolean(matchCase);
this.regex = Boolean(regex); this.regexp = Boolean(regexp);
this.ranges = this.makeFrameList(window.content); this.ranges = this.makeFrameList(window.content);
@@ -282,8 +282,8 @@ const RangeFind = Class("RangeFind", {
get matchCase() this.finder.caseSensitive, get matchCase() this.finder.caseSensitive,
set matchCase(val) this.finder.caseSensitive = Boolean(val), set matchCase(val) this.finder.caseSensitive = Boolean(val),
get regex() this.finder.regularExpression || false, get regexp() this.finder.regularExpression || false,
set regex(val) { set regexp(val) {
try { try {
return this.finder.regularExpression = Boolean(val); return this.finder.regularExpression = Boolean(val);
} }

View File

@@ -630,7 +630,7 @@ const Hints = Module("hints", {
*/ */
function wordStartsWithMatcher(hintString, allowWordOverleaping) { //{{{ function wordStartsWithMatcher(hintString, allowWordOverleaping) { //{{{
let hintStrings = tokenize(/\s+/, hintString); let hintStrings = tokenize(/\s+/, hintString);
let wordSplitRegex = RegExp(options["wordseparators"]); let wordSplitRegexp = RegExp(options["wordseparators"]);
/** /**
* Match a set of characters to the start of words. * Match a set of characters to the start of words.
@@ -728,7 +728,7 @@ const Hints = Module("hints", {
if (hintStrings.length == 1 && hintStrings[0].length == 0) if (hintStrings.length == 1 && hintStrings[0].length == 0)
return true; return true;
let words = tokenize(wordSplitRegex, linkText); let words = tokenize(wordSplitRegexp, linkText);
if (hintStrings.length == 1) if (hintStrings.length == 1)
return charsAtBeginningOfWords(hintStrings[0], words, allowWordOverleaping); return charsAtBeginningOfWords(hintStrings[0], words, allowWordOverleaping);
else else
@@ -1119,7 +1119,7 @@ const Hints = Module("hints", {
options.add(["extendedhinttags", "eht"], options.add(["extendedhinttags", "eht"],
"XPath string of hintable elements activated by ';'", "XPath string of hintable elements activated by ';'",
"regexmap", "[iI]:" + Option.quote(util.makeXPath(["img"])) + "regexpmap", "[iI]:" + Option.quote(util.makeXPath(["img"])) +
",[OTivVWy]:" + Option.quote(util.makeXPath( ",[OTivVWy]:" + Option.quote(util.makeXPath(
["{a,area}[@href]", "{img,iframe}[@src]"])) + ["{a,area}[@href]", "{img,iframe}[@src]"])) +
",[S]:" + Option.quote(util.makeXPath( ",[S]:" + Option.quote(util.makeXPath(

View File

@@ -761,7 +761,7 @@ lookup:
options.add(["wildignore", "wig"], options.add(["wildignore", "wig"],
"List of file patterns to ignore when completing files", "List of file patterns to ignore when completing files",
"regexlist", ""); "regexplist", "");
} }
}); });

View File

@@ -255,9 +255,9 @@ const Option = Class("Option", {
* "number" - Integer, e.g., 1 * "number" - Integer, e.g., 1
* "string" - String, e.g., "Pentadactyl" * "string" - String, e.g., "Pentadactyl"
* "charlist" - Character list, e.g., "rb" * "charlist" - Character list, e.g., "rb"
* "regexlist" - Regex list, e.g., "^foo,bar$" * "regexplist" - Regexp list, e.g., "^foo,bar$"
* "stringmap" - String map, e.g., "key:v,foo:bar" * "stringmap" - String map, e.g., "key:v,foo:bar"
* "regexmap" - Regex map, e.g., "^key:v,foo$:bar" * "regexpmap" - Regexp map, e.g., "^key:v,foo$:bar"
*/ */
type: null, type: null,
@@ -384,28 +384,28 @@ const Option = Class("Option", {
toggleAll: function toggleAll() toggleAll.supercall(this, "all") ^ !!toggleAll.superapply(this, arguments), toggleAll: function toggleAll() toggleAll.supercall(this, "all") ^ !!toggleAll.superapply(this, arguments),
}, },
parseRegex: function (value, result, flags) { parseRegexp: function (value, result, flags) {
let [, bang, val] = /^(!?)(.*)/.exec(value); let [, bang, val] = /^(!?)(.*)/.exec(value);
let re = RegExp(Option.dequote(val), flags); let re = RegExp(Option.dequote(val), flags);
re.bang = bang; re.bang = bang;
re.result = result !== undefined ? result : !bang; re.result = result !== undefined ? result : !bang;
re.toString = function () Option.unparseRegex(this); re.toString = function () Option.unparseRegexp(this);
return re; return re;
}, },
unparseRegex: function (re) re.bang + Option.quote(re.source.replace(/\\(.)/g, function (m, n1) n1 == "/" ? n1 : m), /^!|:/) + unparseRegexp: function (re) re.bang + Option.quote(re.source.replace(/\\(.)/g, function (m, n1) n1 == "/" ? n1 : m), /^!|:/) +
(typeof re.result === "string" ? ":" + Option.quote(re.result) : ""), (typeof re.result === "string" ? ":" + Option.quote(re.result) : ""),
getKey: { getKey: {
stringlist: function (k) this.value.indexOf(k) >= 0, stringlist: function (k) this.value.indexOf(k) >= 0,
get charlist() this.stringlist, get charlist() this.stringlist,
regexlist: function (k, default_) { regexplist: function (k, default_) {
for (let re in values(this.value)) for (let re in values(this.value))
if (re.test(k)) if (re.test(k))
return re.result; return re.result;
return arguments.length > 1 ? default_ : null; return arguments.length > 1 ? default_ : null;
}, },
get regexmap() this.regexlist get regexpmap() this.regexplist
}, },
stringify: { stringify: {
@@ -415,8 +415,8 @@ const Option = Class("Option", {
stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v) for ([k, v] in Iterator(vals))].join(","), stringmap: function (vals) [Option.quote(k, /:/) + ":" + Option.quote(v) for ([k, v] in Iterator(vals))].join(","),
regexlist: function (vals) vals.join(","), regexplist: function (vals) vals.join(","),
get regexmap() this.regexlist get regexpmap() this.regexplist
}, },
parse: { parse: {
@@ -428,9 +428,9 @@ const Option = Class("Option", {
stringlist: function (value) (value === "") ? [] : Option.splitList(value), stringlist: function (value) (value === "") ? [] : Option.splitList(value),
regexlist: function (value) (value === "") ? [] : regexplist: function (value) (value === "") ? [] :
Option.splitList(value, true) Option.splitList(value, true)
.map(function (re) Option.parseRegex(re, undefined, this.regexFlags), this), .map(function (re) Option.parseRegexp(re, undefined, this.regexpFlags), this),
stringmap: function (value) array.toObject( stringmap: function (value) array.toObject(
Option.splitList(value, true).map(function (v) { Option.splitList(value, true).map(function (v) {
@@ -438,18 +438,18 @@ const Option = Class("Option", {
return [key, Option.dequote(v.substr(count + 1))] return [key, Option.dequote(v.substr(count + 1))]
})), })),
regexmap: function (value) regexpmap: function (value)
Option.splitList(value, true).map(function (v) { Option.splitList(value, true).map(function (v) {
let [count, re, quote] = Commands.parseArg(v, /:/, true); let [count, re, quote] = Commands.parseArg(v, /:/, true);
v = Option.dequote(v.substr(count + 1)); v = Option.dequote(v.substr(count + 1));
if (count === v.length) if (count === v.length)
[v, re] = [re, ".?"]; [v, re] = [re, ".?"];
return Option.parseRegex(re, v, this.regexFlags); return Option.parseRegexp(re, v, this.regexpFlags);
}, this) }, this)
}, },
testValues: { testValues: {
regexmap: function (vals, validator) vals.every(function (re) validator(re.result)), regexpmap: function (vals, validator) vals.every(function (re) validator(re.result)),
stringlist: function (vals, validator) vals.every(validator, this), stringlist: function (vals, validator) vals.every(validator, this),
stringmap: function (vals, validator) array(values(vals)).every(validator, this) stringmap: function (vals, validator) array(values(vals)).every(validator, this)
}, },
@@ -557,8 +557,8 @@ const Option = Class("Option", {
return null; return null;
}, },
get charlist() this.stringlist, get charlist() this.stringlist,
get regexlist() this.stringlist, get regexplist() this.stringlist,
get regexmap() this.stringlist, get regexpmap() this.stringlist,
string: function (operator, values, scope, invert) { string: function (operator, values, scope, invert) {
switch (operator) { switch (operator) {
@@ -593,7 +593,7 @@ const Option = Class("Option", {
let res = context.fork("", 0, this, this.completer); let res = context.fork("", 0, this, this.completer);
if (!res) if (!res)
res = context.allItems.items.map(function (item) [item.text]); res = context.allItems.items.map(function (item) [item.text]);
if (this.type == "regexmap") if (this.type == "regexpmap")
return Array.concat(values).every(function (re) res.some(function (item) item[0] == re.result)); return Array.concat(values).every(function (re) res.some(function (item) item[0] == re.result));
return Array.concat(values).every(function (value) res.some(function (item) item[0] == value)); return Array.concat(values).every(function (value) res.some(function (item) item[0] == value));
}, },
@@ -1168,13 +1168,13 @@ const Options = Module("options", {
if (!completer) if (!completer)
completer = function () [["true", ""], ["false", ""]]; completer = function () [["true", ""], ["false", ""]];
break; break;
case "regexlist": case "regexplist":
newValues = Option.splitList(context.filter); newValues = Option.splitList(context.filter);
// Fallthrough // Fallthrough
case "stringlist": case "stringlist":
break; break;
case "stringmap": case "stringmap":
case "regexmap": case "regexpmap":
let vals = Option.splitList(context.filter); let vals = Option.splitList(context.filter);
let target = vals.pop() || ""; let target = vals.pop() || "";
let [count, key, quote] = Commands.parseArg(target, /:/, true); let [count, key, quote] = Commands.parseArg(target, /:/, true);

View File

@@ -424,7 +424,7 @@ This file contains a list of all available commands, mappings and options.
<dt><o>strictfocus</o></dt> <dd>Prevent scripts from focusing input elements without user intervention</dd> <dt><o>strictfocus</o></dt> <dd>Prevent scripts from focusing input elements without user intervention</dd>
<dt><o>suggestengines</o></dt> <dd>Engine Alias which has a feature of suggest</dd> <dt><o>suggestengines</o></dt> <dd>Engine Alias which has a feature of suggest</dd>
<dt><o>titlestring</o></dt> <dd>Change the title of the window</dd> <dt><o>titlestring</o></dt> <dd>Change the title of the window</dd>
<dt><o>urlseparator</o></dt> <dd>Set the separator regex used to separate multiple URL args</dd> <dt><o>urlseparator</o></dt> <dd>Set the separator regexp used to separate multiple URL args</dd>
<dt><o>usermode</o></dt> <dd>Show current website with a minimal style sheet to make it easily accessible</dd> <dt><o>usermode</o></dt> <dd>Show current website with a minimal style sheet to make it easily accessible</dd>
<dt><o>verbose</o></dt> <dd>Define which info messages are displayed</dd> <dt><o>verbose</o></dt> <dd>Define which info messages are displayed</dd>
<dt><o>visualbell</o></dt> <dd>Use visual bell instead of beeping on errors</dd> <dt><o>visualbell</o></dt> <dd>Use visual bell instead of beeping on errors</dd>

View File

@@ -46,8 +46,8 @@
<dt>stringmap</dt> <dt>stringmap</dt>
<dd>A comma-separated list of key-value pairs, e.g., <str delim="">key:val,foo:bar</str></dd> <dd>A comma-separated list of key-value pairs, e.g., <str delim="">key:val,foo:bar</str></dd>
<dt/><dd tag="regexlist"/> <dt/><dd tag="regexplist"/>
<dt>regexlist</dt> <dt>regexplist</dt>
<dd> <dd>
A comma-separated list of regular expressions. Expressions may be A comma-separated list of regular expressions. Expressions may be
prefixed with a <em>!</em>, in which case the match will be negated. A prefixed with a <em>!</em>, in which case the match will be negated. A
@@ -58,10 +58,10 @@
<em>\</em>, will not be treated as an item separator. <em>\</em>, will not be treated as an item separator.
</dd> </dd>
<dt/><dd tag="regexmap"/> <dt/><dd tag="regexpmap"/>
<dt>regexmap</dt> <dt>regexpmap</dt>
<dd> <dd>
A combination of a <em>stringmap</em> and a <em>regexlist</em>. Each key A combination of a <em>stringmap</em> and a <em>regexplist</em>. Each key
in the <a>key</a>:<a>value</a> pair is a regexp. If the regexp begins with a in the <a>key</a>:<a>value</a> pair is a regexp. If the regexp begins with a
<em>!</em>, the sense of the match is negated, such that a non-matching <em>!</em>, the sense of the match is negated, such that a non-matching
expression will be considered a match and <html:i>vice versa</html:i>. expression will be considered a match and <html:i>vice versa</html:i>.
@@ -360,7 +360,7 @@
<item> <item>
<tags>'au' 'autocomplete'</tags> <tags>'au' 'autocomplete'</tags>
<spec>'autocomplete' 'au'</spec> <spec>'autocomplete' 'au'</spec>
<type>regexlist</type> <type>regexplist</type>
<default>.*</default> <default>.*</default>
<description> <description>
<p> <p>
@@ -602,7 +602,7 @@
<tags>'eht' 'extendedhinttags'</tags> <tags>'eht' 'extendedhinttags'</tags>
<spec>'extendedhinttags' 'eht'</spec> <spec>'extendedhinttags' 'eht'</spec>
<strut/> <strut/>
<type>regexmap</type> <type>regexpmap</type>
<default>[iI]:'//img | //xhtml:img', <default>[iI]:'//img | //xhtml:img',
[OTivVWy]:'//a[@href] | //xhtml:a[@href] | [OTivVWy]:'//a[@href] | //xhtml:a[@href] |
//area[@href] | //xhtml:area[@href] | //area[@href] | //xhtml:area[@href] |
@@ -947,7 +947,7 @@
<tags>'nolpl' 'lpl'</tags> <tags>'nolpl' 'lpl'</tags>
<tags>'noloadplugins' 'loadplugins'</tags> <tags>'noloadplugins' 'loadplugins'</tags>
<spec>'loadplugins' 'lpl'</spec> <spec>'loadplugins' 'lpl'</spec>
<type>regexlist</type> <type>regexplist</type>
<default>'\.(js|&dactyl.fileExt;)$'</default> <default>'\.(js|&dactyl.fileExt;)$'</default>
<description> <description>
<p> <p>
@@ -974,7 +974,7 @@
<p> <p>
Note that in the first expression of the latter example you don't Note that in the first expression of the latter example you don't
need parentheses, as the <em>!</em> negates the whole of the need parentheses, as the <em>!</em> negates the whole of the
following expression (cf. <t>regexlist</t>). following expression (cf. <t>regexplist</t>).
</p> </p>
<p> <p>
See also <ex>:runtime</ex>. See also <ex>:runtime</ex>.
@@ -1459,7 +1459,7 @@
<item> <item>
<tags>'wia' 'wildanchor'</tags> <tags>'wia' 'wildanchor'</tags>
<spec>'wildanchor' 'wia'</spec> <spec>'wildanchor' 'wia'</spec>
<type>regexlist</type> <type>regexplist</type>
<default>!'/ex/(back|buffer|ext|forward|help|undo)'</default> <default>!'/ex/(back|buffer|ext|forward|help|undo)'</default>
<description> <description>
<p> <p>
@@ -1477,12 +1477,12 @@
<item> <item>
<tags>'wic' 'wildcase'</tags> <tags>'wic' 'wildcase'</tags>
<spec>'wildcase' 'wic'</spec> <spec>'wildcase' 'wic'</spec>
<type>regexmap</type> <type>regexpmap</type>
<default>.?:smart</default> <default>.?:smart</default>
<description> <description>
<p> <p>
Defines how completions are matched with regard to character case. Defines how completions are matched with regard to character case.
Keys in the <t>regexmap</t> refer to completion context names (see Keys in the <t>regexpmap</t> refer to completion context names (see
<ex>:contexts</ex>) for which the value applies. Possible values <ex>:contexts</ex>) for which the value applies. Possible values
are: are:
</p> </p>
@@ -1498,7 +1498,7 @@
<item> <item>
<tags>'wildignore' 'wig'</tags> <tags>'wildignore' 'wig'</tags>
<spec>'wildignore' 'wig'</spec> <spec>'wildignore' 'wig'</spec>
<type>regexlist</type> <type>regexplist</type>
<default></default> <default></default>
<description> <description>
<p> <p>
@@ -1553,7 +1553,7 @@
<item> <item>
<tags>'wis' 'wildsort'</tags> <tags>'wis' 'wildsort'</tags>
<spec>'wildsort' 'wis'</spec> <spec>'wildsort' 'wis'</spec>
<type>regexlist</type> <type>regexplist</type>
<default>.*</default> <default>.*</default>
<description> <description>
<p> <p>

View File

@@ -64,7 +64,7 @@
<description> <description>
<p> <p>
List recorded macros matching the optional regular expression List recorded macros matching the optional regular expression
<oa>pat</oa>. If no regex is given, list all macros. <oa>pat</oa>. If no regexp is given, list all macros.
</p> </p>
</description> </description>
</item> </item>

View File

@@ -511,7 +511,7 @@ const File = Class("File", {
// expand ~ // expand ~
// Yuck. // Yuck.
if (!relative && RegExp("~(?:$|[/" + util.escapeRegex(File.PATH_SEP) + "])").test(path)) { if (!relative && RegExp("~(?:$|[/" + util.escapeRegexp(File.PATH_SEP) + "])").test(path)) {
// Try $HOME first, on all systems // Try $HOME first, on all systems
let home = services.get("environment").get("HOME"); let home = services.get("environment").get("HOME");

View File

@@ -330,7 +330,7 @@ const Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
* @param {string} str * @param {string} str
* @returns {string} * @returns {string}
*/ */
escapeRegex: function escapeRegex(str) { escapeRegexp: function escapeRegexp(str) {
return str.replace(/([\\{}()[\].?*+])/g, "\\$1"); return str.replace(/([\\{}()[\].?*+])/g, "\\$1");
}, },