mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-09 23:34:17 +01:00
Replace expression closures (function expressions).
Expression closures are to be axed. See https://bugzil.la/1083458.
This commit is contained in:
@@ -432,10 +432,10 @@ var Bookmarks = Module("bookmarks", {
|
||||
names: ["-tags", "-T"],
|
||||
description: "A comma-separated list of tags",
|
||||
completer: function tags(context) {
|
||||
context.generate = function () Ary(b.tags
|
||||
for (b of bookmarkcache)
|
||||
if (b.tags))
|
||||
.flatten().uniq().array;
|
||||
context.generate = () => Ary(b.tags
|
||||
for (b of bookmarkcache)
|
||||
if (b.tags))
|
||||
.flatten().uniq().array;
|
||||
context.keys = { text: util.identity, description: util.identity };
|
||||
},
|
||||
type: CommandOption.LIST
|
||||
@@ -561,7 +561,7 @@ var Bookmarks = Module("bookmarks", {
|
||||
function (args) {
|
||||
if (args.bang)
|
||||
commandline.input(_("bookmark.prompt.deleteAll") + " ").then(
|
||||
function (resp) {
|
||||
resp => {
|
||||
if (resp && resp.match(/^y(es)?$/i)) {
|
||||
bookmarks.remove(Object.keys(bookmarkcache.bookmarks));
|
||||
dactyl.echomsg(_("bookmark.allDeleted"));
|
||||
@@ -680,12 +680,12 @@ var Bookmarks = Module("bookmarks", {
|
||||
|
||||
let item = keywords[keyword];
|
||||
if (item && item.url.contains("%s"))
|
||||
context.fork("keyword/" + keyword, keyword.length + space.length, null, function (context) {
|
||||
context.fork("keyword/" + keyword, keyword.length + space.length, null, context => {
|
||||
context.format = history.format;
|
||||
context.title = [/*L*/keyword + " Quick Search"];
|
||||
context.keys = { text: "url", description: "title", icon: "icon" };
|
||||
context.compare = CompletionContext.Sort.unsorted;
|
||||
context.generate = function () {
|
||||
context.generate = () => {
|
||||
let [begin, end] = item.url.split("%s");
|
||||
|
||||
let seen = new RealSet;
|
||||
|
||||
@@ -271,8 +271,8 @@ var CommandWidgets = Class("CommandWidgets", {
|
||||
|
||||
active: Class.Memoize(Object),
|
||||
activeGroup: Class.Memoize(Object),
|
||||
commandbar: Class.Memoize(function () ({ group: "Cmd" })),
|
||||
statusbar: Class.Memoize(function () ({ group: "Status" })),
|
||||
commandbar: Class.Memoize(() => ({ group: "Cmd" })),
|
||||
statusbar: Class.Memoize(() => ({ group: "Status" })),
|
||||
|
||||
_ready: function _ready(elem) {
|
||||
return elem.contentDocument.documentURI === elem.getAttribute("src") &&
|
||||
@@ -505,7 +505,7 @@ var CommandLine = Module("commandline", {
|
||||
init: function init() {
|
||||
this._callbacks = {};
|
||||
|
||||
memoize(this, "_store", function () storage.newMap("command-history", { store: true, privateData: true }));
|
||||
memoize(this, "_store", () => storage.newMap("command-history", { store: true, privateData: true }));
|
||||
|
||||
for (let name of ["command", "search"])
|
||||
if (storage.exists("history-" + name)) {
|
||||
@@ -778,7 +778,7 @@ var CommandLine = Module("commandline", {
|
||||
|
||||
highlightGroup = highlightGroup || this.HL_NORMAL;
|
||||
|
||||
let appendToMessages = (data) => {
|
||||
let appendToMessages = data => {
|
||||
let message = isObject(data) && !DOM.isJSONXML(data) ? data : { message: data };
|
||||
|
||||
// Make sure the memoized message property is an instance property.
|
||||
@@ -1797,7 +1797,7 @@ var CommandLine = Module("commandline", {
|
||||
self.completions.tabTimer.flush();
|
||||
|
||||
self.accepted = true;
|
||||
return function () { modes.pop(); };
|
||||
return () => { modes.pop(); };
|
||||
});
|
||||
|
||||
[
|
||||
@@ -2347,7 +2347,7 @@ var ItemList = Class("ItemList", {
|
||||
var scrollY = this.win.scrollY + rect.bottom - this.win.innerHeight;
|
||||
}
|
||||
|
||||
return function () {
|
||||
return () => {
|
||||
container.style.height = height + "px";
|
||||
container.scrollTop = scroll;
|
||||
if (scrollY != null)
|
||||
|
||||
@@ -26,9 +26,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
this._observers = {};
|
||||
util.addObserver(this);
|
||||
|
||||
this.commands["dactyl.restart"] = function (event) {
|
||||
dactyl.restart();
|
||||
};
|
||||
this.commands["dactyl.restart"] = event => { dactyl.restart(); };
|
||||
|
||||
styles.registerSheet("resource://dactyl-skin/dactyl.css");
|
||||
|
||||
@@ -852,7 +850,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
event.preventDefault();
|
||||
|
||||
if (dactyl.commands[command])
|
||||
dactyl.withSavedValues(["forceTarget"], function () {
|
||||
dactyl.withSavedValues(["forceTarget"], () => {
|
||||
if (event.ctrlKey || event.shiftKey || event.button == 1)
|
||||
dactyl.forceTarget = dactyl.NEW_TAB;
|
||||
dactyl.commands[command](event);
|
||||
@@ -1199,7 +1197,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
let saved = save.map(p => dactyl[p]);
|
||||
return function wrappedCallback() {
|
||||
let args = arguments;
|
||||
return dactyl.withSavedValues(save, function () {
|
||||
return dactyl.withSavedValues(save, () => {
|
||||
saved.forEach((p, i) => { dactyl[save[i]] = p; });
|
||||
try {
|
||||
return callback.apply(self, args);
|
||||
@@ -1222,7 +1220,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
elem.getAttribute("collapsed"))
|
||||
}, {
|
||||
cache: function initCache() {
|
||||
cache.register("help/plugins.xml", function () {
|
||||
cache.register("help/plugins.xml", () => {
|
||||
// Process plugin help entries.
|
||||
|
||||
let body = [];
|
||||
@@ -1268,7 +1266,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
body]);
|
||||
}, true);
|
||||
|
||||
cache.register("help/index.xml", function () {
|
||||
cache.register("help/index.xml", () => {
|
||||
return '<?xml version="1.0"?>\n' +
|
||||
DOM.toXML(["overlay", { xmlns: "dactyl" },
|
||||
template.map(iter(dactyl.indices),
|
||||
@@ -1278,7 +1276,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"\n\n")]);
|
||||
}, true);
|
||||
|
||||
cache.register("help/gui.xml", function () {
|
||||
cache.register("help/gui.xml", () => {
|
||||
return '<?xml version="1.0"?>\n' +
|
||||
DOM.toXML(["overlay", { xmlns: "dactyl" },
|
||||
["dl", { insertafter: "dialog-list" },
|
||||
@@ -1291,7 +1289,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
"\n")]]);
|
||||
}, true);
|
||||
|
||||
cache.register("help/privacy.xml", function () {
|
||||
cache.register("help/privacy.xml", () => {
|
||||
return '<?xml version="1.0"?>\n' +
|
||||
DOM.toXML(["overlay", { xmlns: "dactyl" },
|
||||
["dl", { insertafter: "sanitize-items" },
|
||||
@@ -1894,7 +1892,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
||||
&& root._lightweightTheme._lastScreenWidth == null) {
|
||||
|
||||
dactyl.withSavedValues.call(PrivateBrowsingUtils,
|
||||
["isWindowPrivate"], function () {
|
||||
["isWindowPrivate"],
|
||||
() => {
|
||||
PrivateBrowsingUtils.isWindowPrivate = () => false;
|
||||
Cu.import("resource://gre/modules/LightweightThemeConsumer.jsm", {})
|
||||
.LightweightThemeConsumer.call(root._lightweightTheme, document);
|
||||
|
||||
@@ -16,7 +16,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
if (elem)
|
||||
this.element = elem;
|
||||
else
|
||||
this.__defineGetter__("element", function () {
|
||||
this.__defineGetter__("element", () => {
|
||||
let elem = dactyl.focusedElement;
|
||||
if (elem)
|
||||
return elem.inputField || elem;
|
||||
@@ -771,17 +771,17 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
|
||||
context.match = function (r) !this.filter || this.filter.contains(r);
|
||||
|
||||
context.fork("clipboard", 0, this, function (ctxt) {
|
||||
context.fork("clipboard", 0, this, ctxt => {
|
||||
ctxt.match = context.match;
|
||||
ctxt.title = ["Clipboard Registers"];
|
||||
ctxt.completions = Object.keys(editor.selectionRegisters);
|
||||
});
|
||||
context.fork("kill-ring", 0, this, function (ctxt) {
|
||||
context.fork("kill-ring", 0, this, ctxt => {
|
||||
ctxt.match = context.match;
|
||||
ctxt.title = ["Kill Ring Registers"];
|
||||
ctxt.completions = Array.slice("0123456789");
|
||||
});
|
||||
context.fork("user", 0, this, function (ctxt) {
|
||||
context.fork("user", 0, this, ctxt => {
|
||||
ctxt.match = context.match;
|
||||
ctxt.title = ["User Defined Registers"];
|
||||
ctxt.completions = editor.registers.keys();
|
||||
@@ -914,7 +914,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
|
||||
function clear(forward, re)
|
||||
function _clear(editor) {
|
||||
updateRange(editor, forward, re, function (range) {});
|
||||
updateRange(editor, forward, re, range => {});
|
||||
dactyl.assert(!editor.selection.isCollapsed);
|
||||
editor.selection.deleteFromDocument();
|
||||
let parent = DOM(editor.rootElement.parentNode);
|
||||
@@ -925,13 +925,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
function move(forward, re, sameWord)
|
||||
function _move(editor) {
|
||||
updateRange(editor, forward, re,
|
||||
function (range) { range.collapse(!forward); },
|
||||
range => { range.collapse(!forward); },
|
||||
sameWord);
|
||||
}
|
||||
function select(forward, re)
|
||||
function _select(editor) {
|
||||
updateRange(editor, forward, re,
|
||||
function (range) {});
|
||||
updateRange(editor, forward, re, range => {});
|
||||
}
|
||||
function beginLine(editor_) {
|
||||
editor.executeCommand("cmd_beginLine");
|
||||
@@ -1319,7 +1318,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
|
||||
["~"], "Switch case of the character under the cursor and move the cursor to the right",
|
||||
function ({ count }) {
|
||||
function munger(range)
|
||||
String(range).replace(/./g, function (c) {
|
||||
String(range).replace(/./g, c => {
|
||||
let lc = c.toLocaleLowerCase();
|
||||
return c == lc ? c.toLocaleUpperCase() : lc;
|
||||
});
|
||||
|
||||
@@ -1083,7 +1083,7 @@ var Events = Module("events", {
|
||||
function ({ keypressEvents: [event] }) {
|
||||
dactyl.assert(event.dactylSavedEvents,
|
||||
_("event.nothingToPass"));
|
||||
return function () {
|
||||
return () => {
|
||||
events.feedevents(null, event.dactylSavedEvents,
|
||||
{ skipmap: true, isMacro: true, isReplay: true });
|
||||
};
|
||||
@@ -1150,8 +1150,8 @@ var Events = Module("events", {
|
||||
"Pass certain keys through directly for the given URLs",
|
||||
"sitemap", "", {
|
||||
flush: function flush() {
|
||||
memoize(this, "filters", function () this.value.filter(function (f) f(buffer.documentURI)));
|
||||
memoize(this, "pass", function () new RealSet(Ary.flatten(this.filters.map(function (f) f.keys))));
|
||||
memoize(this, "filters", function () this.value.filter(f => f(buffer.documentURI)));
|
||||
memoize(this, "pass", function () new RealSet(Ary.flatten(this.filters.map(f => f.keys))));
|
||||
memoize(this, "commandHive", function hive() Hive(this.filters, "command"));
|
||||
memoize(this, "inputHive", function hive() Hive(this.filters, "input"));
|
||||
},
|
||||
|
||||
@@ -746,7 +746,7 @@ var HintSession = Class("HintSession", CommandMode, {
|
||||
|
||||
var Hints = Module("hints", {
|
||||
init: function init() {
|
||||
this.resizeTimer = Timer(100, 500, function () {
|
||||
this.resizeTimer = Timer(100, 500, () => {
|
||||
if (isinstance(modes.main, modes.HINTS))
|
||||
modes.getStack(0).params.onResize();
|
||||
});
|
||||
@@ -789,7 +789,7 @@ var Hints = Module("hints", {
|
||||
this.addMode("V", "View hint source in external editor", (elem, loc) => buffer.viewSource(loc, true));
|
||||
this.addMode("y", "Yank hint location", (elem, loc) => editor.setRegister(null, cleanLoc(loc), true));
|
||||
this.addMode("Y", "Yank hint description", elem => editor.setRegister(null, elem.textContent || "", true));
|
||||
this.addMode("A", "Yank hint anchor url", function (elem) {
|
||||
this.addMode("A", "Yank hint anchor url", elem => {
|
||||
let uri = elem.ownerDocument.documentURIObject.clone();
|
||||
uri.ref = elem.id || elem.name;
|
||||
dactyl.clipboardWrite(uri.spec, true);
|
||||
@@ -934,7 +934,7 @@ var Hints = Module("hints", {
|
||||
*/
|
||||
function containsMatcher(hintString) { //{{{
|
||||
let tokens = tokenize(/\s+/, hintString);
|
||||
return function (linkText) {
|
||||
return linkText => {
|
||||
linkText = linkText.toLowerCase();
|
||||
return tokens.every(token => indexOf(linkText, token) >= 0);
|
||||
};
|
||||
@@ -1049,7 +1049,7 @@ var Hints = Module("hints", {
|
||||
return true;
|
||||
}
|
||||
|
||||
return function (linkText) {
|
||||
return linkText => {
|
||||
if (hintStrings.length == 1 && hintStrings[0].length == 0)
|
||||
return true;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ var History = Module("history", {
|
||||
|
||||
let obj = [];
|
||||
obj.__defineGetter__("index", () => sh.index);
|
||||
obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val); });
|
||||
obj.__defineSetter__("index", val => { webNav.gotoIndex(val); });
|
||||
obj[Symbol.iterator] = function () this.entries();
|
||||
|
||||
for (let item of iter(sh.SHistoryEnumerator, Ci.nsISHEntry))
|
||||
@@ -111,7 +111,7 @@ var History = Module("history", {
|
||||
var ctxt;
|
||||
var filter = item => true;
|
||||
if (item == "domain")
|
||||
var filter = function (item) {
|
||||
var filter = item => {
|
||||
let res = item.URI.hostPort != ctxt;
|
||||
ctxt = item.URI.hostPort;
|
||||
return res;
|
||||
@@ -324,7 +324,7 @@ var History = Module("history", {
|
||||
|
||||
},
|
||||
completion: function initCompletion() {
|
||||
completion.domain = function (context) {
|
||||
completion.domain = context => {
|
||||
context.anchored = false;
|
||||
context.compare = (a, b) => String.localeCompare(a.key, b.key);
|
||||
context.keys = { text: util.identity, description: util.identity,
|
||||
|
||||
@@ -173,7 +173,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
|
||||
iterate: function (modes) {
|
||||
let stacks = Array.concat(modes).map(this.bound.getStack);
|
||||
return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name))
|
||||
.filter((map) => map.rhs &&
|
||||
.filter(map => map.rhs &&
|
||||
stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name))));
|
||||
},
|
||||
|
||||
@@ -803,7 +803,7 @@ var Mappings = Module("mappings", {
|
||||
]
|
||||
});
|
||||
|
||||
iter.forEach(modes.mainModes, function (mode) {
|
||||
iter.forEach(modes.mainModes, mode => {
|
||||
if (mode.char && !commands.get(mode.char + "listkeys", true))
|
||||
dactyl.addUsageCommand({
|
||||
__proto__: args,
|
||||
|
||||
@@ -649,7 +649,7 @@ var Modes = Module("modes", {
|
||||
},
|
||||
prefs: function initPrefs() {
|
||||
prefs.watch("accessibility.browsewithcaret",
|
||||
function () { apply(modes, "onCaretChange", arguments); });
|
||||
() => { apply(modes, "onCaretChange", arguments); });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
var QuickMarks = Module("quickmarks", {
|
||||
init: function () {
|
||||
this._qmarks = storage.newMap("quickmarks", { store: true });
|
||||
storage.addObserver("quickmarks", function () {
|
||||
storage.addObserver("quickmarks", () => {
|
||||
statusline.updateStatus();
|
||||
}, window);
|
||||
},
|
||||
@@ -154,7 +154,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
if (args.length == 1)
|
||||
return completion.quickmark(context);
|
||||
if (args.length == 2) {
|
||||
context.fork("current", 0, this, function (context) {
|
||||
context.fork("current", 0, this, context => {
|
||||
context.title = ["Extra Completions"];
|
||||
context.completions = [
|
||||
[quickmarks.get(args[0]), _("option.currentValue")]
|
||||
@@ -176,7 +176,7 @@ var QuickMarks = Module("quickmarks", {
|
||||
});
|
||||
},
|
||||
completion: function initCompletion() {
|
||||
completion.quickmark = function (context) {
|
||||
completion.quickmark = context => {
|
||||
context.title = ["QuickMark", "URL"];
|
||||
context.generate = () => iter(quickmarks._qmarks);
|
||||
};
|
||||
|
||||
@@ -32,7 +32,7 @@ var Tabs = Module("tabs", {
|
||||
"{ visibility: collapse; }",
|
||||
false, true);
|
||||
|
||||
dactyl.commands["tabs.select"] = function (event) {
|
||||
dactyl.commands["tabs.select"] = event => {
|
||||
tabs.switchTo(event.originalTarget.getAttribute("identifier"));
|
||||
};
|
||||
|
||||
@@ -1096,7 +1096,7 @@ var Tabs = Module("tabs", {
|
||||
description: function (group) group.getTitle() ||
|
||||
group.getChildren().map(t => t.tab.label).join(", ")
|
||||
};
|
||||
context.generate = function () {
|
||||
context.generate = () => {
|
||||
context.incomplete = true;
|
||||
tabs.getGroups(function ({ GroupItems }) {
|
||||
context.incomplete = false;
|
||||
@@ -1120,7 +1120,7 @@ var Tabs = Module("tabs", {
|
||||
"Execute the next mapping in a new tab",
|
||||
function ({ count }) {
|
||||
dactyl.forceTarget = dactyl.NEW_TAB;
|
||||
mappings.afterCommands((count || 1) + 1, function () {
|
||||
mappings.afterCommands((count || 1) + 1, () => {
|
||||
dactyl.forceTarget = null;
|
||||
});
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user