diff --git a/common/bootstrap.js b/common/bootstrap.js index 795e9fe5..76c5437f 100755 --- a/common/bootstrap.js +++ b/common/bootstrap.js @@ -11,7 +11,9 @@ const global = this; var { classes: Cc, interfaces: Ci, results: Cr, utils: Cu } = Components; -function module(uri) Cu.import(uri, {}); +function module(uri) { + return Cu.import(uri, {}); +} const DEBUG = true; @@ -316,7 +318,9 @@ function init() { * Performs necessary migrations after a version change. */ function updateVersion() { - function isDev(ver) /^hg|pre$/.test(ver); + function isDev(ver) { + return /^hg|pre$/.test(ver); + } try { if (typeof require === "undefined" || addon === addonData) return; diff --git a/common/content/bookmarks.js b/common/content/bookmarks.js index 195b16a3..180c3751 100644 --- a/common/content/bookmarks.js +++ b/common/content/bookmarks.js @@ -287,7 +287,9 @@ var Bookmarks = Module("bookmarks", { if (!queryURI) return Promise.reject(); - function parse(req) JSON.parse(req.responseText)[1].filter(isString); + function parse(req) { + return JSON.parse(req.responseText)[1].filter(isString); + } return this.makeSuggestions(queryURI, parse, callback); }, diff --git a/common/content/browser.js b/common/content/browser.js index 2c4c2d22..ff19142a 100644 --- a/common/content/browser.js +++ b/common/content/browser.js @@ -243,9 +243,11 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), CommandExMode().open(mode + "open " + (args || "")); } - function decode(uri) util.losslessDecodeURI(uri) - .replace(/%20(?!(?:%20)*$)/g, " ") - .replace(RegExp(options["urlseparator"], "g"), encodeURIComponent); + function decode(uri) { + return util.losslessDecodeURI(uri) + .replace(/%20(?!(?:%20)*$)/g, " ") + .replace(RegExp(options["urlseparator"], "g"), encodeURIComponent); + } mappings.add([modes.NORMAL], ["o"], "Open one or more URLs", diff --git a/common/content/commandline.js b/common/content/commandline.js index 1b66af3f..9de5c705 100644 --- a/common/content/commandline.js +++ b/common/content/commandline.js @@ -165,7 +165,9 @@ var CommandWidgets = Class("CommandWidgets", { const self = this; this.elements[obj.name] = obj; - function get(prefix, map, id) (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id)); + function get(prefix, map, id) { + return (obj.getElement || util.identity)(map[id] || document.getElementById(prefix + id)); + } this.active.__defineGetter__(obj.name, () => this.activeGroup[obj.name][obj.name]); this.activeGroup.__defineGetter__(obj.name, () => this.getGroup(obj.name)); diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 042444be..38127a74 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -231,7 +231,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, addUsageCommand: function (params) { - function keys(item) (item.names || [item.name]).concat(item.description, item.columns || []); + function keys(item) { + return (item.names || [item.name]).concat(item.description, item.columns || []); + } let name = commands.add(params.name, params.description, function (args) { @@ -1667,10 +1669,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { options: startupOptions }); - function findToolbar(name) DOM.XPath( - "//*[@toolbarname=" + util.escapeString(name, "'") + " or " + - "@toolbarname=" + util.escapeString(name.trim(), "'") + "]", - document).snapshotItem(0); + function findToolbar(name) { + return DOM.XPath( + "//*[@toolbarname=" + util.escapeString(name, "'") + " or " + + "@toolbarname=" + util.escapeString(name.trim(), "'") + "]", + document).snapshotItem(0); + } var toolbox = document.getElementById("navigator-toolbox"); if (toolbox) { diff --git a/common/content/editor.js b/common/content/editor.js index ab7fe27d..c86f5fbd 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -299,7 +299,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), { // Find the *count*th occurance of *char* before a non-collapsed // \n, ignoring the character at the caret. let i = 0; - function test(c) (collapse || c != "\n") && !!(!i++ || c != char || --count) + function test(c) { + return (collapse || c != "\n") && !!(!i++ || c != char || --count); + } Editor.extendRange(range, !backward, { test: test }, true); dactyl.assert(count == 0); diff --git a/common/content/events.js b/common/content/events.js index f3cd3ac6..9f36f6e7 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -861,7 +861,10 @@ var Events = Module("events", { // access to the real focus target // Huh? --djk onFocusChange: util.wrapCallback(function onFocusChange(event) { - function hasHTMLDocument(win) win && win.document && win.document instanceof Ci.nsIDOMHTMLDocument + function hasHTMLDocument(win) { + return win && win.document && win.document instanceof Ci.nsIDOMHTMLDocument; + } + if (dactyl.ignoreFocus) return; @@ -1129,10 +1132,12 @@ var Events = Module("events", { init: function init(values, map) { this.name = "passkeys:" + map; this.stack = MapHive.Stack(values.map(v => Map(v[map + "Keys"]))); - function Map(keys) ({ - execute: function () Events.PASS_THROUGH, - keys: keys - }); + function Map(keys) { + return { + execute: function () Events.PASS_THROUGH, + keys: keys + }; + } }, get active() this.stack.length, diff --git a/common/content/hints.js b/common/content/hints.js index 3c1cb50b..cfa2c93c 100644 --- a/common/content/hints.js +++ b/common/content/hints.js @@ -798,9 +798,11 @@ var Hints = Module("hints", { this.addMode("i", "Show image", elem => dactyl.open(elem.src)); this.addMode("I", "Show image in a new tab", elem => dactyl.open(elem.src, dactyl.NEW_TAB)); - function isScrollable(elem) isinstance(elem, [Ci.nsIDOMHTMLFrameElement, - Ci.nsIDOMHTMLIFrameElement]) || - Buffer.isScrollable(elem, 0, true) || Buffer.isScrollable(elem, 0, false); + function isScrollable(elem) { + return isinstance(elem, [Ci.nsIDOMHTMLFrameElement, Ci.nsIDOMHTMLIFrameElement]) || + Buffer.isScrollable(elem, 0, true) || + Buffer.isScrollable(elem, 0, false); + } }, hintSession: Modes.boundProperty(), @@ -820,7 +822,9 @@ var Hints = Module("hints", { * @optional */ addMode: function (mode, prompt, action, filter, tags) { - function toString(regexp) RegExp.prototype.toString.call(regexp); + function toString(regexp) { + return RegExp.prototype.toString.call(regexp); + } if (tags != null) { let eht = options.get("extendedhinttags"); @@ -912,7 +916,9 @@ var Hints = Module("hints", { * @param {string} str The string to split. * @returns {Array(string)} The lowercased splits of the splitting. */ - function tokenize(pat, str) str.split(pat).map(String.toLowerCase); + function tokenize(pat, str) { + return str.split(pat).map(String.toLowerCase); + } /** * Get a hint matcher for hintmatching=contains diff --git a/common/content/history.js b/common/content/history.js index 80584059..f8417a2e 100644 --- a/common/content/history.js +++ b/common/content/history.js @@ -354,7 +354,9 @@ var History = Module("history", { completion.addUrlCompleter("history", "History", completion.history); }, mappings: function initMappings() { - function bind(...args) apply(mappings, "add", [config.browserModes].concat(args)); + function bind(...args) { + return apply(mappings, "add", [config.browserModes].concat(args)); + } bind([""], "Go to an older position in the jump list", function ({ count }) { history.stepTo(-Math.max(count, 1), true); }, diff --git a/common/content/marks.js b/common/content/marks.js index 5e5e9cf6..069a29a4 100644 --- a/common/content/marks.js +++ b/common/content/marks.js @@ -373,7 +373,9 @@ var Marks = Module("marks", { completion: function initCompletion() { completion.mark = function mark(context) { - function percent(i) Math.round(i * 100); + function percent(i) { + return Math.round(i * 100); + } context.title = ["Mark", "HPos VPos File"]; context.keys.description = ([, m]) => (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y) @@ -388,10 +390,14 @@ var Marks = Module("marks", { persistent: true, contains: ["history"], action: function (timespan, host) { - function matchhost(url) !host || util.isDomainURL(url, host); - function match(marks) (k - for ([k, v] of iter(marks)) - if (timespan.contains(v.timestamp) && matchhost(v.location))); + function matchhost(url) { + return !host || util.isDomainURL(url, host); + } + function match(marks) { + return (k + for ([k, v] of iter(marks)) + if (timespan.contains(v.timestamp) && matchhost(v.location))); + } for (let [url, local] of marks._localMarks) if (matchhost(url)) { diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index 59575f23..80a87a5c 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -409,7 +409,9 @@ var Addons = Module("addons", { // TODO: handle extension dependencies values(actions).forEach(function (command) { let perm = command.perm && AddonManager["PERM_CAN_" + command.perm.toUpperCase()]; - function ok(addon) (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon)); + function ok(addon) { + return (!perm || addon.permissions & perm) && (!command.filter || command.filter(addon)); + } commands.add(Array.concat(command.name), command.description, diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 55bcaa62..0a6b6c10 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -44,7 +44,9 @@ function lazyRequire(module, names, target) { let jsmodules = { lazyRequire: lazyRequire }; jsmodules.jsmodules = jsmodules; -function toString() "[module-global " + this.NAME + "]"; +function toString() { + return "[module-global " + this.NAME + "]"; +} function objToString(obj) { try { @@ -406,7 +408,7 @@ function keys(obj) { * @param {object} obj The object to inspect. * @returns {Iter} */ -function values(obj) { +function values(obj) { if (isinstance(obj, ["Map"])) return iter(obj.values()); @@ -582,7 +584,9 @@ function curry(fn, length, self, acc) { return fn; // Close over function with 'this' - function close(self, fn) (...args) => fn.apply(self, args); + function close(self, fn) { + return (...args) => fn.apply(self, args); + } if (acc == null) acc = []; @@ -668,7 +672,9 @@ function isinstance(object, interfaces) { /** * Returns true if obj is a non-null object. */ -function isObject(obj) typeof obj === "object" && obj != null || obj instanceof Ci.nsISupports; +function isObject(obj) { + return typeof obj === "object" && obj != null || obj instanceof Ci.nsISupports; +} /** * Returns true if and only if its sole argument is an @@ -678,7 +684,9 @@ function isObject(obj) typeof obj === "object" && obj != null || obj instanceof */ var isArray = // This is bloody stupid. - function isArray(val) Array.isArray(val) || val && val.constructor && val.constructor.name === "Array"; + function isArray(val) { + return Array.isArray(val) || val && val.constructor && val.constructor.name === "Array"; + } /** * Returns true if and only if its sole argument is an @@ -686,7 +694,9 @@ var isArray = * functions containing the 'yield' statement and generator * statements such as (x for (x in obj)). */ -function isGenerator(val) objToString(val) == "[object Generator]"; +function isGenerator(val) { + return objToString(val) == "[object Generator]"; +} /** * Returns true if and only if its sole argument is a String, @@ -695,13 +705,17 @@ function isGenerator(val) objToString(val) == "[object Generator]"; * namespace, or execution context, which is not the case when * using (obj instanceof String) or (typeof obj == "string"). */ -function isString(val) objToString(val) == "[object String]"; +function isString(val) { + return objToString(val) == "[object String]"; +} /** * Returns true if and only if its sole argument may be called * as a function. This includes classes and function objects. */ -function callable(val) typeof val === "function" && !(val instanceof Ci.nsIDOMElement); +function callable(val) { + return typeof val === "function" && !(val instanceof Ci.nsIDOMElement); +} function call(fn, self, ...args) { fn.apply(self, args); diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm index 5736d038..4710d4c1 100644 --- a/common/modules/bootstrap.jsm +++ b/common/modules/bootstrap.jsm @@ -6,7 +6,9 @@ var EXPORTED_SYMBOLS = ["require"]; -function create(proto) Object.create(proto); +function create(proto) { + return Object.create(proto); +} this["import"] = function import_(obj) { let res = {}; @@ -20,6 +22,8 @@ if (typeof TextEncoder == "undefined") // Deal with subScriptLoader prepending crap to loaded URLs Components.utils.import("resource://gre/modules/Services.jsm"); -function loadSubScript() Services.scriptloader.loadSubScript.apply(null, arguments); +function loadSubScript() { + return Services.scriptloader.loadSubScript.apply(null, arguments); +} // vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: diff --git a/common/modules/buffer.jsm b/common/modules/buffer.jsm index dfaae61f..c8f24e12 100644 --- a/common/modules/buffer.jsm +++ b/common/modules/buffer.jsm @@ -515,11 +515,15 @@ var Buffer = Module("Buffer", { for (let elem of iter(elems)) yield elem; - function a(regexp, elem) regexp.test(elem.textContent) === regexp.result || - Array.some(elem.childNodes, - child => (regexp.test(child.alt) === regexp.result)); + function a(regexp, elem) { + return regexp.test(elem.textContent) === regexp.result || + Array.some(elem.childNodes, + child => (regexp.test(child.alt) === regexp.result)); + } - function b(regexp, elem) regexp.test(elem.title) === regexp.result; + function b(regexp, elem) { + return regexp.test(elem.title) === regexp.result; + } let res = Array.filter(frame.document.querySelectorAll(selector), Hints.isVisible); @@ -617,7 +621,9 @@ var Buffer = Module("Buffer", { * viewport. */ resetCaret: function resetCaret() { - function visible(range) util.intersection(DOM(range).rect, viewport); + function visible(range) { + return util.intersection(DOM(range).rect, viewport); + } function getRanges(rect) { let nodes = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils) @@ -2771,9 +2777,12 @@ Buffer.addPageInfoSection("s", "Security", function* (verbose) { return; // For now // Modified from Firefox - function location(data) Ary.compact([ - data.city, data.state, data.country - ]).join(", "); + function location(data) { + return Ary.compact([data.city, + data.state, + data.country]) + .join(", "); + } switch (statusline.security) { case "secure": diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 266bc3b8..501f1393 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -767,7 +767,9 @@ var Commands = Module("commands", { return ""; } // TODO: allow matching of aliases? - function cmds(hive) hive._list.filter(cmd => cmd.name.startsWith(filter || "")) + function cmds(hive) { + return hive._list.filter(cmd => cmd.name.startsWith(filter || "")); + } hives = (hives || this.userHives).map(h => [h, cmds(h)]) .filter(([h, c]) => c.length); @@ -1401,8 +1403,10 @@ 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) { + return str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4}|(.))/g, + (m, n1) => n1 || m); + } // Fix me. if (isString(sep)) @@ -1798,8 +1802,10 @@ var Commands = Module("commands", { let quote = function quote(q, list, 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) { + return (q + String.replace(str, re, $0 => ($0 in map ? map[$0] : ("\\" + $0))) + + q); + } quote.list = list; return quote; }; diff --git a/common/modules/completion.jsm b/common/modules/completion.jsm index 6e132907..5914dfd1 100644 --- a/common/modules/completion.jsm +++ b/common/modules/completion.jsm @@ -1095,7 +1095,9 @@ var Completion = Module("completion", { contains(item.title, tok))); let re = RegExp(tokens.filter(util.identity).map(util.regexp.escape).join("|"), "g"); - function highlight(item, text, i) process[i].call(this, item, template.highlightRegexp(text, re)); + function highlight(item, text, i) { + return process[i].call(this, item, template.highlightRegexp(text, re)); + } let process = context.process; context.process = [ function process_0(item, text) highlight.call(this, item, item.text, 0), diff --git a/common/modules/config.jsm b/common/modules/config.jsm index 3745c26a..6414e6aa 100644 --- a/common/modules/config.jsm +++ b/common/modules/config.jsm @@ -174,10 +174,12 @@ var ConfigBase = Class("ConfigBase", { let hl = highlight.set("Find", ""); hl.onChange = function () { - function hex(val) ("#" + util.regexp.iterate(/\d+/g, val) - .map(num => ("0" + Number(num).toString(16)).slice(-2)) - .join("") - ).slice(0, 7); + function hex(val) { + return ("#" + util.regexp.iterate(/\d+/g, val) + .map(num => ("0" + Number(num).toString(16)).slice(-2)) + .join("") + ).slice(0, 7); + } let elem = services.appShell.hiddenDOMWindow.document.createElement("div"); elem.style.cssText = this.cssText; @@ -216,7 +218,9 @@ var ConfigBase = Class("ConfigBase", { */ locales: Class.Memoize(function () { // TODO: Merge with completion.file code. - function getDir(str) str.match(/^(?:.*[\/\\])?/)[0]; + function getDir(str) { + return str.match(/^(?:.*[\/\\])?/)[0]; + } let uri = "resource://dactyl-locale/"; let jar = io.isJarURL(uri); diff --git a/common/modules/contexts.jsm b/common/modules/contexts.jsm index c46ba7f0..71028cf2 100644 --- a/common/modules/contexts.jsm +++ b/common/modules/contexts.jsm @@ -499,12 +499,14 @@ var Contexts = Module("contexts", { bindMacro: function (args, default_, params) { const { dactyl, events, modules } = this.modules; - function Proxy(obj, key) Class.Property({ - configurable: true, - enumerable: true, - get: function Proxy_get() process(obj[key]), - set: function Proxy_set(val) obj[key] = val - }) + function Proxy(obj, key) { + return Class.Property({ + configurable: true, + enumerable: true, + get: function Proxy_get() process(obj[key]), + set: function Proxy_set(val) obj[key] = val + }); + } let process = util.identity; diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index 1e76db2d..1dd8ad61 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -20,15 +20,17 @@ var XHTML = "http://www.w3.org/1999/xhtml"; var XUL = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; var NS = "http://vimperator.org/namespaces/liberator"; -function BooleanAttribute(attr) ({ - get: function (elem) elem.getAttribute(attr) == "true", - set: function (elem, val) { - if (val === "false" || !val) - elem.removeAttribute(attr); - else - elem.setAttribute(attr, true); - } -}); +function BooleanAttribute(attr) { + return { + get: function (elem) elem.getAttribute(attr) == "true", + set: function (elem, val) { + if (val === "false" || !val) + elem.removeAttribute(attr); + else + elem.setAttribute(attr, true); + } + }; +} /** * @class @@ -549,7 +551,9 @@ var DOM = Class("DOM", { * @returns {string} */ get xpath() { - function quote(val) "'" + val.replace(/[\\']/g, "\\$&") + "'"; + function quote(val) { + return "'" + val.replace(/[\\']/g, "\\$&") + "'"; + } if (!(this[0] instanceof Ci.nsIDOMElement)) return null; @@ -1575,7 +1579,9 @@ var DOM = Class("DOM", { attr = attr || {}; - function parseNamespace(name) DOM.parseNamespace(name, namespaces); + function parseNamespace(name) { + return DOM.parseNamespace(name, namespaces); + } // FIXME: Surely we can do better. for (var key in attr) { @@ -1652,7 +1658,9 @@ var DOM = Class("DOM", { throw Error("No such namespace"); } - function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === ""; + function isFragment(args) { + return !isString(args[0]) || args.length == 0 || args[0] === ""; + } function hasString(args) { return args.some(a => (isString(a) || isFragment(a) && hasString(a))); diff --git a/common/modules/finder.jsm b/common/modules/finder.jsm index b97e525c..1aa6910b 100644 --- a/common/modules/finder.jsm +++ b/common/modules/finder.jsm @@ -12,9 +12,14 @@ defineModule("finder", { lazyRequire("buffer", ["Buffer"]); lazyRequire("overlay", ["overlay"]); -function id(w) w.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils) - .outerWindowID; -function equals(a, b) id(a) == id(b); +function id(w) { + return w.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils) + .outerWindowID; +} +function equals(a, b) { + return id(a) == id(b); +} /** @instance rangefinder */ var RangeFinder = Module("rangefinder", { diff --git a/common/modules/help.jsm b/common/modules/help.jsm index e8c6c7a1..8a361b6c 100644 --- a/common/modules/help.jsm +++ b/common/modules/help.jsm @@ -242,7 +242,9 @@ var Help = Module("Help", { let items = modules.completion._runCompleter("help", topic, null, !!consolidated).items; let partialMatch = null; - function format(item) item.description + "#" + encodeURIComponent(item.text); + function format(item) { + return item.description + "#" + encodeURIComponent(item.text); + } for (let item of items) { if (item.text == topic) diff --git a/common/modules/io.jsm b/common/modules/io.jsm index adebcf55..d99554c3 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -528,13 +528,15 @@ var IO = Module("io", { else if (input) stdin.write(input); - function result(status, output) ({ - __noSuchMethod__: function (meth, args) apply(this.output, meth, args), - valueOf: function () this.output, - output: output.replace(/^(.*)\n$/, "$1"), - returnValue: status, - toString: function () this.output - }); + function result(status, output) { + return { + __noSuchMethod__: function (meth, args) apply(this.output, meth, args), + valueOf: function () this.output, + output: output.replace(/^(.*)\n$/, "$1"), + returnValue: status, + toString: function () this.output + }; + } function async(status) { let output = stdout.read(); @@ -1000,7 +1002,9 @@ unlet s:cpo_save context.advance(4); // dir == "" is expanded inside readDirectory to the current dir - function getDir(str) str.match(/^(?:.*[\/\\])?/)[0]; + function getDir(str) { + return str.match(/^(?:.*[\/\\])?/)[0]; + } dir = getDir(dir || context.filter); let file = util.getFile(dir); diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 0e821f90..1d80e70b 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -382,7 +382,10 @@ var JavaScript = Module("javascript", { } // We've already listed anchored matches, so don't list them again here. - function unanchored(item) util.compareIgnoreCase(item.text.substr(0, this.filter.length), this.filter); + function unanchored(item) { + return util.compareIgnoreCase(item.text.substr(0, this.filter.length), + this.filter); + } objects.forEach(function (obj) { let context = base.fork(obj[1]); @@ -856,7 +859,9 @@ var JavaScript = Module("javascript", { mappings: function initMappings(dactyl, modules, window) { const { mappings, modes } = modules; - function bind(...args) apply(mappings, "add", [[modes.REPL]].concat(args)) + function bind(...args) { + return apply(mappings, "add", [[modes.REPL]].concat(args)); + } bind([""], "Accept the current input", function ({ self }) { self.accept(); }); diff --git a/common/modules/messages.jsm b/common/modules/messages.jsm index b450170c..7db782c8 100644 --- a/common/modules/messages.jsm +++ b/common/modules/messages.jsm @@ -106,29 +106,33 @@ var Messages = Module("messages", { let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules; file = io.File(file); - function properties(base, iter_, prop="description") iter(function* _properties() { - function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&"); - - for (var obj of iter_) { - if (!obj.hive || obj.hive.name !== "user") { - yield key(prop) + " = " + obj[prop]; - - if (iter_.values) { - let iter_ = isArray(obj.values) ? obj.values - : iter(obj.values); - - for (let [k, v] of iter_) - yield key("values", k) + " = " + v; - } - - for (let opt of values(obj.options)) - yield key("options", opt.names[0]) + " = " + opt.description; - - if (obj.deprecated) - yield key("deprecated") + " = " + obj.deprecated; + function properties(base, iter_, prop="description") { + return iter(function* _properties() { + function key(...args) { + return [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&"); } - } - }()).toArray(); + + for (var obj of iter_) { + if (!obj.hive || obj.hive.name !== "user") { + yield key(prop) + " = " + obj[prop]; + + if (iter_.values) { + let iter_ = isArray(obj.values) ? obj.values + : iter(obj.values); + + for (let [k, v] of iter_) + yield key("values", k) + " = " + v; + } + + for (let opt of values(obj.options)) + yield key("options", opt.names[0]) + " = " + opt.description; + + if (obj.deprecated) + yield key("deprecated") + " = " + obj.deprecated; + } + } + }()).toArray(); + } file.write( Ary(commands.allHives.map(h => properties("command", h))) @@ -161,7 +165,9 @@ var Messages = Module("messages", { get: function get() { let value = this[_prop]; - function getter(key, default_) function getter() messages.get([name, key].join("."), default_); + function getter(key, default_) { + return function getter() messages.get([name, key].join("."), default_); + } if (value != null) { var name = [this.constructor.className.toLowerCase(), diff --git a/common/modules/options.jsm b/common/modules/options.jsm index 7278db83..86fd59c9 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -1337,9 +1337,11 @@ var Options = Module("options", { function (args) { let globalVariables = dactyl._globalVariables; args = (args[0] || "").trim(); - function fmt(value) (typeof value == "number" ? "#" : - typeof value == "function" ? "*" : - " ") + value; + function fmt(value) { + return (typeof value == "number" ? "#" : + typeof value == "function" ? "*" : + " ") + value; + } util.assert(!(!args || args == "g:")); let matches = args.match(/^([a-z]:)?([\w]+)(?:\s*([-+.])?=\s*(.*)?)?$/); diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index 3956d87f..f9a97c96 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -162,10 +162,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef override: true }); - function ourItems(persistent) [ - item for (item of values(self.itemMap)) - if (!item.builtin && (!persistent || item.persistent) && item.name !== "all") - ]; + function ourItems(persistent) { + return [ + item for (item of values(self.itemMap)) + if (!item.builtin && (!persistent || item.persistent) && item.name !== "all") + ]; + } function prefOverlay(branch, persistent, local) { return update(Object.create(local), diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 783011d0..26d6ce11 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -719,17 +719,21 @@ var File = Class("File", { * @returns {string} */ expandPath: function expandPath(path, relative) { - function getenv(name) services.environment.get(name); + function getenv(name) { + return services.environment.get(name); + } // expand any $ENV vars - this is naive but so is Vim and we like to be compatible // TODO: Vim does not expand variables set to an empty string (and documents it). // Kris reckons we shouldn't replicate this 'bug'. --djk // TODO: should we be doing this for all paths? // No. - function expand(path) path.replace( - win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g - : /\$(\w+)\b|\${(\w+)}/g, - (m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m)); + function expand(path) { + return path.replace( + win32 ? /\$(\w+)\b|\${(\w+)}|%(\w+)%/g + : /\$(\w+)\b|\${(\w+)}/g, + (m, n1, n2, n3) => (getenv(n1 || n2 || n3) || m)); + } path = expand(path); // expand ~ diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index f612b7e9..12193e59 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -570,16 +570,18 @@ var Styles = Module("Styles", { Styles.splitContext(context); } - function nameFlag(filter) ({ - names: ["-name", "-n"], - description: "The name of this stylesheet", - type: modules.CommandOption.STRING, - completer: function (context, args) { - context.keys.text = sheet => sheet.name; - context.filters.unshift(({ item }) => item.name); - sheets(context, args, filter); - } - }); + function nameFlag(filter) { + return { + names: ["-name", "-n"], + description: "The name of this stylesheet", + type: modules.CommandOption.STRING, + completer: function (context, args) { + context.keys.text = sheet => sheet.name; + context.filters.unshift(({ item }) => item.name); + sheets(context, args, filter); + } + }; + } commands.add(["sty[le]"], "Add or list user styles", diff --git a/common/modules/util.jsm b/common/modules/util.jsm index a98a71bf..62cddf97 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -259,17 +259,19 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let stack = [frame()]; stack.__defineGetter__("top", function () this[this.length - 1]); - function frame() update( - function _frame(obj) - _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)) - }); + function frame() { + return update( + function _frame(obj) + _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)) + }); + } let end = 0; for (let match of util.regexp.iterate(/(.*?)%(.)/gy, format)) { @@ -345,17 +347,19 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), if (!keepUnknown) unknown = () => ""; - function frame() update( - function _frame(obj) - _frame === stack.top || _frame.valid(obj) - ? _frame.elements.map(e => callable(e) ? e(obj) : e) - .join("") - : "", - { - elements: [], - seen: new RealSet, - valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj))) - }); + function frame() { + return update( + function _frame(obj) + _frame === stack.top || _frame.valid(obj) + ? _frame.elements.map(e => callable(e) ? e(obj) : e) + .join("") + : "", + { + elements: [], + seen: new RealSet, + valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj))) + }); + } let defaults = { lt: "<", gt: ">" }; @@ -655,8 +659,12 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), * @returns {string} */ formatSeconds: function formatSeconds(seconds) { - function pad(n, val) ("0000000" + val).substr(-Math.max(n, String(val).length)); - function div(num, denom) [Math.floor(num / denom), Math.round(num % denom)]; + function pad(n, val) { + return ("0000000" + val).substr(-Math.max(n, String(val).length)); + } + function div(num, denom) { + return [Math.floor(num / denom), Math.round(num % denom)]; + } let days, hours, minutes; [minutes, seconds] = div(Math.round(seconds), 60); diff --git a/melodactyl/content/player.js b/melodactyl/content/player.js index f56b8cb0..bc76e167 100644 --- a/melodactyl/content/player.js +++ b/melodactyl/content/player.js @@ -550,7 +550,9 @@ const Player = Module("player", { dactyl.assert(/^[+-]?(\d+[smh]?|(\d+:\d\d:|\d+:)?\d{2})$/.test(arg), _("error.invalidArgument", arg)); - function ms(t, m) Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m]) + function ms(t, m) { + return Math.abs(parseInt(t, 10) * { s: 1000, m: 60000, h: 3600000 }[m]); + } if (/:/.test(arg)) { let [seconds, minutes, hours] = arg.split(":").reverse(); diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index a8b5740f..7d615d71 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -119,7 +119,9 @@ var Config = Module("config", ConfigBase, { commands.add(["sideb[ar]", "sb[ar]", "sbop[en]"], "Open the sidebar window", function (args) { - function compare(a, b) util.compareIgnoreCase(a, b) == 0 + function compare(a, b) { + return util.compareIgnoreCase(a, b) == 0; + } let title = document.getElementById("sidebar-title"); dactyl.assert(args.length || title.value || args.bang && config.lastSidebar,