1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-04-01 03:33:34 +02:00

More pointification and general code cleanup. Also massive, crazy, conflict-ridden merge.

This commit is contained in:
Kris Maglione
2013-09-21 14:13:07 -07:00
parent 2d90804d5f
commit 25aae2cc99
44 changed files with 350 additions and 230 deletions

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2009-2013 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2009-2010 by Doug Kearns <dougkearns@gmail.com>
//
// This work is licensed for reuse under an MIT license. Details are
@@ -64,7 +64,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
install.install();
},
onUpdateFinished: function (addon, error) {
this.remaining = this.remaining.filter(a => a.type != addon.type || a.id != addon.id);
this.remaining = this.remaining.filter(a => (a.type != addon.type || a.id != addon.id));
if (!this.remaining.length)
this.dactyl.echomsg(
this.upgrade.length
@@ -118,8 +118,10 @@ var actions = {
});
},
get filter() {
return addon => !addon.userDisabled &&
!(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE | AddonManager.OP_NEEDS_RESTART_DISABLE));
return addon => (
!addon.userDisabled &&
!(addon.operationsRequiringRestart & (AddonManager.OP_NEEDS_RESTART_ENABLE
| AddonManager.OP_NEEDS_RESTART_DISABLE)));
},
perm: "disable"
},
@@ -420,7 +422,7 @@ var Addons = Module("addons", {
AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) {
if (!args.bang || command.bang) {
list = list.filter(addon => addon.id == name || addon.name == name);
list = list.filter(addon => (addon.id == name || addon.name == name));
dactyl.assert(list.length, _("error.invalidArgument", name));
dactyl.assert(list.some(ok), _("error.invalidOperation"));
list = list.filter(ok);
@@ -429,7 +431,7 @@ var Addons = Module("addons", {
if (command.actions)
command.actions(list, this.modules);
else
list.forEach(addon => command.action.call(this.modules, addon, args.bang));
list.forEach(addon => { command.action.call(this.modules, addon, args.bang) });
}));
}, {
argCount: "?", // FIXME: should be "1"
@@ -475,7 +477,7 @@ var Addons = Module("addons", {
context.title = ["Add-on"];
context.anchored = false;
context.keys = {
text: function (addon) [addon.name, addon.id],
text: addon => [addon.name, addon.id],
description: "description",
icon: "iconURL"
};

View File

@@ -929,14 +929,14 @@ Class.prototype = {
return callback.call(self || this);
}
finally {
names.forEach((name, i) => this[name] = vals[i]);
names.forEach((name, i) => { this[name] = vals[i]; });
}
},
toString: function C_toString() {
if (this.toStringParams)
var params = "(" + this.toStringParams.map(m => isArray(m) ? "[" + m + "]" :
isString(m) ? m.quote() : String(m))
var params = "(" + this.toStringParams.map(m => (isArray(m) ? "[" + m + "]" :
isString(m) ? m.quote() : String(m)))
.join(", ") + ")";
return "[instance " + this.constructor.className + (params || "") + "]";
},
@@ -1172,7 +1172,7 @@ Module.INIT = {
module.isLocalModule = true;
modules.jsmodules[this.constructor.className] = module;
locals.reverse().forEach((fn, i) => update(objs[i], fn.apply(module, args)));
locals.reverse().forEach((fn, i) => { update(objs[i], fn.apply(module, args)); });
memoize(module, "closure", Class.makeClosure);
module.instance = module;

View File

@@ -1,4 +1,4 @@
// Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
// Copyright ©2008-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.

View File

@@ -435,7 +435,9 @@ var Buffer = Module("Buffer", {
yield elem;
function a(regexp, elem) regexp.test(elem.textContent) === regexp.result ||
Array.some(elem.childNodes, child => regexp.test(child.alt) === regexp.result);
Array.some(elem.childNodes,
child => (regexp.test(child.alt) === regexp.result));
function b(regexp, elem) regexp.test(elem.title) === regexp.result;
let res = Array.filter(frame.document.querySelectorAll(selector), Hints.isVisible);
@@ -904,8 +906,11 @@ var Buffer = Module("Buffer", {
let path = options["jumptags"][arg];
util.assert(path, _("error.invalidArgument", arg));
let distance = reverse ? rect => -rect.top : rect => rect.top;
let elems = [[e, distance(e.getBoundingClientRect())] for (e in path.matcher(this.focusedFrame.document))]
let distance = reverse ? rect => -rect.top
: rect => rect.top;
let elems = [[e, distance(e.getBoundingClientRect())]
for (e in path.matcher(this.focusedFrame.document))]
.filter(e => e[1] > FUDGE)
.sort((a, b) => a[1] - b[1]);
@@ -1003,7 +1008,7 @@ var Buffer = Module("Buffer", {
let info = template.map(
(sections || options["pageinfo"])
.map((opt) => Buffer.pageInfo[opt].action.call(this)),
res => res && iter(res).join(", ") || undefined,
res => (res && iter(res).join(", ") || undefined),
", ").join("");
if (bookmarkcache.isBookmarked(this.URL))
@@ -2413,7 +2418,8 @@ var Buffer = Module("Buffer", {
var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line);
else
res = iter.nth(filter.matcher(doc),
elem => (elem.nodeValue || elem.textContent).trim() == line && DOM(elem).display != "none",
elem => ((elem.nodeValue || elem.textContent).trim() == line &&
DOM(elem).display != "none"),
0)
|| iter.nth(filter.matcher(doc), util.identity, line - 1);
if (res)

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2011-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.
@@ -167,7 +167,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
},
force: function force(name, localOnly) {
util.waitFor(function () !this.inQueue, this);
util.waitFor(() => !this.inQueue);
if (this.cacheReader && this.cacheReader.hasEntry(name)) {
return this.parse(File.readStream(

View File

@@ -766,7 +766,8 @@ var Commands = Module("commands", {
// TODO: allow matching of aliases?
function cmds(hive) hive._list.filter(cmd => cmd.name.indexOf(filter || "") == 0)
let hives = (hives || this.userHives).map(h => [h, cmds(h)]).filter(([h, c]) => c.length);
let hives = (hives || this.userHives).map(h => [h, cmds(h)])
.filter(([h, c]) => c.length);
let list = ["table", {},
["tr", { highlight: "Title" },
@@ -815,7 +816,8 @@ var Commands = Module("commands", {
/** @property {Iterator(Command)} @private */
iterator: function iterator() iter.apply(null, this.hives.array)
.sort((a, b) => a.serialGroup - b.serialGroup || a.name > b.name)
.sort((a, b) => (a.serialGroup - b.serialGroup ||
a.name > b.name))
.iterValues(),
/** @property {string} The last executed Ex command line. */
@@ -1016,7 +1018,7 @@ var Commands = Module("commands", {
let matchOpts = function matchOpts(arg) {
// Push possible option matches into completions
if (complete && !onlyArgumentsRemaining)
completeOpts = options.filter(opt => opt.multiple || !Set.has(args, opt.names[0]));
completeOpts = options.filter(opt => (opt.multiple || !Set.has(args, opt.names[0])));
};
let resetCompletions = function resetCompletions() {
completeOpts = null;
@@ -1394,7 +1396,8 @@ var Commands = Module("commands", {
let quote = null;
let len = str.length;
function fixEscapes(str) str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g, (m, n1) => n1 || m);
function fixEscapes(str) str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g,
(m, n1) => n1 || m);
// Fix me.
if (isString(sep))
@@ -1725,7 +1728,7 @@ var Commands = Module("commands", {
]
})),
iterateIndex: function (args) let (tags = help.tags)
this.iterate(args).filter(cmd => cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag)),
this.iterate(args).filter(cmd => (cmd.hive === commands.builtin || Set.has(tags, cmd.helpTag))),
format: {
headings: ["Command", "Group", "Description"],
description: function (cmd) template.linkifyHelp(cmd.description + (cmd.replacementText ? ": " + cmd.action : "")),
@@ -1779,7 +1782,8 @@ var Commands = Module("commands", {
let quote = function quote(q, list, map) {
map = map || Commands.quoteMap;
let re = RegExp("[" + list + "]", "g");
function quote(str) q + String.replace(str, re, $0 => $0 in map ? map[$0] : ("\\" + $0)) + q;
function quote(str) (q + String.replace(str, re, $0 => ($0 in map ? map[$0] : ("\\" + $0)))
+ q);
quote.list = list;
return quote;
};

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -152,8 +152,10 @@ var ConfigBase = Class("ConfigBase", {
loadStyles: function loadStyles(force) {
highlight.styleableChrome = this.styleableChrome;
highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g, (m0, m1) => _(m1)));
highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, (m0, m1) => _(m1)));
highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g,
(m0, m1) => _(m1)));
highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g,
(m0, m1) => _(m1)));
if (!this.haveGecko("2b"))
highlight.loadCSS(literal(/*

View File

@@ -1,4 +1,4 @@
// 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.
@@ -78,8 +78,9 @@ var Group = Class("Group", {
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)
@@ -201,9 +202,9 @@ var Contexts = Module("contexts", {
Context: function Context(file, group, args) {
const { contexts, io, newContext, plugins, userContext } = this.modules;
let isPlugin = array.nth(io.getRuntimeDirectories("plugins"),
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(""),
dir => dir.contains(file, true),
0);
@@ -795,7 +796,7 @@ var Contexts = Module("contexts", {
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 || ""]
};

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -108,7 +108,7 @@ var DOM = Class("DOM", {
}]
]),
matcher: function matcher(sel) elem => elem.mozMatchesSelector && elem.mozMatchesSelector(sel),
matcher: function matcher(sel) elem => (elem.mozMatchesSelector && elem.mozMatchesSelector(sel)),
each: function each(fn, self) {
let obj = self || this.Empty();
@@ -794,19 +794,19 @@ var DOM = Class("DOM", {
html: function html(txt, self) {
return this.getSet(arguments,
elem => elem.innerHTML,
util.wrapCallback(function (elem, val) { elem.innerHTML = val; }));
util.wrapCallback((elem, val) => { elem.innerHTML = val; }));
},
text: function text(txt, self) {
return this.getSet(arguments,
elem => elem.textContent,
function (elem, val) { elem.textContent = val; });
(elem, val) => { elem.textContent = val; });
},
val: function val(txt) {
return this.getSet(arguments,
elem => elem.value,
function (elem, val) { elem.value = val == null ? "" : val; });
(elem, val) => { elem.value = val == null ? "" : val; });
},
listen: function listen(event, listener, capture) {
@@ -1664,13 +1664,13 @@ var DOM = Class("DOM", {
function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === "";
function hasString(args) {
return args.some(a => isString(a) || isFragment(a) && hasString(a));
return args.some(a => (isString(a) || isFragment(a) && hasString(a)));
}
function isStrings(args) {
if (!isArray(args))
return util.dump("ARGS: " + {}.toString.call(args) + " " + args), false;
return args.every(a => isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a));
return args.every(a => (isinstance(a, ["String", DOM.DOMString]) || isFragment(a) && isStrings(a)));
}
function tag(args, namespaces, indent) {
@@ -1878,7 +1878,9 @@ var DOM = Class("DOM", {
*/
makeXPath: function makeXPath(nodes) {
return array(nodes).map(util.debrace).flatten()
.map(node => /^[a-z]+:/.test(node) ? node : [node, "xhtml:" + node]).flatten()
.map(node => /^[a-z]+:/.test(node) ? node
: [node, "xhtml:" + node])
.flatten()
.map(node => "//" + node).join(" | ");
},
@@ -1891,7 +1893,7 @@ var DOM = Class("DOM", {
},
namespaceNames: Class.Memoize(function ()
iter(this.namespaces).map(([k, v]) => [v, k]).toObject()),
iter(this.namespaces).map(([k, v]) => ([v, k])).toObject()),
});
Object.keys(DOM.Event.types).forEach(function (event) {

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2011-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.
@@ -131,14 +131,14 @@ var Download = Class("Download", {
},
_compare: {
active: function (a, b) a.alive - b.alive,
complete: function (a, b) a.percentComplete - b.percentComplete,
date: function (a, b) a.startTime - b.startTime,
filename: function (a, b) String.localeCompare(a.targetFile.leafName, b.targetFile.leafName),
size: function (a, b) a.size - b.size,
speed: function (a, b) a.speed - b.speed,
time: function (a, b) a.timeRemaining - b.timeRemaining,
url: function (a, b) String.localeCompare(a.source.spec, b.source.spec)
active: (a, b) => a.alive - b.alive,
complete: (a, b) => a.percentComplete - b.percentComplete,
date: (a, b) => a.startTime - b.startTime,
filename: (a, b) => String.localeCompare(a.targetFile.leafName, b.targetFile.leafName),
size: (a, b) => a.size - b.size,
speed: (a, b) => a.speed - b.speed,
time: (a, b) => a.timeRemaining - b.timeRemaining,
url: (a, b) => String.localeCompare(a.source.spec, b.source.spec)
},
compare: function compare(other) values(this.list.sortOrder).map(function (order) {
@@ -497,13 +497,13 @@ var Downloads = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
.flatten().array;
},
has: function () Array.some(arguments, function (val) this.value.some(v => v.substr(1) == val)),
has: function () Array.some(arguments, val => this.value.some(v => v.substr(1) == val)),
validator: function (value) {
let seen = {};
return value.every(val => /^[+-]/.test(val) && Set.has(this.values, val.substr(1))
&& !Set.add(seen, val.substr(1))
) && value.length;
&& !Set.add(seen, val.substr(1)))
&& value.length;
}
});
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -104,7 +104,7 @@ var RangeFinder = Module("rangefinder", {
return "";
}
this.options["findflags"].forEach(function (f) { replacer(f, f); });
this.options["findflags"].forEach(f => replacer(f, f));
let pattern = str.replace(/\\(.|$)/g, replacer);
@@ -542,7 +542,7 @@ var RangeFind = Class("RangeFind", {
}
}
finally {
saved.forEach(function ([k, v]) { this[k] = v; }, this);
saved.forEach(([k, v]) => { this[k] = v; });
}
},
@@ -611,7 +611,7 @@ var RangeFind = Class("RangeFind", {
this.range = this.findRange(this.startRange) || this.ranges[0];
util.assert(this.range, "Null range", false);
this.ranges.first = this.range;
this.ranges.forEach(function (range) { range.save(); });
this.ranges.forEach(range => { range.save(); });
this.forward = null;
this.found = false;
},

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -367,8 +367,8 @@ var Help = Module("Help", {
for (let [file, ] in Iterator(help.files)) {
let url = "dactyl://help/" + file;
dactyl.open(url);
util.waitFor(() => content.location.href == url && buffer.loaded
&& content.document.documentElement instanceof Ci.nsIDOMHTMLHtmlElement,
util.waitFor(() => (content.location.href == url && buffer.loaded &&
content.document.documentElement instanceof Ci.nsIDOMHTMLHtmlElement),
15000);
events.waitForPageLoad();
var data = [

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -282,8 +282,8 @@ var Highlights = Module("Highlight", {
*/
loadCSS: function loadCSS(css, eager) {
String.replace(css, /\\\n/g, "")
.replace(this.groupRegexp, (m, m1, m2) => m1 + " " + m2.replace(/\n\s*/g, " "))
.split("\n").filter(s => /\S/.test(s) && !/^\s*\/\//.test(s))
.replace(this.groupRegexp, (m, m1, m2) => (m1 + " " + m2.replace(/\n\s*/g, " ")))
.split("\n").filter(s => (/\S/.test(s) && !/^\s*\/\//.test(s)))
.forEach(function (highlight) {
let bang = eager || /^\s*!/.test(highlight);
@@ -354,7 +354,7 @@ var Highlights = Module("Highlight", {
["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"],
template.map(h.extends, s => template.highlight(s), ","),
template.highlightRegexp(h.value, /\b[-\w]+(?=:)|\/\*.*?\*\//g,
function (match) ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])
match => ["span", { highlight: match[0] == "/" ? "Comment" : "Key" }, match])
]
for (h in highlight)
if (!key || h.class.indexOf(key) > -1))));
@@ -424,12 +424,13 @@ var Highlights = Module("Highlight", {
let extRe = RegExp("\\." + config.fileExtension + "$");
context.title = ["Color Scheme", "Runtime Path"];
context.keys = { text: function (f) f.leafName.replace(extRe, ""), description: ".parent.path" };
context.keys = { text: f => f.leafName.replace(extRe, ""),
description: ".parent.path" };
context.completions =
array.flatten(
io.getRuntimeDirectories("colors").map(
dir => dir.readDirectory().filter(
file => extRe.test(file.leafName))))
dir => dir.readDirectory()
.filter(file => extRe.test(file.leafName))))
.concat([
{ leafName: "default", parent: { path: /*L*/"Revert to builtin colorscheme" } }
]);

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2012 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-2013 Kris Maglione <maglione.k@gmail.com>
// Some code based on Venkman
//
// This work is licensed for reuse under an MIT license. Details are
@@ -75,7 +75,7 @@ var IO = Module("io", {
getRuntimeDirectories: function getRuntimeDirectories(name) {
return modules.options.get("runtimepath").files
.map(dir => dir.child(name))
.filter(dir => dir.exists() && dir.isDirectory() && dir.isReadable());
.filter(dir => (dir.exists() && dir.isDirectory() && dir.isReadable()));
},
// FIXME: multiple paths?
@@ -502,7 +502,9 @@ var IO = Module("io", {
function async(status) {
let output = stdout.read();
[stdin, stdout, cmd].forEach(f => f.exists() && f.remove(false));
for (let f of [stdin, stdout, cmd])
if (f.exists())
f.remove(false);
callback(result(status, output));
}
@@ -550,7 +552,7 @@ var IO = Module("io", {
}
finally {
if (!checked || res !== true)
args.forEach(f => f.remove(false));
args.forEach(f => { f.remove(false); });
}
return res;
}
@@ -806,7 +808,9 @@ unlet s:cpo_save
lines.last.push(item, sep);
}
lines.last.pop();
return lines.map(l => l.join("")).join("\n").replace(/\s+\n/gm, "\n");
return lines.map(l => l.join(""))
.join("\n")
.replace(/\s+\n/gm, "\n");
}//}}}
let params = { //{{{
@@ -904,8 +908,8 @@ unlet s:cpo_save
_("command.run.noPrevious"));
arg = arg.replace(/(\\)*!/g,
m => /^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!") : m.replace("!", io._lastRunCommand)
);
m => (/^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!")
: m.replace("!", io._lastRunCommand)));
}
io._lastRunCommand = arg;

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -273,7 +273,7 @@ var JavaScript = Module("javascript", {
// Don't eval any function calls unless the user presses tab.
_checkFunction: function (start, end, key) {
let res = this._functions.some(idx => idx >= start && idx < end);
let res = this._function(idx => (idx >= start && idx < end));
if (!res || this.context.tabPressed || key in this.cache.evalled)
return false;
this.context.waitingForTab = true;
@@ -371,7 +371,8 @@ var JavaScript = Module("javascript", {
};
base.keys = {
text: prefix ? text => text.substr(prefix.length) : util.identity,
text: prefix ? text => text.substr(prefix.length)
: text => text,
description: function (item) self.getKey(this.obj, item),
key: function (item) {
if (!isNaN(key))
@@ -491,7 +492,7 @@ var JavaScript = Module("javascript", {
let [, prefix, args] = /^(function .*?)\((.*?)\)/.exec(Function.prototype.toString.call(func));
let n = this._get(i).comma.length;
args = template.map(Iterator(args.split(", ")),
function ([i, arg]) ["span", { highlight: i == n ? "Filter" : "" }, arg],
([i, arg]) => ["span", { highlight: i == n ? "Filter" : "" }, arg],
",\u00a0");
this.context.message = ["", prefix + "(", args, ")"];
}

View File

@@ -151,7 +151,7 @@ var Modules = function Modules(window) {
Object.getOwnPropertyNames(this)
.map(name => Object.getOwnPropertyDescriptor(this, name).value)),
get moduleList() this.ownPropertyValues.filter(mod => mod instanceof this.ModuleBase || mod.isLocalModule)
get moduleList() this.ownPropertyValues.filter(mod => (mod instanceof this.ModuleBase || mod.isLocalModule))
});
modules.plugins = create(modules);
@@ -161,7 +161,8 @@ var Modules = function Modules(window) {
config.loadStyles();
overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
overlay.overlayWindow(Object.keys(config.overlays),
function _overlay(window) ({
ready: function onInit(document) {
const modules = Modules(window);
modules.moduleManager = this;
@@ -179,7 +180,7 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
});
config.modules.window
.forEach(name => defineModule.time("load", name, modules.load, modules, name));
.forEach(name => { defineModule.time("load", name, modules.load, modules, name); });
}, this);
},

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2011-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.

View File

@@ -75,7 +75,7 @@ var Option = Class("Option", {
get helpTag() "'" + this.name + "'",
initValue: function initValue() {
util.trapErrors(() => this.value = this.value, this);
util.trapErrors(() => { this.value = this.value; });
},
get isDefault() this.stringValue === this.stringDefaultValue,
@@ -464,7 +464,8 @@ var Option = Class("Option", {
let [, bang, filter] = /^(!?)(.*)/.exec(pattern);
filter = Option.dequote(filter).trim();
let quote = this.keepQuotes ? util.identity : function (v) Option.quote(v, /:/);
let quote = this.keepQuotes ? v => v
: v => Option.quote(v, /:/);
return update(Styles.matchFilter(filter), {
bang: bang,
@@ -731,7 +732,7 @@ var Option = Class("Option", {
acceptable = completions.call(this);
if (isArray(acceptable))
acceptable = Set(acceptable.map(([k]) => k));
acceptable = Set(acceptable.map(([k]) => (k)));
if (this.type === "regexpmap" || this.type === "sitemap")
return Array.concat(vals).every(re => Set.has(acceptable, re.result));
@@ -927,7 +928,9 @@ var Options = Module("options", {
let closure = () => this._optionMap[name];
memoize(this._optionMap, name, () => Option.types[type](modules, names, description, defaultValue, extraInfo));
memoize(this._optionMap, name,
function () Option.types[type](modules, names, description, defaultValue, extraInfo));
for (let alias in values(names.slice(1)))
memoize(this._optionMap, alias, closure);
@@ -1098,9 +1101,11 @@ var Options = Module("options", {
let names = Set(list.map(opt => opt.option ? opt.option.name : ""));
if (list.length)
if (list.some(opt => opt.all))
options.list(opt => !(list[0].onlyNonDefault && opt.isDefault), list[0].scope);
options.list(opt => !(list[0].onlyNonDefault && opt.isDefault),
list[0].scope);
else
options.list(opt => Set.has(names, opt.name), list[0].scope);
options.list(opt => Set.has(names, opt.name),
list[0].scope);
list = [];
}
@@ -1229,8 +1234,12 @@ var Options = Module("options", {
context.highlight();
if (context.filter.indexOf("=") == -1) {
if (false && prefix)
context.filters.push(({ item }) => item.type == "boolean" || prefix == "inv" && isArray(item.values));
return completion.option(context, opt.scope, opt.name == "inv" ? opt.name : prefix);
context.filters.push(({ item }) => (item.type == "boolean" ||
prefix == "inv" && isArray(item.values)));
return completion.option(context, opt.scope,
opt.name == "inv" ? opt.name
: prefix);
}
function error(length, message) {
@@ -1484,7 +1493,8 @@ var Options = Module("options", {
function val(obj) {
if (isArray(opt.defaultValue)) {
let val = array.nth(obj, re => re.key == extra.key, 0);
let val = array.nth(obj, re => (re.key == extra.key),
0);
return val && val.result;
}
if (Set.has(opt.defaultValue, extra.key))
@@ -1496,7 +1506,7 @@ var Options = Module("options", {
context.completions = [
[val(opt.value), _("option.currentValue")],
[val(opt.defaultValue), _("option.defaultValue")]
].filter(f => f[0] !== "" && f[0] != null);
].filter(f => (f[0] !== "" && f[0] != null));
});
context = context.fork("stuff", 0);
}

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2009-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2009-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.
@@ -148,7 +148,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
"content-document-global-created": function (window, uri) { this.observe(window, "toplevel-window-ready", null); },
"xul-window-visible": function () {
if (this.onWindowVisible)
this.onWindowVisible.forEach(function (f) { f.call(this); }, this);
this.onWindowVisible.forEach(f => { f.call(this); });
this.onWindowVisible = null;
}
},
@@ -189,7 +189,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
return data[key] = val;
},
overlayWindow: function (url, fn) {
overlayWindow: function overlayWindow(url, fn) {
if (url instanceof Ci.nsIDOMWindow)
overlay._loadOverlay(url, fn);
else {

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -375,7 +375,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
if (!this._observers[pref])
this._observers[pref] = [];
this._observers[pref].push(!strong ? util.weakReference(callback) : { get: function () callback });
this._observers[pref].push(!strong ? util.weakReference(callback)
: { get: function () callback });
},
/**
@@ -422,7 +423,8 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference])
modules.completion.preference = function preference(context) {
context.anchored = false;
context.title = [config.host + " Preference", "Value"];
context.keys = { text: function (item) item, description: function (item) prefs.get(item) };
context.keys = { text: function (item) item,
description: function (item) prefs.get(item) };
context.completions = prefs.getNames();
};
},

View File

@@ -1,5 +1,5 @@
// Copyright (c) 2009 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2009-2012 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2009-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -186,7 +186,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
let (branch = Item.PREFIX + Item.SHUTDOWN_BRANCH) {
overlay.overlayWindow("chrome://browser/content/preferences/sanitize.xul",
function (win) prefOverlay(branch, true, {
function (win) prefOverlay(branch, true, {
append: {
SanitizeDialogPane:
["groupbox", { orient: "horizontal", xmlns: "xul" },
@@ -612,11 +612,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
},
has: function has(val)
let (res = array.nth(this.value, v => v == "all" || v.replace(/^!/, "") == val, 0))
let (res = array.nth(this.value, v => (v == "all" || v.replace(/^!/, "") == val),
0))
res && !/^!/.test(res),
validator: function (values) values.length &&
values.every(val => val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, "")))
values.every(val => (val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, ""))))
});
options.add(["sanitizeshutdown", "ss"],

View File

@@ -126,7 +126,8 @@ var Services = Module("Services", {
if (!service.interfaces.length)
return res.wrappedJSObject || res;
service.interfaces.forEach(iface => res instanceof Ci[iface]);
service.interfaces.forEach(iface => { res instanceof Ci[iface]; });
if (service.init && args.length) {
if (service.callable)
res[service.init].apply(res, args);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -293,7 +293,8 @@ var Storage = Module("Storage", {
this.observers[key] = [];
if (!this.observers[key].some(o => o.callback.get() == callback))
this.observers[key].push({ ref: ref && Cu.getWeakReference(ref), callback: callbackRef });
this.observers[key].push({ ref: ref && Cu.getWeakReference(ref),
callback: callbackRef });
},
removeObserver: function (key, callback) {
@@ -495,7 +496,8 @@ var File = Class("File", {
let array = [e for (e in this.iterDirectory())];
if (sort)
array.sort((a, b) => b.isDirectory() - a.isDirectory() || String.localeCompare(a.path, b.path));
array.sort((a, b) => (b.isDirectory() - a.isDirectory() ||
String.localeCompare(a.path, b.path)));
return array;
},
@@ -693,10 +695,9 @@ var File = Class("File", {
// Kris reckons we shouldn't replicate this 'bug'. --djk
// TODO: should we be doing this for all paths?
function expand(path) path.replace(
!win32 ? /\$(\w+)\b|\${(\w+)}/g
: /\$(\w+)\b|\${(\w+)}|%(\w+)%/g,
(m, n1, n2, n3) => getenv(n1 || n2 || n3) || m
);
win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g
: /\$(\w+)\b|\${(\w+)}/g,
(m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m));
path = expand(path);
// expand ~

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
@@ -36,7 +36,7 @@ Sheet.liveProperty("sites");
update(Sheet.prototype, {
formatSites: function (uris)
template.map(this.sites,
function (filter) ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter],
filter => ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter],
","),
remove: function () { this.hive.remove(this); },
@@ -102,7 +102,8 @@ var Hive = Class("Hive", {
this.dropRef(null);
},
dropRef: function (obj) {
this.refs = this.refs.filter(ref => ref.get() && ref.get() !== obj);
this.refs = this.refs.filter(ref => (ref.get() && ref.get() !== obj));
if (!this.refs.length) {
this.cleanup();
styles.hives = styles.hives.filter(h => h !== this);
@@ -116,7 +117,9 @@ var Hive = Class("Hive", {
__iterator__: function () Iterator(this.sheets),
get sites() array(this.sheets).map(s => s.sites).flatten().uniq().array,
get sites() array(this.sheets).map(s => s.sites)
.flatten()
.uniq().array,
/**
* Add a new style sheet.
@@ -189,6 +192,7 @@ var Hive = Class("Hive", {
matches = matches.filter(i => this.sheets[i].css == css);
if (filter)
matches = matches.filter(i => this.sheets[i].sites.indexOf(filter) >= 0);
return matches.map(i => this.sheets[i]);
},
@@ -273,7 +277,8 @@ var Styles = Module("Styles", {
},
addHive: function addHive(name, ref, persist) {
let hive = array.nth(this.hives, h => h.name === name, 0);
let hive = array.nth(this.hives, h => h.name === name,
0);
if (!hive) {
hive = Hive(name, persist);
this.hives.push(hive);
@@ -304,14 +309,14 @@ var Styles = Module("Styles", {
list: function list(content, sites, name, hives) {
const { commandline, dactyl } = this.modules;
hives = hives || styles.hives.filter(h => h.modifiable && h.sheets.length);
hives = hives || styles.hives.filter(h => (h.modifiable && h.sheets.length));
function sheets(group)
group.sheets.slice()
.filter(sheet => (!name || sheet.name === name) &&
(!sites || sites.every(s => sheet.sites.indexOf(s) >= 0)))
.sort((a, b) => a.name && b.name ? String.localeCompare(a.name, b.name)
: !!b.name - !!a.name || a.id - b.id);
.filter(sheet => ((!name || sheet.name === name) &&
(!sites || sites.every(s => sheet.sites.indexOf(s) >= 0))))
.sort((a, b) => (a.name && b.name ? String.localeCompare(a.name, b.name)
: !!b.name - !!a.name || a.id - b.id));
let uris = util.visibleURIs(content);
@@ -622,7 +627,8 @@ var Styles = Module("Styles", {
.filter(hive => hive.persist)
.map(hive =>
hive.sheets.filter(style => style.persist)
.sort((a, b) => String.localeCompare(a.name || "", b.name || ""))
.sort((a, b) => String.localeCompare(a.name || "",
b.name || ""))
.map(style => ({
command: "style",
arguments: [style.sites.join(",")],
@@ -716,7 +722,8 @@ var Styles = Module("Styles", {
const names = Array.slice(DOM(["div"], window.document).style);
modules.completion.css = function (context) {
context.title = ["CSS Property"];
context.keys = { text: function (p) p + ":", description: function () "" };
context.keys = { text: function (p) p + ":",
description: function () "" };
for (let match in Styles.propertyIter(context.filter, true))
var lastMatch = match;
@@ -749,7 +756,8 @@ var Styles = Module("Styles", {
if (match.function)
return ["", template.filter(match.word),
template.highlightRegexp(match.function, patterns.string,
function (match) ["span", { highlight: "String" }, match.string])
match => ["span", { highlight: "String" },
match.string])
];
if (match.important == "!important")
return ["span", { highlight: "String" }, match.important];

View File

@@ -1,6 +1,6 @@
// Copyright (c) 2006-2008 by Martin Stubenschrott <stubenschrott@vimperator.org>
// Copyright (c) 2007-2011 by Doug Kearns <dougkearns@gmail.com>
// Copyright (c) 2008-2012 Kris Maglione <maglione.k@gmail.com>
// Copyright (c) 2008-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.
@@ -185,7 +185,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {string} name The name to mangle.
* @returns {string} The mangled name.
*/
camelCase: function camelCase(name) String.replace(name, /-(.)/g, (m, m1) => m1.toUpperCase()),
camelCase: function camelCase(name) String.replace(name, /-(.)/g,
(m, m1) => m1.toUpperCase()),
/**
* Capitalizes the first character of the given string.
@@ -261,8 +262,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
function frame() update(
function _frame(obj)
_frame === stack.top || _frame.valid(obj) ?
_frame.elements.map(e => callable(e) ? e(obj) : e).join("") : "",
_frame === stack.top || _frame.valid(obj)
? _frame.elements.map(e => callable(e) ? e(obj) : e)
.join("")
: "",
{
elements: [],
seen: {},
@@ -295,7 +298,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
char = char.toLowerCase();
stack.top.elements.push(update(
obj => obj[char] != null ? quote(obj, char) : "",
function (obj) obj[char] != null ? quote(obj, char)
: "",
{ test: function test(obj) obj[char] != null }));
for (let elem in array.iterValues(stack))
@@ -344,12 +348,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
function frame() update(
function _frame(obj)
_frame === stack.top || _frame.valid(obj) ?
_frame.elements.map(e => callable(e) ? e(obj) : e).join("") : "",
_frame === stack.top || _frame.valid(obj)
? _frame.elements.map(e => callable(e) ? e(obj) : e)
.join("")
: "",
{
elements: [],
seen: {},
valid: function valid(obj) this.elements.every(e => !e.test || e.test(obj))
valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj)))
});
let defaults = { lt: "<", gt: ">" };
@@ -999,7 +1005,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
if (color) {
obj = template.highlightFilter(util.clip(obj, 150), "\n",
function () ["span", { highlight: "NonText" }, "^J"]);
() => ["span", { highlight: "NonText" },
"^J"]);
var head = ["span", { highlight: "Title Object" }, obj, "::\n"];
}
else
@@ -1066,7 +1074,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
return String.localeCompare(a[0], b[0]);
}
let vals = template.map(keys.sort(compare), f => f[1], "\n");
let vals = template.map(keys.sort(compare), f => f[1],
"\n");
if (color) {
return ["div", { style: "white-space: pre-wrap" }, head, vals];
}
@@ -1252,7 +1262,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
// Strip comments and white space.
if (/x/.test(flags))
expr = String.replace(expr, /(\\.)|\/\/[^\n]*|\/\*[^]*?\*\/|\s+/gm, (m, m1) => m1 || "");
expr = String.replace(expr, /(\\.)|\/\/[^\n]*|\/\*[^]*?\*\/|\s+/gm,
(m, m1) => m1 || "");
// Replace (?P<named> parameters)
if (/\(\?P</.test(expr)) {
@@ -1296,7 +1307,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
* @param {RegExp} re The regexp showable source of which is to be returned.
* @returns {string}
*/
getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g, (m0, m1) => m1 === "/" ? "/" : m0),
getSource: function regexp_getSource(re) re.source.replace(/\\(.)/g,
(m0, m1) => m1 === "/" ? m1
: m0),
/**
* Iterates over all matches of the given regexp in the given