1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-22 06:47:58 +01:00

Add wildanchor option.

This commit is contained in:
Kris Maglione
2010-09-23 15:15:09 -04:00
parent db2a6ba0a3
commit 2f30daa09e
6 changed files with 37 additions and 13 deletions

View File

@@ -54,7 +54,7 @@ const CompletionContext = Class("CompletionContext", {
["filters", "keys", "title", "quote"].forEach(function (key) ["filters", "keys", "title", "quote"].forEach(function (key)
self[key] = parent[key] && util.cloneObject(parent[key])); self[key] = parent[key] && util.cloneObject(parent[key]));
["anchored", "compare", "editor", "_filter", "filterFunc", "keys", "process", "top"].forEach(function (key) ["anchored", "compare", "editor", "_filter", "filterFunc", "forceAnchored", "keys", "process", "top"].forEach(function (key)
self[key] = parent[key]); self[key] = parent[key]);
self.__defineGetter__("value", function () this.top.value); self.__defineGetter__("value", function () this.top.value);
@@ -96,6 +96,7 @@ const CompletionContext = Class("CompletionContext", {
* @default true * @default true
*/ */
this.anchored = true; this.anchored = true;
this.forceAnchored = null;
this.compare = function (a, b) String.localeCompare(a.text, b.text); this.compare = function (a, b) String.localeCompare(a.text, b.text);
/** /**
@@ -405,6 +406,9 @@ const CompletionContext = Class("CompletionContext", {
let self = this; let self = this;
delete this._substrings; delete this._substrings;
if (!this.forceAnchored)
this.anchored = options.get("wildanchor").getKey(this.name, this.anchored);
// Item matchers // Item matchers
if (this.ignoreCase) if (this.ignoreCase)
this.matchString = this.anchored ? this.matchString = this.anchored ?
@@ -802,7 +806,7 @@ const Completion = Module("completion", {
</div>); </div>);
}, },
{ {
argCount: "1", argCount: "*",
completer: function (context, args) { completer: function (context, args) {
let PREFIX = "/ex/contexts"; let PREFIX = "/ex/contexts";
context.fork("ex", 0, completion, "ex"); context.fork("ex", 0, completion, "ex");
@@ -849,6 +853,10 @@ const Completion = Module("completion", {
completer: function (context) array(values(completion.urlCompleters)) completer: function (context) array(values(completion.urlCompleters))
}); });
options.add(["wildanchor", "wia"],
"Regexp list defining which contexts require matches anchored to the begining of the result",
"regexlist", "!/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", "regexmap", "smart",

View File

@@ -358,6 +358,7 @@ const JavaScript = Module("javascript", {
offset: key.length offset: key.length
}; };
context.forceAnchored = true;
// TODO: Make this a generic completion helper function. // TODO: Make this a generic completion helper function.
for (let [, obj] in Iterator(objects)) for (let [, obj] in Iterator(objects))
this.context.fork(obj[1], this._top.offset, this, this._fill, this.context.fork(obj[1], this._top.offset, this, this._fill,
@@ -605,10 +606,7 @@ const JavaScript = Module("javascript", {
"Switch on/off jsdebugger", "Switch on/off jsdebugger",
"boolean", false, { "boolean", false, {
setter: function (value) { setter: function (value) {
if (value) services.get("debugger")[value ? "on" : "off"]();
services.get("debugger").on();
else
services.get("debugger").off();
}, },
getter: function () services.get("debugger").isOn getter: function () services.get("debugger").isOn
}); });

View File

@@ -382,11 +382,11 @@ const Option = Class("Option", {
stringlist: function (k) this.values.indexOf(k) >= 0, stringlist: function (k) this.values.indexOf(k) >= 0,
get charlist() this.stringlist, get charlist() this.stringlist,
regexlist: function (k) { regexlist: function (k, default_) {
for (let re in values(this.values)) for (let re in values(this.values))
if (re.test(k)) if (re.test(k))
return re.result; return re.result;
return null; return arguments.length > 1 ? default_ : null;
}, },
get regexmap() this.regexlist get regexmap() this.regexlist
}, },

View File

@@ -1376,6 +1376,24 @@
</description> </description>
</item> </item>
<item>
<tags>'wia' 'wildanchor'</tags>
<spec>'wildanchor' 'wia'</spec>
<type>regexlist</type>
<default>!/ex/(back|buffer|ext|forward|help|undo),.*</default>
<description>
<p>
Regular expression list defining which completion groups show only
matches anchored to the beginning of the result. The first
matching expression is the one that applies. If the match is
negated, then the current filter may match anywhere in the result.
If it is not negated, then the match may only occur at the
beginning of the result. If no items match, then a
context-dependent default value is used.
</p>
</description>
</item>
<item> <item>
<tags>'wic' 'wildcase'</tags> <tags>'wic' 'wildcase'</tags>
<spec>'wildcase' 'wic'</spec> <spec>'wildcase' 'wic'</spec>

View File

@@ -24,13 +24,14 @@
I.e., 'fo\o''bar' ≡ fo\o'bar I.e., 'fo\o''bar' ≡ fo\o'bar
* IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ,, * IMPORTANT: 'cdpath' and 'runtimepath' no longer treat ,,
specially. Use . instead. specially. Use . instead.
* Replaced 'focuscontent' with 'strictfocus'.
* Added 'hintkeys' option.
* Added 'altwildmode' and <A-Tab> commandline key binding. * Added 'altwildmode' and <A-Tab> commandline key binding.
* Added 'banghist' option.
* Added transliterated option to 'hintmatching'.
* Added 'autocomplete' option for specifying which completion * Added 'autocomplete' option for specifying which completion
groups should be auto-completed. groups should be auto-completed.
* Added 'banghist' option.
* Added 'hintkeys' option.
* Replaced 'focuscontent' with 'strictfocus'.
* Added 'wildanchor' option.
* Added transliterated option to 'hintmatching'.
* Added -javascript option to :abbrev and :map. * Added -javascript option to :abbrev and :map.
* Added several new options to :map. * Added several new options to :map.
* Removed the :source line at the end of files generated by * Removed the :source line at the end of files generated by

View File

@@ -42,7 +42,6 @@ BUGS:
FEATURES: FEATURES:
9 Make 'loadplugins' a regexlist 9 Make 'loadplugins' a regexlist
9 Add 'wildanchor' option
9 Add quoting help tag 9 Add quoting help tag
9 JavaScript completer: show function parameter spec 9 JavaScript completer: show function parameter spec
9 Fix the arbitrary distinction between 'hinttags' and 9 Fix the arbitrary distinction between 'hinttags' and