summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKris Maglione <maglione.k@gmail.com>2010-12-29 23:09:29 -0500
committerKris Maglione <maglione.k@gmail.com>2010-12-29 23:09:29 -0500
commit538b91719e8406615694564a9ff560a77d973436 (patch)
tree379d4b54f3f212fc4e0ddad84f5aa6f2fae90b61
parent8d8df1e53ee5d41a594129670b31250ca2eaea9a (diff)
downloadpentadactyl-538b91719e8406615694564a9ff560a77d973436.tar.gz
Allow recursive :hi linking.
-rw-r--r--common/modules/highlight.jsm30
1 files changed, 22 insertions, 8 deletions
diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm
index 8561afd1..54311f6a 100644
--- a/common/modules/highlight.jsm
+++ b/common/modules/highlight.jsm
@@ -60,7 +60,17 @@ update(Highlight.prototype, {
get bases() array.compact(this.extends.map(function (name) highlight.get(name))),
- get inheritedCSS() this.bases.map(function (b) b.value.replace(/;?\s*$/, "; ")).join(""),
+ get inheritedCSS() {
+ if (this.gettingCSS)
+ return "";
+ try {
+ this.gettingCSS = true;
+ return this.bases.map(function (b) (b.inheritedCSS + b.value).replace(/;?\s*$/, "; ")).join("");
+ }
+ finally {
+ this.gettingCSS = false;
+ }
+ },
get css() this.selector + "{" + this.inheritedCSS + this.value + "}",
@@ -128,15 +138,15 @@ var Highlights = Module("Highlight", {
let highlight = this.highlight[key] || this._create(false, [key]);
- extend = extend || highlight.extend;
+ let extends = extend || highlight.extend;
if (append) {
newStyle = Styles.append(highlight.value || "", newStyle);
- extend = highlight.extends.concat(extend);
+ extends = highlight.extends.concat(extends);
}
if (/^\s*$/.test(newStyle))
newStyle = null;
- if (newStyle == null) {
+ if (newStyle == null && extend == null) {
if (highlight.default == null && highight.defaultExtends.length == 0) {
highlight.style.enabled = false;
delete this.loaded[highlight.class];
@@ -144,11 +154,11 @@ var Highlights = Module("Highlight", {
return null;
}
newStyle = highlight.default;
- extend = highlight.defaultExtends;
+ extends = highlight.defaultExtends;
}
- highlight.set("value", newStyle);
- highlight.extends = array.uniq(extend, true);
+ highlight.set("value", newStyle || "");
+ highlight.extends = array.uniq(extends, true);
if (force)
highlight.style.enabled = true;
this.highlight[highlight.class] = highlight;
@@ -295,9 +305,13 @@ var Highlights = Module("Highlight", {
args.shift();
let [key, css] = args;
- dactyl.assert(!(clear && css), "E488: Trailing characters");
let modify = css || clear || args["-append"] || args["-link"];
+ if (!modify && /&$/.test(key))
+ [clear, modify, key] = [true, true, key.replace(/&$/, "")];
+
+ dactyl.assert(!(clear && css), "E488: Trailing characters");
+
if (!modify)
modules.commandline.commandOutput(
template.tabular(["Key", "Sample", "CSS"],