-// Copyright (c) 2010-2012 Kris Maglione <maglione.k@gmail.com>
+// Copyright (c) 2010-2013 Kris Maglione <maglione.k@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
get builtin() this.modules.contexts.builtinGroups.indexOf(this) >= 0,
}, {
- compileFilter: function (patterns, default_ = false) {
- if (arguments.length < 2)
- default_ = false;
-
+ compileFilter: function (patterns, default_=false) {
function siteFilter(uri)
- let (match = array.nth(siteFilter.filters, function (f) f(uri), 0))
+ let (match = array.nth(siteFilter.filters, f => f(uri), 0))
match ? match.result : default_;
return update(siteFilter, {
toJSONXML: function (modules) let (uri = modules && modules.buffer.uri)
template.map(this.filters,
- function (f) ["span", { highlight: uri && f(uri) ? "Filter" : "" },
- "toJSONXML" in f ? f.toJSONXML() : String(f)],
+ f => ["span", { highlight: uri && f(uri) ? "Filter" : "" },
+ ("toJSONXML" in f ? f.toJSONXML()
+ : String(f))],
","),
filters: Option.parse.sitelist(patterns)
completer: function (context) modules.completion.group(context)
});
- memoize(modules, "userContext", function () contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, true]));
- memoize(modules, "_userContext", function () contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules.userContext]));
+ memoize(modules, "userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules, true]));
+ memoize(modules, "_userContext", () => contexts.Context(modules.io.getRCFile("~", true), contexts.user, [modules.userContext]));
},
cleanup: function () {
});
memoize(contexts.hives, name,
- function () Object.create(Object.create(contexts.hiveProto,
- { _hive: { value: name } })));
+ () => Object.create(Object.create(contexts.hiveProto,
+ { _hive: { value: name } })));
memoize(contexts.groupsProto, name,
function () [group[name] for (group in values(this.groups)) if (Set.has(group, name))]);
Context: function Context(file, group, args) {
const { contexts, io, newContext, plugins, userContext } = this.modules;
- let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
- function (dir) dir.contains(file, true),
- 0);
+ let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
+ dir => dir.contains(file, true),
+ 0);
let isRuntime = array.nth(io.getRuntimeDirectories(""),
- function (dir) dir.contains(file, true),
+ dir => dir.contains(file, true),
0);
let name = isPlugin ? file.getRelativeDescriptor(isPlugin).replace(File.PATH_SEP, "-")
var file = File(uri.file);
let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
- function (dir) dir.contains(file, true),
+ dir => dir.contains(file, true),
0);
let name = isPlugin && file && file.getRelativeDescriptor(isPlugin)
initializedGroups: function (hive)
let (need = hive ? [hive] : Object.keys(this.hives))
- this.groupList.filter(function (group) need.some(Set.has(group))),
+ this.groupList.filter(group => need.some(Set.has(group))),
addGroup: function addGroup(name, description, filter, persist, replace) {
let group = this.getGroup(name);
for ([i, name] in Iterator(params)));
let rhs = args.literalArg;
- let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce(function (a, b) args[b] ? b : a, default_);
+ let type = ["-builtin", "-ex", "-javascript", "-keys"].reduce((a, b) => args[b] ? b : a, default_);
switch (type) {
case "-builtin":
action = dactyl.userEval("(function action() { with (action.makeParams(this, arguments)) {" + args.literalArg + "} })");
else
action = dactyl.userFunc.apply(dactyl, params.concat(args.literalArg));
- process = function (param) isObject(param) && param.valueOf ? param.valueOf() : param;
+ process = param => isObject(param) && param.valueOf ? param.valueOf() : param;
action.params = params;
action.makeParams = makeParams;
break;
util.assert(args.bang ^ !!args[0], _("error.argumentOrBang"));
if (args.bang)
- contexts.groupList = contexts.groupList.filter(function (g) g.builtin);
+ contexts.groupList = contexts.groupList.filter(g => g.builtin);
else {
util.assert(contexts.getGroup(args[0]), _("group.noSuch", args[0]));
contexts.removeGroup(args[0]);
completer: function (context, args) {
if (args.bang)
return;
- context.filters.push(function ({ item }) !item.builtin);
+ context.filters.push(({ item }) => !item.builtin);
modules.completion.group(context);
}
});
context.title = ["Group"];
let uri = modules.buffer.uri;
context.keys = {
- active: function (group) group.filter(uri),
+ active: group => group.filter(uri),
text: "name",
description: function (g) ["", g.filter.toJSONXML ? g.filter.toJSONXML(modules).concat("\u00a0") : "", g.description || ""]
};
iter({ Active: true, Inactive: false }).forEach(function ([name, active]) {
context.split(name, null, function (context) {
context.title[0] = name + " Groups";
- context.filters.push(function ({ item }) !!item.filter(modules.buffer.uri) == active);
+ context.filters.push(({ item }) => !!item.filter(modules.buffer.uri) == active);
});
});
};