aboutsummaryrefslogtreecommitdiffstats
path: root/my-style.js
diff options
context:
space:
mode:
authoranekos2011-09-07 21:46:18 +0900
committeranekos2011-09-07 21:46:18 +0900
commit498bb2abfc44bfcfdfabb0006b5b18bef9cec40d (patch)
tree45356740a153fe29711574711004b5e0b7fc17c3 /my-style.js
parent18658cabbe0f717c08dcadc55a329b5cd31ffea9 (diff)
downloadvimperator-plugins-498bb2abfc44bfcfdfabb0006b5b18bef9cec40d.tar.bz2
一応保存できるようにした
Diffstat (limited to 'my-style.js')
-rw-r--r--my-style.js30
1 files changed, 26 insertions, 4 deletions
diff --git a/my-style.js b/my-style.js
index 7a761d4..9452d1f 100644
--- a/my-style.js
+++ b/my-style.js
@@ -165,7 +165,9 @@ EOM
);
}
- const Currents = {};
+ let Currents = {};
+
+ const store = storage.newMap(__context__.NAME, {store: true});
function expand (css)
css.replace(/\w+/g, function (n) (DefinedStyles.hasOwnProperty(n) ? DefinedStyles[n] : n));
@@ -220,15 +222,17 @@ EOM
];
}
+ function set (url, css) {
+ Currents[url] = css;
+ styles.addSheet(false, StyleNamePrefix + url, url, expand(css));
+ }
const SubCommands = [
new Command(
['s[et]'],
'Set style',
function (args) {
- let m = args[0];
- Currents[m] = args.literalArg;
- styles.addSheet(false, StyleNamePrefix + m, m, expand(args.literalArg));
+ set(args[0], args.literalArg);
},
{
literal: 1,
@@ -257,6 +261,19 @@ EOM
literal: 1,
completer: styleNameCompleter
}
+ ),
+
+ new Command(
+ ['p[ermanent]'],
+ 'Permanent current styles',
+ function (args) {
+ store.set('permanent', Currents);
+ store.save();
+ liberator.echo('Permanent current styles');
+ },
+ {
+ argCount: '0',
+ }
)
];
@@ -274,6 +291,11 @@ EOM
true
);
+ Currents = store.get('permanent', {});
+ for (let [url, css] in Iterator(Currents)) {
+ set(url, css);
+ }
+
})();
// vim:sw=2 ts=2 et si fdm=marker: