]> git.donarmstrong.com Git - dactyl.git/commitdiff
Import r6976 from upstream hg supporting Firefox up to 25.* upstream/1.0+hg6976
authorMichael Schutte <michi@uiae.at>
Sun, 1 Dec 2013 11:11:09 +0000 (12:11 +0100)
committerMichael Schutte <michi@uiae.at>
Sun, 1 Dec 2013 11:11:09 +0000 (12:11 +0100)
59 files changed:
.hg_archival.txt
common/bootstrap.js
common/content/abbreviations.js
common/content/about.xul
common/content/autocommands.js
common/content/bookmarks.js
common/content/browser.js
common/content/commandline.js
common/content/dactyl.js
common/content/editor.js
common/content/events.js
common/content/hints.js
common/content/history.js
common/content/key-processors.js
common/content/mappings.js
common/content/marks.js
common/content/modes.js
common/content/mow.js
common/content/quickmarks.js
common/content/statusline.js
common/content/tabs.js
common/locale/en-US/options.xml
common/locale/en-US/repeat.xml
common/locale/en-US/tabs.xml
common/modules/addons.jsm
common/modules/base.jsm
common/modules/bookmarkcache.jsm
common/modules/buffer.jsm
common/modules/cache.jsm
common/modules/commands.jsm
common/modules/completion.jsm
common/modules/config.jsm
common/modules/contexts.jsm
common/modules/dom.jsm
common/modules/downloads.jsm
common/modules/finder.jsm
common/modules/help.jsm
common/modules/highlight.jsm
common/modules/io.jsm
common/modules/javascript.jsm
common/modules/main.jsm
common/modules/messages.jsm
common/modules/options.jsm
common/modules/overlay.jsm
common/modules/prefs.jsm
common/modules/sanitizer.jsm
common/modules/services.jsm
common/modules/storage.jsm
common/modules/styles.jsm
common/modules/template.jsm
common/modules/util.jsm
melodactyl/content/config.js
melodactyl/content/library.js
melodactyl/content/player.js
pentadactyl/content/config.js
pentadactyl/install.rdf
teledactyl/content/addressbook.js
teledactyl/content/config.js
teledactyl/content/mail.js

index 19d75fba70a2b0cb672b10732fd6393300efa82d..3e94fb38298a78aa97f1bf13b604a45f64a221dd 100644 (file)
@@ -1,5 +1,5 @@
 repo: 373f1649c80dea9be7b5bc9c57e8395f94f93ab1
-node: dd11a1a668d0ac31de134e00a8149fe044dad758
+node: a34a77b2caffe9b07ee32821a66342c9ec6e9e09
 branch: default
 latesttag: pentadactyl-1.0rc1
-latesttagdistance: 219
+latesttagdistance: 247
index de289ee03f849a39bc0af3e2575bfd388ade2a69..4d5dcca634a9e863b5afeebe2ab5fb48e325b6e5 100755 (executable)
@@ -15,7 +15,7 @@ function module(uri) Cu.import(uri, {});
 
 const DEBUG = true;
 
-__defineGetter__("BOOTSTRAP", function () "resource://" + moduleName + "/bootstrap.jsm");
+__defineGetter__("BOOTSTRAP", () => "resource://" + moduleName + "/bootstrap.jsm");
 
 var { AddonManager } = module("resource://gre/modules/AddonManager.jsm");
 var { XPCOMUtils }   = module("resource://gre/modules/XPCOMUtils.jsm");
@@ -125,7 +125,7 @@ let JSMLoader = {
     _load: function _load(name, target) {
         let urls = [name];
         if (name.indexOf(":") === -1)
-            urls = this.config["module-paths"].map(function (path) path + name + ".jsm");
+            urls = this.config["module-paths"].map(path => path + name + ".jsm");
 
         for each (let url in urls)
             try {
@@ -224,7 +224,7 @@ function init() {
 
     for each (let line in manifest.split("\n")) {
         let fields = line.split(/\s+/);
-        switch(fields[0]) {
+        switch (fields[0]) {
         case "category":
             categoryManager.addCategoryEntry(fields[1], fields[2], fields[3], false, true);
             categories.push([fields[1], fields[2]]);
index 4013be29f68b27361e2b16a6b17b07b5d5d2179c..f0cd06d17747011ec4441a5505354031505086cc 100644 (file)
@@ -1,6 +1,6 @@
 // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
 // Copyright (c) 2010 by anekos <anekos@snca.net>
-// Copyright (c) 2010-2012 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2010-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.
@@ -64,7 +64,7 @@ var Abbreviation = Class("Abbreviation", {
      * @param {Mode} mode The mode to test.
      * @returns {boolean} The result of the comparison.
      */
-    inMode: function (mode) this.modes.some(function (_mode) _mode == mode),
+    inMode: function (mode) this.modes.some(m => m == mode),
 
     /**
      * Returns true if this abbreviation is defined in any of *modes*.
@@ -72,7 +72,7 @@ var Abbreviation = Class("Abbreviation", {
      * @param {[Modes]} modes The modes to test.
      * @returns {boolean} The result of the comparison.
      */
-    inModes: function (modes) modes.some(function (mode) this.inMode(mode), this),
+    inModes: function (modes) modes.some(mode => this.inMode(mode)),
 
     /**
      * Remove *mode* from the list of supported modes for this abbreviation.
@@ -80,7 +80,8 @@ var Abbreviation = Class("Abbreviation", {
      * @param {Mode} mode The mode to remove.
      */
     removeMode: function (mode) {
-        this.modes = this.modes.filter(function (m) m != mode).sort();
+        this.modes = this.modes.filter(m => m != mode)
+                               .sort();
     },
 
     /**
@@ -90,7 +91,7 @@ var Abbreviation = Class("Abbreviation", {
     get modeChar() Abbreviation.modeChar(this.modes)
 }, {
     modeChar: function (_modes) {
-        let result = array.uniq(_modes.map(function (m) m.char)).join("");
+        let result = array.uniq(_modes.map(m => m.char)).join("");
         if (result == "ci")
             result = "!";
         return result;
@@ -142,7 +143,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
         // Wth? --Kris;
         let map = values(this._store).map(Iterator).map(iter.toArray)
                                      .flatten().toObject();
-        return Object.keys(map).sort().map(function (k) map[k]);
+        return Object.keys(map).sort().map(k => map[k]);
     },
 
     /**
@@ -227,6 +228,10 @@ var Abbreviations = Module("abbreviations", {
         */), "x", params);
     },
 
+    get allHives() contexts.allGroups.abbrevs,
+
+    get userHives() this.allHives.filter(h => h !== this.builtin),
+
     get: deprecated("group.abbrevs.get", { get: function get() this.user.closure.get }),
     set: deprecated("group.abbrevs.set", { get: function set() this.user.closure.set }),
     remove: deprecated("group.abbrevs.remove", { get: function remove() this.user.closure.remove }),
@@ -244,7 +249,8 @@ var Abbreviations = Module("abbreviations", {
     match: function (mode, text) {
         let match = this._match.exec(text);
         if (match)
-            return this.hives.map(function (h) h.get(mode, match[2] || match[4] || match[6])).nth(util.identity, 0);
+            return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6]))
+                       .nth(util.identity, 0);
         return null;
     },
 
@@ -257,10 +263,10 @@ var Abbreviations = Module("abbreviations", {
      * @optional
      */
     list: function (modes, lhs, hives) {
-        let hives = hives || contexts.allGroups.abbrevs.filter(function (h) !h.empty);
+        let hives = (hives || this.userHives).filter(h => !h.empty);
 
         function abbrevs(hive)
-            hive.merged.filter(function (abbr) (abbr.inModes(modes) && abbr.lhs.indexOf(lhs) == 0));
+            hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.indexOf(lhs) == 0));
 
         let list = ["table", {},
                 ["tr", { highlight: "Title" },
@@ -269,9 +275,9 @@ var Abbreviations = Module("abbreviations", {
                     ["td", { style: "padding-right: 1em;" }, _("title.Abbrev")],
                     ["td", { style: "padding-right: 1em;" }, _("title.Replacement")]],
                 ["col", { style: "min-width: 6em; padding-right: 1em;" }],
-                hives.map(function (hive) let (i = 0) [
+                hives.map(hive => let (i = 0) [
                     ["tr", { style: "height: .5ex;" }],
-                    abbrevs(hive).map(function (abbrev)
+                    abbrevs(hive).map(abbrev =>
                         ["tr", {},
                             ["td", { highlight: "Title" }, !i++ ? String(hive.name) : ""],
                             ["td", {}, abbrev.modeChar],
@@ -298,7 +304,8 @@ var Abbreviations = Module("abbreviations", {
     completion: function initCompletion() {
         completion.abbreviation = function abbreviation(context, modes, group) {
             group = group || abbreviations.user;
-            let fn = modes ? function (abbr) abbr.inModes(modes) : util.identity;
+            let fn = modes ? abbr => abbr.inModes(modes)
+                           : abbr => abbr;
             context.keys = { text: "lhs" , description: "rhs" };
             context.completions = group.merged.filter(fn);
         };
@@ -341,18 +348,22 @@ var Abbreviations = Module("abbreviations", {
                             description: "Expand this abbreviation by evaluating its right-hand-side as JavaScript"
                         }
                     ],
-                    serialize: function () [
-                        {
-                            command: this.name,
-                            arguments: [abbr.lhs],
-                            literalArg: abbr.rhs,
-                            options: {
-                                "-javascript": callable(abbr.rhs) ? null : undefined
+                    serialize: function () array(abbreviations.userHives)
+                        .filter(h => h.persist)
+                        .map(hive => [
+                            {
+                                command: this.name,
+                                arguments: [abbr.lhs],
+                                literalArg: abbr.rhs,
+                                options: {
+                                    "-group": hive.name == "user" ? undefined : hive.name,
+                                    "-javascript": callable(abbr.rhs) ? null : undefined
+                                }
                             }
-                        }
-                        for ([, abbr] in Iterator(abbreviations.user.merged))
-                        if (abbr.modesEqual(modes))
-                    ]
+                            for ([, abbr] in Iterator(hive.merged))
+                            if (abbr.modesEqual(modes))
+                        ]).
+                        flatten().array
                 });
 
             commands.add([ch + "una[bbreviate]"],
index 7c1aa158f82159c2497698172e795b2e0b119de1..3dbfdd5df510fa41ca8e87cc9792f1c9d3eb3496 100644 (file)
@@ -20,7 +20,7 @@ by Kris Maglione, Doug Kearns, et al.
 &dactyl.appName; is open source and freely distributable
 
 type :q&lt;<span class="key">Enter</span>>                 to exit         <!---->
-type :help&lt;<span class="key">Enter</span>>                                        for on-line help
+type :help&lt;<span class="key">Enter</span>>              for on-line help
 type :help faq&lt;<span class="key">Enter</span>>          for the FAQ page
 type :help versions&lt;<span class="key">Enter</span>>     for version info
       </div>
index eaaa1c785e1613b2c04ab535fc1f34d5d7f2d19f..582337ce8bf3a63777b0d6fbdc0aab8cb4731479 100644 (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.
@@ -51,7 +51,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
      */
     get: function (event, filter) {
         filter = filter && String(Group.compileFilter(filter));
-        return this._store.filter(function (autoCmd) autoCmd.match(event, filter));
+        return this._store.filter(cmd => cmd.match(event, filter));
     },
 
     /**
@@ -62,7 +62,7 @@ var AutoCmdHive = Class("AutoCmdHive", Contexts.Hive, {
      */
     remove: function (event, filter) {
         filter = filter && String(Group.compileFilter(filter));
-        this._store = this._store.filter(function (autoCmd) !autoCmd.match(event, filter));
+        this._store = this._store.filter(cmd => !cmd.match(event, filter));
     },
 });
 
@@ -73,7 +73,7 @@ var AutoCommands = Module("autocommands", {
     init: function () {
     },
 
-    get activeHives() contexts.allGroups.autocmd.filter(function (h) h._store.length),
+    get activeHives() contexts.allGroups.autocmd.filter(h => h._store.length),
 
     add: deprecated("group.autocmd.add", { get: function add() autocommands.user.closure.add }),
     get: deprecated("group.autocmd.get", { get: function get() autocommands.user.closure.get }),
@@ -107,15 +107,15 @@ var AutoCommands = Module("autocommands", {
             ["table", {},
                 ["tr", { highlight: "Title" },
                     ["td", { colspan: "3" }, "----- Auto Commands -----"]],
-                hives.map(function (hive) [
+                hives.map(hive => [
                     ["tr", {},
                         ["td", { colspan: "3" },
                             ["span", { highlight: "Title" }, hive.name],
                             " ", hive.filter.toJSONXML(modules)]],
                     ["tr", { style: "height: .5ex;" }],
-                    iter(cmds(hive)).map(function ([event, items]) [
+                    iter(cmds(hive)).map(([event, items]) => [
                         ["tr", { style: "height: .5ex;" }],
-                        items.map(function (item, i)
+                        items.map((item, i) =>
                             ["tr", {},
                                 ["td", { highlight: "Title", style: "padding-left: 1em; padding-right: 1em;" },
                                     i == 0 ? event : ""],
@@ -186,14 +186,14 @@ var AutoCommands = Module("autocommands", {
                     validEvents.push("*");
 
                     events = Option.parse.stringlist(event);
-                    dactyl.assert(events.every(function (event) validEvents.indexOf(event.toLowerCase()) >= 0),
+                    dactyl.assert(events.every(e => validEvents.indexOf(e.toLowerCase()) >= 0),
                                   _("autocmd.noGroup", event));
                 }
 
                 if (args.length > 2) { // add new command, possibly removing all others with the same event/pattern
                     if (args.bang)
                         args["-group"].remove(event, filter);
-                    cmd = contexts.bindMacro(args, "-ex", function (params) params);
+                    cmd = contexts.bindMacro(args, "-ex", params => params);
                     args["-group"].add(events, filter, cmd);
                 }
                 else {
@@ -254,7 +254,7 @@ var AutoCommands = Module("autocommands", {
                                   _("autocmd.cantExecuteAll"));
                     dactyl.assert(validEvents.indexOf(event) >= 0,
                                   _("autocmd.noGroup", args));
-                    dactyl.assert(autocommands.get(event).some(function (c) c.filter(uri)),
+                    dactyl.assert(autocommands.get(event).some(c => c.filter(uri)),
                                   _("autocmd.noMatching"));
 
                     if (this.name == "doautoall" && dactyl.has("tabs")) {
@@ -283,7 +283,7 @@ var AutoCommands = Module("autocommands", {
         };
     },
     javascript: function initJavascript() {
-        JavaScript.setCompleter(AutoCmdHive.prototype.get, [function () Iterator(config.autocommands)]);
+        JavaScript.setCompleter(AutoCmdHive.prototype.get, [() => Iterator(config.autocommands)]);
     },
     options: function initOptions() {
         options.add(["eventignore", "ei"],
index d92c62476e5939647b790017da70e96cb907e457..09f088c54fef59759a0c14206954ec51c9d4adca 100644 (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.
@@ -349,8 +349,8 @@ var Bookmarks = Module("bookmarks", {
             else
                 encodedParam = bookmarkcache.keywords[keyword.toLowerCase()].encodeURIComponent(param);
 
-            url = url.replace(/%s/g, function () encodedParam)
-                     .replace(/%S/g, function () param);
+            url = url.replace(/%s/g, () => encodedParam)
+                     .replace(/%S/g, () => param);
             if (/%s/i.test(data))
                 postData = window.getPostDataStream(data, param, encodedParam, "application/x-www-form-urlencoded");
         }
@@ -388,7 +388,7 @@ var Bookmarks = Module("bookmarks", {
         let items = completion.runCompleter("bookmark", filter, maxItems, tags, extra);
 
         if (items.length)
-            return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
+            return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB);
 
         if (filter.length > 0 && tags.length > 0)
             dactyl.echoerr(_("bookmark.noMatching", tags.map(String.quote), filter.quote()));
@@ -408,7 +408,10 @@ var Bookmarks = Module("bookmarks", {
             names: ["-tags", "-T"],
             description: "A comma-separated list of tags",
             completer: function tags(context, args) {
-                context.generate = function () array(b.tags for (b in bookmarkcache) if (b.tags)).flatten().uniq().array;
+                context.generate = function () array(b.tags
+                                                     for (b in bookmarkcache)
+                                                     if (b.tags))
+                                                  .flatten().uniq().array;
                 context.keys = { text: util.identity, description: util.identity };
             },
             type: CommandOption.LIST
@@ -547,7 +550,9 @@ var Bookmarks = Module("bookmarks", {
                         let context = CompletionContext(args.join(" "));
                         context.fork("bookmark", 0, completion, "bookmark",
                                      args["-tags"], { keyword: args["-keyword"], title: args["-title"] });
-                        deletedCount = bookmarks.remove(context.allItems.items.map(function (item) item.item.id));
+
+                        deletedCount = bookmarks.remove(context.allItems.items
+                                                               .map(item => item.item.id));
                     }
 
                     dactyl.echomsg({ message: _("bookmark.deleted", deletedCount) });
@@ -574,7 +579,7 @@ var Bookmarks = Module("bookmarks", {
                 let options = {};
 
                 let url = buffer.uri.spec;
-                let bmarks = bookmarks.get(url).filter(function (bmark) bmark.url == url);
+                let bmarks = bookmarks.get(url).filter(bmark => bmark.url == url);
 
                 if (bmarks.length == 1) {
                     let bmark = bmarks[0];
@@ -623,14 +628,14 @@ var Bookmarks = Module("bookmarks", {
     },
 
     completion: function initCompletion() {
-        completion.bookmark = function bookmark(context, tags, extra) {
+        completion.bookmark = function bookmark(context, tags, extra = {}) {
             context.title = ["Bookmark", "Title"];
             context.format = bookmarks.format;
-            iter(extra || {}).forEach(function ([k, v]) {
+            iter(extra).forEach(function ([k, v]) {
                 if (v != null)
                     context.filters.push(function (item) item.item[k] != null && this.matchString(v, item.item[k]));
             });
-            context.generate = function () values(bookmarkcache.bookmarks);
+            context.generate = () => values(bookmarkcache.bookmarks);
             completion.urls(context, tags);
         };
 
@@ -680,7 +685,7 @@ var Bookmarks = Module("bookmarks", {
              context.keys = { text: "keyword", description: "title", icon: "icon" };
              context.completions = values(bookmarks.searchEngines);
              if (suggest)
-                 context.filters.push(function ({ item }) item.supportsResponseType("application/x-suggestions+json"));
+                 context.filters.push(({ item }) => item.supportsResponseType("application/x-suggestions+json"));
 
         };
 
@@ -712,13 +717,13 @@ var Bookmarks = Module("bookmarks", {
                     return;
 
                 let words = ctxt.filter.toLowerCase().split(/\s+/g);
-                ctxt.completions = ctxt.completions.filter(function (i) words.every(function (w) i.toLowerCase().indexOf(w) >= 0));
+                ctxt.completions = ctxt.completions.filter(i => words.every(w => i.toLowerCase().indexOf(w) >= 0));
 
                 ctxt.hasItems = ctxt.completions.length;
                 ctxt.incomplete = true;
                 ctxt.cache.request = bookmarks.getSuggestions(name, ctxt.filter, function (compl) {
                     ctxt.incomplete = false;
-                    ctxt.completions = array.uniq(ctxt.completions.filter(function (c) compl.indexOf(c) >= 0)
+                    ctxt.completions = array.uniq(ctxt.completions.filter(c => compl.indexOf(c) >= 0)
                                                       .concat(compl), true);
                 });
             });
index 79d98d2df8fbe57b2b024b557a0307d349d0beef..95c1fd4a8e9586a3dbe3c49399496c0864d460f0 100644 (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 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.
@@ -193,8 +193,8 @@ var Browser = Module("browser", XPCOM(Ci.nsISupportsWeakReference, ModuleBase),
             function (args) { dactyl.open(args[0] || "about:blank"); },
             {
                 completer: function (context) completion.url(context),
-                domains: function (args) array.compact(dactyl.parseURLs(args[0] || "").map(
-                    function (url) util.getHost(url))),
+                domains: function (args) array.compact(dactyl.parseURLs(args[0] || "")
+                                                             .map(url => util.getHost(url))),
                 literal: 0,
                 privateData: true
             });
index 9ea1fc33ba78d13920b7979c8f0430e5fee2756b..de8d9c3c79d6e9607c12dfa9a7167df11322e0a3 100644 (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.
@@ -199,7 +199,7 @@ var CommandWidgets = Class("CommandWidgets", {
                             highlight.highlightNode(elem,
                                 (val[0] != null ? val[0] : obj.defaultGroup)
                                     .split(/\s/).filter(util.identity)
-                                    .map(function (g) g + " " + nodeSet.group + g)
+                                    .map(g => g + " " + nodeSet.group + g)
                                     .join(" "));
                             elem.value = val[1];
                             if (obj.onChange)
@@ -217,7 +217,8 @@ var CommandWidgets = Class("CommandWidgets", {
                 let elem = nodeSet[obj.name];
                 if (elem)
                     highlight.highlightNode(elem, obj.defaultGroup.split(/\s/)
-                                                     .map(function (g) g + " " + nodeSet.group + g).join(" "));
+                                                     .map(g => g + " " + nodeSet.group + g)
+                                                     .join(" "));
             });
         }
     },
@@ -253,8 +254,10 @@ var CommandWidgets = Class("CommandWidgets", {
         // choose which element to select.
         function check(node) {
             if (DOM(node).style.display === "-moz-stack") {
-                let nodes = Array.filter(node.children, function (n) !n.collapsed && n.boxObject.height);
-                nodes.forEach(function (node, i) { node.style.opacity = (i == nodes.length - 1) ? "" : "0" });
+                let nodes = Array.filter(node.children, n => !n.collapsed && n.boxObject.height);
+                nodes.forEach((node, i) => {
+                    node.style.opacity = (i == nodes.length - 1) ? "" : "0";
+                });
             }
             Array.forEach(node.children, check);
         }
@@ -309,13 +312,14 @@ var CommandWidgets = Class("CommandWidgets", {
         return document.getElementById("dactyl-contextmenu");
     }),
 
-    multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output", function (elem) {
+    multilineOutput: Class.Memoize(function () this._whenReady("dactyl-multiline-output",
+                                                               elem => {
         highlight.highlightNode(elem.contentDocument.body, "MOW");
     }), true),
 
-    multilineInput: Class.Memoize(function () document.getElementById("dactyl-multiline-input")),
+    multilineInput: Class.Memoize(() => document.getElementById("dactyl-multiline-input")),
 
-    mowContainer: Class.Memoize(function () document.getElementById("dactyl-multiline-output-container"))
+    mowContainer: Class.Memoize(() => document.getElementById("dactyl-multiline-output-container"))
 }, {
     getEditor: function getEditor(elem) {
         elem.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
@@ -612,7 +616,7 @@ var CommandLine = Module("commandline", {
         }, this);
     },
 
-    widgets: Class.Memoize(function () CommandWidgets()),
+    widgets: Class.Memoize(() => CommandWidgets()),
 
     runSilently: function runSilently(func, self) {
         this.withSavedValues(["silent"], function () {
@@ -862,16 +866,14 @@ var CommandLine = Module("commandline", {
      * @... {string} default - The initial value that will be returned
      *     if the user presses <CR> straightaway. @default ""
      */
-    input: function _input(prompt, callback, extra) {
-        extra = extra || {};
-
+    input: function _input(prompt, callback, extra = {}) {
         CommandPromptMode(prompt, update({ onSubmit: callback }, extra)).open();
     },
 
     readHeredoc: function readHeredoc(end) {
         let args;
         commandline.inputMultiline(end, function (res) { args = res; });
-        util.waitFor(function () args !== undefined);
+        util.waitFor(() => args !== undefined);
         return args;
     },
 
@@ -916,7 +918,7 @@ var CommandLine = Module("commandline", {
 
     events: update(
         iter(CommandMode.prototype.events).map(
-            function ([event, handler]) [
+            ([event, handler]) => [
                 event, function (event) {
                     if (this.commandMode)
                         handler.call(this.commandSession, event);
@@ -967,7 +969,7 @@ var CommandLine = Module("commandline", {
         this.savingOutput = true;
         dactyl.trapErrors.apply(dactyl, [fn, self].concat(args));
         this.savingOutput = false;
-        return output.map(function (elem) elem instanceof Node ? DOM.stringify(elem) : elem)
+        return output.map(elem => elem instanceof Node ? DOM.stringify(elem) : elem)
                      .join("\n");
     }
 }, {
@@ -1008,7 +1010,7 @@ var CommandLine = Module("commandline", {
             if (privateData == "never-save")
                 return;
 
-            this.store = this.store.filter(function (line) (line.value || line) != str);
+            this.store = this.store.filter(line => (line.value || line) != str);
             dactyl.trapErrors(function () {
                 this.store.push({ value: str, timestamp: Date.now() * 1000, privateData: privateData });
             }, this);
@@ -1162,7 +1164,7 @@ var CommandLine = Module("commandline", {
         },
 
         get activeContexts() this.context.contextList
-                                 .filter(function (c) c.items.length || c.incomplete),
+                                 .filter(c => c.items.length || c.incomplete),
 
         /**
          * Returns the current completion string relative to the
@@ -1392,10 +1394,8 @@ var CommandLine = Module("commandline", {
          *      @default {@link #selected}
          * @returns {object}
          */
-        getItem: function getItem(tuple) {
-            tuple = tuple || this.selected;
-            return tuple && tuple[0] && tuple[0].items[tuple[1]];
-        },
+        getItem: function getItem(tuple = this.selected)
+            tuple && tuple[0] && tuple[0].items[tuple[1]],
 
         /**
          * Returns a tuple representing the next item, at the given
@@ -1506,11 +1506,10 @@ var CommandLine = Module("commandline", {
          *      @default 1
          * @param {boolean} fromTab If true, this function was
          *      called by {@link #tab}.
+         *      @default false
          *      @private
          */
-        select: function select(idx, count, fromTab) {
-            count = count || 1;
-
+        select: function select(idx, count = 1, fromTab = false) {
             switch (idx) {
             case this.UP:
             case this.DOWN:
@@ -1693,7 +1692,7 @@ var CommandLine = Module("commandline", {
                 }
                 else if (commandline._messageHistory.length > 1) {
                     commandline.commandOutput(
-                        template.map(commandline._messageHistory.messages, function (message)
+                        template.map(commandline._messageHistory.messages, message =>
                            ["div", { highlight: message.highlight + " Message" },
                                message.message]));
                 }
@@ -1708,7 +1707,7 @@ var CommandLine = Module("commandline", {
         commands.add(["sil[ent]"],
             "Run a command silently",
             function (args) {
-                commandline.runSilently(function () commands.execute(args[0] || "", null, true));
+                commandline.runSilently(() => { commands.execute(args[0] || "", null, true); });
             }, {
                 completer: function (context) completion.ex(context),
                 literal: 0,
@@ -1759,7 +1758,7 @@ var CommandLine = Module("commandline", {
                     text = text.substring(1, index);
                     modes.pop();
 
-                    return function () self.callback.call(commandline, text);
+                    return () => self.callback.call(commandline, text);
                 }
                 return Events.PASS;
             });
@@ -1893,10 +1892,10 @@ var CommandLine = Module("commandline", {
                 let store = commandline._store;
                 for (let [k, v] in store) {
                     if (k == "command")
-                        store.set(k, v.filter(function (item)
+                        store.set(k, v.filter(item =>
                             !(timespan.contains(item.timestamp) && (!host || commands.hasDomain(item.value, host)))));
                     else if (!host)
-                        store.set(k, v.filter(function (item) !timespan.contains(item.timestamp)));
+                        store.set(k, v.filter(item => !timespan.contains(item.timestamp)));
                 }
             }
         });
@@ -1904,20 +1903,24 @@ var CommandLine = Module("commandline", {
         sanitizer.addItem("history", {
             action: function (timespan, host) {
                 commandline._store.set("command",
-                    commandline._store.get("command", []).filter(function (item)
+                    commandline._store.get("command", []).filter(item =>
                         !(timespan.contains(item.timestamp) && (host ? commands.hasDomain(item.value, host)
                                                                      : item.privateData))));
 
-                commandline._messageHistory.filter(function (item) !timespan.contains(item.timestamp * 1000) ||
-                    !item.domains && !item.privateData ||
-                    host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host))));
+                commandline._messageHistory.filter(item =>
+                    ( !timespan.contains(item.timestamp * 1000)
+                   || !item.domains && !item.privateData
+                   || host && ( !item.domains
+                             || !item.domains.some(d => util.isSubdomain(d, host)))));
             }
         });
         sanitizer.addItem("messages", {
             description: "Saved :messages",
             action: function (timespan, host) {
-                commandline._messageHistory.filter(function (item) !timespan.contains(item.timestamp * 1000) ||
-                    host && (!item.domains || !item.domains.some(function (d) util.isSubdomain(d, host))));
+                commandline._messageHistory.filter(item =>
+                    ( !timespan.contains(item.timestamp * 1000)
+                   || host && ( !item.domains
+                             || !item.domains.some(d => util.isSubdomain(d, host)))));
             }
         });
     }
@@ -1965,18 +1968,18 @@ var ItemList = Class("ItemList", {
                 ["div", { key: "completions" }]],
 
             ["div", { highlight: "Completions" },
-                template.map(util.range(0, options["maxitems"] * 2), function (i)
+                template.map(util.range(0, options["maxitems"] * 2), i =>
                     ["div", { highlight: "CompItem NonText" },
                         "~"])]],
 
     get itemCount() this.context.contextList
-                        .reduce(function (acc, ctxt) acc + ctxt.items.length, 0),
+                        .reduce((acc, ctxt) => acc + ctxt.items.length, 0),
 
     get visible() !this.container.collapsed,
     set visible(val) this.container.collapsed = !val,
 
     get activeGroups() this.context.contextList
-                           .filter(function (c) c.items.length || c.message || c.incomplete)
+                           .filter(c => c.items.length || c.message || c.incomplete)
                            .map(this.getGroup, this),
 
     get selected() let (g = this.selectedGroup) g && g.selectedIdx != null
@@ -2026,7 +2029,7 @@ var ItemList = Class("ItemList", {
         if (start < 0 || start >= this.itemCount)
             return null;
 
-        group = array.nth(groups, function (g) let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0);
+        group = array.nth(groups, g => let (i = start - g.offsets.start) i >= 0 && i < g.itemCount, 0);
         return [group.context, start - group.offsets.start];
     },
 
@@ -2144,8 +2147,8 @@ var ItemList = Class("ItemList", {
         // We need to collect all of the rescrolling functions in
         // one go, as the height calculation that they need to do
         // would force a reflow after each DOM modification.
-        this.activeGroups.filter(function (g) !g.collapsed)
-            .map(function (g) g.rescrollFunc)
+        this.activeGroups.filter(g => !g.collapsed)
+            .map(g => g.rescrollFunc)
             .forEach(call);
 
         if (!this.selected)
index 64aa91358d46886bd9cbe3e492cf8cb991a054df..6ad9e5534ca899160a439e8b5014974c20d58f20 100644 (file)
@@ -211,7 +211,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
 
     unregisterObserver: function unregisterObserver(type, callback) {
         if (type in this._observers)
-            this._observers[type] = this._observers[type].filter(function (c) c.get() != callback);
+            this._observers[type] = this._observers[type].filter(c => c.get() != callback);
     },
 
     applyTriggerObserver: function triggerObserver(type, args) {
@@ -245,12 +245,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         let name = commands.add(params.name, params.description,
             function (args) {
                 let results = array(params.iterate(args))
-                    .sort(function (a, b) String.localeCompare(a.name, b.name));
+                    .sort((a, b) => String.localeCompare(a.name, b.name));
 
-                let filters = args.map(function (arg) let (re = util.regexp.escape(arg))
+                let filters = args.map(arg => let (re = util.regexp.escape(arg))
                                         util.regexp("\\b" + re + "\\b|(?:^|[()\\s])" + re + "(?:$|[()\\s])", "i"));
                 if (filters.length)
-                    results = results.filter(function (item) filters.every(function (re) keys(item).some(re.closure.test)));
+                    results = results.filter(item => filters.every(re => keys(item).some(re.closure.test)));
 
                 commandline.commandOutput(
                     template.usage(results, params.format));
@@ -276,7 +276,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         if (params.index)
             this.indices[params.index] = function () {
                 let results = array((params.iterateIndex || params.iterate).call(params, commands.get(name).newArgs()))
-                        .array.sort(function (a, b) String.localeCompare(a.name, b.name));
+                        .array.sort((a, b) => String.localeCompare(a.name, b.name));
 
                 let haveTag = Set.has(help.tags);
                 for (let obj in values(results)) {
@@ -538,13 +538,11 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
      * @param {boolean} silent Whether the command should be echoed on the
      *     command line.
      */
-    execute: function execute(str, modifiers, silent) {
+    execute: function execute(str, modifiers = {}, silent = false) {
         // skip comments and blank lines
         if (/^\s*("|$)/.test(str))
             return;
 
-        modifiers = modifiers || {};
-
         if (!silent)
             commands.lastCommand = str.replace(/^\s*:\s*/, "");
         let res = true;
@@ -667,22 +665,23 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         let args = null;
 
         if (obj instanceof Command) {
-            link = function (cmd) ["ex", {}, cmd];
+            link = cmd => ["ex", {}, cmd];
             args = obj.parseArgs("", CompletionContext(str || ""));
-            tag  = function (cmd) DOM.DOMString(":" + cmd);
-            spec = function (cmd) [
+            tag  = cmd => DOM.DOMString(":" + cmd);
+            spec = cmd => [
                 obj.count ? ["oa", {}, "count"] : [],
                 cmd,
                 obj.bang ? ["oa", {}, "!"] : []
             ];
         }
         else if (obj instanceof Map) {
-            spec = function (map) obj.count ? [["oa", {}, "count"], map] : DOM.DOMString(map);
-            tag = function (map) [
+            spec = map => (obj.count ? [["oa", {}, "count"], map]
+                                     : DOM.DOMString(map));
+            tag = map => [
                 let (c = obj.modes[0].char) c ? c + "_" : "",
                 map
             ];
-            link = function (map) {
+            link = map => {
                 let [, mode, name, extra] = /^(?:(.)_)?(?:<([^>]+)>)?(.*)$/.exec(map);
                 let k = ["k", {}, extra];
                 if (name)
@@ -693,9 +692,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             };
         }
         else if (obj instanceof Option) {
-            spec = function () template.map(obj.names, tag, " ");
-            tag = function (name) DOM.DOMString("'" + name + "'");
-            link = function (opt, name) ["o", {}, name];
+            spec = () => template.map(obj.names, tag, " ");
+            tag = name => DOM.DOMString("'" + name + "'");
+            link = (opt, name) => ["o", {}, name];
             args = { value: "", values: [] };
         }
 
@@ -720,7 +719,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     let (name = (obj.specs || obj.names)[0])
                           spec(template.highlightRegexp(tag(name),
                                /\[(.*?)\]/g,
-                               function (m, n0) ["oa", {}, n0]),
+                               (m, n0) => ["oa", {}, n0]),
                                name)],
                 !obj.type ? "" : [
                     ["type", {}, obj.type],
@@ -736,16 +735,18 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
 
         if (obj.completer && false)
             add(completion._runCompleter(obj.closure.completer, "", null, args).items
-                          .map(function (i) [i.text, i.description]));
+                          .map(i => [i.text, i.description]));
 
-        if (obj.options && obj.options.some(function (o) o.description) && false)
-            add(obj.options.filter(function (o) o.description)
-                   .map(function (o) [
+        if (obj.options && obj.options.some(o => o.description) && false)
+            add(obj.options.filter(o => o.description)
+                   .map(o => [
                         o.names[0],
                         [o.description,
                          o.names.length == 1 ? "" :
                              ["", " (short name: ",
-                                 template.map(o.names.slice(1), function (n) ["em", {}, n], ", "),
+                                 template.map(o.names.slice(1),
+                                              n => ["em", {}, n],
+                                              ", "),
                               ")"]]
                     ]));
 
@@ -889,7 +890,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
      *     tabs.
      * @returns {boolean}
      */
-    open: function open(urls, params, force) {
+    open: function open(urls, params = {}, force = false) {
         if (typeof urls == "string")
             urls = dactyl.parseURLs(urls);
 
@@ -900,7 +901,6 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                         dactyl.open(urls, params, true);
                 });
 
-        params = params || {};
         if (isString(params))
             params = { where: params };
 
@@ -960,7 +960,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                         options.push("private");
 
                     let win = window.openDialog(document.documentURI, "_blank", options.join(","));
-                    util.waitFor(function () win.document.readyState === "complete");
+                    util.waitFor(() => win.document.readyState === "complete");
                     browser = win.dactyl && win.dactyl.modules.config.tabbrowser || win.getBrowser();
                     // FALLTHROUGH
                 case dactyl.CURRENT_TAB:
@@ -1037,7 +1037,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         }, this);
     },
     stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
-    urlish: Class.Memoize(function () util.regexp(literal(/*
+    urlish: Class.Memoize(() => util.regexp(literal(/*
             ^ (
                 <domain>+ (:\d+)? (/ .*) |
                 <domain>+ (:\d+) |
@@ -1184,14 +1184,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             return [];
         }
     },
-    wrapCallback: function wrapCallback(callback, self) {
-        self = self || this;
+    wrapCallback: function wrapCallback(callback, self = this) {
         let save = ["forceOpen"];
-        let saved = save.map(function (p) dactyl[p]);
+        let saved = save.map(p => dactyl[p]);
         return function wrappedCallback() {
             let args = arguments;
             return dactyl.withSavedValues(save, function () {
-                saved.forEach(function (p, i) dactyl[save[i]] = p);
+                saved.forEach((p, i) => { dactyl[save[i]] = p; });
                 try {
                     return callback.apply(self, args);
                 }
@@ -1220,15 +1219,16 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 try {
                     let info = contexts.getDocs(context);
                     if (DOM.isJSONXML(info)) {
-                        let langs = info.slice(2).filter(function (e) isArray(e) && isObject(e[1]) && e[1].lang);
+                        let langs = info.slice(2).filter(e => isArray(e) && isObject(e[1]) && e[1].lang);
                         if (langs) {
                             let lang = config.bestLocale(l[1].lang for each (l in langs));
 
                             info = info.slice(0, 2).concat(
-                                info.slice(2).filter(function (e) !isArray(e) || !isObject(e[1])
-                                                               || e[1].lang == lang));
+                                info.slice(2).filter(e => !isArray(e)
+                                                       || !isObject(e[1])
+                                                       || e[1].lang == lang));
 
-                            for each (let elem in info.slice(2).filter(function (e) isArray(e) && e[0] == "info" && isObject(e[1])))
+                            for each (let elem in info.slice(2).filter(e => isArray(e) && e[0] == "info" && isObject(e[1])))
                                 for (let attr in values(["name", "summary", "href"]))
                                     if (attr in elem[1])
                                         info[attr] = elem[1][attr];
@@ -1256,7 +1256,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         cache.register("help/index.xml", function () {
             return '<?xml version="1.0"?>\n' +
                    DOM.toXML(["overlay", { xmlns: "dactyl" },
-                       template.map(dactyl.indices, function ([name, iter])
+                       template.map(dactyl.indices, ([name, iter]) =>
                            ["dl", { insertafter: name + "-index" },
                                template.map(iter(), util.identity)],
                            "\n\n")]);
@@ -1266,7 +1266,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             return '<?xml version="1.0"?>\n' +
                    DOM.toXML(["overlay", { xmlns: "dactyl" },
                        ["dl", { insertafter: "dialog-list" },
-                           template.map(config.dialogs, function ([name, val])
+                           template.map(config.dialogs, ([name, val]) =>
                                (!val[2] || val[2]())
                                    ? [["dt", {}, name],
                                       ["dd", {}, val[0]]]
@@ -1279,9 +1279,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                    DOM.toXML(["overlay", { xmlns: "dactyl" },
                        ["dl", { insertafter: "sanitize-items" },
                            template.map(options.get("sanitizeitems").values
-                                                .sort(function (a, b) String.localeCompare(a.name,
-                                                                                           b.name)),
-                               function ({ name, description })
+                                                .sort((a, b) => String.localeCompare(a.name,
+                                                                                     b.name)),
+                               ({ name, description }) =>
                                [["dt", {}, name],
                                 ["dd", {}, template.linkifyHelp(description, true)]],
                                "\n")]]);
@@ -1325,7 +1325,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 }, config.guioptions),
                 setter: function (opts) {
                     for (let [opt, [, ids]] in Iterator(this.opts)) {
-                        ids.map(function (id) document.getElementById(id))
+                        ids.map(id => document.getElementById(id))
                            .forEach(function (elem) {
                             if (elem)
                                 dactyl.setNodeVisible(elem, opts.indexOf(opt) >= 0);
@@ -1341,10 +1341,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 },
                 setter: function (opts) {
                     let dir = ["horizontal", "vertical"].filter(
-                        function (dir) !Array.some(opts,
-                            function (o) this.opts[o] && this.opts[o][1] == dir, this),
-                        this);
-                    let class_ = dir.map(function (dir) "html|html > xul|scrollbar[orient=" + dir + "]");
+                        dir => !Array.some(opts,
+                                           o => this.opts[o] && this.opts[o][1] == dir));
+                    let class_ = dir.map(dir => "html|html > xul|scrollbar[orient=" + dir + "]");
 
                     styles.system.add("scrollbar", "*",
                                       class_.length ? class_.join(", ") + " { visibility: collapse !important; }" : "",
@@ -1369,7 +1368,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                                       classes.length ? classes.join(",") + "{ display: none; }" : "");
 
                     if (!dactyl.has("Gecko2")) {
-                        tabs.tabBinding.enabled = Array.some(opts, function (k) k in this.opts, this);
+                        tabs.tabBinding.enabled = Array.some(opts, k => k in this.opts);
                         tabs.updateTabCount();
                     }
                     if (config.tabbrowser.tabContainer._positionPinnedTabs)
@@ -1380,7 +1379,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     Option.validIf(!/[nN]/.test(opts), "Tab numbering not available in this " + config.host + " version")
                  */
             }
-        ].filter(function (group) !group.feature || dactyl.has(group.feature));
+        ].filter(group => !group.feature || dactyl.has(group.feature));
 
         options.add(["guioptions", "go"],
             "Show or hide certain GUI elements like the menu or toolbar",
@@ -1391,7 +1390,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     "rb" + [k for ([k, v] in iter(groups[1].opts))
                             if (!Dactyl.toolbarHidden(document.getElementById(v[1][0])))].join(""),
 
-                values: array(groups).map(function (g) [[k, v[0]] for ([k, v] in Iterator(g.opts))]).flatten(),
+                values: array(groups).map(g => [[k, v[0]] for ([k, v] in Iterator(g.opts))])
+                                     .flatten(),
 
                 setter: function (value) {
                     for (let group in values(groups))
@@ -1399,8 +1399,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                     events.checkFocus();
                     return value;
                 },
-                validator: function (val) Option.validateCompleter.call(this, val) &&
-                        groups.every(function (g) !g.validator || g.validator(val))
+                validator: function (val) Option.validateCompleter.call(this, val)
+                                       && groups.every(g => !g.validator || g.validator(val))
             });
 
         options.add(["loadplugins", "lpl"],
@@ -1449,7 +1449,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
         options.add(["verbose", "vbs"],
             "Define which info messages are displayed",
             "number", 1,
-            { validator: function (value) Option.validIf(value >= 0 && value <= 15, "Value must be between 0 and 15") });
+            { validator: function (value) Option.validIf(value >= 0 && value <= 15,
+                                                         "Value must be between 0 and 15") });
 
         options.add(["visualbell", "vb"],
             "Use visual bell instead of beeping on errors",
@@ -1504,7 +1505,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 let arg = args[0] || "";
                 let items = dactyl.getMenuItems(arg);
 
-                dactyl.assert(items.some(function (i) i.dactylPath == arg),
+                dactyl.assert(items.some(i => i.dactylPath == arg),
                               _("emenu.notFound", arg));
 
                 for (let [, item] in Iterator(items)) {
@@ -1684,13 +1685,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
             };
 
             toolbarCommand(["toolbars[how]", "tbs[how]"], "Show the named toolbar",
-                function (toolbar) dactyl.setNodeVisible(toolbar, true),
-                function ({ item }) Dactyl.toolbarHidden(item));
+                toolbar => dactyl.setNodeVisible(toolbar, true),
+                ({ item }) => Dactyl.toolbarHidden(item));
             toolbarCommand(["toolbarh[ide]", "tbh[ide]"], "Hide the named toolbar",
-                function (toolbar) dactyl.setNodeVisible(toolbar, false),
-                function ({ item }) !Dactyl.toolbarHidden(item));
+                toolbar => dactyl.setNodeVisible(toolbar, false),
+                ({ item }) => !Dactyl.toolbarHidden(item));
             toolbarCommand(["toolbart[oggle]", "tbt[oggle]"], "Toggle the named toolbar",
-                function (toolbar) dactyl.setNodeVisible(toolbar, Dactyl.toolbarHidden(toolbar)));
+                toolbar => dactyl.setNodeVisible(toolbar, Dactyl.toolbarHidden(toolbar)));
         }
 
         commands.add(["time"],
@@ -1701,7 +1702,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 args = args[0] || "";
 
                 if (args[0] == ":")
-                    var func = function () commands.execute(args, null, false);
+                    var func = () => commands.execute(args, null, false);
                 else
                     func = dactyl.userFunc(args);
 
@@ -1836,7 +1837,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
     completion: function initCompletion() {
         completion.dialog = function dialog(context) {
             context.title = ["Dialog"];
-            context.filters.push(function ({ item }) !item[2] || item[2]());
+            context.filters.push(({ item }) => !item[2] || item[2]());
             context.completions = [[k, v[0], v[2]] for ([k, v] in Iterator(config.dialogs))];
         };
 
@@ -1848,7 +1849,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 description: function (item) item.getAttribute("label"),
                 highlight: function (item) item.disabled ? "Disabled" : ""
             };
-            context.generate = function () dactyl.menuItems;
+            context.generate = () => dactyl.menuItems;
         };
 
         var toolbox = document.getElementById("navigator-toolbox");
@@ -1860,7 +1861,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
 
         completion.window = function window(context) {
             context.title = ["Window", "Title"];
-            context.keys = { text: function (win) dactyl.windows.indexOf(win) + 1, description: function (win) win.document.title };
+            context.keys = { text: win => dactyl.windows.indexOf(win) + 1,
+                             description: win => win.document.title };
             context.completions = dactyl.windows;
         };
     },
@@ -1880,9 +1882,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
                 && root._lightweightTheme._lastScreenWidth == null) {
 
             dactyl.withSavedValues.call(PrivateBrowsingUtils,
-                                      ["isWindowPrivate"], function () {
-                PrivateBrowsingUtils.isWindowPrivate = function () false;
-
+                                        ["isWindowPrivate"], function () {
+                PrivateBrowsingUtils.isWindowPrivate = () => false;
                 Cu.import("resource://gre/modules/LightweightThemeConsumer.jsm", {})
                   .LightweightThemeConsumer.call(root._lightweightTheme, document);
             });
index 01a25ebddb60346e5412d735ae2422b5716a99e1..d98fa950da6b4f8ad99cc7431beaee07762cd034 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2008-2011 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2013 Kris Maglione <maglione.k at Gmail>
 // Copyright (c) 2006-2009 by Martin Stubenschrott <stubenschrott@vimperator.org>
 //
 // This work is licensed for reuse under an MIT license. Details are
@@ -304,7 +304,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
 
         // Skip to any requested offset.
         count = Math.abs(offset);
-        Editor.extendRange(range, offset > 0, { test: function (c) !!count-- }, true);
+        Editor.extendRange(range, offset > 0,
+                           { test: c => !!count-- },
+                           true);
         range.collapse(offset < 0);
 
         return range;
@@ -381,7 +383,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
             textBox = null;
 
         let line, column;
-        let keepFocus = modes.stack.some(function (m) isinstance(m.main, modes.COMMAND_LINE));
+        let keepFocus = modes.stack.some(m => isinstance(m.main, modes.COMMAND_LINE));
 
         if (!forceEditing && textBox && textBox.type == "password") {
             commandline.input(_("editor.prompt.editPassword") + " ",
@@ -400,7 +402,9 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
             var editor_ = window.GetCurrentEditor ? GetCurrentEditor()
                                                   : Editor.getEditor(document.commandDispatcher.focusedWindow);
             dactyl.assert(editor_);
-            text = Array.map(editor_.rootElement.childNodes, function (e) DOM.stringify(e, true)).join("");
+            text = Array.map(editor_.rootElement.childNodes,
+                             e => DOM.stringify(e, true))
+                        .join("");
 
             if (!editor_.selection.rangeCount)
                 var sel = "";
@@ -1131,7 +1135,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
              "<*-Home>", "<*-End>", "<*-PageUp>", "<*-PageDown>",
              "<M-c>", "<M-v>", "<*-Tab>"],
             "Handled by " + config.host,
-            function () Events.PASS_THROUGH);
+            () => Events.PASS_THROUGH);
 
         mappings.add([modes.INSERT],
             ["<Space>", "<Return>"], "Expand Insert mode abbreviation",
@@ -1316,7 +1320,7 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
                 var range = editor.selectedRange;
                 if (range.collapsed) {
                     count = count || 1;
-                    Editor.extendRange(range, true, { test: function (c) !!count-- }, true);
+                    Editor.extendRange(range, true, { test: c => !!count-- }, true);
                 }
                 editor.mungeRange(range, munger, count != null);
 
@@ -1327,19 +1331,19 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
         let bind = function bind(...args) mappings.add.apply(mappings, [[modes.AUTOCOMPLETE]].concat(args));
 
         bind(["<Esc>"], "Return to Insert mode",
-             function () Events.PASS_THROUGH);
+             () => Events.PASS_THROUGH);
 
         bind(["<C-[>"], "Return to Insert mode",
              function () { events.feedkeys("<Esc>", { skipmap: true }); });
 
         bind(["<Up>"], "Select the previous autocomplete result",
-             function () Events.PASS_THROUGH);
+             () => Events.PASS_THROUGH);
 
         bind(["<C-p>"], "Select the previous autocomplete result",
              function () { events.feedkeys("<Up>", { skipmap: true }); });
 
         bind(["<Down>"], "Select the next autocomplete result",
-             function () Events.PASS_THROUGH);
+             () => Events.PASS_THROUGH);
 
         bind(["<C-n>"], "Select the next autocomplete result",
              function () { events.feedkeys("<Down>", { skipmap: true }); });
@@ -1349,9 +1353,12 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
             "The external text editor",
             "string", 'gvim -f +<line> +"sil! call cursor(0, <column>)" <file>', {
                 format: function (obj, value) {
-                    let args = commands.parseArgs(value || this.value, { argCount: "*", allowUnknownOptions: true })
-                                       .map(util.compileMacro).filter(function (fmt) fmt.valid(obj))
-                                       .map(function (fmt) fmt(obj));
+                    let args = commands.parseArgs(value || this.value,
+                                                  { argCount: "*", allowUnknownOptions: true })
+                                       .map(util.compileMacro)
+                                       .filter(fmt => fmt.valid(obj))
+                                       .map(fmt => fmt(obj));
+
                     if (obj["file"] && !this.has("file"))
                         args.push(obj["file"]);
                     return args;
@@ -1359,7 +1366,8 @@ var Editor = Module("editor", XPCOM(Ci.nsIEditActionListener, ModuleBase), {
                 has: function (key) Set.has(util.compileMacro(this.value).seen, key),
                 validator: function (value) {
                     this.format({}, value);
-                    return Object.keys(util.compileMacro(value).seen).every(function (k) ["column", "file", "line"].indexOf(k) >= 0);
+                    return Object.keys(util.compileMacro(value).seen)
+                                 .every(k => ["column", "file", "line"].indexOf(k) >= 0);
                 }
             });
 
index ffa279bb1fd41ebc1b362bdee56d9908dffba44c..8006c4cdb422a0aa203159400d69d58ed011c922 100644 (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 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.
@@ -140,7 +140,7 @@ var Events = Module("events", {
                         this.active.push(elem);
                 }
 
-                this.active = this.active.filter(function (e) e.popupBoxObject && e.popupBoxObject.popupState != "closed");
+                this.active = this.active.filter(e => e.popupBoxObject && e.popupBoxObject.popupState != "closed");
 
                 if (!this.active.length && !this.activeMenubar)
                     modes.remove(modes.MENU, true);
@@ -212,8 +212,7 @@ var Events = Module("events", {
     /**
      * Wraps an event listener to ensure that errors are reported.
      */
-    wrapListener: function wrapListener(method, self) {
-        self = self || this;
+    wrapListener: function wrapListener(method, self = this) {
         method.wrapper = wrappedListener;
         wrappedListener.wrapped = method;
         function wrappedListener(event) {
@@ -465,34 +464,35 @@ var Events = Module("events", {
         let accel = config.OS.isMacOSX ? "metaKey" : "ctrlKey";
 
         let access = iter({ 1: "shiftKey", 2: "ctrlKey", 4: "altKey", 8: "metaKey" })
-                        .filter(function ([k, v]) this & k, prefs.get("ui.key.chromeAccess"))
-                        .map(function ([k, v]) [v, true])
+                        .filter(function ([k, v]) this & k,
+                                prefs.get("ui.key.chromeAccess"))
+                        .map(([k, v]) => [v, true])
                         .toObject();
 
     outer:
         for (let [, key] in iter(elements))
-            if (filters.some(function ([k, v]) key.getAttribute(k) == v)) {
+            if (filters.some(([k, v]) => key.getAttribute(k) == v)) {
                 let keys = { ctrlKey: false, altKey: false, shiftKey: false, metaKey: false };
                 let needed = { ctrlKey: event.ctrlKey, altKey: event.altKey, shiftKey: event.shiftKey, metaKey: event.metaKey };
 
                 let modifiers = (key.getAttribute("modifiers") || "").trim().split(/[\s,]+/);
                 for (let modifier in values(modifiers))
                     switch (modifier) {
-                        case "access": update(keys, access); break;
-                        case "accel":  keys[accel] = true; break;
-                        default:       keys[modifier + "Key"] = true; break;
-                        case "any":
-                            if (!iter.some(keys, function ([k, v]) v && needed[k]))
-                                continue outer;
-                            for (let [k, v] in iter(keys)) {
-                                if (v)
-                                    needed[k] = false;
-                                keys[k] = false;
-                            }
-                            break;
+                    case "access": update(keys, access); break;
+                    case "accel":  keys[accel] = true; break;
+                    default:       keys[modifier + "Key"] = true; break;
+                    case "any":
+                        if (!iter.some(keys, ([k, v]) => v && needed[k]))
+                            continue outer;
+                        for (let [k, v] in iter(keys)) {
+                            if (v)
+                                needed[k] = false;
+                            keys[k] = false;
+                        }
+                        break;
                     }
 
-                if (iter(needed).every(function ([k, v]) v == keys[k]))
+                if (iter(needed).every(([k, v]) => (v == keys[k])))
                     return key;
             }
 
@@ -542,7 +542,8 @@ var Events = Module("events", {
         dactyl.echo(_("macro.loadWaiting"), commandline.FORCE_SINGLELINE);
 
         const maxWaitTime = (time || 25);
-        util.waitFor(function () buffer.loaded, this, maxWaitTime * 1000, true);
+        util.waitFor(() => buffer.loaded, this,
+                     maxWaitTime * 1000, true);
 
         dactyl.echo("", commandline.FORCE_SINGLELINE);
         if (!buffer.loaded)
@@ -659,7 +660,7 @@ var Events = Module("events", {
         // the command-line has focus
         // TODO: ...help me...please...
         keypress: function onKeyPress(event) {
-            event.dactylDefaultPrevented = event.getPreventDefault();
+            event.dactylDefaultPrevented = event.defaultPrevented;
 
             let duringFeed = this.duringFeed || [];
             this.duringFeed = [];
@@ -797,8 +798,9 @@ var Events = Module("events", {
                         && let (key = DOM.Event.stringify(event))
                             !(modes.main.count && /^\d$/.test(key) ||
                               modes.main.allBases.some(
-                                function (mode) mappings.hives.some(
-                                    function (hive) hive.get(mode, key) || hive.getCandidates(mode, key))));
+                                mode => mappings.hives
+                                                .some(hive => hive.get(mode, key)
+                                                           || hive.getCandidates(mode, key))));
 
             events.dbg("ON " + event.type.toUpperCase() + " " + DOM.Event.stringify(event) +
                        " passing: " + this.passing + " " +
@@ -870,7 +872,7 @@ var Events = Module("events", {
                 return;
             }
 
-            let haveInput = modes.stack.some(function (m) m.main.input);
+            let haveInput = modes.stack.some(m => m.main.input);
 
             if (DOM(elem || win).isEditable) {
                 if (!haveInput)
@@ -1104,7 +1106,7 @@ var Events = Module("events", {
         const Hive = Class("Hive", {
             init: function init(values, map) {
                 this.name = "passkeys:" + map;
-                this.stack = MapHive.Stack(values.map(function (v) Map(v[map + "Keys"])));
+                this.stack = MapHive.Stack(values.map(v => Map(v[map + "Keys"])));
                 function Map(keys) ({
                     execute: function () Events.PASS_THROUGH,
                     keys: keys
index d151c2c3d688f439cc802ea732309d23ec896495..af09ad4dd499498ef16561971e67bb3a09af3c68 100644 (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.
 var HintSession = Class("HintSession", CommandMode, {
     get extendedMode() modes.HINTS,
 
-    init: function init(mode, opts) {
+    init: function init(mode, opts = {}) {
         init.supercall(this);
 
-        opts = opts || {};
-
         if (!opts.window)
             opts.window = modes.getStack(0).params.window;
 
@@ -281,7 +279,7 @@ var HintSession = Class("HintSession", CommandMode, {
 
         let doc = win.document;
 
-        memoize(doc, "dactylLabels", function ()
+        memoize(doc, "dactylLabels", () =>
             iter([l.getAttribute("for"), l]
                  for (l in array.iterValues(doc.querySelectorAll("label[for]"))))
              .toObject());
@@ -300,7 +298,9 @@ var HintSession = Class("HintSession", CommandMode, {
                 return false;
 
             if (!rect.width || !rect.height)
-                if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem)))
+                if (!Array.some(elem.childNodes, elem => elem instanceof Element
+                                                      && DOM(elem).style.float != "none"
+                                                      && isVisible(elem)))
                     if (elem.textContent || !elem.name)
                         return false;
 
@@ -473,7 +473,7 @@ var HintSession = Class("HintSession", CommandMode, {
         if (!followFirst) {
             let firstHref = this.validHints[0].elem.getAttribute("href") || null;
             if (firstHref) {
-                if (this.validHints.some(function (h) h.elem.getAttribute("href") != firstHref))
+                if (this.validHints.some(h => h.elem.getAttribute("href") != firstHref))
                     return;
             }
             else if (this.validHints.length > 1)
@@ -496,7 +496,7 @@ var HintSession = Class("HintSession", CommandMode, {
                 // Hint document has been unloaded.
                 return;
 
-            let hinted = n || this.validHints.some(function (h) h.elem === elem);
+            let hinted = n || this.validHints.some(h => h.elem === elem);
             if (!hinted)
                 hints.setClass(elem, null);
             else if (n)
@@ -756,32 +756,32 @@ var Hints = Module("hints", {
 
         this.modes = {};
         this.addMode(";", "Focus hint",                           buffer.closure.focusElement);
-        this.addMode("?", "Show information for hint",            function (elem) buffer.showElementInfo(elem));
+        this.addMode("?", "Show information for hint",            elem => buffer.showElementInfo(elem));
         // TODO: allow for ! override to overwrite existing paths -- where? --djk
-        this.addMode("s", "Save hint",                            function (elem) buffer.saveLink(elem, false));
-        this.addMode("f", "Focus frame",                          function (elem) dactyl.focus(elem.ownerDocument.defaultView));
+        this.addMode("s", "Save hint",                            elem => buffer.saveLink(elem, false));
+        this.addMode("f", "Focus frame",                          elem => dactyl.focus(elem.ownerDocument.defaultView));
         this.addMode("F", "Focus frame or pseudo-frame",          buffer.closure.focusElement, isScrollable);
-        this.addMode("o", "Follow hint",                          function (elem) buffer.followLink(elem, dactyl.CURRENT_TAB));
-        this.addMode("t", "Follow hint in a new tab",             function (elem) buffer.followLink(elem, dactyl.NEW_TAB));
-        this.addMode("b", "Follow hint in a background tab",      function (elem) buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB));
-        this.addMode("w", "Follow hint in a new window",          function (elem) buffer.followLink(elem, dactyl.NEW_WINDOW));
-        this.addMode("O", "Generate an â€˜:open URL’ prompt",       function (elem, loc) CommandExMode().open("open " + loc));
-        this.addMode("T", "Generate a â€˜:tabopen URL’ prompt",     function (elem, loc) CommandExMode().open("tabopen " + loc));
-        this.addMode("W", "Generate a â€˜:winopen URL’ prompt",     function (elem, loc) CommandExMode().open("winopen " + loc));
-        this.addMode("a", "Add a bookmark",                       function (elem) bookmarks.addSearchKeyword(elem));
-        this.addMode("S", "Add a search keyword",                 function (elem) bookmarks.addSearchKeyword(elem));
-        this.addMode("v", "View hint source",                     function (elem, loc) buffer.viewSource(loc, false));
-        this.addMode("V", "View hint source in external editor",  function (elem, loc) buffer.viewSource(loc, true));
-        this.addMode("y", "Yank hint location",                   function (elem, loc) editor.setRegister(null, loc, true));
-        this.addMode("Y", "Yank hint description",                function (elem) editor.setRegister(null, elem.textContent || "", true));
+        this.addMode("o", "Follow hint",                          elem => buffer.followLink(elem, dactyl.CURRENT_TAB));
+        this.addMode("t", "Follow hint in a new tab",             elem => buffer.followLink(elem, dactyl.NEW_TAB));
+        this.addMode("b", "Follow hint in a background tab",      elem => buffer.followLink(elem, dactyl.NEW_BACKGROUND_TAB));
+        this.addMode("w", "Follow hint in a new window",          elem => buffer.followLink(elem, dactyl.NEW_WINDOW));
+        this.addMode("O", "Generate an â€˜:open URL’ prompt",       (elem, loc) => CommandExMode().open("open " + loc));
+        this.addMode("T", "Generate a â€˜:tabopen URL’ prompt",     (elem, loc) => CommandExMode().open("tabopen " + loc));
+        this.addMode("W", "Generate a â€˜:winopen URL’ prompt",     (elem, loc) => CommandExMode().open("winopen " + loc));
+        this.addMode("a", "Add a bookmark",                       elem => bookmarks.addSearchKeyword(elem));
+        this.addMode("S", "Add a search keyword",                 elem => bookmarks.addSearchKeyword(elem));
+        this.addMode("v", "View hint source",                     (elem, loc) => buffer.viewSource(loc, false));
+        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, loc, true));
+        this.addMode("Y", "Yank hint description",                elem => editor.setRegister(null, elem.textContent || "", true));
         this.addMode("A", "Yank hint anchor url",                 function (elem) {
             let uri = elem.ownerDocument.documentURIObject.clone();
             uri.ref = elem.id || elem.name;
             dactyl.clipboardWrite(uri.spec, true);
         });
-        this.addMode("c", "Open context menu",                    function (elem) DOM(elem).contextmenu());
-        this.addMode("i", "Show image",                           function (elem) dactyl.open(elem.src));
-        this.addMode("I", "Show image in a new tab",              function (elem) dactyl.open(elem.src, dactyl.NEW_TAB));
+        this.addMode("c", "Open context menu",                    elem => DOM(elem).contextmenu());
+        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]) ||
@@ -812,7 +812,7 @@ var Hints = Module("hints", {
             let update = eht.isDefault;
 
             let value = eht.parse(Option.quote(util.regexp.escape(mode)) + ":" + tags.map(Option.quote))[0];
-            eht.defaultValue = eht.defaultValue.filter(function (re) toString(re) != toString(value))
+            eht.defaultValue = eht.defaultValue.filter(re => toString(re) != toString(value))
                                   .concat(value);
 
             if (update)
@@ -915,7 +915,7 @@ var Hints = Module("hints", {
             let tokens = tokenize(/\s+/, hintString);
             return function (linkText) {
                 linkText = linkText.toLowerCase();
-                return tokens.every(function (token) indexOf(linkText, token) >= 0);
+                return tokens.every(token => indexOf(linkText, token) >= 0);
             };
         } //}}}
 
@@ -1054,16 +1054,14 @@ var Hints = Module("hints", {
         return null;
     }, //}}}
 
-    open: function open(mode, opts) {
+    open: function open(mode, opts = {}) {
         this._extendedhintCount = opts.count;
 
-        opts = opts || {};
-
         mappings.pushCommand();
         commandline.input(["Normal", mode], null, {
             autocomplete: false,
             completer: function (context) {
-                context.compare = function () 0;
+                context.compare = () => 0;
                 context.completions = [[k, v.prompt] for ([k, v] in Iterator(hints.modes))];
             },
             onCancel: mappings.closure.popCommand,
@@ -1073,7 +1071,7 @@ var Hints = Module("hints", {
                 mappings.popCommand();
             },
             onChange: function (arg) {
-                if (Object.keys(hints.modes).some(function (m) m != arg && m.indexOf(arg) == 0))
+                if (Object.keys(hints.modes).some(m => m != arg && m.indexOf(arg) == 0))
                     return;
 
                 this.accepted = true;
@@ -1111,7 +1109,9 @@ var Hints = Module("hints", {
     isVisible: function isVisible(elem, offScreen) {
         let rect = elem.getBoundingClientRect();
         if (!rect.width || !rect.height)
-            if (!Array.some(elem.childNodes, function (elem) elem instanceof Element && DOM(elem).style.float != "none" && isVisible(elem)))
+            if (!Array.some(elem.childNodes, elem => elem instanceof Element
+                                                  && DOM(elem).style.float != "none"
+                                                  && isVisible(elem)))
                 return false;
 
         let win = elem.ownerDocument.defaultView;
@@ -1300,7 +1300,7 @@ var Hints = Module("hints", {
             {
                 keepQuotes: true,
                 getKey: function (val, default_)
-                    let (res = array.nth(this.value, function (re) let (match = re.exec(val)) match && match[0] == val, 0))
+                    let (res = array.nth(this.value, re => let (match = re.exec(val)) match && match[0] == val, 0))
                         res ? res.matcher : default_,
                 parse: function parse(val) {
                     let vals = parse.supercall(this, val);
@@ -1308,7 +1308,7 @@ var Hints = Module("hints", {
                         value.matcher = DOM.compileMatcher(Option.splitList(value.result));
                     return vals;
                 },
-                testValues: function testValues(vals, validator) vals.every(function (re) Option.splitList(re).every(validator)),
+                testValues: function testValues(vals, validator) vals.every(re => Option.splitList(re).every(validator)),
                 validator: DOM.validateMatcher
             });
 
@@ -1368,7 +1368,8 @@ var Hints = Module("hints", {
                     "transliterated": UTF8("When true, special latin characters are translated to their ASCII equivalents (e.g., Ã© â‡’ e)")
                 },
                 validator: function (values) Option.validateCompleter.call(this, values) &&
-                    1 === values.reduce(function (acc, v) acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0), 0)
+                    1 === values.reduce((acc, v) => acc + (["contains", "custom", "firstletters", "wordstartswith"].indexOf(v) >= 0),
+                                        0)
             });
 
         options.add(["wordseparators", "wsp"],
index f19b1e2458bb9c52f749651eb649c1519165872d..62aacf1bb3a0692fb5dd33e529bf989ffe63aaa4 100644 (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.
@@ -13,9 +13,7 @@ var History = Module("history", {
 
     get service() services.history,
 
-    get: function get(filter, maxItems, sort) {
-        sort = sort || this.SORT_DEFAULT;
-
+    get: function get(filter, maxItems, sort = this.SORT_DEFAULT) {
         if (isString(filter))
             filter = { searchTerms: filter };
 
@@ -65,11 +63,11 @@ var History = Module("history", {
         let sh = webNav.sessionHistory;
 
         let obj = [];
-        obj.__defineGetter__("index", function () sh.index);
+        obj.__defineGetter__("index", () => sh.index);
         obj.__defineSetter__("index", function (val) { webNav.gotoIndex(val); });
         obj.__iterator__ = function () array.iterItems(this);
 
-        for (let item in iter(sh.SHistoryEnumerator, Ci.nsIHistoryEntry))
+        for (let item in iter(sh.SHistoryEnumerator, Ci.nsISHEntry))
             obj.push(update(Object.create(item), {
                 index: obj.length,
                 icon: Class.Memoize(function () services.favicon.getFaviconImageForPage(this.URI).spec)
@@ -111,7 +109,7 @@ var History = Module("history", {
      */
     search: function search(item, steps) {
         var ctxt;
-        var filter = function (item) true;
+        var filter = item => true;
         if (item == "domain")
             var filter = function (item) {
                 let res = item.URI.hostPort != ctxt;
@@ -165,7 +163,7 @@ var History = Module("history", {
         let items = completion.runCompleter("history", filter, maxItems, maxItems, sort);
 
         if (items.length)
-            return dactyl.open(items.map(function (i) i.url), dactyl.NEW_TAB);
+            return dactyl.open(items.map(i => i.url), dactyl.NEW_TAB);
 
         if (filter.length > 0)
             dactyl.echoerr(_("history.noMatching", filter.quote()));
@@ -209,7 +207,9 @@ var History = Module("history", {
                     context.compare = CompletionContext.Sort.unsorted;
                     context.filters = [CompletionContext.Filter.textDescription];
                     context.completions = sh.slice(0, sh.index).reverse();
-                    context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
+                    context.keys = { text: function (item) (sh.index - item.index) + ": " + item.URI.spec,
+                                     description: "title",
+                                     icon: "icon" };
                 },
                 count: true,
                 literal: 0,
@@ -249,7 +249,9 @@ var History = Module("history", {
                     context.compare = CompletionContext.Sort.unsorted;
                     context.filters = [CompletionContext.Filter.textDescription];
                     context.completions = sh.slice(sh.index + 1);
-                    context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec, description: "title", icon: "icon" };
+                    context.keys = { text: function (item) (item.index - sh.index) + ": " + item.URI.spec,
+                                     description: "title",
+                                     icon: "icon" };
                 },
                 count: true,
                 literal: 0,
@@ -284,7 +286,7 @@ var History = Module("history", {
                                 "title",
                                 "uri",
                                 "visitcount"
-                            ].map(function (order) [
+                            ].map(order => [
                                   ["+" + order.replace(" ", ""), /*L*/"Sort by " + order + " ascending"],
                                   ["-" + order.replace(" ", ""), /*L*/"Sort by " + order + " descending"]
                             ]));
@@ -305,7 +307,7 @@ var History = Module("history", {
                     jumps = [sh[sh.index]];
                 else {
                     index += jumps.index;
-                    jumps = jumps.locations.map(function (l) ({
+                    jumps = jumps.locations.map(l => ({
                         __proto__: l,
                         title: buffer.title,
                         get URI() util.newURI(this.location)
@@ -324,12 +326,12 @@ var History = Module("history", {
     completion: function initCompletion() {
         completion.domain = function (context) {
             context.anchored = false;
-            context.compare = function (a, b) String.localeCompare(a.key, b.key);
+            context.compare = (a, b) => String.localeCompare(a.key, b.key);
             context.keys = { text: util.identity, description: util.identity,
                 key: function (host) host.split(".").reverse().join(".") };
 
             // FIXME: Schema-specific
-            context.generate = function () [
+            context.generate = () => [
                 Array.slice(row.rev_host).reverse().join("").slice(1)
                 for (row in iter(services.history.DBConnection
                                          .createStatement("SELECT DISTINCT rev_host FROM moz_places WHERE rev_host IS NOT NULL;")))
index 08cc401a8f4c2badabf0592dbd3977b6639fe89c..305964392cf4818c34f9dbf1eccaac875090e8f6 100644 (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.
@@ -20,11 +20,11 @@ var ProcessorStack = Class("ProcessorStack", {
         this.modes = array([mode.params.keyModes, main, mode.main.allBases.slice(1)]).flatten().compact();
 
         if (builtin)
-            hives = hives.filter(function (h) h.name === "builtin");
+            hives = hives.filter(h => h.name === "builtin");
 
-        this.processors = this.modes.map(function (m) hives.map(function (h) KeyProcessor(m, h)))
+        this.processors = this.modes.map(m => hives.map(h => KeyProcessor(m, h)))
                                     .flatten().array;
-        this.ownsBuffer = !this.processors.some(function (p) p.main.ownsBuffer);
+        this.ownsBuffer = !this.processors.some(p => p.main.ownsBuffer);
 
         for (let [i, input] in Iterator(this.processors)) {
             let params = input.main.params;
@@ -77,7 +77,7 @@ var ProcessorStack = Class("ProcessorStack", {
         if (this.ownsBuffer)
             statusline.inputBuffer = this.processors.length ? this.buffer : "";
 
-        if (!this.processors.some(function (p) !p.extended) && this.actions.length) {
+        if (!this.processors.some(p => !p.extended) && this.actions.length) {
             // We have matching actions and no processors other than
             // those waiting on further arguments. Execute actions as
             // long as they continue to return PASS.
@@ -134,17 +134,17 @@ var ProcessorStack = Class("ProcessorStack", {
             events.passing = true;
 
         if (result === Events.PASS_THROUGH && this.keyEvents.length)
-            events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(function (e) [e.type, DOM.Event.stringify(e)]).join("\n\t"));
+            events.dbg("PASS_THROUGH:\n\t" + this.keyEvents.map(e => [e.type, DOM.Event.stringify(e)]).join("\n\t"));
 
         if (result === Events.PASS_THROUGH)
             events.feedevents(null, this.keyEvents, { skipmap: true, isMacro: true, isReplay: true });
         else {
-            let list = this.events.filter(function (e) e.getPreventDefault() && !e.dactylDefaultPrevented);
+            let list = this.events.filter(e => e.defaultPrevented && !e.dactylDefaultPrevented);
 
             if (result === Events.PASS)
-                events.dbg("PASS THROUGH: " + list.slice(0, length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify));
+                events.dbg("PASS THROUGH: " + list.slice(0, length).filter(e => e.type === "keypress").map(DOM.Event.closure.stringify));
             if (list.length > length)
-                events.dbg("REFEED: " + list.slice(length).filter(function (e) e.type === "keypress").map(DOM.Event.closure.stringify));
+                events.dbg("REFEED: " + list.slice(length).filter(e => e.type === "keypress").map(DOM.Event.closure.stringify));
 
             if (result === Events.PASS)
                 events.feedevents(null, list.slice(0, length), { skipmap: true, isMacro: true, isReplay: true });
@@ -190,7 +190,7 @@ var ProcessorStack = Class("ProcessorStack", {
                 processors.push(res);
         }
 
-        events.dbg("RESULT: " + event.getPreventDefault() + " " + this._result(result));
+        events.dbg("RESULT: " + event.defaultPrevented + " " + this._result(result));
         events.dbg("ACTIONS: " + actions.length + " " + this.actions.length);
         events.dbg("PROCESSORS:", processors, "\n");
 
index 68bba94c6e9bed082211128e30069ddb5cf53b8e..fa113b4d4de0229bd2ca5e24b202c2ffc39f7438 100644 (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 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.
@@ -48,9 +48,10 @@ var Map = Class("Map", {
     name: Class.Memoize(function () this.names[0]),
 
     /** @property {[string]} All of this mapping's names (key sequences). */
-    names: Class.Memoize(function () this._keys.map(function (k) DOM.Event.canonicalKeys(k))),
+    names: Class.Memoize(function () this._keys.map(k => DOM.Event.canonicalKeys(k))),
 
-    get toStringParams() [this.modes.map(function (m) m.name), this.names.map(String.quote)],
+    get toStringParams() [this.modes.map(m => m.name),
+                          this.names.map(String.quote)],
 
     get identifier() [this.modes[0].name, this.hive.prefix + this.names[0]].join("."),
 
@@ -116,7 +117,7 @@ var Map = Class("Map", {
     execute: function (args) {
         if (!isObject(args)) // Backwards compatibility :(
             args = iter(["motion", "count", "arg", "command"])
-                .map(function ([i, prop]) [prop, this[i]], arguments)
+                .map(([i, prop]) => [prop, this[i]], arguments)
                 .toObject();
 
         args = this.hive.makeArgs(this.hive.group.lastDocument,
@@ -171,9 +172,9 @@ var MapHive = Class("MapHive", Contexts.Hive, {
      */
     iterate: function (modes) {
         let stacks = Array.concat(modes).map(this.closure.getStack);
-        return values(stacks.shift().sort(function (m1, m2) String.localeCompare(m1.name, m2.name))
-            .filter(function (map) map.rhs &&
-                stacks.every(function (stack) stack.some(function (m) m.rhs && m.rhs === map.rhs && m.name === map.name))));
+        return values(stacks.shift().sort((m1, m2) => String.localeCompare(m1.name, m2.name))
+            .filter((map) => map.rhs &&
+                stacks.every(stack => stack.some(m => m.rhs && m.rhs === map.rhs && m.name === map.name))));
     },
 
     /**
@@ -186,9 +187,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
      * @param {Object} extra An optional extra configuration hash.
      * @optional
      */
-    add: function (modes, keys, description, action, extra) {
-        extra = extra || {};
-
+    add: function (modes, keys, description, action, extra = {}) {
         modes = Array.concat(modes);
         if (!modes.every(util.identity))
             throw TypeError(/*L*/"Invalid modes: " + modes);
@@ -263,7 +262,7 @@ var MapHive = Class("MapHive", Contexts.Hive, {
                 map.names.splice(j, 1);
                 if (map.names.length == 0) // FIX ME.
                     for (let [mode, stack] in Iterator(this.stacks))
-                        this.stacks[mode] = MapHive.Stack(stack.filter(function (m) m != map));
+                        this.stacks[mode] = MapHive.Stack(stack.filter(m => m != map));
                 return;
             }
         }
@@ -352,15 +351,17 @@ var Mappings = Module("mappings", {
 
     get allHives() contexts.allGroups.mappings,
 
-    get userHives() this.allHives.filter(function (h) h !== this.builtin, this),
+    get userHives() this.allHives.filter(h => h !== this.builtin),
 
     expandLeader: deprecated("your brain", function expandLeader(keyString) keyString),
 
     prefixes: Class.Memoize(function () {
-        let list = Array.map("CASM", function (s) s + "-");
+        let list = Array.map("CASM", s => s + "-");
 
-        return iter(util.range(0, 1 << list.length)).map(function (mask)
-            list.filter(function (p, i) mask & (1 << i)).join("")).toArray().concat("*-");
+        return iter(util.range(0, 1 << list.length)).map(mask =>
+            list.filter((p, i) => mask & (1 << i)).join(""))
+                .toArray()
+                .concat("*-");
     }),
 
     expand: function expand(keys) {
@@ -371,7 +372,7 @@ var Mappings = Module("mappings", {
                 if (/^<\*-/.test(key))
                     return ["<", this.prefixes, key.slice(3)];
                 return key;
-            }, this).flatten().array).map(function (k) DOM.Event.canonicalKeys(k));
+            }, this).flatten().array).map(k => DOM.Event.canonicalKeys(k));
 
         if (keys != arguments[0])
             return [arguments[0]].concat(keys);
@@ -442,7 +443,8 @@ var Mappings = Module("mappings", {
      * @param {string} cmd The map name to match.
      * @returns {Map}
      */
-    get: function get(mode, cmd) this.hives.map(function (h) h.get(mode, cmd)).compact()[0] || null,
+    get: function get(mode, cmd) this.hives.map(h => h.get(mode, cmd))
+                                     .compact()[0] || null,
 
     /**
      * Returns a count of maps with names starting with but not equal to
@@ -453,8 +455,8 @@ var Mappings = Module("mappings", {
      * @returns {[Map]}
      */
     getCandidates: function (mode, prefix)
-        this.hives.map(function (h) h.getCandidates(mode, prefix))
-                  .reduce(function (a, b) a + b, 0),
+        this.hives.map(h => h.getCandidates(mode, prefix))
+                  .reduce((a, b) => (a + b), 0),
 
     /**
      * Lists all user-defined mappings matching *filter* for the specified
@@ -465,17 +467,17 @@ var Mappings = Module("mappings", {
      * @param {[MapHive]} hives The map hives to list. @optional
      */
     list: function (modes, filter, hives) {
-        let modeSign = modes.map(function (m) m.char || "").join("")
-                     + modes.map(function (m) !m.char ? " " + m.name : "").join("");
+        let modeSign = modes.map(m => m.char || "").join("")
+                     + modes.map(m => !m.char ? " " + m.name : "").join("");
         modeSign = modeSign.replace(/^ /, "");
 
-        hives = (hives || mappings.userHives).map(function (h) [h, maps(h)])
-                                             .filter(function ([h, m]) m.length);
+        hives = (hives || mappings.userHives).map(h => [h, maps(h)])
+                                             .filter(([h, m]) => m.length);
 
         function maps(hive) {
             let maps = iter.toArray(hive.iterate(modes));
             if (filter)
-                maps = maps.filter(function (m) m.names[0] === filter);
+                maps = maps.filter(m => m.names[0] === filter);
             return maps;
         }
 
@@ -486,10 +488,10 @@ var Mappings = Module("mappings", {
                     ["td", { style: "padding-right: 1em;" }, _("title.Command")],
                     ["td", { style: "padding-right: 1em;" }, _("title.Action")]],
                 ["col", { style: "min-width: 6em; padding-right: 1em;" }],
-                hives.map(function ([hive, maps]) let (i = 0) [
+                hives.map(([hive, maps]) => let (i = 0) [
                     ["tr", { style: "height: .5ex;" }],
-                    maps.map(function (map)
-                        map.names.map(function (name)
+                    maps.map(map =>
+                        map.names.map(name =>
                         ["tr", {},
                             ["td", { highlight: "Title" }, !i++ ? hive.name : ""],
                             ["td", {}, modeSign],
@@ -526,7 +528,7 @@ var Mappings = Module("mappings", {
 
                 if (args[1] && !/^<nop>$/i.test(args[1])
                     && !args["-count"] && !args["-ex"] && !args["-javascript"]
-                    && mapmodes.every(function (m) m.count))
+                    && mapmodes.every(m => m.count))
                     args[1] = "<count>" + args[1];
 
                 let [lhs, rhs] = args;
@@ -541,7 +543,7 @@ var Mappings = Module("mappings", {
 
                     args["-group"].add(mapmodes, [lhs],
                         args["-description"],
-                        contexts.bindMacro(args, "-keys", function (params) params),
+                        contexts.bindMacro(args, "-keys", params => params),
                         {
                             arg: args["-arg"],
                             count: args["-count"] || !(args["-ex"] || args["-javascript"]),
@@ -614,8 +616,8 @@ var Mappings = Module("mappings", {
                 serialize: function () {
                     return this.name != "map" ? [] :
                         array(mappings.userHives)
-                            .filter(function (h) h.persist)
-                            .map(function (hive) [
+                            .filter(h => h.persist)
+                            .map(hive => [
                                 {
                                     command: "map",
                                     options: {
@@ -711,9 +713,9 @@ var Mappings = Module("mappings", {
         }
         function uniqueModes(modes) {
             let chars = [k for ([k, v] in Iterator(modules.modes.modeChars))
-                         if (v.every(function (mode) modes.indexOf(mode) >= 0))];
-            return array.uniq(modes.filter(function (m) chars.indexOf(m.char) < 0)
-                                   .map(function (m) m.name.toLowerCase())
+                         if (v.every(mode => modes.indexOf(mode) >= 0))];
+            return array.uniq(modes.filter(m => chars.indexOf(m.char) < 0)
+                                   .map(m => m.name.toLowerCase())
                                    .concat(chars));
         }
 
@@ -773,7 +775,7 @@ var Mappings = Module("mappings", {
                             : [],
                         template.linkifyHelp(map.description + (map.rhs ? ": " + map.rhs : ""))
                 ],
-                help: function (map) let (char = array.compact(map.modes.map(function (m) m.char))[0])
+                help: function (map) let (char = array.compact(map.modes.map(m => m.char))[0])
                     char === "n" ? map.name : char ? char + "_" + map.name : "",
                 headings: ["Command", "Mode", "Group", "Description"]
             }
@@ -810,10 +812,9 @@ var Mappings = Module("mappings", {
         });
     },
     completion: function initCompletion(dactyl, modules, window) {
-        completion.userMapping = function userMapping(context, modes_, hive) {
-            hive = hive || mappings.user;
-            modes_ = modes_ || [modes.NORMAL];
-            context.keys = { text: function (m) m.names[0], description: function (m) m.description + ": " + m.action };
+        completion.userMapping = function userMapping(context, modes_ = [modes.NORMAL], hive = mappings.user) {
+            context.keys = { text: function (m) m.names[0],
+                             description: function (m) m.description + ": " + m.action };
             context.completions = hive.iterate(modes_);
         };
     },
@@ -821,7 +822,8 @@ var Mappings = Module("mappings", {
         JavaScript.setCompleter([Mappings.prototype.get, MapHive.prototype.get],
             [
                 null,
-                function (context, obj, args) [[m.names, m.description] for (m in this.iterate(args[0]))]
+                function (context, obj, args) [[m.names, m.description]
+                                               for (m in this.iterate(args[0]))]
             ]);
     },
     mappings: function initMappings(dactyl, modules, window) {
index 8131e2963b51bfa31db0e4d477fdc51f349a532d..cfa27bf30b90ee25346974e3bc79851aa8a40aef 100644 (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.
@@ -30,16 +30,14 @@ var Marks = Module("marks", {
      */
     get all() iter(this._localMarks.get(this.localURI) || {},
                    this._urlMarks
-                  ).sort(function (a, b) String.localeCompare(a[0], b[0])),
+                  ).sort((a, b) => String.localeCompare(a[0], b[0])),
 
     get localURI() buffer.focusedFrame.document.documentURI.replace(/#.*/, ""),
 
-    Mark: function Mark(params) {
+    Mark: function Mark(params = {}) {
         let win = buffer.focusedFrame;
         let doc = win.document;
 
-        params = params || {};
-
         params.location = doc.documentURI.replace(/#.*/, ""),
         params.offset = buffer.scrollPosition;
         params.path = DOM(buffer.findScrollable(0, false)).xpath;
@@ -137,7 +135,7 @@ var Marks = Module("marks", {
         let store = buffer.localStore;
         return {
             index: store.jumpsIndex,
-            locations: store.jumps.map(function (j) j.mark)
+            locations: store.jumps.map(j => j.mark)
         };
     },
 
@@ -260,7 +258,7 @@ var Marks = Module("marks", {
 
         if (filter.length > 0) {
             let pattern = util.charListToRegexp(filter, "a-zA-Z");
-            marks = marks.filter(function ([k, ]) pattern.test(k));
+            marks = marks.filter(([k]) => (pattern.test(k)));
             dactyl.assert(marks.length > 0, _("mark.noMatching", filter.quote()));
         }
 
@@ -376,9 +374,9 @@ var Marks = Module("marks", {
             function percent(i) Math.round(i * 100);
 
             context.title = ["Mark", "HPos VPos File"];
-            context.keys.description = function ([, m]) (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y)
-                                                                  : percent(m.position.x) + "% " + percent(m.position.y) + "%"
-                                                        ) + " " + m.location;
+            context.keys.description = ([, m]) => (m.offset ? Math.round(m.offset.x) + " " + Math.round(m.offset.y)
+                                                            : percent(m.position.x) + "% " + percent(m.position.y) + "%"
+                                                  ) + " " + m.location;
             context.completions = marks.all;
         };
     },
index fc33fd7f24e95d88795de024fa9d690d8a166a6a..838eab65d1186d67f684389d1e49ab79929fdb3d 100644 (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.
@@ -237,7 +237,7 @@ var Modes = Module("modes", {
         if (this._modeMap[mode.mode] == mode)
             delete this._modeMap[mode.mode];
 
-        this._mainModes = this._mainModes.filter(function (m) m != mode);
+        this._mainModes = this._mainModes.filter(m => m != mode);
     },
 
     dumpStack: function dumpStack() {
@@ -254,11 +254,11 @@ var Modes = Module("modes", {
 
     getCharModes: function getCharModes(chr) (this.modeChars[chr] || []).slice(),
 
-    have: function have(mode) this._modeStack.some(function (m) isinstance(m.main, mode)),
+    have: function have(mode) this._modeStack.some(m => isinstance(m.main, mode)),
 
     matchModes: function matchModes(obj)
-        this._modes.filter(function (mode) Object.keys(obj)
-                                                 .every(function (k) obj[k] == (mode[k] || false))),
+        this._modes.filter(mode => Object.keys(obj)
+                                         .every(k => obj[k] == (mode[k] || false))),
 
     // show the current mode string in the command line
     show: function show() {
@@ -274,10 +274,10 @@ var Modes = Module("modes", {
     remove: function remove(mode, covert) {
         if (covert && this.topOfStack.main != mode) {
             util.assert(mode != this.NORMAL);
-            for (let m; m = array.nth(this.modeStack, function (m) m.main == mode, 0);)
+            for (let m; m = array.nth(this.modeStack, m => m.main == mode, 0);)
                 this._modeStack.splice(this._modeStack.indexOf(m));
         }
-        else if (this.stack.some(function (m) m.main == mode)) {
+        else if (this.stack.some(m => m.main == mode)) {
             this.pop(mode);
             this.pop();
         }
@@ -361,7 +361,9 @@ var Modes = Module("modes", {
                               push ? { push: push } : stack || {},
                               prev);
 
-        delayed.forEach(function ([fn, self]) dactyl.trapErrors(fn, self));
+        delayed.forEach(([fn, self]) => {
+            dactyl.trapErrors(fn, self);
+        });
 
         dactyl.triggerObserver("modes.change", [oldMain, oldExtended], [this._main, this._extended], stack);
         this.show();
@@ -425,8 +427,8 @@ var Modes = Module("modes", {
     Mode: Class("Mode", {
         init: function init(name, options, params) {
             if (options.bases)
-                util.assert(options.bases.every(function (m) m instanceof this, this.constructor),
-                           _("mode.invalidBases"), false);
+                util.assert(options.bases.every(m => m instanceof this.constructor),
+                            _("mode.invalidBases"), false);
 
             this.update({
                 id: 1 << Modes.Mode._id++,
@@ -465,11 +467,11 @@ var Modes = Module("modes", {
 
         hidden: false,
 
-        input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(function (b) b.input)),
+        input: Class.Memoize(function input() this.insert || this.bases.length && this.bases.some(b => b.input)),
 
-        insert: Class.Memoize(function insert() this.bases.length && this.bases.some(function (b) b.insert)),
+        insert: Class.Memoize(function insert() this.bases.length && this.bases.some(b => b.insert)),
 
-        ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(function (b) b.ownsFocus)),
+        ownsFocus: Class.Memoize(function ownsFocus() this.bases.length && this.bases.some(b => b.ownsFocus)),
 
         passEvent: function passEvent(event) this.input && event.charCode && !(event.ctrlKey || event.altKey || event.metaKey),
 
@@ -491,19 +493,19 @@ var Modes = Module("modes", {
         update(StackElement.prototype, {
             get toStringParams() !loaded.modes ? this.main.name : [
                 this.main.name,
-                ["(", modes.all.filter(function (m) this.extended & m, this)
-                           .map(function (m) m.name).join("|"),
+                ["(", modes.all.filter(m => this.extended & m)
+                               .map(m => m.name)
+                               .join("|"),
                  ")"].join("")
             ]
         });
         return StackElement;
     })(),
     cacheId: 0,
-    boundProperty: function BoundProperty(desc) {
+    boundProperty: function BoundProperty(desc = {}) {
         let id = this.cacheId++;
         let value;
 
-        desc = desc || {};
         return Class.Property(update({
             configurable: true,
             enumerable: true,
@@ -525,7 +527,7 @@ var Modes = Module("modes", {
 }, {
     cache: function initCache() {
         function makeTree() {
-            let list = modes.all.filter(function (m) m.name !== m.description);
+            let list = modes.all.filter(m => m.name !== m.description);
 
             let tree = {};
 
@@ -558,7 +560,7 @@ var Modes = Module("modes", {
             return rec(roots);
         }
 
-        cache.register("modes.dtd", function ()
+        cache.register("modes.dtd", () =>
             util.makeDTD(iter({ "modes.tree": makeTree() },
                               config.dtd)));
     },
@@ -599,7 +601,7 @@ var Modes = Module("modes", {
 
             getKey: function getKey(val, default_) {
                 if (isArray(val))
-                    return (array.nth(this.value, function (v) val.some(function (m) m.name === v.mode), 0)
+                    return (array.nth(this.value, v => val.some(m => m.name === v.mode), 0)
                                 || { result: default_ }).result;
 
                 return Set.has(this.valueMap, val) ? this.valueMap[val] : default_;
@@ -608,16 +610,19 @@ var Modes = Module("modes", {
             setter: function (vals) {
                 modes.all.forEach(function (m) { delete m.passUnknown; });
 
-                vals = vals.map(function (v) update(new String(v.toLowerCase()), {
-                    mode: v.replace(/^!/, "").toUpperCase(),
-                    result: v[0] !== "!"
-                }));
+                vals = vals.map(v => update(new String(v.toLowerCase()),
+                                            {
+                                                mode: v.replace(/^!/, "").toUpperCase(),
+                                                result: v[0] !== "!"
+                                            }));
 
-                this.valueMap = values(vals).map(function (v) [v.mode, v.result]).toObject();
+                this.valueMap = values(vals).map(v => [v.mode, v.result])
+                                            .toObject();
                 return vals;
             },
 
-            validator: function validator(vals) vals.map(function (v) v.replace(/^!/, "")).every(Set.has(this.values)),
+            validator: function validator(vals) vals.map(v => v.replace(/^!/, ""))
+                                                    .every(Set.has(this.values)),
 
             get values() array.toObject([[m.name.toLowerCase(), m.description] for (m in values(modes._modes)) if (!m.hidden)])
         };
index 6ef53f8fb54e278b3b3cbf652575102b63bedc45..7149f9cba230ad1a01c1c3ae8a1d91e193b985e0 100644 (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.
@@ -149,7 +149,7 @@ var MOW = Module("mow", {
 
     events: {
         click: function onClick(event) {
-            if (event.getPreventDefault())
+            if (event.defaultPrevented)
                 return;
 
             const openLink = function openLink(where) {
@@ -199,7 +199,7 @@ var MOW = Module("mow", {
 
             for (let node in array.iterValues(menu.children)) {
                 let group = node.getAttributeNS(NS, "group");
-                node.hidden = group && !group.split(/\s+/).every(function (g) enabled[g]);
+                node.hidden = group && !group.split(/\s+/).every(g => enabled[g]);
             }
         }
     },
@@ -346,36 +346,36 @@ var MOW = Module("mow", {
 
         bind(["j", "<C-e>", "<Down>"], "Scroll down one line",
              function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); },
-             function () mow.canScroll(1), BEEP);
+             () => mow.canScroll(1), BEEP);
 
         bind(["k", "<C-y>", "<Up>"], "Scroll up one line",
              function ({ count }) { mow.scrollVertical("lines", -1 * (count || 1)); },
-             function () mow.canScroll(-1), BEEP);
+             () => mow.canScroll(-1), BEEP);
 
         bind(["<C-j>", "<C-m>", "<Return>"], "Scroll down one line, exit on last line",
              function ({ count }) { mow.scrollVertical("lines", 1 * (count || 1)); },
-             function () mow.canScroll(1), DROP);
+             () => mow.canScroll(1), DROP);
 
         // half page down
         bind(["<C-d>"], "Scroll down half a page",
              function ({ count }) { mow.scrollVertical("pages", .5 * (count || 1)); },
-             function () mow.canScroll(1), BEEP);
+             () => mow.canScroll(1), BEEP);
 
         bind(["<C-f>", "<PageDown>"], "Scroll down one page",
              function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); },
-             function () mow.canScroll(1), BEEP);
+             () => mow.canScroll(1), BEEP);
 
         bind(["<Space>"], "Scroll down one page",
              function ({ count }) { mow.scrollVertical("pages", 1 * (count || 1)); },
-             function () mow.canScroll(1), DROP);
+             () => mow.canScroll(1), DROP);
 
         bind(["<C-u>"], "Scroll up half a page",
              function ({ count }) { mow.scrollVertical("pages", -.5 * (count || 1)); },
-             function () mow.canScroll(-1), BEEP);
+             () => mow.canScroll(-1), BEEP);
 
         bind(["<C-b>", "<PageUp>"], "Scroll up half a page",
              function ({ count }) { mow.scrollVertical("pages", -1 * (count || 1)); },
-             function () mow.canScroll(-1), BEEP);
+             () => mow.canScroll(-1), BEEP);
 
         bind(["gg"], "Scroll to the beginning of output",
              function () { mow.scrollToPercent(null, 0); });
@@ -390,7 +390,7 @@ var MOW = Module("mow", {
         // close the window
         bind(["q"], "Close the output window",
              function () {},
-             function () false, DROP);
+             () => false, DROP);
     },
     options: function initOptions() {
         options.add(["more"],
index f2c10399e4782a6bd2c9ce7117701ec885fe48b0..0fc4dc3de275b9678e4be1d94299cdcbca7d3c23 100644 (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.
@@ -40,7 +40,7 @@ var QuickMarks = Module("quickmarks", {
     find: function find(url) {
         let res = [];
         for (let [k, v] in this._qmarks)
-            if (dactyl.parseURLs(v).some(function (u) String.replace(u, /#.*/, "") == url))
+            if (dactyl.parseURLs(v).some(u => String.replace(u, /#.*/, "") == url))
                 res.push(k);
         return res;
     },
@@ -109,7 +109,7 @@ var QuickMarks = Module("quickmarks", {
 
         if (filter.length > 0) {
             let pattern = util.charListToRegexp(filter, "a-zA-Z0-9");
-            marks = marks.filter(function (qmark) pattern.test(qmark));
+            marks = marks.filter(qmark => pattern.test(qmark));
             dactyl.assert(marks.length >= 0, _("quickmark.noMatching", filter.quote()));
         }
 
@@ -158,7 +158,7 @@ var QuickMarks = Module("quickmarks", {
                             context.title = ["Extra Completions"];
                             context.completions = [
                                 [quickmarks.get(args[0]), _("option.currentValue")]
-                            ].filter(function ([k, v]) k);
+                            ].filter(([k, v]) => k);
                         });
                         context.fork("url", 0, completion, "url");
                     }
@@ -178,7 +178,7 @@ var QuickMarks = Module("quickmarks", {
     completion: function initCompletion() {
         completion.quickmark = function (context) {
             context.title = ["QuickMark", "URL"];
-            context.generate = function () Iterator(quickmarks._qmarks);
+            context.generate = () => Iterator(quickmarks._qmarks);
         };
     },
     mappings: function initMappings() {
index 4cf50c47813e4a8b119dcfa837eabe5cc4c82941..7b0cd48d59b65da6d38df8b1de4d8e08f1198f96 100644 (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.
@@ -14,6 +14,9 @@ var StatusLine = Module("statusline", {
         this.statusBar = document.getElementById("addon-bar") || this._statusLine;
         this.baseGroup = this.statusBar == this._statusLine ? "StatusLine " : "";
 
+        if (config.haveGecko("25"))
+            config.tabbrowser.getStatusPanel().hidden = true;
+
         if (this.statusBar.localName == "toolbar") {
             styles.system.add("addon-bar", config.styleableChrome, literal(/*
                 #status-bar { margin-top: 0 !important; }
@@ -245,7 +248,7 @@ var StatusLine = Module("statusline", {
                 url = _("buffer.noName");
         }
         else {
-            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), function (m, n1, n2) n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help"))
+            url = url.replace(RegExp("^dactyl://help/(\\S+)#(.*)"), (m, n1, n2) => n1 + " " + decodeURIComponent(n2) + " " + _("buffer.help"))
                      .replace(RegExp("^dactyl://help/(\\S+)"), "$1 " + _("buffer.help"));
         }
 
@@ -330,7 +333,7 @@ var StatusLine = Module("statusline", {
     updateTabCount: function updateTabCount(delayed) {
         if (dactyl.has("tabs")) {
             if (delayed) {
-                this.timeout(function () this.updateTabCount(false), 0);
+                this.timeout(() => { this.updateTabCount(false); }, 0);
                 return;
             }
 
@@ -377,10 +380,7 @@ var StatusLine = Module("statusline", {
      * @param {number} percent The zoom level, as a percentage. @optional
      * @param {boolean} full True if full zoom is in operation. @optional
      */
-    updateZoomLevel: function updateZoomLevel(percent, full) {
-        if (arguments.length == 0)
-            [percent, full] = [buffer.zoomLevel, buffer.fullZoom];
-
+    updateZoomLevel: function updateZoomLevel(percent=buffer.zoomLevel, full=buffer.fullZoom) {
         if (percent == 100)
             this.widgets.zoomlevel.value = "";
         else {
index 016355fa9630d8fa0980498c6f36bccd337b0f84..a7f038e3603b6c4004ed26b3d22aeabb2fa37f05 100644 (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 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.
@@ -37,7 +37,7 @@ var Tabs = Module("tabs", {
 
         this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", literal(/*
                 xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; }
-            */).replace(/tab-./g, function (m) config.OS.isMacOSX ? "tab-mac" : m),
+            */).replace(/tab-./g, m => config.OS.isMacOSX ? "tab-mac" : m),
             false, true);
 
         this.timeout(function () {
@@ -57,7 +57,7 @@ var Tabs = Module("tabs", {
         }
     },
 
-    _alternates: Class.Memoize(function () [config.tabbrowser.mCurrentTab, null]),
+    _alternates: Class.Memoize(() => [config.tabbrowser.mCurrentTab, null]),
 
     cleanup: function cleanup() {
         for (let [i, tab] in Iterator(this.allTabs)) {
@@ -139,7 +139,7 @@ var Tabs = Module("tabs", {
      */
     get options() this.localStore.options,
 
-    get visibleTabs() config.tabbrowser.visibleTabs || this.allTabs.filter(function (tab) !tab.hidden),
+    get visibleTabs() config.tabbrowser.visibleTabs || this.allTabs.filter(tab => !tab.hidden),
 
     /**
      * Returns the local state store for the tab at the specified *tabIndex*.
@@ -244,7 +244,7 @@ var Tabs = Module("tabs", {
 
         this._groups = iframe ? iframe.contentWindow : null;
         if (this._groups && !func)
-            util.waitFor(function () this._groups.TabItems, this);
+            util.waitFor(() => this._groups.TabItems);
         return this._groups;
     },
 
@@ -408,8 +408,7 @@ var Tabs = Module("tabs", {
      * @param {number} count How many tabs to remove.
      * @param {boolean} focusLeftTab Focus the tab to the left of the removed tab.
      */
-    remove: function remove(tab, count, focusLeftTab) {
-        count = count || 1;
+    remove: function remove(tab, count = 1, focusLeftTab = false) {
         let res = this.count > count;
 
         let tabs = this.visibleTabs;
@@ -426,9 +425,13 @@ var Tabs = Module("tabs", {
         }
 
         if (focusLeftTab)
-            tabs.slice(Math.max(0, index + 1 - count), index + 1).forEach(config.closure.removeTab);
+            tabs.slice(Math.max(0, index + 1 - count),
+                       index + 1)
+                .forEach(config.closure.removeTab);
         else
-            tabs.slice(index, index + count).forEach(config.closure.removeTab);
+            tabs.slice(index,
+                       index + count)
+                .forEach(config.closure.removeTab);
         return res;
     },
 
@@ -548,11 +551,11 @@ var Tabs = Module("tabs", {
         if (matches)
             return tabs.select(this.allTabs[parseInt(matches[1], 10) - 1], false);
 
-        matches = array.nth(tabs.allTabs, function (t) (t.linkedBrowser.lastURI || {}).spec === buffer, 0);
+        matches = array.nth(tabs.allTabs, t => (t.linkedBrowser.lastURI || {}).spec === buffer, 0);
         if (matches)
             return tabs.select(matches, false);
 
-        matches = completion.runCompleter("buffer", buffer).map(function (obj) obj.tab);
+        matches = completion.runCompleter("buffer", buffer).map(obj => obj.tab);
 
         if (matches.length == 0)
             dactyl.echoerr(_("buffer.noMatching", buffer));
@@ -650,7 +653,7 @@ var Tabs = Module("tabs", {
                 count: true,
                 completer: function (context, args) {
                     if (!args.bang)
-                        context.filters.push(function ({ item }) !item.tab.pinned);
+                        context.filters.push(({ item }) => !item.tab.pinned);
                     completion.buffer(context);
                 }
             });
@@ -665,7 +668,7 @@ var Tabs = Module("tabs", {
                 argCount: "?",
                 count: true,
                 completer: function (context, args) {
-                    context.filters.push(function ({ item }) item.tab.pinned);
+                    context.filters.push(({ item }) => item.tab.pinned);
                     completion.buffer(context);
                 }
             });
@@ -730,7 +733,7 @@ var Tabs = Module("tabs", {
 
         commands.add(["tabl[ast]", "bl[ast]"],
             "Switch to the last tab",
-            function () tabs.select("$", false),
+            function () { tabs.select("$", false); },
             { argCount: "0" });
 
         // TODO: "Zero count" if 0 specified as arg
@@ -794,7 +797,12 @@ var Tabs = Module("tabs", {
         if (config.has("tabbrowser")) {
             commands.add(["b[uffer]"],
                 "Switch to a buffer",
-                function (args) { tabs.switchTo(args[0], args.bang, args.count); }, {
+                function (args) {
+                    if (args.length)
+                        tabs.switchTo(args[0], args.bang, args.count);
+                    else if (args.count)
+                        tabs.switchTo(String(args.count));
+                }, {
                     argCount: "?",
                     bang: true,
                     count: true,
@@ -893,10 +901,10 @@ var Tabs = Module("tabs", {
             commands.add(["taba[ttach]"],
                 "Attach the current tab to another window",
                 function (args) {
-                    dactyl.assert(args.length <= 2 && !args.some(function (i) !/^\d+(?:$|:)/.test(i)),
+                    dactyl.assert(args.length <= 2 && !args.some(i => !/^\d+(?:$|:)/.test(i)),
                                   _("error.trailingCharacters"));
 
-                    let [winIndex, tabIndex] = args.map(function (arg) parseInt(arg));
+                    let [winIndex, tabIndex] = args.map(arg => parseInt(arg));
                     if (args["-group"]) {
                         util.assert(args.length == 1);
                         window.TabView.moveTabTo(tabs.getTab(), winIndex);
@@ -912,12 +920,6 @@ var Tabs = Module("tabs", {
                     let modules     = win.dactyl.modules;
                     let { browser } = modules.config;
 
-                    if (args[1]) {
-                        let tabList = modules.tabs.visibleTabs;
-                        let target  = dactyl.assert(tabList[tabIndex]);
-                        tabIndex = Array.indexOf(tabs.allTabs, target) - 1;
-                    }
-
                     let newTab = browser.addTab("about:blank");
                     browser.stop();
                     // XXX: the implementation of DnD in tabbrowser.xml suggests
@@ -925,10 +927,13 @@ var Tabs = Module("tabs", {
                     // without this reference?
                     browser.docShell;
 
-                    let last = modules.tabs.allTabs.length - 1;
+                    if (args[1]) {
+                        let { visibleTabs, allTabs } = modules.tabs;
+                        tabIndex = Math.constrain(tabIndex, 1, visibleTabs.length);
+                        let target = visibleTabs[tabIndex - 1];
+                        browser.moveTabTo(newTab, Array.indexOf(allTabs, target));
+                    }
 
-                    if (args[1])
-                        browser.moveTabTo(newTab, tabIndex);
                     browser.selectedTab = newTab; // required
                     browser.swapBrowsersAndCloseOther(newTab, sourceTab);
                 }, {
@@ -940,7 +945,7 @@ var Tabs = Module("tabs", {
                             if (args["-group"])
                                 completion.tabGroup(context);
                             else {
-                                context.filters.push(function ({ item }) item != window);
+                                context.filters.push(({ item }) => item != window);
                                 completion.window(context);
                             }
                             break;
@@ -992,7 +997,9 @@ var Tabs = Module("tabs", {
                         context.anchored = false;
                         context.compare = CompletionContext.Sort.unsorted;
                         context.filters = [CompletionContext.Filter.textDescription];
-                        context.keys = { text: function ([i, { state: s }]) (i + 1) + ": " + s.entries[s.index - 1].url, description: "[1].title", icon: "[1].image" };
+                        context.keys = { text: function ([i, { state: s }]) (i + 1) + ": " + s.entries[s.index - 1].url,
+                                         description: "[1].title",
+                                         icon: "[1].image" };
                         context.completions = Iterator(tabs.closedTabs);
                     },
                     count: true,
@@ -1061,7 +1068,7 @@ var Tabs = Module("tabs", {
             for (let [id, vals] in Iterator(tabGroups))
                 context.fork(id, 0, this, function (context, [name, browsers]) {
                     context.title = [name || "Buffers"];
-                    context.generate = function ()
+                    context.generate = () =>
                         Array.map(browsers, function ([i, browser]) {
                             let indicator = " ";
                             if (i == tabs.index())
@@ -1089,7 +1096,7 @@ var Tabs = Module("tabs", {
             context.keys = {
                 text: "id",
                 description: function (group) group.getTitle() ||
-                    group.getChildren().map(function (t) t.tab.label).join(", ")
+                    group.getChildren().map(t => t.tab.label).join(", ")
             };
             context.generate = function () {
                 context.incomplete = true;
@@ -1166,12 +1173,12 @@ var Tabs = Module("tabs", {
 
             mappings.add([modes.NORMAL], ["d"],
                 "Delete current buffer",
-                function ({ count }) { tabs.remove(tabs.getTab(), count, false); },
+                function ({ count }) { tabs.remove(tabs.getTab(), count || 1, false); },
                 { count: true });
 
             mappings.add([modes.NORMAL], ["D"],
                 "Delete current buffer, focus tab to the left",
-                function ({ count }) { tabs.remove(tabs.getTab(), count, true); },
+                function ({ count }) { tabs.remove(tabs.getTab(), count || 1, true); },
                 { count: true });
 
             mappings.add([modes.NORMAL], ["gb"],
index af586ab20638fe2757834f1b8282b02919ca1367..eed009c12da3a513b4e2954a9f63144e97bfbcbf 100644 (file)
         </p>
 
         <p>
-            The order is important, such that <se opt="complete"><str delim="">bsf</str></se> will
-            list bookmarks followed by matching quick searches and then
-            matching files.
+            The order is important, such that <se opt="complete">
+            <str delim="">bookmark,search,file</str></se> will list bookmarks
+            followed by matching quick searches and then matching files.
         </p>
 
         <note>
     <description>
         <p>Change the hint matching algorithm used in Hints mode.</p>
 
-        <p>Possible values:</p>
+        <p>Possible values are one of:</p>
 
         <dl>
             <dt>contains</dt>
                 Delegate to the function
                 <tt>dactyl.plugins.customHintMatcher</tt>.
             </dd>
+        </dl>
+        <p>and optionally:</p>
+        <dl>
             <dt>transliterated</dt>
             <dd>
                 Certain alphanumeric characters are transliterated into their
index f977e0cb24a6453aee2a2b7e650c41addfb0da08..3aaaa4d9e194d585b41016cf51ed1240529d49dd 100644 (file)
         <p>
             In addition to its own JavaScript context, each script is executed
             with its own default <link topic="groups">group</link> into which
-            its styles, mappings, commands, and autocommands are placed. This
-            means that commands such as <ex>:delcommand!</ex> can be issued
-            without fear of trampling other user-defined mappings. The command
-            <ex>:group! default</ex> can be issued to clear all such items at
-            once, and should be placed at the head of most scripts to prevent
-            the accumulation of stale items when the script is re-sourced.
+            its styles, mappings, commands, abbreviations and autocommands are
+            placed. This means that commands such as <ex>:delcommand!</ex> can
+            be issued without fear of trampling other user-defined mappings.
+            The command <ex>:group! default</ex> can be issued to clear all
+            such items at once, and should be placed at the head of most
+            scripts to prevent the accumulation of stale items when the script
+            is re-sourced.
         </p>
 
         <h3 tag=":source-css">Cascading Stylesheets</h3>
index f4379266061982ab031b558c5a2bd2f83443031f..35d32595373d8a1c9e2ae9f0e4a13136167da812 100644 (file)
         <p>
             If argument is neither a full URL nor an index but uniquely identifies a
             buffer, by a partial match with the URL or title, it is selected.
-            With <oa>!</oa> the next buffer matching the argument is selected,
-            even if it cannot be identified uniquely. Use <k>b</k> as a
-            shortcut to open this prompt.
+            With <oa>!</oa> the next, or <oa>count</oa>th, buffer matching the
+            argument is selected, even if it cannot be identified uniquely. Use
+            <k>b</k> as a shortcut to open this prompt.
         </p>
 
         <p>If argument is <em>#</em>, the alternate buffer will be selected (see <k name="C-^"/>).</p>
index e2c577ad9f704a611207314cf97ffd40881e112b..fb1e59616a57e86d8bca74d159e32dfd852512b2 100644 (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
@@ -53,7 +53,7 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
 
         this.remaining = addons;
         this.upgrade = [];
-        this.dactyl.echomsg(_("addon.check", addons.map(function (a) a.name).join(", ")));
+        this.dactyl.echomsg(_("addon.check", addons.map(a => a.name).join(", ")));
         for (let addon in values(addons))
             addon.findUpdates(this, AddonManager.UPDATE_WHEN_USER_REQUESTED, null, null);
 
@@ -64,11 +64,11 @@ var updateAddons = Class("UpgradeListener", AddonListener, {
         install.install();
     },
     onUpdateFinished: function (addon, error) {
-        this.remaining = this.remaining.filter(function (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
-                    ? _("addon.installingUpdates", this.upgrade.map(function (i) i.name).join(", "))
+                    ? _("addon.installingUpdates", this.upgrade.map(i => i.name).join(", "))
                     : _("addon.noUpdates"));
     }
 });
@@ -118,8 +118,10 @@ var actions = {
             });
         },
         get filter() {
-            return function (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"
     },
@@ -302,7 +304,7 @@ var AddonList = Class("AddonList", {
             addon = Addon(addon, this);
             this.addons[addon.id] = addon;
 
-            let index = values(this.addons).sort(function (a, b) a.compare(b))
+            let index = values(this.addons).sort((a, b) => a.compare(b))
                                            .indexOf(addon);
 
             this.nodes.list.insertBefore(addon.nodes.row,
@@ -343,10 +345,10 @@ var AddonList = Class("AddonList", {
 });
 
 var Addons = Module("addons", {
-    errors: Class.Memoize(function ()
+    errors: Class.Memoize(() =>
             array(["ERROR_NETWORK_FAILURE", "ERROR_INCORRECT_HASH",
                    "ERROR_CORRUPT_FILE", "ERROR_FILE_ACCESS"])
-                .map(function (e) [AddonManager[e], _("AddonManager." + e)])
+                .map(e => [AddonManager[e], _("AddonManager." + e)])
                 .toObject())
 }, {
 }, {
@@ -360,7 +362,7 @@ var Addons = Module("addons", {
                 modules.commandline.echo(addons);
 
                 if (modules.commandline.savingOutput)
-                    util.waitFor(function () addons.ready);
+                    util.waitFor(() => addons.ready);
             },
             {
                 argCount: "?",
@@ -398,7 +400,7 @@ var Addons = Module("addons", {
             }, {
                 argCount: "1",
                 completer: function (context) {
-                    context.filters.push(function ({ isdir, text }) isdir || /\.xpi$/.test(text));
+                    context.filters.push(({ isdir, text }) => isdir || /\.xpi$/.test(text));
                     completion.file(context);
                 },
                 literal: 0
@@ -420,7 +422,7 @@ var Addons = Module("addons", {
 
                     AddonManager.getAddonsByTypes(args["-types"], dactyl.wrapCallback(function (list) {
                         if (!args.bang || command.bang) {
-                            list = list.filter(function (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,14 +431,14 @@ var Addons = Module("addons", {
                         if (command.actions)
                             command.actions(list, this.modules);
                         else
-                            list.forEach(function (addon) command.action.call(this.modules, addon, args.bang), this);
+                            list.forEach(addon => { command.action.call(this.modules, addon, args.bang) });
                     }));
                 }, {
                     argCount: "?", // FIXME: should be "1"
                     bang: true,
                     completer: function (context, args) {
                         completion.addon(context, args["-types"]);
-                        context.filters.push(function ({ item }) ok(item));
+                        context.filters.push(({ item }) => ok(item));
                     },
                     literal: 0,
                     options: [
@@ -455,7 +457,7 @@ var Addons = Module("addons", {
         completion.addonType = function addonType(context) {
             let base = ["extension", "theme"];
             function update(types) {
-                context.completions = types.map(function (t) [t, util.capitalize(t)]);
+                context.completions = types.map(t => [t, util.capitalize(t)]);
             }
 
             context.generate = function generate() {
@@ -464,7 +466,7 @@ var Addons = Module("addons", {
                     context.incomplete = true;
                     AddonManager.getAllAddons(function (addons) {
                         context.incomplete = false;
-                        update(array.uniq(base.concat(addons.map(function (a) a.type)),
+                        update(array.uniq(base.concat(addons.map(a => a.type)),
                                           true));
                     });
                 }
@@ -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"
             };
index a9318eb414119a78cb118446827cf1f377a93379..e0f0eaad1bff85036755b1c98f512ce5bc81e733 100644 (file)
@@ -20,13 +20,13 @@ let { __lookupGetter__, __lookupSetter__, __defineGetter__, __defineSetter__,
 if (typeof XPCSafeJSObjectWrapper === "undefined")
     this.XPCSafeJSObjectWrapper = XPCNativeWrapper;
 
-let getGlobalForObject = Cu.getGlobalForObject || function (obj) obj.__parent__;
+let getGlobalForObject = Cu.getGlobalForObject || (obj => obj.__parent__);
 
 function require(module, target) JSMLoader.load(module, target);
 
 function lazyRequire(module, names, target) {
     for each (let name in names)
-        memoize(target || this, name, function (name) require(module)[name]);
+        memoize(target || this, name, name => require(module)[name]);
 }
 
 let jsmodules = { lazyRequire: lazyRequire };
@@ -167,7 +167,7 @@ function literal(/* comment */) {
     // Later...
     return cache.get(key, function () {
         let source = cache.get("literal:" + file,
-                               function () util.httpGet(file).responseText);
+                               () => util.httpGet(file).responseText);
 
         let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" +
                            ".*literal\\(/\\*([^]*?)\\*/\\)").exec(source);
@@ -271,7 +271,7 @@ function iterOwnProperties(obj) {
 
 function deprecated(alternative, fn) {
     if (isObject(fn))
-        return Class.Property(iter(fn).map(function ([k, v]) [k, callable(v) ? deprecated(alternative, v) : v])
+        return Class.Property(iter(fn).map(([k, v]) => [k, callable(v) ? deprecated(alternative, v) : v])
                                       .toObject());
 
     let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
@@ -441,7 +441,7 @@ function curry(fn, length, self, acc) {
         return fn;
 
     // Close over function with 'this'
-    function close(self, fn) function () fn.apply(self, arguments);
+    function close(self, fn) (...args) => fn.apply(self, args);
 
     if (acc == null)
         acc = [];
@@ -858,7 +858,7 @@ Class.Memoize = function Memoize(getter, wait)
                     Object.defineProperty(obj, key,  {
                         configurable: true, enumerable: false,
                         get: function get() {
-                            util.waitFor(function () done);
+                            util.waitFor(() => done);
                             return this[key];
                         }
                     });
@@ -924,19 +924,19 @@ Class.prototype = {
     set instance(val) Class.replaceProperty(this, "instance", val),
 
     withSavedValues: function withSavedValues(names, callback, self) {
-        let vals = names.map(function (name) this[name], this);
+        let vals = names.map(name => this[name]);
         try {
             return callback.call(self || this);
         }
         finally {
-            names.forEach(function (name, i) this[name] = vals[i], this);
+            names.forEach((name, i) => { this[name] = vals[i]; });
         }
     },
 
     toString: function C_toString() {
         if (this.toStringParams)
-            var params = "(" + this.toStringParams.map(function (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 || "") + "]";
     },
@@ -1079,7 +1079,7 @@ function XPCOMShim(interfaces) {
         getHelperForLanguage: function () null,
         getInterfaces: function (count) { count.value = 0; }
     });
-    return (interfaces || []).reduce(function (shim, iface) shim.QueryInterface(Ci[iface]),
+    return (interfaces || []).reduce((shim, iface) => shim.QueryInterface(Ci[iface]),
                                      ip.data);
 };
 let stub = Class.Property({
@@ -1094,8 +1094,7 @@ let stub = Class.Property({
  */
 var ErrorBase = Class("ErrorBase", Error, {
     level: 2,
-    init: function EB_init(message, level) {
-        level = level || 0;
+    init: function EB_init(message, level = 0) {
         let error = Error(message);
         update(this, error);
         this.stack = error.stack;
@@ -1172,7 +1171,7 @@ Module.INIT = {
             module.isLocalModule = true;
 
             modules.jsmodules[this.constructor.className] = module;
-            locals.reverse().forEach(function (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;
@@ -1205,7 +1204,7 @@ function Struct(...args) {
 
     const Struct = Class(className || "Struct", StructBase, {
         length: args.length,
-        members: array.toObject(args.map(function (v, k) [v, k]))
+        members: array.toObject(args.map((v, k) => [v, k]))
     });
     args.forEach(function (name, i) {
         Struct.prototype.__defineGetter__(name, function () this[i]);
@@ -1269,10 +1268,10 @@ var StructBase = Class("StructBase", Array, {
 });
 
 var Timer = Class("Timer", {
-    init: function init(minInterval, maxInterval, callback, self) {
+    init: function init(minInterval, maxInterval, callback, self = this) {
         this._timer = services.Timer();
         this.callback = callback;
-        this.self = self || this;
+        this.self = self;
         this.minInterval = minInterval;
         this.maxInterval = maxInterval;
         this.doneAt = 0;
@@ -1384,7 +1383,7 @@ function octal(decimal) parseInt(decimal, 8);
  */
 function iter(obj, iface) {
     if (arguments.length == 2 && iface instanceof Ci.nsIJSIID)
-        return iter(obj).map(function (item) item.QueryInterface(iface));
+        return iter(obj).map(item => item.QueryInterface(iface));
 
     let args = arguments;
     let res = Iterator(obj);
@@ -1521,7 +1520,7 @@ update(iter, {
      */
     nth: function nth(iter, pred, n, self) {
         if (typeof pred === "number")
-            [pred, n] = [function () true, pred]; // Hack.
+            [pred, n] = [() => true, pred]; // Hack.
 
         for (let elem in iter)
             if (pred.call(self, elem) && n-- === 0)
@@ -1629,7 +1628,7 @@ var array = Class("array", Array, {
      * @param {Array} ary
      * @returns {Array}
      */
-    compact: function compact(ary) ary.filter(function (item) item != null),
+    compact: function compact(ary) ary.filter(item => item != null),
 
     /**
      * Returns true if each element of ary1 is equal to the
@@ -1640,7 +1639,7 @@ var array = Class("array", Array, {
      * @returns {boolean}
      */
     equals: function (ary1, ary2)
-        ary1.length === ary2.length && Array.every(ary1, function (e, i) e === ary2[i]),
+        ary1.length === ary2.length && Array.every(ary1, (e, i) => e === ary2[i]),
 
     /**
      * Flattens an array, such that all elements of the array are
index be55f9816cbc28955f3c802e8a2ae9146c6f0943..031618941e915c2e2d6121f7cad5344085be185a 100644 (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.
@@ -27,7 +27,7 @@ update(Bookmark.prototype, {
     get extra() [
         ["keyword", this.keyword,         "Keyword"],
         ["tags",    this.tags.join(", "), "Tag"]
-    ].filter(function (item) item[1]),
+    ].filter(item => item[1]),
 
     get uri() newURI(this.url),
     set uri(uri) {
@@ -90,7 +90,7 @@ var BookmarkCache = Module("BookmarkCache", XPCOM(Ci.nsINavBookmarkObserver), {
     keywords: Class.Memoize(function () array.toObject([[b.keyword, b] for (b in this) if (b.keyword)])),
 
     rootFolders: ["toolbarFolder", "bookmarksMenuFolder", "unfiledBookmarksFolder"]
-        .map(function (s) services.bookmarks[s]),
+        .map(s => services.bookmarks[s]),
 
     _deleteBookmark: function deleteBookmark(id) {
         let result = this.bookmarks[id] || null;
index 15aea79b1257040fefb5bdc2b55f2e5e60b02b72..97b37b25787e0e88a1ba67e5efcb81b06c02d615 100644 (file)
@@ -61,10 +61,10 @@ var Buffer = Module("Buffer", {
      */
     get alternateStyleSheets() {
         let stylesheets = array.flatten(
-            this.allFrames().map(function (w) Array.slice(w.document.styleSheets)));
+            this.allFrames().map(w => Array.slice(w.document.styleSheets)));
 
         return stylesheets.filter(
-            function (stylesheet) /^(screen|all|)$/i.test(stylesheet.media.mediaText) && !/^\s*$/.test(stylesheet.title)
+            s => /^(screen|all|)$/i.test(s.media.mediaText) && !/^\s*$/.test(s.title)
         );
     },
 
@@ -142,8 +142,8 @@ var Buffer = Module("Buffer", {
      */
     get loaded() Math.min.apply(null,
         this.allFrames()
-            .map(function (frame) ["loading", "interactive", "complete"]
-                                      .indexOf(frame.document.readyState))),
+            .map(frame => ["loading", "interactive", "complete"]
+                              .indexOf(frame.document.readyState))),
 
     /**
      * @property {Object} The local state store for the currently selected
@@ -275,8 +275,8 @@ var Buffer = Module("Buffer", {
         })(win || this.win);
 
         if (focusedFirst)
-            return frames.filter(function (f) f === this.focusedFrame, this).concat(
-                   frames.filter(function (f) f !== this.focusedFrame, this));
+            return frames.filter(f => f === this.focusedFrame).concat(
+                   frames.filter(f => f !== this.focusedFrame));
         return frames;
     },
 
@@ -435,7 +435,9 @@ var Buffer = Module("Buffer", {
                 yield elem;
 
             function a(regexp, elem) regexp.test(elem.textContent) === regexp.result ||
-                            Array.some(elem.childNodes, function (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);
@@ -541,7 +543,7 @@ var Buffer = Module("Buffer", {
         function getRanges(rect) {
             let nodes = win.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils)
                            .nodesFromRect(rect.x, rect.y, 0, rect.width, rect.height, 0, false, false);
-            return Array.filter(nodes, function (n) n instanceof Ci.nsIDOMText)
+            return Array.filter(nodes, n => n instanceof Ci.nsIDOMText)
                         .map(RangeFind.nodeContents);
         }
 
@@ -565,11 +567,11 @@ var Buffer = Module("Buffer", {
             rect = { x: w / 3, y: 0, width: w / 3, height: win.innerHeight };
         }
 
-        var reduce = function (a, b) DOM(a).rect.top < DOM(b).rect.top ? a : b;
+        var reduce = (a, b) => DOM(a).rect.top < DOM(b).rect.top ? a : b;
         var dir = "forward";
         var y = 0;
         if (reverse) {
-            reduce = function (a, b) DOM(b).rect.bottom > DOM(a).rect.bottom ? b : a;
+            reduce = (a, b) => DOM(b).rect.bottom > DOM(a).rect.bottom ? b : a;
             dir = "backward";
             y = win.innerHeight - 1;
         }
@@ -622,11 +624,20 @@ var Buffer = Module("Buffer", {
     get shortURL() {
         let { uri, doc } = this;
 
+        function hashify(url) {
+            let newURI = util.newURI(url);
+
+            if (uri.hasRef && !newURI.hasRef)
+                newURI.ref = uri.ref;
+
+            return newURI.spec;
+        }
+
         for each (let shortener in Buffer.uriShorteners)
             try {
                 let shortened = shortener(uri, doc);
                 if (shortened)
-                    return shortened.spec;
+                    return hashify(shortened.spec);
             }
             catch (e) {
                 util.reportError(e);
@@ -634,8 +645,8 @@ var Buffer = Module("Buffer", {
 
         let link = DOM("link[href][rev=canonical], \
                         link[href][rel=shortlink]", doc);
-        if (link)
-            return link.attr("href");
+        if (link.length)
+            return hashify(link.attr("href"));
 
         return null;
     },
@@ -782,11 +793,10 @@ var Buffer = Module("Buffer", {
      * @param {number} count The multiple of 'scroll' lines to scroll.
      * @optional
      */
-    scrollByScrollSize: function scrollByScrollSize(direction, count) {
+    scrollByScrollSize: function scrollByScrollSize(direction, count = 1) {
         let { options } = this.modules;
 
         direction = direction ? 1 : -1;
-        count = count || 1;
 
         if (options["scroll"] > 0)
             this.scrollVertical("lines", options["scroll"] * direction);
@@ -904,10 +914,13 @@ var Buffer = Module("Buffer", {
         let path = options["jumptags"][arg];
         util.assert(path, _("error.invalidArgument", arg));
 
-        let distance = reverse ? function (rect) -rect.top : function (rect) rect.top;
-        let elems = [[e, distance(e.getBoundingClientRect())] for (e in path.matcher(this.focusedFrame.document))]
-                        .filter(function (e) e[1] > FUDGE)
-                        .sort(function (a, b) a[1] - b[1]);
+        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]);
 
         if (offScreen && !reverse)
             elems = elems.filter(function (e) e[1] > this, this.topWindow.innerHeight);
@@ -941,8 +954,8 @@ var Buffer = Module("Buffer", {
             return;
 
         // remove all hidden frames
-        frames = frames.filter(function (frame) !(frame.document.body instanceof Ci.nsIDOMHTMLFrameSetElement))
-                       .filter(function (frame) !frame.frameElement ||
+        frames = frames.filter(frame => !(frame.document.body instanceof Ci.nsIDOMHTMLFrameSetElement))
+                       .filter(frame => !frame.frameElement ||
             let (rect = frame.frameElement.getBoundingClientRect())
                 rect.width && rect.height);
 
@@ -1003,7 +1016,7 @@ var Buffer = Module("Buffer", {
             let info = template.map(
                 (sections || options["pageinfo"])
                     .map((opt) => Buffer.pageInfo[opt].action.call(this)),
-                function (res) res && iter(res).join(", ") || undefined,
+                res => (res && iter(res).join(", ") || undefined),
                 ", ").join("");
 
             if (bookmarkcache.isBookmarked(this.URL))
@@ -1443,9 +1456,9 @@ var Buffer = Module("Buffer", {
         names.push([decodeURIComponent(url.replace(/.*?([^\/]*)\/*$/, "$1")),
                     _("buffer.save.filename")]);
 
-        return names.filter(function ([leaf, title]) leaf)
-                    .map(function ([leaf, title]) [leaf.replace(config.OS.illegalCharacters, encodeURIComponent)
-                                                       .replace(re, ext), title]);
+        return names.filter(([leaf, title]) => leaf)
+                    .map(([leaf, title]) => [leaf.replace(config.OS.illegalCharacters, encodeURIComponent)
+                                                 .replace(re, ext), title]);
     },
 
     findScrollableWindow: deprecated("buffer.findScrollableWindow", function findScrollableWindow()
@@ -1526,7 +1539,8 @@ var Buffer = Module("Buffer", {
      * Like scrollTo, but scrolls more smoothly and does not update
      * marks.
      */
-    smoothScrollTo: function smoothScrollTo(node, x, y) {
+    smoothScrollTo: let (timers = WeakMap())
+                    function smoothScrollTo(node, x, y) {
         let { options } = overlay.activeModules;
 
         let time = options["scrolltime"];
@@ -1534,8 +1548,8 @@ var Buffer = Module("Buffer", {
 
         let elem = Buffer.Scrollable(node);
 
-        if (node.dactylScrollTimer)
-            node.dactylScrollTimer.cancel();
+        if (timers.has(node))
+            timers.get(node).cancel();
 
         if (x == null)
             x = elem.scrollLeft;
@@ -1556,7 +1570,7 @@ var Buffer = Module("Buffer", {
             else {
                 elem.scrollLeft = startX + (x - startX) / steps * n;
                 elem.scrollTop  = startY + (y - startY) / steps * n;
-                node.dactylScrollTimer = util.timeout(next, time / steps);
+                timers.set(node, util.timeout(next, time / steps));
             }
         }).call(this);
     },
@@ -1751,8 +1765,10 @@ var Buffer = Module("Buffer", {
                     if (arg) {
                         prefs.set("print.print_printer", PRINTER);
 
+                        let { path } = io.File(arg.substr(1));
                         set("print_to_file", true);
-                        set("print_to_filename", io.File(arg.substr(1)).path);
+                        set("print_to_filename", path);
+                        prefs.set("print_to_filename", path);
 
                         dactyl.echomsg(_("print.toFile", arg.substr(1)));
                     }
@@ -1801,7 +1817,7 @@ var Buffer = Module("Buffer", {
             function (args) {
                 let arg = args[0] || "";
 
-                let titles = buffer.alternateStyleSheets.map(function (stylesheet) stylesheet.title);
+                let titles = buffer.alternateStyleSheets.map(sheet => sheet.title);
 
                 dactyl.assert(!arg || titles.indexOf(arg) >= 0,
                               _("error.invalidArgument", arg));
@@ -2206,7 +2222,7 @@ var Buffer = Module("Buffer", {
 
                     let frames = buffer.allFrames(null, true);
 
-                    let elements = array.flatten(frames.map(function (win) [m for (m in DOM.XPath(xpath, win.document))]))
+                    let elements = array.flatten(frames.map(win => [m for (m in DOM.XPath(xpath, win.document))]))
                                         .filter(function (elem) {
                         if (isinstance(elem, [Ci.nsIDOMHTMLFrameElement,
                                               Ci.nsIDOMHTMLIFrameElement]))
@@ -2388,7 +2404,7 @@ var Buffer = Module("Buffer", {
                     return vals;
                 },
                 validator: function (value) DOM.validateMatcher.call(this, value)
-                    && Object.keys(value).every(function (v) v.length == 1)
+                    && Object.keys(value).every(v => v.length == 1)
             });
 
         options.add(["linenumbers", "ln"],
@@ -2413,7 +2429,8 @@ var Buffer = Module("Buffer", {
                                 var res = dactyl.userEval("(" + Option.dequote(filter.result.substr(5)) + ")")(doc, line);
                             else
                                 res = iter.nth(filter.matcher(doc),
-                                               function (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)
@@ -2656,9 +2673,9 @@ Buffer.addPageInfoSection("m", "Meta Tags", function (verbose) {
     // get meta tag data, sort and put into pageMeta[]
     let metaNodes = this.focusedFrame.document.getElementsByTagName("meta");
 
-    return Array.map(metaNodes, function (node) [(node.name || node.httpEquiv),
-                                                 template.highlightURL(node.content)])
-                .sort(function (a, b) util.compareIgnoreCase(a[0], b[0]));
+    return Array.map(metaNodes, node => [(node.name || node.httpEquiv),
+                                         template.highlightURL(node.content)])
+                .sort((a, b) => util.compareIgnoreCase(a[0], b[0]));
 });
 
 Buffer.addPageInfoSection("s", "Security", function (verbose) {
@@ -2691,14 +2708,23 @@ Buffer.addPageInfoSection("s", "Security", function (verbose) {
 
         yield ["Verified by", data.caOrg];
 
-        if (identity._overrideService.hasMatchingOverride(identity._lastLocation.hostname,
-                                                      (identity._lastLocation.port || 443),
-                                                      data.cert, {}, {}))
+        let { host, port } = identity._lastUri;
+        if (port == -1)
+            port = 443;
+
+        if (identity._overrideService.hasMatchingOverride(host, port, data.cert, {}, {}))
             yield ["User exception", /*L*/"true"];
         break;
     }
 });
 
+// internal navigation doesn't currently update link[rel='shortlink']
+Buffer.addURIShortener("youtube.com", (uri, doc) => {
+    let video = array.toObject(uri.query.split("&")
+                                        .map(p => p.split("="))).v;
+    return video ? util.newURI("http://youtu.be/" + video) : null;
+});
+
 // catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
 
 endModule();
index e25bd4263ecc839f87e6e062430b8e77987db5e0..3f8e2f1ce75d4436d6d199b1d0e14b266949041d 100644 (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(
@@ -219,7 +219,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), {
     _has: function _has(name) Set.has(this.providers, name) || set.has(this.cache, name),
 
     has: function has(name) [this.globalProviders, this.cache, this.localProviders]
-            .some(function (obj) Set.has(obj, name)),
+            .some(obj => Set.has(obj, name)),
 
     register: function register(name, callback, self) {
         if (this.isLocal)
index 617c6bd168c8371310fcefd5f0ae5865365aed94..0e0d58fc8b6468f2961eea1c7e50d6f96feef2e5 100644 (file)
@@ -46,9 +46,9 @@ lazyRequire("template", ["template"]);
  */
 
 var CommandOption = Struct("names", "type", "validator", "completer", "multiple", "description", "default");
-CommandOption.defaultValue("description", function () "");
-CommandOption.defaultValue("type", function () CommandOption.NOARG);
-CommandOption.defaultValue("multiple", function () false);
+CommandOption.defaultValue("description", () => "");
+CommandOption.defaultValue("type", () => CommandOption.NOARG);
+CommandOption.defaultValue("multiple", () => false);
 
 var ArgType = Struct("description", "parse");
 update(CommandOption, {
@@ -64,7 +64,7 @@ update(CommandOption, {
      * @property {object} The option doesn't accept an argument.
      * @final
      */
-    NOARG: ArgType("no arg",  function (arg) !arg || null),
+    NOARG: ArgType("no arg",  arg => !arg || null),
     /**
      * @property {object} The option accepts a boolean argument.
      * @final
@@ -74,12 +74,12 @@ update(CommandOption, {
      * @property {object} The option accepts a string argument.
      * @final
      */
-    STRING: ArgType("string", function (val) val),
+    STRING: ArgType("string", val => val),
     /**
      * @property {object} The option accepts a stringmap argument.
      * @final
      */
-    STRINGMAP: ArgType("stringmap", function (val, quoted) Option.parse.stringmap(quoted)),
+    STRINGMAP: ArgType("stringmap", (val, quoted) => Option.parse.stringmap(quoted)),
     /**
      * @property {object} The option accepts an integer argument.
      * @final
@@ -155,15 +155,13 @@ var Command = Class("Command", {
      * @param {Args} args The Args object passed to {@link #action}.
      * @param {Object} modifiers Any modifiers to be passed to {@link #action}.
      */
-    execute: function execute(args, modifiers) {
+    execute: function execute(args, modifiers = {}) {
         const { dactyl } = this.modules;
 
         let context = args.context;
         if (this.deprecated)
             this.warn(context, "deprecated", _("warn.deprecated", ":" + this.name, this.deprecated));
 
-        modifiers = modifiers || {};
-
         if (args.count != null && !this.count)
             throw FailedAssertion(_("command.noCount"));
         if (args.bang && !this.bang)
@@ -221,12 +219,12 @@ var Command = Class("Command", {
     parsedSpecs: Class.Memoize(function () Command.parseSpecs(this.specs)),
 
     /** @property {[string]} All of this command's short names, e.g., "com" */
-    shortNames: Class.Memoize(function () array.compact(this.parsedSpecs.map(function (n) n[1]))),
+    shortNames: Class.Memoize(function () array.compact(this.parsedSpecs.map(n => n[1]))),
 
     /**
      * @property {[string]} All of this command's long names, e.g., "command"
      */
-    longNames: Class.Memoize(function () this.parsedSpecs.map(function (n) n[0])),
+    longNames: Class.Memoize(function () this.parsedSpecs.map(n => n[0])),
 
     /** @property {string} The command's canonical name. */
     name: Class.Memoize(function () this.longNames[0]),
@@ -309,7 +307,7 @@ var Command = Class("Command", {
     _options: [],
 
     optionMap: Class.Memoize(function () array(this.options)
-                .map(function (opt) opt.names.map(function (name) [name, opt]))
+                .map(opt => opt.names.map(name => [name, opt]))
                 .flatten().toObject()),
 
     newArgs: function newArgs(base) {
@@ -409,7 +407,7 @@ var Command = Class("Command", {
     }
 }, {
     hasName: function hasName(specs, name)
-        specs.some(function ([long, short])
+        specs.some(([long, short]) =>
             name.indexOf(short) == 0 && long.indexOf(name) == 0),
 
     // TODO: do we really need more than longNames as a convenience anyway?
@@ -536,28 +534,28 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
         if (this.cached)
             this.modules.initDependencies("commands");
         this.cached = false;
-        return array.iterValues(this._list.sort(function (a, b) a.name > b.name));
+        return array.iterValues(this._list.sort((a, b) => a.name > b.name));
     },
 
     /** @property {string} The last executed Ex command line. */
     repeat: null,
 
     /**
-     * Adds a new command to the builtin hive. Accessible only to core
-     * dactyl code. Plugins should use group.commands.add instead.
+     * Adds a new command to the builtin hive. Accessible only to core dactyl
+     * code. Plugins should use group.commands.add instead.
      *
-     * @param {[string]} specs The names by which this command can be
-     *     invoked. The first name specified is the command's canonical
-     *     name.
+     * @param {[string]} specs The names by which this command can be invoked.
+     *     The first name specified is the command's canonical name.
      * @param {string} description A description of the command.
      * @param {function} action The action invoked by this command.
      * @param {Object} extra An optional extra configuration hash.
-     * @optional
+     *     @optional
+     * @param {boolean} replace Replace an existing command of the same name.
+     *     @optional
      */
-    add: function add(specs, description, action, extra, replace) {
+    add: function add(specs, description, action, extra = {}, replace = false) {
         const { commands, contexts } = this.modules;
 
-        extra = extra || {};
         if (!extra.definedAt)
             extra.definedAt = contexts.getCaller(Components.stack.caller);
         if (!extra.sourceModule)
@@ -570,10 +568,10 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
         let name = names[0];
 
         if (this.name != "builtin") {
-            util.assert(!names.some(function (name) name in commands.builtin._map),
+            util.assert(!names.some(name => name in commands.builtin._map),
                         _("command.cantReplace", name));
 
-            util.assert(replace || names.every(function (name) !(name in this._map), this),
+            util.assert(replace || names.every(name => !(name in this._map)),
                         _("command.wontReplace", name));
         }
 
@@ -585,7 +583,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
 
         let closure = () => this._map[name];
 
-        memoize(this._map, name, function () commands.Command(specs, description, action, extra));
+        memoize(this._map, name, () => commands.Command(specs, description, action, extra));
         if (!extra.hidden)
             memoize(this._list, this._list.length, closure);
         for (let alias in values(names.slice(1)))
@@ -594,10 +592,8 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
         return name;
     },
 
-    _add: function _add(names, description, action, extra, replace) {
+    _add: function _add(names, description, action, extra = {}, replace = false) {
         const { contexts } = this.modules;
-
-        extra = extra || {};
         extra.definedAt = contexts.getCaller(Components.stack.caller.caller);
         return this.add.apply(this, arguments);
     },
@@ -623,11 +619,11 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
      */
     get: function get(name, full) {
         let cmd = this._map[name]
-               || !full && array.nth(this._list, function (cmd) cmd.hasName(name), 0)
+               || !full && array.nth(this._list, cmd => cmd.hasName(name), 0)
                || null;
 
         if (!cmd && full) {
-            let name = array.nth(this.specs, function (spec) Command.hasName(spec, name), 0);
+            let name = array.nth(this.specs, spec => Command.hasName(spec, name), 0);
             return name && this.get(name);
         }
 
@@ -648,7 +644,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, {
         util.assert(this.group.modifiable, _("command.cantDelete"));
 
         let cmd = this.get(name);
-        this._list = this._list.filter(function (c) c !== cmd);
+        this._list = this._list.filter(c => c !== cmd);
         for (let name in values(cmd.names))
             delete this._map[name];
     }
@@ -684,7 +680,7 @@ var Commands = Module("commands", {
 
         get allHives() contexts.allGroups.commands,
 
-        get userHives() this.allHives.filter(function (h) h !== this.builtin, this),
+        get userHives() this.allHives.filter(h => h !== this.builtin),
 
         /**
          * Executes an Ex command script.
@@ -764,9 +760,10 @@ var Commands = Module("commands", {
                 return "";
             }
             // TODO: allow matching of aliases?
-            function cmds(hive) hive._list.filter(function (cmd) cmd.name.indexOf(filter || "") == 0)
+            function cmds(hive) hive._list.filter(cmd => cmd.name.indexOf(filter || "") == 0)
 
-            let hives = (hives || this.userHives).map(function (h) [h, cmds(h)]).filter(function ([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" },
@@ -778,9 +775,9 @@ var Commands = Module("commands", {
                     ["td", { style: "padding-right: 1ex;" }, _("title.Complete")],
                     ["td", { style: "padding-right: 1ex;" }, _("title.Definition")]],
                 ["col", { style: "min-width: 6em; padding-right: 1em;" }],
-                hives.map(function ([hive, cmds]) let (i = 0) [
+                hives.map(([hive, cmds]) => let (i = 0) [
                     ["tr", { style: "height: .5ex;" }],
-                    cmds.map(function (cmd)
+                    cmds.map(cmd =>
                         ["tr", {},
                             ["td", { highlight: "Title" }, !i++ ? hive.name : ""],
                             ["td", {}, cmd.bang ? "!" : " "],
@@ -815,7 +812,8 @@ var Commands = Module("commands", {
 
     /** @property {Iterator(Command)} @private */
     iterator: function iterator() iter.apply(null, this.hives.array)
-                              .sort(function (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. */
@@ -846,7 +844,7 @@ var Commands = Module("commands", {
 
         let defaults = {};
         if (args.ignoreDefaults)
-            defaults = array(this.options).map(function (opt) [opt.names[0], opt.default])
+            defaults = array(this.options).map(opt => [opt.names[0], opt.default])
                                           .toObject();
 
         for (let [opt, val] in Iterator(args.options || {})) {
@@ -881,7 +879,7 @@ var Commands = Module("commands", {
      *     any of the command's names.
      * @returns {Command}
      */
-    get: function get(name, full) iter(this.hives).map(function ([i, hive]) hive.get(name, full))
+    get: function get(name, full) iter(this.hives).map(([i, hive]) => hive.get(name, full))
                                                   .nth(util.identity, 0),
 
     /**
@@ -895,7 +893,7 @@ var Commands = Module("commands", {
     hasDomain: function hasDomain(command, host) {
         try {
             for (let [cmd, args] in this.subCommands(command))
-                if (Array.concat(cmd.domains(args)).some(function (domain) util.isSubdomain(domain, host)))
+                if (Array.concat(cmd.domains(args)).some(domain => util.isSubdomain(domain, host)))
                     return true;
         }
         catch (e) {
@@ -966,13 +964,10 @@ var Commands = Module("commands", {
      *     Args object.
      * @returns {Args}
      */
-    parseArgs: function parseArgs(str, params) {
+    parseArgs: function parseArgs(str, params = {}) {
         const self = this;
 
-        function getNextArg(str, _keepQuotes) {
-            if (arguments.length < 2)
-                _keepQuotes = keepQuotes;
-
+        function getNextArg(str, _keepQuotes=keepQuotes) {
             if (str.substr(0, 2) === "<<" && hereDoc) {
                 let arg = /^<<(\S*)/.exec(str)[1];
                 let count = arg.length + 2;
@@ -991,7 +986,7 @@ var Commands = Module("commands", {
 
         try {
 
-            var { allowUnknownOptions, argCount, complete, extra, hereDoc, literal, options, keepQuotes } = params || {};
+            var { allowUnknownOptions, argCount, complete, extra, hereDoc, literal, options, keepQuotes } = params;
 
             if (!options)
                 options = [];
@@ -1016,7 +1011,7 @@ var Commands = Module("commands", {
             let matchOpts = function matchOpts(arg) {
                 // Push possible option matches into completions
                 if (complete && !onlyArgumentsRemaining)
-                    completeOpts = options.filter(function (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;
@@ -1208,7 +1203,7 @@ var Commands = Module("commands", {
                     context.filter = args.completeFilter;
 
                     if (isArray(arg))
-                        context.filters.push(function (item) arg.indexOf(item.text) === -1);
+                        context.filters.push(item => arg.indexOf(item.text) === -1);
 
                     if (typeof opt.completer == "function")
                         var compl = opt.completer(context, args);
@@ -1394,7 +1389,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, function (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))
@@ -1436,9 +1432,9 @@ var Commands = Module("commands", {
             context.title = ["Command"];
             context.keys = { text: "longNames", description: "description" };
             if (group)
-                context.generate = function () group._list;
+                context.generate = () => group._list;
             else
-                context.generate = function () modules.commands.hives.map(function (h) h._list).flatten();
+                context.generate = () => modules.commands.hives.map(h => h._list).flatten();
         };
 
         // provides completions for ex commands, including their arguments
@@ -1577,7 +1573,7 @@ var Commands = Module("commands", {
                             };
                         }
                         else
-                            completerFunc = function (context) modules.completion.closure[config.completers[completer]](context);
+                            completerFunc = context => modules.completion.closure[config.completers[completer]](context);
                     }
 
                     let added = args["-group"].add(cmd.split(","),
@@ -1662,8 +1658,8 @@ var Commands = Module("commands", {
                 literal: 1,
 
                 serialize: function () array(commands.userHives)
-                    .filter(function (h) h.persist)
-                    .map(function (hive) [
+                    .filter(h => h.persist)
+                    .map(hive => [
                         {
                             command: this.name,
                             bang: true,
@@ -1681,7 +1677,7 @@ var Commands = Module("commands", {
                             ignoreDefaults: true
                         }
                         for (cmd in hive) if (cmd.persist)
-                    ], this)
+                    ])
                     .flatten().array
             });
 
@@ -1725,7 +1721,7 @@ var Commands = Module("commands", {
                 ]
             })),
             iterateIndex: function (args) let (tags = help.tags)
-                this.iterate(args).filter(function (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 : "")),
@@ -1776,10 +1772,10 @@ var Commands = Module("commands", {
     }
 });
 
-let quote = function quote(q, list, map) {
-    map = map || Commands.quoteMap;
+let quote = function quote(q, list, map = Commands.quoteMap) {
     let re = RegExp("[" + list + "]", "g");
-    function quote(str) q + String.replace(str, re, function ($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;
 };
index 24b091a0d935631a47b3c74442b226eb44afa453..001b267b7d1d84f0b63b5322c9eed5a6eab9362c 100644 (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.
@@ -33,10 +33,7 @@ lazyRequire("template", ["template"]);
  * @constructor
  */
 var CompletionContext = Class("CompletionContext", {
-    init: function cc_init(editor, name, offset) {
-        if (!name)
-            name = "";
-
+    init: function cc_init(editor, name = "", offset = 0) {
         let self = this;
         if (editor instanceof this.constructor) {
             let parent = editor;
@@ -60,15 +57,15 @@ var CompletionContext = Class("CompletionContext", {
              */
             self.parent = parent;
 
-            ["filters", "keys", "process", "title", "quote"].forEach(function fe(key)
-                self[key] = parent[key] && util.cloneObject(parent[key]));
-            ["anchored", "compare", "editor", "_filter", "filterFunc", "forceAnchored", "top"].forEach(function (key)
-                self[key] = parent[key]);
+            ["filters", "keys", "process", "title", "quote"]
+                .forEach(key => self[key] = parent[key] && util.cloneObject(parent[key]));
+            ["anchored", "compare", "editor", "_filter", "filterFunc", "forceAnchored", "top"]
+                .forEach(key => self[key] = parent[key]);
 
             self.__defineGetter__("value", function get_value() this.top.value);
 
             self.offset = parent.offset;
-            self.advance(offset || 0);
+            self.advance(offset);
 
             /**
              * @property {boolean} Specifies that this context is not finished
@@ -156,7 +153,7 @@ var CompletionContext = Class("CompletionContext", {
              * @property {number} This context's offset from the beginning of
              *     {@link #editor}'s value.
              */
-            this.offset = offset || 0;
+            this.offset = offset;
             /**
              * @property {function} A function which is called when any subcontext
              *     changes its completion list. Only called when
@@ -171,9 +168,9 @@ var CompletionContext = Class("CompletionContext", {
              */
             this.top = this;
             this.__defineGetter__("incomplete", function get_incomplete() this._incomplete
-                || this.contextList.some(function (c) c.parent && c.incomplete));
+                || this.contextList.some(c => c.parent && c.incomplete));
             this.__defineGetter__("waitingForTab", function get_waitingForTab() this._waitingForTab
-                || this.contextList.some(function (c) c.parent && c.waitingForTab));
+                || this.contextList.some(c => c.parent && c.waitingForTab));
             this.__defineSetter__("incomplete", function get_incomplete(val) { this._incomplete = val; });
             this.__defineSetter__("waitingForTab", function get_waitingForTab(val) { this._waitingForTab = val; });
             this.reset();
@@ -214,7 +211,7 @@ var CompletionContext = Class("CompletionContext", {
         return this;
     },
 
-    __title: Class.Memoize(function __title() this._title.map(function (s)
+    __title: Class.Memoize(function __title() this._title.map(s =>
                 typeof s == "string" ? messages.get("completion.title." + s, s)
                                      : s)),
 
index 9e5b7c0c59ea3526d4c79afcd5c0f769de8d2eee..d009e1a4ca602024eae72ffccabb8836abaa9c71 100644 (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.
@@ -57,10 +57,10 @@ var ConfigBase = Class("ConfigBase", {
                      "resource://dactyl-content/")));
 
         this.timeout(function () {
-            cache.register("config.dtd", function () util.makeDTD(config.dtd));
+            cache.register("config.dtd", () => util.makeDTD(config.dtd));
         });
 
-        services["dactyl:"].pages["dtd"] = function () [null, cache.get("config.dtd")];
+        services["dactyl:"].pages["dtd"] = () => [null, cache.get("config.dtd")];
 
         update(services["dactyl:"].providers, {
             "locale": function (uri, path) LocaleChannel("dactyl-locale", config.locale, path, uri),
@@ -77,7 +77,7 @@ var ConfigBase = Class("ConfigBase", {
         "resource://dactyl-local/config.json"
     ],
 
-    configs: Class.Memoize(function () this.configFiles.map(function (url) JSON.parse(File.readURL(url)))),
+    configs: Class.Memoize(function () this.configFiles.map(url => JSON.parse(File.readURL(url)))),
 
     loadConfig: function loadConfig(documentURL) {
 
@@ -152,8 +152,10 @@ var ConfigBase = Class("ConfigBase", {
     loadStyles: function loadStyles(force) {
         highlight.styleableChrome = this.styleableChrome;
 
-        highlight.loadCSS(this.CSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1)));
-        highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, function (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(/*
@@ -169,14 +171,14 @@ var ConfigBase = Class("ConfigBase", {
         let hl = highlight.set("Find", "");
         hl.onChange = function () {
             function hex(val) ("#" + util.regexp.iterate(/\d+/g, val)
-                                         .map(function (num) ("0" + Number(num).toString(16)).slice(-2))
+                                         .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;
 
-            let keys = iter(Styles.propertyIter(this.cssText)).map(function (p) p.name).toArray();
+            let keys = iter(Styles.propertyIter(this.cssText)).map(p => p.name).toArray();
             let bg = keys.some(bind("test", /^background/));
             let fg = keys.indexOf("color") >= 0;
 
@@ -198,7 +200,7 @@ var ConfigBase = Class("ConfigBase", {
     /**
      * The current application locale.
      */
-    appLocale: Class.Memoize(function () services.chromeRegistry.getSelectedLocale("global")),
+    appLocale: Class.Memoize(() => services.chromeRegistry.getSelectedLocale("global")),
 
     /**
      * The current dactyl locale.
@@ -411,8 +413,8 @@ var ConfigBase = Class("ConfigBase", {
         get plugins() "http://5digits.org/" + this.name + "/plugins",
         get faq() this.home + this.name + "/faq",
 
-        "list.mailto": Class.Memoize(function () config.name + "@googlegroups.com"),
-        "list.href": Class.Memoize(function () "http://groups.google.com/group/" + config.name),
+        "list.mailto": Class.Memoize(() => config.name + "@googlegroups.com"),
+        "list.href": Class.Memoize(() => "http://groups.google.com/group/" + config.name),
 
         "hg.latest": Class.Memoize(function () this.code + "source/browse/"), // XXX
         "irc": "irc://irc.oftc.net/#pentadactyl"
@@ -478,8 +480,8 @@ var ConfigBase = Class("ConfigBase", {
             get commandContainer() document.documentElement.id
         }),
 
-        browser: Class.Memoize(function () window.gBrowser),
-        tabbrowser: Class.Memoize(function () window.gBrowser),
+        browser: Class.Memoize(() => window.gBrowser),
+        tabbrowser: Class.Memoize(() => window.gBrowser),
 
         get browserModes() [modules.modes.NORMAL],
 
@@ -573,9 +575,9 @@ var ConfigBase = Class("ConfigBase", {
      * @property {string} The default highlighting rules.
      * See {@link Highlights#loadCSS} for details.
      */
-    CSS: Class.Memoize(function () File.readURL("resource://dactyl-skin/global-styles.css")),
+    CSS: Class.Memoize(() => File.readURL("resource://dactyl-skin/global-styles.css")),
 
-    helpCSS: Class.Memoize(function () File.readURL("resource://dactyl-skin/help-styles.css"))
+    helpCSS: Class.Memoize(() => File.readURL("resource://dactyl-skin/help-styles.css"))
 }, {
 });
 JSMLoader.loadSubScript("resource://dactyl-local-content/config.js", this);
@@ -594,7 +596,7 @@ config.INIT = update(Object.create(config.INIT), config.INIT, {
                      width:      {width}px;
                      height:     {height}px;
                 }
-            */).replace(/\{(.*?)\}/g, function (m, m1) img[m1]));
+            */).replace(/\{(.*?)\}/g, (m, m1) => img[m1]));
             img = null;
         });
     },
index ffada2b7635446021f543c06cdc5c2a6e8165f7b..3c0ca3a94c39ea4ee79ae07addef934043fe1862 100644 (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.
@@ -65,12 +65,9 @@ var Group = Class("Group", {
     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, {
@@ -78,8 +75,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)
@@ -140,8 +138,8 @@ var Contexts = Module("contexts", {
                 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 () {
@@ -187,8 +185,8 @@ var Contexts = Module("contexts", {
                 });
 
                 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))]);
@@ -201,11 +199,11 @@ 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"),
-                                 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, "-")
@@ -305,7 +303,7 @@ var Contexts = Module("contexts", {
             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)
@@ -413,7 +411,7 @@ var Contexts = Module("contexts", {
 
     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);
@@ -515,7 +513,7 @@ var Contexts = Module("contexts", {
                               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":
@@ -544,7 +542,7 @@ var Contexts = Module("contexts", {
                 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;
@@ -707,7 +705,7 @@ var Contexts = Module("contexts", {
                 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]);
@@ -719,7 +717,7 @@ var Contexts = Module("contexts", {
                 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);
                 }
             });
@@ -795,7 +793,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 || ""]
             };
@@ -805,7 +803,7 @@ var Contexts = Module("contexts", {
             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);
                 });
             });
         };
index b76bc0fe492499362dc4480e3e7afc6259209445..6831bd3e83b9a35fc3a56bf0594d9e6b435aea7b 100644 (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) function (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();
@@ -158,11 +158,11 @@ var DOM = Class("DOM", {
     },
 
     find: function find(val) {
-        return this.map(function (elem) elem.querySelectorAll(val));
+        return this.map(elem => elem.querySelectorAll(val));
     },
 
     findAnon: function findAnon(attr, val) {
-        return this.map(function (elem) elem.ownerDocument.getAnonymousElementByAttribute(elem, attr, val));
+        return this.map(elem => elem.ownerDocument.getAnonymousElementByAttribute(elem, attr, val));
     },
 
     filter: function filter(val, self) {
@@ -213,7 +213,7 @@ var DOM = Class("DOM", {
 
         for (let i = 0; i < this.length; i++) {
             let tmp = fn.call(self || update(obj, [this[i]]), this[i], i);
-            if (isObject(tmp) && "length" in tmp)
+            if (isObject(tmp) && !(tmp instanceof Ci.nsIDOMNode) && "length" in tmp)
                 for (let j = 0; j < tmp.length; j++)
                     res[res.length++] = tmp[j];
             else if (tmp != null)
@@ -234,7 +234,7 @@ var DOM = Class("DOM", {
         return false;
     },
 
-    get parent() this.map(function (elem) elem.parentNode, this),
+    get parent() this.map(elem => elem.parentNode, this),
 
     get offsetParent() this.map(function (elem) {
         do {
@@ -245,23 +245,23 @@ var DOM = Class("DOM", {
         while (parent);
     }, this),
 
-    get ancestors() this.all(function (elem) elem.parentNode),
+    get ancestors() this.all(elem => elem.parentNode),
 
-    get children() this.map(function (elem) Array.filter(elem.childNodes,
-                                                         function (e) e instanceof Ci.nsIDOMElement),
+    get children() this.map(elem => Array.filter(elem.childNodes,
+                                                 e => e instanceof Ci.nsIDOMElement),
                             this),
 
-    get contents() this.map(function (elem) elem.childNodes, this),
+    get contents() this.map(elem => elem.childNodes, this),
 
-    get siblings() this.map(function (elem) Array.filter(elem.parentNode.childNodes,
-                                                         function (e) e != elem && e instanceof Ci.nsIDOMElement),
+    get siblings() this.map(elem => Array.filter(elem.parentNode.childNodes,
+                                                 e => e != elem && e instanceof Ci.nsIDOMElement),
                             this),
 
-    get siblingsBefore() this.all(function (elem) elem.previousElementSibling),
-    get siblingsAfter() this.all(function (elem) elem.nextElementSibling),
+    get siblingsBefore() this.all(elem => elem.previousElementSibling),
+    get siblingsAfter() this.all(elem => elem.nextElementSibling),
 
-    get allSiblingsBefore() this.all(function (elem) elem.previousSibling),
-    get allSiblingsAfter() this.all(function (elem) elem.nextSibling),
+    get allSiblingsBefore() this.all(elem => elem.previousSibling),
+    get allSiblingsAfter() this.all(elem => elem.nextSibling),
 
     get class() let (self = this) ({
         toString: function () self[0].className,
@@ -305,7 +305,7 @@ var DOM = Class("DOM", {
         }),
 
         remove: function remove(hl) self.each(function () {
-            this.highlight.list = this.highlight.list.filter(function (h) h != hl);
+            this.highlight.list = this.highlight.list.filter(h => h != hl);
         }),
 
         toggle: function toggle(hl, val, thisObj) self.each(function (elem, i) {
@@ -584,7 +584,7 @@ var DOM = Class("DOM", {
                         ["span", { highlight: "HelpXMLTagStart" },
                             "<", namespaced(elem), " ",
                             template.map(array.iterValues(elem.attributes),
-                                function (attr) [
+                                attr => [
                                     ["span", { highlight: "HelpXMLAttribute" }, namespaced(attr)],
                                     ["span", { highlight: "HelpXMLString" }, attr.value]
                                 ],
@@ -660,9 +660,9 @@ var DOM = Class("DOM", {
 
         return this[0].style[css.property(key)];
     }, {
-        name: function (property) property.replace(/[A-Z]/g, function (m0) "-" + m0.toLowerCase()),
+        name: function (property) property.replace(/[A-Z]/g, m0 => "-" + m0.toLowerCase()),
 
-        property: function (name) name.replace(/-(.)/g, function (m0, m1) m1.toUpperCase())
+        property: function (name) name.replace(/-(.)/g, (m0, m1) => m1.toUpperCase())
     }),
 
     append: function append(val) {
@@ -738,7 +738,7 @@ var DOM = Class("DOM", {
     },
 
     clone: function clone(deep)
-        this.map(function (elem) elem.cloneNode(deep)),
+        this.map(elem => elem.cloneNode(deep)),
 
     toggle: function toggle(val, self) {
         if (callable(val))
@@ -749,7 +749,7 @@ var DOM = Class("DOM", {
         if (arguments.length)
             return this[val ? "show" : "hide"]();
 
-        let hidden = this.map(function (elem) elem.style.display == "none");
+        let hidden = this.map(elem => elem.style.display == "none");
         return this.each(function (elem, i) {
             this[hidden[i] ? "show" : "hide"]();
         });
@@ -784,7 +784,7 @@ var DOM = Class("DOM", {
 
         let [fn, self] = args;
         if (!callable(fn))
-            fn = function () args[0];
+            fn = () => args[0];
 
         return this.each(function (elem, i) {
             set.call(this, elem, fn.call(self || this, elem, i));
@@ -793,20 +793,20 @@ var DOM = Class("DOM", {
 
     html: function html(txt, self) {
         return this.getSet(arguments,
-                           function (elem) elem.innerHTML,
-                           util.wrapCallback(function (elem, val) { elem.innerHTML = val; }));
+                           elem => elem.innerHTML,
+                           util.wrapCallback((elem, val) => { elem.innerHTML = val; }));
     },
 
     text: function text(txt, self) {
         return this.getSet(arguments,
-                           function (elem) elem.textContent,
-                           function (elem, val) { elem.textContent = val; });
+                           elem => elem.textContent,
+                           (elem, val) => { elem.textContent = val; });
     },
 
     val: function val(txt) {
         return this.getSet(arguments,
-                           function (elem) elem.value,
-                           function (elem, val) { elem.value = val == null ? "" : val; });
+                           elem => elem.value,
+                           (elem, val) => { elem.value = val == null ? "" : val; });
     },
 
     listen: function listen(event, listener, capture) {
@@ -985,7 +985,7 @@ var DOM = Class("DOM", {
             update(params, this.constructor.defaults[type],
                    iter.toObject([k, opts[k]] for (k in opts) if (k in params)));
 
-            evt["init" + t + "Event"].apply(evt, args.map(function (k) params[k]));
+            evt["init" + t + "Event"].apply(evt, args.map(k => params[k]));
             return evt;
         }
     }, {
@@ -1040,7 +1040,7 @@ var DOM = Class("DOM", {
                 this.code_nativeKey[v] = k.substr(4);
 
                 k = k.substr(7).toLowerCase();
-                let names = [k.replace(/(^|_)(.)/g, function (m, n1, n2) n2.toUpperCase())
+                let names = [k.replace(/(^|_)(.)/g, (m, n1, n2) => n2.toUpperCase())
                               .replace(/^NUMPAD/, "k")];
 
                 if (names[0].length == 1)
@@ -1090,12 +1090,10 @@ var DOM = Class("DOM", {
          * @param {string} keys Messy form.
          * @param {boolean} unknownOk Whether unknown keys are passed
          *     through rather than being converted to <lt>keyname>.
-         *     @default false
+         *     @default true
          * @returns {string} Canonical form.
          */
-        canonicalKeys: function canonicalKeys(keys, unknownOk) {
-            if (arguments.length === 1)
-                unknownOk = true;
+        canonicalKeys: function canonicalKeys(keys, unknownOk=true) {
             return this.parse(keys, unknownOk).map(this.closure.stringify).join("");
         },
 
@@ -1122,15 +1120,12 @@ var DOM = Class("DOM", {
          * @param {string} keys The string to parse.
          * @param {boolean} unknownOk Whether unknown keys are passed
          *     through rather than being converted to <lt>keyname>.
-         *     @default false
+         *     @default true
          * @returns {Array[Object]}
          */
-        parse: function parse(input, unknownOk) {
+        parse: function parse(input, unknownOk=true) {
             if (isArray(input))
-                return array.flatten(input.map(function (k) this.parse(k, unknownOk), this));
-
-            if (arguments.length === 1)
-                unknownOk = true;
+                return array.flatten(input.map(k => this.parse(k, unknownOk)));
 
             let out = [];
             for (let match in util.regexp.iterate(/<.*?>?>|[^<]|<(?!.*>)/g, input)) {
@@ -1214,7 +1209,7 @@ var DOM = Class("DOM", {
          */
         stringify: function stringify(event) {
             if (isArray(event))
-                return event.map(function (e) this.stringify(e), this).join("");
+                return event.map(e => this.stringify(e)).join("");
 
             if (event.dactylString)
                 return event.dactylString;
@@ -1338,7 +1333,7 @@ var DOM = Class("DOM", {
             submit: { cancelable: true }
         },
 
-        types: Class.Memoize(function () iter(
+        types: Class.Memoize(() => iter(
             {
                 Mouse: "click mousedown mouseout mouseover mouseup dblclick " +
                        "hover " +
@@ -1349,7 +1344,7 @@ var DOM = Class("DOM", {
                        "load unload pageshow pagehide DOMContentLoaded " +
                        "resize scroll"
             }
-        ).map(function ([k, v]) v.split(" ").map(function (v) [v, k]))
+        ).map(([k, v]) => v.split(" ").map(v => [v, k]))
          .flatten()
          .toObject()),
 
@@ -1372,7 +1367,7 @@ var DOM = Class("DOM", {
                                    .dispatchDOMEventViaPresShell(target, event, true);
                         else {
                             target.dispatchEvent(event);
-                            return !event.getPreventDefault();
+                            return !event.defaultPrevented;
                         }
                     }
                     catch (e) {
@@ -1393,12 +1388,12 @@ var DOM = Class("DOM", {
                 })
     }),
 
-    createContents: Class.Memoize(function () services.has("dactyl") && services.dactyl.createContents
-        || function (elem) {}),
+    createContents: Class.Memoize(() => services.has("dactyl") && services.dactyl.createContents
+        || (elem => {})),
 
-    isScrollable: Class.Memoize(function () services.has("dactyl") && services.dactyl.getScrollable
-        ? function (elem, dir) services.dactyl.getScrollable(elem) & (dir ? services.dactyl["DIRECTION_" + dir.toUpperCase()] : ~0)
-        : function (elem, dir) true),
+    isScrollable: Class.Memoize(() => services.has("dactyl") && services.dactyl.getScrollable
+        ? (elem, dir) => services.dactyl.getScrollable(elem) & (dir ? services.dactyl["DIRECTION_" + dir.toUpperCase()] : ~0)
+        : (elem, dir) => true),
 
     isJSONXML: function isJSONXML(val) isArray(val) && isinstance(val[0], ["String", "Array", "XML", DOM.DOMString])
                                     || isObject(val) && "toDOM" in val,
@@ -1524,7 +1519,7 @@ var DOM = Class("DOM", {
     escapeHTML: function escapeHTML(str, simple) {
         let map = { "'": "&apos;", '"': "&quot;", "%": "&#x25;", "&": "&amp;", "<": "&lt;", ">": "&gt;" };
         let regexp = simple ? /[<>]/g : /['"&<>]/g;
-        return str.replace(regexp, function (m) map[m]);
+        return str.replace(regexp, m => map[m]);
     },
 
     /**
@@ -1664,13 +1659,13 @@ var DOM = Class("DOM", {
         function isFragment(args) !isString(args[0]) || args.length == 0 || args[0] === "";
 
         function hasString(args) {
-            return args.some(function (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(function (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) {
@@ -1782,7 +1777,7 @@ var DOM = Class("DOM", {
                 res.push(">");
 
                 if (isStrings(args))
-                    res.push(args.map(function (e) tag(e, namespaces, "")).join(""),
+                    res.push(args.map(e => tag(e, namespaces, "")).join(""),
                              "</", name, ">");
                 else {
                     let contents = [];
@@ -1840,7 +1835,7 @@ var DOM = Class("DOM", {
                 let resolver = XPath.resolver;
                 if (namespaces) {
                     namespaces = update({}, DOM.namespaces, namespaces);
-                    resolver = function (prefix) namespaces[prefix] || null;
+                    resolver = prefix => namespaces[prefix] || null;
                 }
 
                 let result = doc.evaluate(expression, elem,
@@ -1878,8 +1873,10 @@ var DOM = Class("DOM", {
      */
     makeXPath: function makeXPath(nodes) {
         return array(nodes).map(util.debrace).flatten()
-                           .map(function (node) /^[a-z]+:/.test(node) ? node : [node, "xhtml:" + node]).flatten()
-                           .map(function (node) "//" + node).join(" | ");
+                           .map(node => /^[a-z]+:/.test(node) ? node
+                                                              : [node, "xhtml:" + node])
+                           .flatten()
+                           .map(node => "//" + node).join(" | ");
     },
 
     namespaces: {
@@ -1891,11 +1888,11 @@ var DOM = Class("DOM", {
     },
 
     namespaceNames: Class.Memoize(function ()
-        iter(this.namespaces).map(function ([k, v]) [v, k]).toObject()),
+        iter(this.namespaces).map(([k, v]) => ([v, k])).toObject()),
 });
 
 Object.keys(DOM.Event.types).forEach(function (event) {
-    let name = event.replace(/-(.)/g, function (m, m1) m1.toUpperCase());
+    let name = event.replace(/-(.)/g, (m, m1) => m1.toUpperCase());
     if (!Set.has(DOM.prototype, name))
         DOM.prototype[name] =
             function _event(arg, extra) {
index 26ac1ccd31dc0df00f00d86bfdb954e27f2d0cd5..cbcd9a6e4fcaf4ff3ffccc4ae1bb3e35213c4850 100644 (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) {
@@ -281,7 +281,7 @@ var DownloadList = Class("DownloadList",
                 return;
 
             this.downloads[id] = download;
-            let index = values(this.downloads).sort(function (a, b) a.compare(b))
+            let index = values(this.downloads).sort((a, b) => a.compare(b))
                                               .indexOf(download);
 
             this.nodes.list.insertBefore(download.nodes.row,
@@ -301,7 +301,7 @@ var DownloadList = Class("DownloadList",
     },
 
     allowedCommands: Class.Memoize(function () let (self = this) ({
-        get clear() values(self.downloads).some(function (dl) dl.allowedCommands.remove)
+        get clear() values(self.downloads).some(dl => dl.allowedCommands.remove)
     })),
 
     commands: {
@@ -311,7 +311,7 @@ var DownloadList = Class("DownloadList",
     },
 
     sort: function sort() {
-        let list = values(this.downloads).sort(function (a, b) a.compare(b));
+        let list = values(this.downloads).sort((a, b) => a.compare(b));
 
         for (let [i, download] in iter(list))
             if (this.nodes.list.childNodes[i + 1] != download.nodes.row)
@@ -319,7 +319,7 @@ var DownloadList = Class("DownloadList",
                                              this.nodes.list.childNodes[i + 1]);
     },
 
-    shouldSort: function shouldSort() Array.some(arguments, function (val) this.sortOrder.some(function (v) v.substr(1) == val), this),
+    shouldSort: function shouldSort() Array.some(arguments, val => this.sortOrder.some(v => v.substr(1) == val)),
 
     update: function update() {
         for (let node in values(this.nodes))
@@ -336,11 +336,11 @@ var DownloadList = Class("DownloadList",
 
     updateProgress: function updateProgress() {
         let downloads = values(this.downloads).toArray();
-        let active    = downloads.filter(function (d) d.alive);
+        let active    = downloads.filter(d => d.alive);
 
         let self = Object.create(this);
         for (let prop in values(["amountTransferred", "size", "speed", "timeRemaining"]))
-            this[prop] = active.reduce(function (acc, dl) dl[prop] + acc, 0);
+            this[prop] = active.reduce((acc, dl) => dl[prop] + acc, 0);
 
         Download.prototype.updateProgress.call(self);
 
@@ -489,21 +489,21 @@ var Downloads = Module("downloads", XPCOM(Ci.nsIDownloadProgressListener), {
                 },
 
                 completer: function (context, extra) {
-                    let seen = Set.has(Set(extra.values.map(function (val) val.substr(1))));
+                    let seen = Set.has(Set(extra.values.map(val => val.substr(1))));
 
-                    context.completions = iter(this.values).filter(function ([k, v]) !seen(k))
-                                                           .map(function ([k, v]) [["+" + k, [v, " (", _("sort.ascending"), ")"].join("")],
-                                                                                   ["-" + k, [v, " (", _("sort.descending"), ")"].join("")]])
+                    context.completions = iter(this.values).filter(([k, v]) => !seen(k))
+                                                           .map(([k, v]) => [["+" + k, [v, " (", _("sort.ascending"), ")"].join("")],
+                                                                             ["-" + k, [v, " (", _("sort.descending"), ")"].join("")]])
                                                            .flatten().array;
                 },
 
-                has: function () Array.some(arguments, function (val) this.value.some(function (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(function (val) /^[+-]/.test(val) && Set.has(this.values, val.substr(1))
-                                                                        && !Set.add(seen, val.substr(1)),
-                                       this) && value.length;
+                    return value.every(val => /^[+-]/.test(val) && Set.has(this.values, val.substr(1))
+                                                                && !Set.add(seen, val.substr(1)))
+                        && value.length;
                 }
             });
     }
index 9c1897deb9859bd34c0bbf62404423de2fd31f75..738b17772bf4835fe5def2d718c3d6f4b26ad4f3 100644 (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.
@@ -75,9 +75,7 @@ var RangeFinder = Module("rangefinder", {
         this.find("", mode == this.modes.FIND_BACKWARD);
     },
 
-    bootstrap: function bootstrap(str, backward) {
-        if (arguments.length < 2 && this.rangeFind)
-            backward = this.rangeFind.reverse;
+    bootstrap: function bootstrap(str, backward=this.rangeFind && this.rangeFind.reverse) {
 
         let highlighted = this.rangeFind && this.rangeFind.highlighted;
         let selections = this.rangeFind && this.rangeFind.selections;
@@ -104,7 +102,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);
 
@@ -430,7 +428,7 @@ var RangeFind = Class("RangeFind", {
     findRange: function findRange(range) {
         let doc = range.startContainer.ownerDocument;
         let win = doc.defaultView;
-        let ranges = this.ranges.filter(function (r)
+        let ranges = this.ranges.filter(r =>
             r.window === win && RangeFind.sameDocument(r.range, range) && RangeFind.contains(r.range, range));
 
         if (this.backward)
@@ -516,7 +514,7 @@ var RangeFind = Class("RangeFind", {
     },
 
     iter: function iter(word) {
-        let saved = ["lastRange", "lastString", "range", "regexp"].map(function (s) [s, this[s]], this);
+        let saved = ["lastRange", "lastString", "range", "regexp"].map(s => [s, this[s]]);
         let res;
         try {
             let regexp = this.regexp && word != util.regexp.escape(word);
@@ -542,7 +540,7 @@ var RangeFind = Class("RangeFind", {
             }
         }
         finally {
-            saved.forEach(function ([k, v]) this[k] = v, this);
+            saved.forEach(([k, v]) => { this[k] = v; });
         }
     },
 
@@ -611,7 +609,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;
     },
@@ -837,7 +835,7 @@ var RangeFind = Class("RangeFind", {
         }
         return true;
     },
-    selectNodePath: ["a", "xhtml:a", "*[@onclick]"].map(function (p) "ancestor-or-self::" + p).join(" | "),
+    selectNodePath: ["a", "xhtml:a", "*[@onclick]"].map(p => "ancestor-or-self::" + p).join(" | "),
     union: function union(a, b) {
         let start = a.compareBoundaryPoints(a.START_TO_START, b) < 0 ? a : b;
         let end   = a.compareBoundaryPoints(a.END_TO_END, b) > 0 ? a : b;
index 623aeca1a6844dbd06842dc01095b43b48da5a3a..f477411ed4b9acae873f5792a36b995f6cc14b04 100644 (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.
@@ -27,7 +27,7 @@ var HelpBuilder = Class("HelpBuilder", {
 
             // Scrape the list of help files from all.xml
             this.tags["all"] = this.tags["all.xml"] = "all";
-            let files = this.findHelpFile("all").map(function (doc)
+            let files = this.findHelpFile("all").map(doc =>
                     [f.value for (f in DOM.XPath("//dactyl:include/@href", doc))]);
 
             // Scrape the tags from the rest of the help files.
@@ -90,8 +90,8 @@ var Help = Module("Help", {
             }
 
         update(services["dactyl:"].providers, {
-            "help": Loop(function (uri, path) help.files[path]),
-            "help-overlay": Loop(function (uri, path) help.overlays[path]),
+            "help": Loop((uri, path) => help.files[path]),
+            "help-overlay": Loop((uri, path) => help.overlays[path]),
             "help-tag": Loop(function (uri, path) {
                 let tag = decodeURIComponent(path);
                 if (tag in help.files)
@@ -129,7 +129,7 @@ var Help = Module("Help", {
             let betas = util.regexp(/\[((?:b|rc)\d)\]/, "gx");
 
             let beta = array(betas.iterate(NEWS))
-                        .map(function (m) m[1]).uniq().slice(-1)[0];
+                        .map(m => m[1]).uniq().slice(-1)[0];
 
             function rec(text, level, li) {
                 let res = [];
@@ -151,10 +151,10 @@ var Help = Module("Help", {
                     else if (match.par) {
                         let [, par, tags] = /([^]*?)\s*((?:\[[^\]]+\])*)\n*$/.exec(match.par);
                         let t = tags;
-                        tags = array(betas.iterate(tags)).map(function (m) m[1]);
+                        tags = array(betas.iterate(tags)).map(m => m[1]);
 
-                        let group = !tags.length                       ? "" :
-                                    !tags.some(function (t) t == beta) ? "HelpNewsOld" : "HelpNewsNew";
+                        let group = !tags.length               ? "" :
+                                    !tags.some(t => t == beta) ? "HelpNewsOld" : "HelpNewsNew";
                         if (i === 0 && li) {
                             li[1]["dactyl:highlight"] = group;
                             group = "";
@@ -307,7 +307,7 @@ var Help = Module("Help", {
             let empty = Set("area base basefont br col frame hr img input isindex link meta param"
                                 .split(" "));
             function fix(node) {
-                switch(node.nodeType) {
+                switch (node.nodeType) {
                 case Ci.nsIDOMNode.ELEMENT_NODE:
                     if (isinstance(node, [Ci.nsIDOMHTMLBaseElement]))
                         return;
@@ -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(function () 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 = [
@@ -381,9 +381,9 @@ var Help = Module("Help", {
             }
 
             let data = [h for (h in highlight) if (Set.has(styles, h.class) || /^Help/.test(h.class))]
-                .map(function (h) h.selector
-                                   .replace(/^\[.*?=(.*?)\]/, ".hl-$1")
-                                   .replace(/html\|/g, "") + "\t" + "{" + h.cssText + "}")
+                .map(h => h.selector
+                           .replace(/^\[.*?=(.*?)\]/, ".hl-$1")
+                           .replace(/html\|/g, "") + "\t" + "{" + h.cssText + "}")
                 .join("\n");
             addDataEntry("help.css", data.replace(/chrome:[^ ")]+\//g, ""));
 
@@ -444,7 +444,7 @@ var Help = Module("Help", {
     },
     javascript: function initJavascript(dactyl, modules, window) {
         modules.JavaScript.setCompleter([modules.help.exportHelp],
-            [function (context, args) overlay.activeModules.completion.file(context)]);
+            [(context, args) => overlay.activeModules.completion.file(context)]);
     },
     options: function initOptions(dactyl, modules, window) {
         const { options } = modules;
index fca93478b3f7ce514cabba374e700eaf5bde62a8..e25b7cc1f5d71adee0103944a26321b8326be465 100644 (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.
@@ -57,22 +57,22 @@ Highlight.defaultValue("sites", function ()
 Highlight.defaultValue("style", function ()
     styles.system.add("highlight:" + this.class, this.sites, this.css, this.agent, true));
 
-Highlight.defaultValue("defaultExtends", function () []);
-Highlight.defaultValue("defaultValue", function () "");
+Highlight.defaultValue("defaultExtends", () => []);
+Highlight.defaultValue("defaultValue", () => "");
 Highlight.defaultValue("extends", function () this.defaultExtends);
 Highlight.defaultValue("value", function () this.defaultValue);
 
 update(Highlight.prototype, {
     get base() this.baseClass != this.class && highlight.highlight[this.baseClass] || null,
 
-    get bases() array.compact(this.extends.map(function (name) highlight.get(name))),
+    get bases() array.compact(this.extends.map(name => highlight.get(name))),
 
     get inheritedCSS() {
         if (this.gettingCSS)
             return "";
         try {
             this.gettingCSS = true;
-            return this.bases.map(function (b) b.cssText.replace(/;?\s*$/, "; ")).join("");
+            return this.bases.map(b => b.cssText.replace(/;?\s*$/, "; ")).join("");
         }
         finally {
             this.gettingCSS = false;
@@ -100,7 +100,7 @@ var Highlights = Module("Highlight", {
 
     keys: function keys() Object.keys(this.highlight).sort(),
 
-    __iterator__: function () values(this.highlight).sort(function (a, b) String.localeCompare(a.class, b.class))
+    __iterator__: function () values(this.highlight).sort((a, b) => String.localeCompare(a.class, b.class))
                                                     .iterValues(),
 
     _create: function _create(agent, args) {
@@ -282,8 +282,8 @@ var Highlights = Module("Highlight", {
      */
     loadCSS: function loadCSS(css, eager) {
         String.replace(css, /\\\n/g, "")
-              .replace(this.groupRegexp, function (m, m1, m2) m1 + " " + m2.replace(/\n\s*/g, " "))
-              .split("\n").filter(function (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);
@@ -352,9 +352,9 @@ var Highlights = Module("Highlight", {
                              "text-align: center"],
                             ([h.class,
                               ["span", { style: "text-align: center; line-height: 1em;" + h.value + style }, "XXX"],
-                              template.map(h.extends, function (s) template.highlight(s), ","),
+                              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))));
@@ -395,7 +395,7 @@ var Highlights = Module("Highlight", {
                         completer: function (context, args) {
                             let group = args[0] && highlight.get(args[0]);
                             if (group)
-                                context.fork("extra", 0, this, function (context) [
+                                context.fork("extra", 0, this, context => [
                                      [String(group.extends), _("option.currentValue")],
                                      [String(group.defaultExtends) || "", _("option.defaultValue")]
                                 ]);
@@ -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(
-                            function (dir) dir.readDirectory().filter(
-                                function (file) extRe.test(file.leafName))))
+                            dir => dir.readDirectory()
+                                      .filter(file => extRe.test(file.leafName))))
                      .concat([
                         { leafName: "default", parent: { path: /*L*/"Revert to builtin colorscheme" } }
                      ]);
@@ -442,10 +443,10 @@ var Highlights = Module("Highlight", {
         };
     },
     javascript: function initJavascript(dactyl, modules, window) {
-        modules.JavaScript.setCompleter(["get", "set"].map(function (m) highlight[m]),
-            [ function (context, obj, args) Iterator(highlight.highlight) ]);
-        modules.JavaScript.setCompleter(["highlightNode"].map(function (m) highlight[m]),
-            [ null, function (context, obj, args) Iterator(highlight.highlight) ]);
+        modules.JavaScript.setCompleter(["get", "set"].map(m => highlight[m]),
+            [ (context, obj, args) => Iterator(highlight.highlight) ]);
+        modules.JavaScript.setCompleter(["highlightNode"].map(m => highlight[m]),
+            [ null, (context, obj, args) => Iterator(highlight.highlight) ]);
     }
 });
 
index 8a3a06b2994c4f7a7e40a39c28c361f9b0b71bdd..4a61d67313b74d7e1c3a2092a44ef7ea027c1125 100644 (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
@@ -74,8 +74,8 @@ var IO = Module("io", {
          */
         getRuntimeDirectories: function getRuntimeDirectories(name) {
             return modules.options.get("runtimepath").files
-                .map(function (dir) dir.child(name))
-                .filter(function (dir) dir.exists() && dir.isDirectory() && dir.isReadable());
+                .map(dir => dir.child(name))
+                .filter(dir => (dir.exists() && dir.isDirectory() && dir.isReadable()));
         },
 
         // FIXME: multiple paths?
@@ -241,11 +241,13 @@ var IO = Module("io", {
     /**
      * Sets the current working directory.
      *
-     * @param {string} newDir The new CWD. This may be a relative or
+     * @param {File|string} newDir The new CWD. This may be a relative or
      *     absolute path and is expanded by {@link #expandPath}.
+     *     @optional
+     *     @default = "~"
      */
-    set cwd(newDir) {
-        newDir = newDir && newDir.path || newDir || "~";
+    set cwd(newDir = "~") {
+        newDir = newDir.path || newDir;
 
         if (newDir == "-") {
             util.assert(this._oldcwd != null, _("io.noPrevDir"));
@@ -266,8 +268,8 @@ var IO = Module("io", {
      */
     File: Class.Memoize(function () let (io = this)
         Class("File", File, {
-            init: function init(path, checkCWD)
-                init.supercall(this, path, (arguments.length < 2 || checkCWD) && io.cwd)
+            init: function init(path, checkCWD=true)
+                init.supercall(this, path, checkCWD && io.cwd)
         })),
 
     /**
@@ -502,7 +504,9 @@ var IO = Module("io", {
 
             function async(status) {
                 let output = stdout.read();
-                [stdin, stdout, cmd].forEach(function (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 +554,7 @@ var IO = Module("io", {
         }
         finally {
             if (!checked || res !== true)
-                args.forEach(function (f) f.remove(false));
+                args.forEach(f => { f.remove(false); });
         }
         return res;
     }
@@ -806,7 +810,9 @@ unlet s:cpo_save
                         lines.last.push(item, sep);
                     }
                     lines.last.pop();
-                    return lines.map(function (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 +910,8 @@ unlet s:cpo_save
                         _("command.run.noPrevious"));
 
                     arg = arg.replace(/(\\)*!/g,
-                        function (m) /^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!") : m.replace("!", io._lastRunCommand)
-                    );
+                                      m => (/^\\(\\\\)*!$/.test(m) ? m.replace("\\!", "!")
+                                                                   : m.replace("!", io._lastRunCommand)));
                 }
 
                 io._lastRunCommand = arg;
@@ -942,21 +948,21 @@ unlet s:cpo_save
                     }
                 }
             };
-            context.generate = function () iter(services.charset.getDecoderList());
+            context.generate = () => iter(services.charset.getDecoderList());
         };
 
         completion.directory = function directory(context, full) {
             this.file(context, full);
-            context.filters.push(function (item) item.isdir);
+            context.filters.push(item => item.isdir);
         };
 
         completion.environment = function environment(context) {
             context.title = ["Environment Variable", "Value"];
-            context.generate = function ()
+            context.generate = () =>
                 io.system(config.OS.isWindows ? "set" : "env")
                   .output.split("\n")
-                  .filter(function (line) line.indexOf("=") > 0)
-                  .map(function (line) line.match(/([^=]+)=(.*)/).slice(1));
+                  .filter(line => line.indexOf("=") > 0)
+                  .map(line => line.match(/([^=]+)=(.*)/).slice(1));
         };
 
         completion.file = function file(context, full, dir) {
@@ -983,10 +989,10 @@ unlet s:cpo_save
                 icon: function (f) this.isdir ? "resource://gre/res/html/folder.png"
                                               : "moz-icon://" + f.leafName
             };
-            context.compare = function (a, b) b.isdir - a.isdir || String.localeCompare(a.text, b.text);
+            context.compare = (a, b) => b.isdir - a.isdir || String.localeCompare(a.text, b.text);
 
             if (modules.options["wildignore"])
-                context.filters.push(function (item) !modules.options.get("wildignore").getKey(item.path));
+                context.filters.push(item => !modules.options.get("wildignore").getKey(item.path));
 
             // context.background = true;
             context.key = dir;
@@ -1054,7 +1060,7 @@ unlet s:cpo_save
                 if (!match.path) {
                     context.key = match.proto;
                     context.advance(match.proto.length);
-                    context.generate = function () config.chromePackages.map(function (p) [p, match.proto + p + "/"]);
+                    context.generate = () => config.chromePackages.map(p => [p, match.proto + p + "/"]);
                 }
                 else if (match.scheme === "chrome") {
                     context.key = match.prefix;
@@ -1121,8 +1127,8 @@ unlet s:cpo_save
             "List of directories searched when executing :cd",
             "stringlist", ["."].concat(services.environment.get("CDPATH").split(/[:;]/).filter(util.identity)).join(","),
             {
-                get files() this.value.map(function (path) File(path, modules.io.cwd))
-                                .filter(function (dir) dir.exists()),
+                get files() this.value.map(path => File(path, modules.io.cwd))
+                                .filter(dir => dir.exists()),
                 setter: function (value) File.expandPathList(value)
             });
 
@@ -1130,8 +1136,8 @@ unlet s:cpo_save
             "List of directories searched for runtime files",
             "stringlist", IO.runtimePath,
             {
-                get files() this.value.map(function (path) File(path, modules.io.cwd))
-                                .filter(function (dir) dir.exists())
+                get files() this.value.map(path => File(path, modules.io.cwd))
+                                .filter(dir => dir.exists())
             });
 
         options.add(["shell", "sh"],
index b74c86f48f53ced9f1affd7cceb9cc2ad65c33c3..dcf206bfacce9b93c66e2e10131ef28c86748369 100644 (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.
@@ -57,7 +57,7 @@ var JavaScript = Module("javascript", {
 
     newContext: function () this.modules.newContext(this.modules.userContext, true, "Dactyl JS Temp Context"),
 
-    completers: Class.Memoize(function () Object.create(JavaScript.completers)),
+    completers: Class.Memoize(() => Object.create(JavaScript.completers)),
 
     // Some object members are only accessible as function calls
     getKey: function (obj, key) {
@@ -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(function (idx) idx >= start && idx < end);
+        let res = this._functions.some(idx => (idx >= start && idx < end));
         if (!res || this.context.tabPressed || key in this.cache.evalled)
             return false;
         this.context.waitingForTab = true;
@@ -345,11 +345,11 @@ var JavaScript = Module("javascript", {
         let prefix  = last != null ? key : "";
 
         if (last == null) // We're not looking for a quoted string, so filter out anything that's not a valid identifier
-            base.filters.push(function (item) /^[a-zA-Z_$][\w$]*$/.test(item.text));
+            base.filters.push(item => /^[a-zA-Z_$][\w$]*$/.test(item.text));
         else {
-            base.quote = [last, function (text) util.escapeString(text, ""), last];
+            base.quote = [last, text => util.escapeString(text, ""), last];
             if (prefix)
-                base.filters.push(function (item) item.item.indexOf(prefix) === 0);
+                base.filters.push(item => item.item.indexOf(prefix) === 0);
         }
 
         if (!compl) {
@@ -371,7 +371,8 @@ var JavaScript = Module("javascript", {
             };
 
             base.keys = {
-                text: prefix ? function (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))
@@ -389,7 +390,7 @@ var JavaScript = Module("javascript", {
         objects.forEach(function (obj) {
             let context = base.fork(obj[1]);
             context.title = [obj[1]];
-            context.keys.obj = function () obj[0];
+            context.keys.obj = () => obj[0];
             context.key = obj[1] + last;
             if (obj[0] == this.cache.evalContext)
                 context.regenerate = true;
@@ -397,8 +398,8 @@ var JavaScript = Module("javascript", {
             obj.ctxt_t = context.fork("toplevel");
             if (!compl) {
                 obj.ctxt_p = context.fork("prototypes");
-                obj.ctxt_t.generate = function () self.objectKeys(obj[0], true);
-                obj.ctxt_p.generate = function () self.objectKeys(obj[0], false);
+                obj.ctxt_t.generate = () => self.objectKeys(obj[0], true);
+                obj.ctxt_p.generate = () => self.objectKeys(obj[0], false);
             }
         }, this);
 
@@ -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, ")"];
                     }
@@ -563,7 +564,7 @@ var JavaScript = Module("javascript", {
                 for (let [i, idx] in Iterator(this._get(-2).comma)) {
                     let arg = this._str.substring(prev + 1, idx);
                     prev = idx;
-                    memoize(args, i, function () self.evalled(arg));
+                    memoize(args, i, () => self.evalled(arg));
                 }
                 let key = this._getKey();
                 args.push(key + string);
@@ -641,7 +642,7 @@ var JavaScript = Module("javascript", {
     ].concat([k.substr(6) for (k in keys(Ci)) if (/^nsIDOM/.test(k))])
      .concat([k.substr(3) for (k in keys(Ci)) if (/^nsI/.test(k))])
      .concat(this.magicalNames)
-     .filter(function (k) k in self.window))),
+     .filter(k => k in self.window))),
 
 }, {
     EVAL_TMP: "__dactyl_eval_tmp",
@@ -775,7 +776,7 @@ var JavaScript = Module("javascript", {
                 this.js.globals = [
                    [this.context, /*L*/"REPL Variables"],
                    [context, /*L*/"REPL Global"]
-                ].concat(this.js.globals.filter(function ([global]) isPrototypeOf.call(global, context)));
+                ].concat(this.js.globals.filter(([global]) => isPrototypeOf.call(global, context)));
 
                 if (!isPrototypeOf.call(modules.jsmodules, context))
                     this.js.toplevel = context;
@@ -783,7 +784,7 @@ var JavaScript = Module("javascript", {
                 if (!isPrototypeOf.call(window, context))
                     this.js.window = context;
 
-                if (this.js.globals.slice(2).some(function ([global]) global === context))
+                if (this.js.globals.slice(2).some(([global]) => global === context))
                     this.js.globals.splice(1);
 
                 this.repl = REPL(this.context);
index ae6926d003589188bc6c1e821076575c24428bb4..19e36b46a11574f9bd27e16ec7a69e24c867ee3a 100644 (file)
@@ -149,9 +149,9 @@ var Modules = function Modules(window) {
 
         get ownPropertyValues() array.compact(
                 Object.getOwnPropertyNames(this)
-                      .map(function (name) Object.getOwnPropertyDescriptor(this, name).value, this)),
+                      .map(name => Object.getOwnPropertyDescriptor(this, name).value)),
 
-        get moduleList() this.ownPropertyValues.filter(function (mod) mod instanceof this.ModuleBase || mod.isLocalModule, this)
+        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(function (name) defineModule.time("load", name, modules.load, modules, name));
+                  .forEach(name => { defineModule.time("load", name, modules.load, modules, name); });
         }, this);
     },
 
@@ -224,7 +225,7 @@ overlay.overlayWindow(Object.keys(config.overlays), function _overlay(window) ({
     },
 
     cleanup: function cleanup(window) {
-        overlay.windows = overlay.windows.filter(function (w) w != window);
+        overlay.windows = overlay.windows.filter(w => w != window);
     },
 
     unload: function unload(window) {
index 533c0043d5686f25a90e4962156a33a5893a0dd1..36fead2c19abd57265800d202bf0e6bfbb85ae4d 100644 (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.
@@ -11,9 +11,9 @@ defineModule("messages", {
 
 var Messages = Module("messages", {
 
-    init: function init(name) {
+    init: function init(name = "messages") {
         let self = this;
-        this.name = name || "messages";
+        this.name = name;
 
         this._ = Class("_", String, {
             init: function _(message) {
@@ -97,10 +97,9 @@ var Messages = Module("messages", {
         let { Buffer, commands, hints, io, mappings, modes, options, sanitizer } = overlay.activeModules;
         file = io.File(file);
 
-        function properties(base, iter_, prop) iter(function _properties() {
+        function properties(base, iter_, prop = "description") iter(function _properties() {
             function key(...args) [base, obj.identifier || obj.name].concat(args).join(".").replace(/[\\:=]/g, "\\$&");
 
-            prop = prop || "description";
             for (var obj in iter_) {
                 if (!obj.hive || obj.hive.name !== "user") {
                     yield key(prop) + " = " + obj[prop];
@@ -119,11 +118,11 @@ var Messages = Module("messages", {
         }()).toArray();
 
         file.write(
-            array(commands.allHives.map(function (h) properties("command", h)))
-                          .concat(modes.all.map(function (m)
+            array(commands.allHives.map(h => properties("command", h)))
+                          .concat(modes.all.map(m =>
                               properties("map", values(mappings.builtin.getStack(m)
-                                                               .filter(function (map) map.modes[0] == m)))))
-                          .concat(properties("mode", values(modes.all.filter(function (m) !m.hidden))))
+                                                               .filter(map => map.modes[0] == m)))))
+                          .concat(properties("mode", values(modes.all.filter(m => !m.hidden))))
                           .concat(properties("option", options))
                           .concat(properties("hintmode", values(hints.modes), "prompt"))
                           .concat(properties("pageinfo", values(Buffer.pageInfo), "title"))
@@ -168,7 +167,7 @@ var Messages = Module("messages", {
                                 });
                             else
                                 iter(value).forEach(function ([k, v]) {
-                                    memoize(value, k, function () messages.get([name, k].join("."), v));
+                                    memoize(value, k, () => messages.get([name, k].join("."), v));
                                 });
                         }
 
@@ -187,7 +186,7 @@ var Messages = Module("messages", {
         let { JavaScript } = modules;
 
         JavaScript.setCompleter([this._, this.get, this.format], [
-            function (context) messages.iterate()
+            context => messages.iterate()
         ]);
 
         JavaScript.setCompleter([this.export],
index ac5ceb98cb7ef4400d9c0728e0363a661def1cc5..77439afe11273f8c0c7a6513efd7d1ed204d45f9 100644 (file)
@@ -75,7 +75,7 @@ var Option = Class("Option", {
     get helpTag() "'" + this.name + "'",
 
     initValue: function initValue() {
-        util.trapErrors(function () this.value = this.value, this);
+        util.trapErrors(() => { this.value = this.value; });
     },
 
     get isDefault() this.stringValue === this.stringDefaultValue,
@@ -203,7 +203,7 @@ var Option = Class("Option", {
      *
      * @returns {boolean}
      */
-    has: function has() Array.some(arguments, function (val) this.value.indexOf(val) >= 0, this),
+    has: function has() Array.some(arguments, val => this.value.indexOf(val) >= 0),
 
     /**
      * Returns whether this option is identified by *name*.
@@ -318,7 +318,7 @@ var Option = Class("Option", {
      *     references to a given domain from the given values.
      */
     filterDomain: function filterDomain(host, values)
-        Array.filter(values, function (val) !this.domains([val]).some(function (val) util.isSubdomain(val, host)), this),
+        Array.filter(values, val => !this.domains([val]).some(val => util.isSubdomain(val, host))),
 
     /**
      * @property {value} The option's default value. This value will be used
@@ -344,8 +344,8 @@ var Option = Class("Option", {
         if (isArray(defaultValue))
             defaultValue = defaultValue.map(Option.quote).join(",");
         else if (isObject(defaultValue))
-            defaultValue = iter(defaultValue).map(function (val) val.map(function (v) Option.quote(v, /:/))
-                                                                    .join(":"))
+            defaultValue = iter(defaultValue).map(val => val.map(v => Option.quote(v, /:/))
+                                                            .join(":"))
                                              .join(",");
 
         if (isArray(defaultValue))
@@ -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,
@@ -479,11 +480,11 @@ var Option = Class("Option", {
         stringlist: function stringlist(k) this.value.indexOf(k) >= 0,
         get charlist() this.stringlist,
 
-        regexplist: function regexplist(k, default_) {
+        regexplist: function regexplist(k, default_=null) {
             for (let re in values(this.value))
                 if ((re.test || re).call(re, k))
                     return re.result;
-            return arguments.length > 1 ? default_ : null;
+            return default_;
         },
         get regexpmap() this.regexplist,
         get sitelist() this.regexplist,
@@ -491,7 +492,7 @@ var Option = Class("Option", {
     },
 
     domains: {
-        sitelist: function (vals) array.compact(vals.map(function (site) util.getHost(site.filter))),
+        sitelist: function (vals) array.compact(vals.map(site => util.getHost(site.filter))),
         get sitemap() this.sitelist
     },
 
@@ -520,7 +521,7 @@ var Option = Class("Option", {
 
         regexplist: function regexplist(value) (value === "") ? [] :
             Option.splitList(value, true)
-                  .map(function (re) Option.parseRegexp(re, undefined, this.regexpFlags), this),
+                  .map(re => Option.parseRegexp(re, undefined, this.regexpFlags)),
 
         sitelist: function sitelist(value) {
             if (value === "")
@@ -558,7 +559,7 @@ var Option = Class("Option", {
     },
 
     testValues: {
-        regexpmap:  function regexpmap(vals, validator) vals.every(function (re) validator(re.result)),
+        regexpmap:  function regexpmap(vals, validator) vals.every(re => validator(re.result)),
         get sitemap() this.regexpmap,
         stringlist: function stringlist(vals, validator) vals.every(validator, this),
         stringmap:  function stringmap(vals, validator) values(vals).every(validator, this)
@@ -587,7 +588,7 @@ var Option = Class("Option", {
         return res;
     },
 
-    quote: function quote(str, re) isArray(str) ? str.map(function (s) quote(s, re)).join(",") :
+    quote: function quote(str, re) isArray(str) ? str.map(s => quote(s, re)).join(",") :
         Commands.quoteArg[/[\s|"'\\,]|^$/.test(str) || re && re.test && re.test(str)
             ? (/[\b\f\n\r\t]/.test(str) ? '"' : "'")
             : ""](str, re),
@@ -671,7 +672,7 @@ var Option = Class("Option", {
 
             function uniq(ary) {
                 let seen = {};
-                return ary.filter(function (elem) !Set.add(seen, elem));
+                return ary.filter(elem => !Set.add(seen, elem));
             }
 
             switch (operator) {
@@ -716,7 +717,7 @@ var Option = Class("Option", {
         function completions(extra) {
             let context = CompletionContext("");
             return context.fork("", 0, this, this.completer, extra) ||
-                   context.allItems.items.map(function (item) [item.text]);
+                   context.allItems.items.map(item => [item.text]);
         };
 
         if (isObject(vals) && !isArray(vals)) {
@@ -731,10 +732,10 @@ var Option = Class("Option", {
             acceptable = completions.call(this);
 
         if (isArray(acceptable))
-            acceptable = Set(acceptable.map(function ([k]) k));
+            acceptable = Set(acceptable.map(([k]) => (k)));
 
         if (this.type === "regexpmap" || this.type === "sitemap")
-            return Array.concat(vals).every(function (re) Set.has(acceptable, re.result));
+            return Array.concat(vals).every(re => Set.has(acceptable, re.result));
 
         return Array.concat(vals).every(Set.has(acceptable));
     },
@@ -821,7 +822,7 @@ var Options = Module("options", {
                     opt.set(opt.globalValue, Option.SCOPE_GLOBAL, true);
             }, window);
 
-            modules.cache.register("options.dtd", function ()
+            modules.cache.register("options.dtd", () =>
                 util.makeDTD(
                     iter(([["option", o.name, "default"].join("."),
                            o.type === "string" ? o.defaultValue.replace(/'/g, "''") :
@@ -877,7 +878,7 @@ var Options = Module("options", {
                     else if (isArray(opt.value) && opt.type != "charlist")
                         option.value = ["", "=",
                                         template.map(opt.value,
-                                                     function (v) template.highlight(String(v)),
+                                                     v => template.highlight(String(v)),
                                                      ["", ",",
                                                       ["span", { style: "width: 0; display: inline-block" }, " "]])];
                     else
@@ -927,7 +928,9 @@ var Options = Module("options", {
 
             let closure = () => this._optionMap[name];
 
-            memoize(this._optionMap, name, function () 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);
 
@@ -948,7 +951,7 @@ var Options = Module("options", {
 
     /** @property {Iterator(Option)} @private */
     __iterator__: function __iterator__()
-        values(this._options.sort(function (a, b) String.localeCompare(a.name, b.name))),
+        values(this._options.sort((a, b) => String.localeCompare(a.name, b.name))),
 
     allPrefs: deprecated("prefs.getNames", function allPrefs() prefs.getNames.apply(prefs, arguments)),
     getPref: deprecated("prefs.get", function getPref() prefs.get.apply(prefs, arguments)),
@@ -963,7 +966,7 @@ var Options = Module("options", {
     setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
     withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
 
-    cleanupPrefs: Class.Memoize(function () config.prefs.Branch("cleanup.option.")),
+    cleanupPrefs: Class.Memoize(() => config.prefs.Branch("cleanup.option.")),
 
     cleanup: function cleanup(reason) {
         if (~["disable", "uninstall"].indexOf(reason))
@@ -1059,7 +1062,7 @@ var Options = Module("options", {
      */
     remove: function remove(name) {
         let opt = this.get(name);
-        this._options = this._options.filter(function (o) o != opt);
+        this._options = this._options.filter(o => o != opt);
         for (let name in values(opt.names))
             delete this._optionMap[name];
     },
@@ -1095,12 +1098,14 @@ var Options = Module("options", {
 
             let list = [];
             function flushList() {
-                let names = Set(list.map(function (opt) opt.option ? opt.option.name : ""));
+                let names = Set(list.map(opt => opt.option ? opt.option.name : ""));
                 if (list.length)
-                    if (list.some(function (opt) opt.all))
-                        options.list(function (opt) !(list[0].onlyNonDefault && opt.isDefault), list[0].scope);
+                    if (list.some(opt => opt.all))
+                        options.list(opt => !(list[0].onlyNonDefault && opt.isDefault),
+                                     list[0].scope);
                     else
-                        options.list(function (opt) Set.has(names, opt.name), list[0].scope);
+                        options.list(opt => Set.has(names, opt.name),
+                                     list[0].scope);
                 list = [];
             }
 
@@ -1212,11 +1217,11 @@ var Options = Module("options", {
                     context.advance(filter.length);
                     filter = filter.substr(0, filter.length - 1);
 
-                    context.pushProcessor(0, function (item, text, next) next(item, text.substr(0, 100)));
+                    context.pushProcessor(0, (item, text, next) => next(item, text.substr(0, 100)));
                     context.completions = [
                             [prefs.get(filter), _("option.currentValue")],
                             [prefs.defaults.get(filter), _("option.defaultValue")]
-                    ].filter(function (k) k[0] != null);
+                    ].filter(k => k[0] != null);
                     return null;
                 }
 
@@ -1229,8 +1234,12 @@ var Options = Module("options", {
             context.highlight();
             if (context.filter.indexOf("=") == -1) {
                 if (false && prefix)
-                    context.filters.push(function ({ 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) {
@@ -1256,11 +1265,11 @@ var Options = Module("options", {
             if (!opt.value && !opt.operator && !opt.invert) {
                 context.fork("default", 0, this, function (context) {
                     context.title = ["Extra Completions"];
-                    context.pushProcessor(0, function (item, text, next) next(item, text.substr(0, 100)));
+                    context.pushProcessor(0, (item, text, next) => next(item, text.substr(0, 100)));
                     context.completions = [
                             [option.stringValue, _("option.currentValue")],
                             [option.stringDefaultValue, _("option.defaultValue")]
-                    ].filter(function (f) f[0] !== "");
+                    ].filter(f => f[0] !== "");
                     context.quote = ["", util.identity, ""];
                 });
             }
@@ -1275,10 +1284,10 @@ var Options = Module("options", {
                 context.anchored = optcontext.anchored;
                 context.maxItems = optcontext.maxItems;
 
-                context.filters.push(function (i) !Set.has(have, i.text));
+                context.filters.push(i => !Set.has(have, i.text));
                 modules.completion.optionValue(context, opt.name, opt.operator, null,
                                        function (context) {
-                                           context.generate = function () option.value.map(function (o) [o, ""]);
+                                           context.generate = () => option.value.map(o => [o, ""]);
                                        });
                 context.title = ["Current values"];
             }
@@ -1426,11 +1435,11 @@ var Options = Module("options", {
             context.anchored = false;
             context.completions = modules.options;
             if (prefix == "inv")
-                context.keys.text = function (opt)
-                    opt.type == "boolean" || isArray(opt.value) ? opt.names.map(function (n) "inv" + n)
+                context.keys.text = opt =>
+                    opt.type == "boolean" || isArray(opt.value) ? opt.names.map(n => "inv" + n)
                                                                 : opt.names;
             if (scope)
-                context.filters.push(function ({ item }) item.scope & scope);
+                context.filters.push(({ item }) => item.scope & scope);
         };
 
         completion.optionValue = function (context, name, op, curValue, completer) {
@@ -1484,7 +1493,8 @@ var Options = Module("options", {
 
             function val(obj) {
                 if (isArray(opt.defaultValue)) {
-                    let val = array.nth(obj, function (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(function (f) f[0] !== "" && f[0] != null);
+                    ].filter(f => (f[0] !== "" && f[0] != null));
                 });
                 context = context.fork("stuff", 0);
             }
@@ -1506,17 +1516,17 @@ var Options = Module("options", {
             // Not Vim compatible, but is a significant enough improvement
             // that it's worth breaking compatibility.
             if (isArray(newValues)) {
-                context.filters.push(function (i) newValues.indexOf(i.text) == -1);
+                context.filters.push(i => newValues.indexOf(i.text) == -1);
                 if (op == "+")
-                    context.filters.push(function (i) curValues.indexOf(i.text) == -1);
+                    context.filters.push(i => curValues.indexOf(i.text) == -1);
                 if (op == "-")
-                    context.filters.push(function (i) curValues.indexOf(i.text) > -1);
+                    context.filters.push(i => curValues.indexOf(i.text) > -1);
 
                 memoize(extra, "values", function () {
                     if (op == "+")
                         return curValues.concat(newValues);
                     if (op == "-")
-                        return curValues.filter(function (v) newValues.indexOf(val) == -1);
+                        return curValues.filter(v => newValues.indexOf(val) == -1);
                     return newValues;
                 });
             }
@@ -1528,7 +1538,7 @@ var Options = Module("options", {
     },
     javascript: function initJavascript(dactyl, modules, window) {
         const { options, JavaScript } = modules;
-        JavaScript.setCompleter(Options.prototype.get, [function () ([o.name, o.description] for (o in options))]);
+        JavaScript.setCompleter(Options.prototype.get, [() => ([o.name, o.description] for (o in options))]);
     },
     sanitizer: function initSanitizer(dactyl, modules, window) {
         const { sanitizer } = modules;
index 560982c2d266352119f13331f7004043ba646485..c52ba4ad95a9fceb4d599fa9131b302854be3a4f 100644 (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.
@@ -27,8 +27,8 @@ var Overlay = Class("Overlay", {
         this.window = window;
     },
 
-    cleanups: Class.Memoize(function () []),
-    objects: Class.Memoize(function () ({})),
+    cleanups: Class.Memoize(() => []),
+    objects: Class.Memoize(() => ({})),
 
     get doc() this.window.document,
 
@@ -52,7 +52,7 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
         this.onWindowVisible = [];
     },
 
-    id: Class.Memoize(function () config.addon.id),
+    id: Class.Memoize(() => config.addon.id),
 
     /**
      * Adds an event listener for this session and removes it on
@@ -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 {
@@ -281,10 +281,10 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
             }
         }
 
-        insert("before", function (elem, dom) elem.parentNode.insertBefore(dom, elem));
-        insert("after", function (elem, dom) elem.parentNode.insertBefore(dom, elem.nextSibling));
-        insert("append", function (elem, dom) elem.appendChild(dom));
-        insert("prepend", function (elem, dom) elem.insertBefore(dom, elem.firstChild));
+        insert("before", (elem, dom) => elem.parentNode.insertBefore(dom, elem));
+        insert("after", (elem, dom) => elem.parentNode.insertBefore(dom, elem.nextSibling));
+        insert("append", (elem, dom) => elem.appendChild(dom));
+        insert("prepend", (elem, dom) => elem.insertBefore(dom, elem.firstChild));
         if (obj.ready)
             util.trapErrors("ready", obj, window);
 
@@ -412,19 +412,19 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen
 
     get activeModules() this.activeWindow && this.activeWindow.dactyl.modules,
 
-    get modules() this.windows.map(function (w) w.dactyl.modules),
+    get modules() this.windows.map(w => w.dactyl.modules),
 
     /**
      * The most recently active dactyl window.
      */
     get activeWindow() this.windows[0],
 
-    set activeWindow(win) this.windows = [win].concat(this.windows.filter(function (w) w != win)),
+    set activeWindow(win) this.windows = [win].concat(this.windows.filter(w => w != win)),
 
     /**
      * A list of extant dactyl windows.
      */
-    windows: Class.Memoize(function () [])
+    windows: Class.Memoize(() => [])
 });
 
 endModule();
index d01d1c26041237d746f7a70f815bea9b902dc021..47fec508aafeb08c2fb4d63c998e8bf9ffa4d46b 100644 (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,13 +423,14 @@ 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();
         };
     },
     javascript: function init_javascript(dactyl, modules) {
         modules.JavaScript.setCompleter([this.get, this.safeSet, this.set, this.reset, this.toggle],
-                [function (context) (context.anchored=false, this.getNames().map(function (pref) [pref, ""]))]);
+                [function (context) (context.anchored=false, this.getNames().map(pref => [pref, ""]))]);
     }
 });
 
index 01b0ecad1b750f0ee7238f0b9da099182bdf589d..2db1dfe54d1455ce9faebf3933e788649b8f84bd 100644 (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.
@@ -171,7 +171,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
             before: [
                 ["preferences", { id: branch.substr(Item.PREFIX.length) + "history",
                                   xmlns: "xul" },
-                  template.map(ourItems(persistent), function (item)
+                  template.map(ourItems(persistent), item =>
                       ["preference", { type: "bool", id: branch + item.name, name: branch + item.name }])]
             ],
             init: function init(win) {
@@ -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" },
@@ -197,9 +197,9 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                                     ["column", { flex: "1" }]],
                                 ["rows", {},
                                   let (items = ourItems(true))
-                                     template.map(util.range(0, Math.ceil(items.length / 2)), function (i)
+                                     template.map(util.range(0, Math.ceil(items.length / 2)), i =>
                                          ["row", {},
-                                             template.map(items.slice(i * 2, i * 2 + 2), function (item)
+                                             template.map(items.slice(i * 2, i * 2 + 2), item =>
                                                 ["checkbox", { xmlns: XUL, label: item.description, preference: branch + item.name }])])]]]
                     }
                 }));
@@ -211,7 +211,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                         itemList: [
                             ["listitem", { xmlns: "xul", label: /*L*/"See :help privacy for the following:",
                                            disabled: "true", style: "font-style: italic; font-weight: bold;" }],
-                            template.map(ourItems(), function ([item, desc])
+                            template.map(ourItems(), ([item, desc]) =>
                                 ["listitem", { xmlns: "xul", preference: branch + item,
                                                type: "checkbox", label: config.appName + ", " + desc,
                                                onsyncfrompreference: "return gSanitizePromptDialog.onReadGeneric();" }])
@@ -247,7 +247,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
             if (!("value" in prop) || !callable(prop.value) && !(k in item))
                 Object.defineProperty(item, k, prop);
 
-        let names = Set([name].concat(params.contains || []).map(function (e) "clear-" + e));
+        let names = Set([name].concat(params.contains || []).map(e => "clear-" + e));
         if (params.action)
             storage.addObserver("sanitizer",
                 function (key, event, arg) {
@@ -466,7 +466,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                         sanitizer.sanitize(items, range);
                 }
 
-                if (array.nth(opt.value, function (i) i == "all" || /^!/.test(i), 0) == "all" && !args["-host"])
+                if (array.nth(opt.value, i => i == "all" || /^!/.test(i), 0) == "all" && !args["-host"])
                     modules.commandline.input(_("sanitize.prompt.deleteAll") + " ",
                         function (resp) {
                             if (resp.match(/^y(es)?$/i)) {
@@ -493,8 +493,8 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                         names: ["-host", "-h"],
                         description: "Only sanitize items referring to listed host or hosts",
                         completer: function (context, args) {
-                            context.filters.push(function (item)
-                                !args["-host"].some(function (host) util.isSubdomain(item.text, host)));
+                            context.filters.push(item =>
+                                !args["-host"].some(host => util.isSubdomain(item.text, host)));
                             modules.completion.domain(context);
                         },
                         type: modules.CommandOption.LIST
@@ -586,7 +586,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
     completion: function initCompletion(dactyl, modules, window) {
         modules.completion.visibleHosts = function completeHosts(context) {
             let res = util.visibleHosts(window.content);
-            if (context.filter && !res.some(function (host) host.indexOf(context.filter) >= 0))
+            if (context.filter && !res.some(host => host.indexOf(context.filter) >= 0))
                 res.push(context.filter);
 
             context.title = ["Domain"];
@@ -612,11 +612,12 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                 },
 
                 has: function has(val)
-                    let (res = array.nth(this.value, function (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(function (val) val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, "")))
+                    values.every(val => (val === "all" || Set.has(sanitizer.itemMap, val.replace(/^!/, ""))))
             });
 
         options.add(["sanitizeshutdown", "ss"],
@@ -679,7 +680,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                 ],
                 getter: function () (this.values[prefs.get(this.PREF)] || ["all"])[0],
                 setter: function (val) {
-                    prefs.set(this.PREF, this.values.map(function (i) i[0]).indexOf(val));
+                    prefs.set(this.PREF, this.values.map(i => i[0]).indexOf(val));
                     return val;
                 },
                 initialValue: true,
@@ -698,7 +699,7 @@ var Sanitizer = Module("sanitizer", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakRef
                 ],
                 getter: function () (this.values[prefs.get(this.PREF)] || [prefs.get(this.PREF_DAYS)])[0],
                 setter: function (value) {
-                    let val = this.values.map(function (i) i[0]).indexOf(value);
+                    let val = this.values.map(i => i[0]).indexOf(value);
                     if (val > -1)
                         prefs.set(this.PREF, val);
                     else {
index 377cd13edec5345d5e8809a9b35474bcf89c7752..315f95189531ef9bd5098dde994faa6693a8967f 100644 (file)
@@ -111,7 +111,7 @@ var Services = Module("Services", {
         this.addClass("URL",          "@mozilla.org/network/standard-url;1",       ["nsIStandardURL", "nsIURL"], "init");
         this.addClass("Xmlhttp",      "@mozilla.org/xmlextras/xmlhttprequest;1",   [], "open");
         this.addClass("XPathEvaluator", "@mozilla.org/dom/xpath-evaluator;1",      "nsIDOMXPathEvaluator");
-        this.addClass("XMLDocument",  "@mozilla.org/xml/xml-document;1",           ["nsIDOMXMLDocument", "nsIDOMNodeSelector"]);
+        this.addClass("XMLDocument",  "@mozilla.org/xml/xml-document;1",           "nsIDOMXMLDocument");
         this.addClass("XMLSerializer","@mozilla.org/xmlextras/xmlserializer;1",    ["nsIDOMSerializer"]);
         this.addClass("ZipReader",    "@mozilla.org/libjar/zip-reader;1",          "nsIZipReader", "open", false);
         this.addClass("ZipWriter",    "@mozilla.org/zipwriter;1",                  "nsIZipWriter", "open", false);
@@ -126,7 +126,8 @@ var Services = Module("Services", {
             if (!service.interfaces.length)
                 return res.wrappedJSObject || res;
 
-            service.interfaces.forEach(function (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);
@@ -162,7 +163,7 @@ var Services = Module("Services", {
         this.services[name] = { method: meth, class: class_, interfaces: Array.concat(ifaces || []) };
         if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
             throw TypeError();
-        memoize(this, name, function () self._create(name));
+        memoize(this, name, () => self._create(name));
     },
 
     /**
@@ -206,7 +207,7 @@ var Services = Module("Services", {
      * @param {string} name The service's cache key.
      */
     has: function has(name) Set.has(this.services, name) && this.services[name].class in Cc &&
-        this.services[name].interfaces.every(function (iface) iface in Ci)
+        this.services[name].interfaces.every(iface => iface in Ci)
 });
 
 endModule();
index f37524d843e79186c40ad36c5e02627b775f2276..6cc704f0040c477242a61d3ee7705160621a9961 100644 (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.
@@ -27,8 +27,8 @@ var StoreBase = Class("StoreBase", {
         this._load = load;
         this._options = options;
 
-        this.__defineGetter__("store", function () store);
-        this.__defineGetter__("name", function () name);
+        this.__defineGetter__("store", () => store);
+        this.__defineGetter__("name", () => name);
         for (let [k, v] in Iterator(options))
             if (this.OPTIONS.indexOf(k) >= 0)
                 this[k] = v;
@@ -224,7 +224,7 @@ var Storage = Module("Storage", {
             delete this.dactylSession[key];
     },
 
-    infoPath: Class.Memoize(function ()
+    infoPath: Class.Memoize(() =>
         File(IO.runtimePath.replace(/,.*/, ""))
             .child("info").child(config.profileName)),
 
@@ -292,8 +292,9 @@ var Storage = Module("Storage", {
         if (!(key in this.observers))
             this.observers[key] = [];
 
-        if (!this.observers[key].some(function (o) o.callback.get() == callback))
-            this.observers[key].push({ ref: ref && Cu.getWeakReference(ref), callback: callbackRef });
+        if (!this.observers[key].some(o => o.callback.get() == callback))
+            this.observers[key].push({ ref: ref && Cu.getWeakReference(ref),
+                                       callback: callbackRef });
     },
 
     removeObserver: function (key, callback) {
@@ -302,7 +303,7 @@ var Storage = Module("Storage", {
         if (!(key in this.observers))
             return;
 
-        this.observers[key] = this.observers[key].filter(function (elem) elem.callback.get() != callback);
+        this.observers[key] = this.observers[key].filter(elem => elem.callback.get() != callback);
         if (this.observers[key].length == 0)
             delete obsevers[key];
     },
@@ -427,7 +428,7 @@ var File = Class("File", {
         return this;
     },
 
-    charset: Class.Memoize(function () File.defaultEncoding),
+    charset: Class.Memoize(() => File.defaultEncoding),
 
     /**
      * @property {nsIFileURL} Returns the nsIFileURL object for this file.
@@ -495,7 +496,8 @@ var File = Class("File", {
 
         let array = [e for (e in this.iterDirectory())];
         if (sort)
-            array.sort(function (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,
-            function (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 ~
index ffa4c696fc0b3e2d5f548c78967d0aa935855f20..6584a7ef704482fa9c6efd0c1b5697d8569ea023 100644 (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); },
@@ -63,7 +63,7 @@ update(Sheet.prototype, {
     match: function (uri) {
         if (isString(uri))
             uri = util.newURI(uri);
-        return this.sites.some(function (site) Styles.matchFilter(site, uri));
+        return this.sites.some(site => Styles.matchFilter(site, uri));
     },
 
     get fullCSS() {
@@ -74,7 +74,7 @@ update(Sheet.prototype, {
         if (filter[0] == "*")
             return preamble + css;
 
-        let selectors = filter.map(function (part)
+        let selectors = filter.map(part =>
                                     !/^(?:[a-z-]+[:*]|[a-z-.]+$)/i.test(part) ? "regexp(" + Styles.quote(".*(?:" + part + ").*") + ")" :
                                        (/[*]$/.test(part)   ? "url-prefix" :
                                         /[\/:]/.test(part)  ? "url"
@@ -102,10 +102,11 @@ var Hive = Class("Hive", {
         this.dropRef(null);
     },
     dropRef: function (obj) {
-        this.refs = this.refs.filter(function (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(function (h) h !== this, this);
+            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(function (s) s.sites).flatten().uniq().array,
+    get sites() array(this.sheets).map(s => s.sites)
+                                  .flatten()
+                                  .uniq().array,
 
     /**
      * Add a new style sheet.
@@ -182,14 +185,15 @@ var Hive = Class("Hive", {
         // Grossly inefficient.
         let matches = [k for ([k, v] in Iterator(this.sheets))];
         if (index)
-            matches = String(index).split(",").filter(function (i) i in this.sheets, this);
+            matches = String(index).split(",").filter(i => i in this.sheets);
         if (name)
-            matches = matches.filter(function (i) this.sheets[i].name == name, this);
+            matches = matches.filter(i => this.sheets[i].name == name);
         if (css)
-            matches = matches.filter(function (i) this.sheets[i].css == css, this);
+            matches = matches.filter(i => this.sheets[i].css == css);
         if (filter)
-            matches = matches.filter(function (i) this.sheets[i].sites.indexOf(filter) >= 0, this);
-        return matches.map(function (i) this.sheets[i], this);
+            matches = matches.filter(i => this.sheets[i].sites.indexOf(filter) >= 0);
+
+        return matches.map(i => this.sheets[i]);
     },
 
     /**
@@ -222,7 +226,7 @@ var Hive = Class("Hive", {
 
         for (let [, sheet] in Iterator(matches.reverse())) {
             if (filter) {
-                let sites = sheet.sites.filter(function (f) f != filter);
+                let sites = sheet.sites.filter(f => f != filter);
                 if (sites.length) {
                     sheet.sites = sites;
                     continue;
@@ -233,7 +237,7 @@ var Hive = Class("Hive", {
                 delete this.names[sheet.name];
             delete styles.allSheets[sheet.id];
         }
-        this.sheets = this.sheets.filter(function (s) matches.indexOf(s) == -1);
+        this.sheets = this.sheets.filter(s => matches.indexOf(s) == -1);
         return matches.length;
     },
 });
@@ -273,7 +277,8 @@ var Styles = Module("Styles", {
     },
 
     addHive: function addHive(name, ref, persist) {
-        let hive = array.nth(this.hives, function (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(function (h) h.modifiable && h.sheets.length);
+        hives = hives || styles.hives.filter(h => (h.modifiable && h.sheets.length));
 
         function sheets(group)
             group.sheets.slice()
-                 .filter(function (sheet) (!name || sheet.name === name) &&
-                                          (!sites || sites.every(function (s) sheet.sites.indexOf(s) >= 0)))
-                 .sort(function (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);
 
@@ -326,9 +331,9 @@ var Styles = Module("Styles", {
                 ["col", { style: "min-width: 1em; text-align: center; color: red; font-weight: bold;" }],
                 ["col", { style: "padding: 0 1em 0 1ex; vertical-align: top;" }],
                 ["col", { style: "padding: 0 1em 0 0; vertical-align: top;" }],
-                template.map(hives, function (hive) let (i = 0) [
+                template.map(hives, hive => let (i = 0) [
                     ["tr", { style: "height: .5ex;" }],
-                    template.map(sheets(hive), function (sheet)
+                    template.map(sheets(hive), sheet =>
                         ["tr", {},
                             ["td", { highlight: "Title" }, !i++ ? hive.name : ""],
                             ["td", {}, sheet.enabled ? "" : UTF8("×")],
@@ -369,7 +374,7 @@ var Styles = Module("Styles", {
                 props[prop.name] = prop.value;
 
         let val = Object.keys(props)[sort ? "sort" : "slice"]()
-                        .map(function (prop) prop + ": " + props[prop] + ";")
+                        .map(prop => prop + ": " + props[prop] + ";")
                         .join(" ");
 
         if (/^\s*(\/\*.*?\*\/)/.exec(src))
@@ -377,8 +382,7 @@ var Styles = Module("Styles", {
         return val;
     },
 
-    completeSite: function (context, content, group) {
-        group = group || styles.user;
+    completeSite: function (context, content, group = styles.user) {
         context.anchored = false;
         try {
             context.fork("current", 0, this, function (context) {
@@ -393,13 +397,13 @@ var Styles = Module("Styles", {
 
         let uris = util.visibleURIs(content);
 
-        context.generate = function () values(group.sites);
+        context.generate = () => values(group.sites);
 
         context.keys.text = util.identity;
         context.keys.description = function (site) this.sheets.length + /*L*/" sheet" + (this.sheets.length == 1 ? "" : "s") + ": " +
-            array.compact(this.sheets.map(function (s) s.name)).join(", ");
-        context.keys.sheets = function (site) group.sheets.filter(function (s) s.sites.indexOf(site) >= 0);
-        context.keys.active = function (site) uris.some(Styles.matchFilter(site));
+            array.compact(this.sheets.map(s => s.name)).join(", ");
+        context.keys.sheets = site => group.sheets.filter(s => s.sites.indexOf(site) >= 0);
+        context.keys.active = site => uris.some(Styles.matchFilter(site));
 
         Styles.splitContext(context, "Sites");
     },
@@ -445,7 +449,7 @@ var Styles = Module("Styles", {
             let [name, active] = item;
             context.split(name, null, function (context) {
                 context.title[0] = /*L*/name + " " + (title || "Sheets");
-                context.filters.push(function (item) !!item.active == active);
+                context.filters.push(item => !!item.active == active);
             });
         }
     },
@@ -548,11 +552,11 @@ var Styles = Module("Styles", {
         function sheets(context, args, filter) {
             let uris = util.visibleURIs(window.content);
             context.compare = modules.CompletionContext.Sort.number;
-            context.generate = function () args["-group"].sheets;
-            context.keys.active = function (sheet) uris.some(sheet.closure.match);
-            context.keys.description = function (sheet) [sheet.formatSites(uris), ": ", sheet.css.replace("\n", "\\n")];
+            context.generate = () => args["-group"].sheets;
+            context.keys.active = sheet => uris.some(sheet.closure.match);
+            context.keys.description = sheet => [sheet.formatSites(uris), ": ", sheet.css.replace("\n", "\\n")];
             if (filter)
-                context.filters.push(function ({ item }) filter(item));
+                context.filters.push(({ item }) => filter(item));
             Styles.splitContext(context);
         }
 
@@ -561,8 +565,8 @@ var Styles = Module("Styles", {
             description: "The name of this stylesheet",
             type: modules.CommandOption.STRING,
             completer: function (context, args) {
-                context.keys.text = function (sheet) sheet.name;
-                context.filters.unshift(function ({ item }) item.name);
+                context.keys.text = sheet => sheet.name;
+                context.filters.unshift(({ item }) => item.name);
                 sheets(context, args, filter);
             }
         });
@@ -619,11 +623,12 @@ var Styles = Module("Styles", {
                 ],
                 serialize: function ()
                     array(styles.hives)
-                        .filter(function (hive) hive.persist)
-                        .map(function (hive)
-                             hive.sheets.filter(function (style) style.persist)
-                                 .sort(function (a, b) String.localeCompare(a.name || "", b.name || ""))
-                                 .map(function (style) ({
+                        .filter(hive => hive.persist)
+                        .map(hive =>
+                             hive.sheets.filter(style => style.persist)
+                                 .sort((a, b) => String.localeCompare(a.name || "",
+                                                                      b.name || ""))
+                                 .map(style => ({
                                     command: "style",
                                     arguments: [style.sites.join(",")],
                                     literalArg: style.css,
@@ -673,7 +678,7 @@ var Styles = Module("Styles", {
 
                         Styles.completeSite(context, window.content, args["-group"]);
                         if (cmd.filter)
-                            context.filters.push(function ({ sheets }) sheets.some(cmd.filter));
+                            context.filters.push(({ sheets }) => sheets.some(cmd.filter));
                     },
                     literal: 1,
                     options: [
@@ -682,7 +687,7 @@ var Styles = Module("Styles", {
                             names: ["-index", "-i"],
                             type: modules.CommandOption.INT,
                             completer: function (context, args) {
-                                context.keys.text = function (sheet) args["-group"].sheets.indexOf(sheet);
+                                context.keys.text = sheet => args["-group"].sheets.indexOf(sheet);
                                 sheets(context, args, cmd.filter);
                             }
                         },
@@ -716,7 +721,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;
@@ -728,10 +734,10 @@ var Styles = Module("Styles", {
         };
     },
     javascript: function initJavascript(dactyl, modules, window) {
-        modules.JavaScript.setCompleter(["get", "add", "remove", "find"].map(function (m) Hive.prototype[m]),
+        modules.JavaScript.setCompleter(["get", "add", "remove", "find"].map(m => Hive.prototype[m]),
             [ // Prototype: (name, filter, css, index)
                 function (context, obj, args) this.names,
-                function (context, obj, args) Styles.completeSite(context, window.content),
+                (context, obj, args) => Styles.completeSite(context, window.content),
                 null,
                 function (context, obj, args) this.sheets
             ]);
@@ -749,14 +755,15 @@ 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];
                         if (match.string)
                             return ["span", { highlight: "String" }, match.string];
                         return template._highlightRegexp(match.wholeMatch, /^(\d+)(em|ex|px|in|cm|mm|pt|pc)?/g,
-                                                         function (m, n, u) [
+                                                         (m, n, u) => [
                                                              ["span", { highlight: "Number" }, n],
                                                              ["span", { highlight: "Object" }, u || ""]
                                                          ]);
index b9f5fda9b7ba6a7f7010be5e09a402038467b306..5b89f187524e336eb95e7c2899c01a1c686d996d 100644 (file)
@@ -172,7 +172,7 @@ var Template = Module("Template", {
         !(item.extra && item.extra.length) ? [] :
         ["span", { highlight: "URLExtra" },
             " (",
-            template.map(item.extra, function (e)
+            template.map(item.extra, e =>
                 ["", e[0], ": ",
                  ["span", { highlight: e[2] }, e[1]]],
                 "\u00a0"),
@@ -278,8 +278,8 @@ var Template = Module("Template", {
         }
     },
 
-    _sandbox: Class.Memoize(function () Cu.Sandbox(Cu.getGlobalForObject(global),
-                                                   { wantXrays: false })),
+    _sandbox: Class.Memoize(() => Cu.Sandbox(Cu.getGlobalForObject(global),
+                                             { wantXrays: false })),
 
     // if "processStrings" is true, any passed strings will be surrounded by " and
     // any line breaks are displayed as \n
@@ -403,7 +403,7 @@ var Template = Module("Template", {
                     ["th", {}, _("title.VPos")],
                     ["th", {}, _("title.Title")],
                     ["th", {}, _("title.URI")]],
-                this.map(Iterator(elems), function ([idx, val])
+                this.map(Iterator(elems), ([idx, val]) =>
                     ["tr", {},
                         ["td", { class: "indicator" }, idx == index ? ">" : ""],
                         ["td", {}, Math.abs(idx - index)],
@@ -419,7 +419,7 @@ var Template = Module("Template", {
         return ["table", {},
                 ["tr", { highlight: "Title", align: "left" },
                     ["th", {}, "--- " + title + " ---"]],
-                this.map(opts, function (opt)
+                this.map(opts, opt =>
                     ["tr", {},
                         ["td", {},
                             ["div", { highlight: "Message" },
@@ -446,7 +446,7 @@ var Template = Module("Template", {
         let table = ["table", {},
             ["tr", { highlight: "Title", align: "left" },
                 ["th", { colspan: "2" }, title]],
-            this.map(data, function (datum)
+            this.map(data, datum =>
                 ["tr", {},
                     ["td", { style: "font-weight: bold; min-width: 150px; padding-left: " + (indent || "2ex") }, datum[0]],
                     ["td", {}, datum[1]]])];
@@ -463,13 +463,11 @@ var Template = Module("Template", {
                     ["th", {}, h])],
             this.map(iter, (row) =>
                 ["tr", {},
-                    this.map(Iterator(row), function ([i, d])
+                    this.map(Iterator(row), ([i, d]) =>
                         ["td", { style: style[i] || "" }, d])])];
     },
 
-    usage: function usage(iter, format) {
-
-        format = format || {};
+    usage: function usage(iter, format = {}) {
         let desc = format.description || (item => this.linkifyHelp(item.description));
         let help = format.help || (item => item.name);
         let sourceLink = (frame) => {
index bf7b67eeefa1ad7427becced9a9890a5b5db3184..d6eaf80ceaa1d0430d6886b9c8d6b860bd750bb8 100644 (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.
@@ -161,7 +161,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                 }
             });
 
-        obj.observe.unregister = function () register("removeObserver");
+        obj.observe.unregister = () => register("removeObserver");
         register("addObserver");
     }, { dump: dump, Error: Error }),
 
@@ -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, function (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,12 +262,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(function (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(function (e) !e.test || e.test(obj))
+                valid: function valid(obj) this.elements.every(e => !e.test || e.test(obj))
             });
 
         let end = 0;
@@ -295,7 +298,8 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                 char = char.toLowerCase();
 
                 stack.top.elements.push(update(
-                    function (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))
@@ -340,16 +344,18 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
 
         let unknown = util.identity;
         if (!keepUnknown)
-            unknown = function () "";
+            unknown = () => "";
 
         function frame() update(
             function _frame(obj)
-                _frame === stack.top || _frame.valid(obj) ?
-                    _frame.elements.map(function (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(function (e) !e.test || e.test(obj))
+                valid: function valid(obj) this.elements.every(e => (!e.test || e.test(obj)))
             });
 
         let defaults = { lt: "<", gt: ">" };
@@ -396,7 +402,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                     if (idx) {
                         idx = Number(idx) - 1;
                         stack.top.elements.push(update(
-                            function (obj) obj[name] != null && idx in obj[name] ? quote(obj[name][idx])
+                            obj => obj[name] != null && idx in obj[name] ? quote(obj[name][idx])
                                                                                  : Set.has(obj, name) ? "" : unknown(full),
                             {
                                 test: function test(obj) obj[name] != null && idx in obj[name]
@@ -406,7 +412,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                     }
                     else {
                         stack.top.elements.push(update(
-                            function (obj) obj[name] != null ? quote(obj[name])
+                            obj => obj[name] != null ? quote(obj[name])
                                                              : Set.has(obj, name) ? "" : unknown(full),
                             {
                                 test: function test(obj) obj[name] != null
@@ -491,7 +497,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                         fn(match);
                 }
                 res.push(pattern.substr(end));
-                return res.map(function (s) util.dequote(s, dequote));
+                return res.map(s => util.dequote(s, dequote));
             };
 
             let patterns = [];
@@ -539,7 +545,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
      * @returns {string}
      */
     dequote: function dequote(pattern, chars)
-        pattern.replace(/\\(.)/, function (m0, m1) chars.indexOf(m1) >= 0 ? m1 : m0),
+        pattern.replace(/\\(.)/, (m0, m1) => chars.indexOf(m1) >= 0 ? m1 : m0),
 
     /**
      * Returns the nsIDocShell for the given window.
@@ -582,10 +588,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
      * @param {string} msg The trace message.
      * @param {number} frames The number of frames to print.
      */
-    dumpStack: function dumpStack(msg, frames) {
+    dumpStack: function dumpStack(msg="Stack", frames=null) {
         let stack = util.stackLines(Error().stack);
         stack = stack.slice(1, 1 + (frames || stack.length)).join("\n").replace(/^/gm, "    ");
-        util.dump((arguments.length == 0 ? "Stack" : msg) + "\n" + stack + "\n");
+        util.dump(msg + "\n" + stack + "\n");
     },
 
     /**
@@ -747,7 +753,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
     httpGet: function httpGet(url, callback, self) {
         let params = callback;
         if (!isObject(params))
-            params = { callback: params && function () callback.apply(self, arguments) };
+            params = { callback: params && ((...args) => callback.apply(self, args)) };
 
         try {
             let xmlhttp = services.Xmlhttp();
@@ -868,7 +874,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
      * top-level window and sub-frames thereof.
      */
     iterDocuments: function iterDocuments(types) {
-        types = types ? types.map(function (s) "type" + util.capitalize(s))
+        types = types ? types.map(s => "type" + util.capitalize(s))
                       : ["typeChrome", "typeContent"];
 
         let windows = services.windowMediator.getXULWindowEnumerator(null);
@@ -887,7 +893,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
     },
 
     // ripped from Firefox; modified
-    unsafeURI: Class.Memoize(function () util.regexp(String.replace(literal(/*
+    unsafeURI: Class.Memoize(() => util.regexp(String.replace(literal(/*
             [
                 \s
                 // Invisible characters (bug 452979)
@@ -933,10 +939,10 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
                                                  : val,
                                      isDOM ? /['%]/g
                                            : /['"%&<>]/g,
-                                     function (m) map[m]);
+                                     m => map[m]);
             }
 
-            return iter(obj).map(function ([k, v])
+            return iter(obj).map(([k, v]) =>
                                  ["<!ENTITY ", k, " '", escape(v), "'>"].join(""))
                             .join("\n");
         },
@@ -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), function (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];
         }
@@ -1245,14 +1255,15 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
         // Replace replacement <tokens>.
         if (tokens)
             expr = String.replace(expr, /(\(?P)?<(\w+)>/g,
-                                  function (m, n1, n2) !n1 && Set.has(tokens, n2) ?    tokens[n2].dactylSource
-                                                                                    || tokens[n2].source
-                                                                                    || tokens[n2]
-                                                                                  : m);
+                                  (m, n1, n2) => !n1 && Set.has(tokens, n2) ?    tokens[n2].dactylSource
+                                                                              || tokens[n2].source
+                                                                              || tokens[n2]
+                                                                            : m);
 
         // Strip comments and white space.
         if (/x/.test(flags))
-            expr = String.replace(expr, /(\\.)|\/\/[^\n]*|\/\*[^]*?\*\/|\s+/gm, function (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, function (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
@@ -1345,7 +1358,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
     },
 
     errorCount: 0,
-    errors: Class.Memoize(function () []),
+    errors: Class.Memoize(() => []),
     maxErrors: 15,
     /**
      * Reports an error to the Error Console and the standard output,
@@ -1411,7 +1424,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
 
         let ary = host.split(".");
         ary = [ary.slice(i).join(".") for (i in util.range(ary.length, 0, -1))];
-        return ary.filter(function (h) h.length >= base.length);
+        return ary.filter(h => h.length >= base.length);
     },
 
     /**
@@ -1669,7 +1682,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
             catch (e) {}
             Array.forEach(frame.frames, rec);
         })(win);
-        return res.filter(function (h) !Set.add(seen, h));
+        return res.filter(h => !Set.add(seen, h));
     },
 
     /**
@@ -1688,7 +1701,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
             catch (e) {}
             Array.forEach(frame.frames, rec);
         })(win);
-        return res.filter(function (h) !Set.add(seen, h.spec));
+        return res.filter(h => !Set.add(seen, h.spec));
     },
 
     /**
index 20a12983e84cff4d0d743bbb6e896e2906573e00..baa5b3b6f9dfb6a1e39cdf11cb10e8f340c6eaef 100644 (file)
@@ -47,7 +47,7 @@ const Config = Module("config", ConfigBase, {
                 function () { window.toJavaScriptConsole(); }],
             dominspector: ["DOM Inspector",
                 function () { window.inspectDOMDocument(window.content.document); },
-                function () "inspectDOMDocument" in window],
+                () => "inspectDOMDocument" in window],
             downloads: ["Manage Downloads",
                 function () { window.toOpenWindowByType("Download:Manager", "chrome://mozapps/content/downloads/downloads.xul", "chrome,dialog=no,resizable"); }],
             newsmartplaylist: ["Open the file selector dialog",
index 5ab691ebd72625f7802ce6c9394b40d6fa56b3e5..65bfb768447c6be14ce6564485ca1e5fe7019d40 100644 (file)
@@ -36,7 +36,7 @@ const Library = Module("library", {
      */
     getAlbums: function getAlbums(artist) {
         let albums = this._toJSArray(this.MAIN_LIBRARY.getItemsByProperty(SBProperties.artistName, artist))
-                         .map(function (track) track.getProperty(SBProperties.albumName));
+                         .map(track => track.getProperty(SBProperties.albumName));
         return array.uniq(albums);
     },
 
@@ -55,7 +55,7 @@ const Library = Module("library", {
         properties.appendProperty(SBProperties.albumName, album);
 
         return this._toJSArray(this.MAIN_LIBRARY.getItemsByProperties(properties))
-                   .map(function (track) track.getProperty(SBProperties.trackName));
+                   .map(track => track.getProperty(SBProperties.trackName));
     }
 }, {
 }, {
index 96e97a04254fdc8587b63282e0f6d7afeace4eef..f56b8cb0591253f8386692c6be47481155f4f245 100644 (file)
@@ -43,38 +43,38 @@ const Player = Module("player", {
     _mediaCoreListener: {
         onMediacoreEvent: function (event) {
             switch (event.type) {
-                case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
-                    dactyl.log(_("player.preTrackChange", event.data));
-                    autocommands.trigger("TrackChangePre", { track: event.data });
-                    break;
-                case Ci.sbIMediacoreEvent.TRACK_CHANGE:
-                    dactyl.log(_("player.trackChanged", event.data));
-                    autocommands.trigger("TrackChange", { track: event.data });
-                    break;
-                case Ci.sbIMediacoreEvent.BEFORE_VIEW_CHANGE:
-                    dactyl.log(_("player.preViewChange", event.data));
-                    autocommands.trigger("ViewChangePre", { view: event.data });
-                    break;
-                case Ci.sbIMediacoreEvent.VIEW_CHANGE:
-                    dactyl.log(_("player.viewChange", event.data));
-                    autocommands.trigger("ViewChange", { view: event.data });
-                    break;
-                case Ci.sbIMediacoreEvent.STREAM_START:
-                    dactyl.log(_("player.trackStart", gMM.sequencer.currentItem));
-                    autocommands.trigger("StreamStart", { track: gMM.sequencer.currentItem });
-                    break;
-                case Ci.sbIMediacoreEvent.STREAM_PAUSE:
-                    dactyl.log(_("player.trackPause", gMM.sequencer.currentItem));
-                    autocommands.trigger("StreamPause", { track: gMM.sequencer.currentItem });
-                    break;
-                case Ci.sbIMediacoreEvent.STREAM_END:
-                    dactyl.log(_("player.trackEnd", gMM.sequencer.currentItem));
-                    autocommands.trigger("StreamEnd", { track: gMM.sequencer.currentItem });
-                    break;
-                case Ci.sbIMediacoreEvent.STREAM_STOP:
-                    dactyl.log(_("player.trackStop", gMM.sequencer.currentItem));
-                    autocommands.trigger("StreamStop", { track: gMM.sequencer.currentItem });
-                    break;
+            case Ci.sbIMediacoreEvent.BEFORE_TRACK_CHANGE:
+                dactyl.log(_("player.preTrackChange", event.data));
+                autocommands.trigger("TrackChangePre", { track: event.data });
+                break;
+            case Ci.sbIMediacoreEvent.TRACK_CHANGE:
+                dactyl.log(_("player.trackChanged", event.data));
+                autocommands.trigger("TrackChange", { track: event.data });
+                break;
+            case Ci.sbIMediacoreEvent.BEFORE_VIEW_CHANGE:
+                dactyl.log(_("player.preViewChange", event.data));
+                autocommands.trigger("ViewChangePre", { view: event.data });
+                break;
+            case Ci.sbIMediacoreEvent.VIEW_CHANGE:
+                dactyl.log(_("player.viewChange", event.data));
+                autocommands.trigger("ViewChange", { view: event.data });
+                break;
+            case Ci.sbIMediacoreEvent.STREAM_START:
+                dactyl.log(_("player.trackStart", gMM.sequencer.currentItem));
+                autocommands.trigger("StreamStart", { track: gMM.sequencer.currentItem });
+                break;
+            case Ci.sbIMediacoreEvent.STREAM_PAUSE:
+                dactyl.log(_("player.trackPause", gMM.sequencer.currentItem));
+                autocommands.trigger("StreamPause", { track: gMM.sequencer.currentItem });
+                break;
+            case Ci.sbIMediacoreEvent.STREAM_END:
+                dactyl.log(_("player.trackEnd", gMM.sequencer.currentItem));
+                autocommands.trigger("StreamEnd", { track: gMM.sequencer.currentItem });
+                break;
+            case Ci.sbIMediacoreEvent.STREAM_STOP:
+                dactyl.log(_("player.trackStop", gMM.sequencer.currentItem));
+                autocommands.trigger("StreamStop", { track: gMM.sequencer.currentItem });
+                break;
             }
         }
     },
@@ -168,18 +168,18 @@ const Player = Module("player", {
      */
     toggleRepeat: function toggleRepeat() {
         switch (gMM.sequencer.repeatMode) {
-            case gMM.sequencer.MODE_REPEAT_NONE:
-                gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
-                break;
-            case gMM.sequencer.MODE_REPEAT_ONE:
-                gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
-                break;
-            case gMM.sequencer.MODE_REPEAT_ALL:
-                gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
-                break;
-            default:
-                gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
-                break;
+        case gMM.sequencer.MODE_REPEAT_NONE:
+            gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ONE;
+            break;
+        case gMM.sequencer.MODE_REPEAT_ONE:
+            gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_ALL;
+            break;
+        case gMM.sequencer.MODE_REPEAT_ALL:
+            gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
+            break;
+        default:
+            gMM.sequencer.repeatMode = gMM.sequencer.MODE_REPEAT_NONE;
+            break;
         }
     },
 
@@ -343,7 +343,7 @@ const Player = Module("player", {
             onEnumerationEnd: function () { },
             onEnumeratedItem: function (list, item) {
                 // FIXME: why are there null items and duplicates?
-                if (!playlists.some(function (list) list.name == item.name) && item.name != null)
+                if (!playlists.some(list => list.name == item.name) && item.name != null)
                     playlists.push(item);
                 return Ci.sbIMediaListEnumerationListener.CONTINUE;
             }
@@ -372,7 +372,7 @@ const Player = Module("player", {
     getMediaPages: function getMediaPages() {
         let list = SBGetBrowser().currentMediaPage.mediaListView.mediaList;
         let pages = services.mediaPageManager.getAvailablePages(list);
-        return ArrayConverter.JSArray(pages).map(function (page) page.QueryInterface(Ci.sbIMediaPageInfo));
+        return ArrayConverter.JSArray(pages).map(page => page.QueryInterface(Ci.sbIMediaPageInfo));
     },
 
     /**
@@ -414,27 +414,27 @@ const Player = Module("player", {
         properties.strict = false;
 
         switch (field) {
-            case "title":
-                properties.appendProperty(SBProperties.trackName, order);
-                break;
-            case "time":
-                properties.appendProperty(SBProperties.duration, order);
-                break;
-            case "artist":
-                properties.appendProperty(SBProperties.artistName, order);
-                break;
-            case "album":
-                properties.appendProperty(SBProperties.albumName, order);
-                break;
-            case "genre":
-                properties.appendProperty(SBProperties.genre, order);
-                break;
-            case "rating":
-                properties.appendProperty(SBProperties.rating, order);
-                break;
-            default:
-                properties.appendProperty(SBProperties.trackName, order);
-                break;
+        case "title":
+            properties.appendProperty(SBProperties.trackName, order);
+            break;
+        case "time":
+            properties.appendProperty(SBProperties.duration, order);
+            break;
+        case "artist":
+            properties.appendProperty(SBProperties.artistName, order);
+            break;
+        case "album":
+            properties.appendProperty(SBProperties.albumName, order);
+            break;
+        case "genre":
+            properties.appendProperty(SBProperties.genre, order);
+            break;
+        case "rating":
+            properties.appendProperty(SBProperties.rating, order);
+            break;
+        default:
+            properties.appendProperty(SBProperties.trackName, order);
+            break;
         }
 
         this._currentView.setSort(properties);
@@ -625,15 +625,15 @@ const Player = Module("player", {
 
                 // args
                 switch (args.length) {
-                    case 3:
-                        properties.appendProperty(SBProperties.trackName, args[2]);
-                    case 2:
-                        properties.appendProperty(SBProperties.albumName, args[1]);
-                    case 1:
-                        properties.appendProperty(SBProperties.artistName, args[0]);
-                        break;
-                    default:
-                        break;
+                case 3:
+                    properties.appendProperty(SBProperties.trackName, args[2]);
+                case 2:
+                    properties.appendProperty(SBProperties.albumName, args[1]);
+                case 1:
+                    properties.appendProperty(SBProperties.artistName, args[0]);
+                    break;
+                default:
+                    break;
                 }
 
                 let library = LibraryUtils.mainLibrary;
index 183f6d103999f489740ed12869f14a1d53f3e66c..3294cb1aee43803c04df64d778582c5c6f5a5a28 100644 (file)
@@ -21,16 +21,16 @@ var Config = Module("config", ConfigBase, {
                 function () { window.openDialog("chrome://browser/content/bookmarks/bookmarksPanel.xul", "Bookmarks", "dialog,centerscreen,width=600,height=600"); }],
             checkupdates: ["Check for updates",
                 function () { window.checkForUpdates(); },
-                function () "checkForUpdates" in window],
+                () => "checkForUpdates" in window],
             cookies: ["List your cookies",
                 function () { window.toOpenWindowByType("Browser:Cookies", "chrome://browser/content/preferences/cookies.xul", "chrome,dialog=no,resizable"); }],
-            console: ["JavaScript console",
-                function () { window.toJavaScriptConsole(); }],
+            console: ["Browser console",
+                function () { window.HUDService.toggleBrowserConsole(); }],
             customizetoolbar: ["Customize the Toolbar",
                 function () { window.BrowserCustomizeToolbar(); }],
             dominspector: ["DOM Inspector",
                 function () { window.inspectDOMDocument(window.content.document); },
-                function () "inspectDOMDocument" in window],
+                () => "inspectDOMDocument" in window],
             downloads: ["Manage Downloads",
                 function () { window.BrowserDownloadsUI(); }],
             history: ["List your history",
@@ -63,7 +63,7 @@ var Config = Module("config", ConfigBase, {
                 function () { modules.buffer.viewSelectionSource(); }],
             venkman: ["The JavaScript debugger",
                 function () { dactyl.assert("start_venkman" in window, "Venkman is not installed"); window.start_venkman() },
-                function () "start_venkman" in window]
+                () => "start_venkman" in window]
         },
 
         removeTab: function removeTab(tab) {
@@ -211,8 +211,8 @@ var Config = Module("config", ConfigBase, {
         completion.sidebar = function sidebar(context) {
             let menu = document.getElementById("viewSidebarMenu");
             context.title = ["Sidebar Panel"];
-            context.completions = Array.filter(menu.childNodes, function (n) n.hasAttribute("label"))
-                                       .map(function (n) [n.getAttribute("label"), ""]);
+            context.completions = Array.filter(menu.childNodes, n => n.hasAttribute("label"))
+                                       .map(n => [n.getAttribute("label"), ""]);
         };
     },
     events: function initEvents(dactyl, modules, window) {
@@ -226,7 +226,7 @@ var Config = Module("config", ConfigBase, {
         mappings.add([modes.NORMAL],
                      ["<Return>", "<Up>", "<Down>"],
                      "Handled by " + config.host,
-                     function () Events.PASS_THROUGH);
+                     () => Events.PASS_THROUGH);
     },
     options: function initOptions(dactyl, modules, window) {
         modules.options.add(["online"],
index 45fb55351cc724ae7b306b12356eb13e7487a92a..d7060288ae357cc855e53ec0b638ae3e55460a00 100644 (file)
@@ -31,8 +31,8 @@
         <em:targetApplication>
             <Description
                 em:id="{ec8030f7-c20a-464f-9b0e-13a3a9e97384}"
-                em:minVersion="22.0"
-                em:maxVersion="24.*"/>
+                em:minVersion="24.0"
+                em:maxVersion="25.*"/>
         </em:targetApplication>
     </Description>
 </RDF>
index 6171b4132778f65622090425145b7e070f276c79..aa90d0acc0c67624d42c49452a522c8a0ac54407 100644 (file)
@@ -73,7 +73,7 @@ var Addressbook = Module("addressbook", {
             // Now we have to create a new message
             let args = {};
             args.to = addresses.map(
-                function (address) "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""
+                address => "\"" + address[0].replace(/"/g, "") + " <" + address[1] + ">\""
             ).join(", ");
 
             mail.composeNewMail(args);
index 72215c8610feccc66c60956cbf6a36f822eaf16c..c9ff88423a3bad8fcbfefb29ad52676164fb75c9 100644 (file)
@@ -11,7 +11,7 @@ var Config = Module("config", ConfigBase, {
             init.superapply(this, arguments);
 
             if (!("content" in modules))
-                modules.__defineGetter__("content", function () window.content);
+                modules.__defineGetter__("content", () => window.content);
 
             util.overlayWindow(window, { append: <><hbox id="statusTextBox" flex=""/></> });
         },
index 9c4502ddad9fa02786b2e8a16813b522ec3a55f8..0daace8b28ec11587b08a25ac88827a66a91509e 100644 (file)
@@ -431,7 +431,7 @@ var Mail = Module("mail", {
                     addresses = addresses.concat(mailargs.cc);
 
                 // TODO: is there a better way to check for validity?
-                if (addresses.some(function (recipient) !(/\S@\S+\.\S/.test(recipient))))
+                if (addresses.some(recipient => !(/\S@\S+\.\S/.test(recipient))))
                     return void dactyl.echoerr(_("command.mail.invalidEmailAddress"));
 
                 mail.composeNewMail(mailargs);
@@ -472,7 +472,7 @@ var Mail = Module("mail", {
 
         commands.add(["get[messages]"],
             "Check for new messages",
-            function (args) mail.getNewMessages(!args.bang),
+            function (args) { mail.getNewMessages(!args.bang); },
             {
                 argCount: "0",
                 bang: true,
@@ -483,7 +483,7 @@ var Mail = Module("mail", {
             let folders = mail.getFolders(context.filter);
             context.anchored = false;
             context.quote = false;
-            context.completions = folders.map(function (folder)
+            context.completions = folders.map(folder =>
                     [folder.server.prettyName + ": " + folder.name,
                      "Unread: " + folder.getNumUnread(false)]);
         };
@@ -506,7 +506,7 @@ var Mail = Module("mail", {
 
         mappings.add(myModes, ["<Space>"],
             "Scroll message or select next unread one",
-            function () Events.PASS);
+            () => Events.PASS);
 
         mappings.add(myModes, ["t"],
             "Select thread",
@@ -518,39 +518,39 @@ var Mail = Module("mail", {
 
         mappings.add(myModes, ["j", "<Right>"],
             "Select next message",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, false, false, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, false, false, count); },
             { count: true });
 
         mappings.add(myModes, ["gj"],
             "Select next message, including closed threads",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, true, false, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, true, false, count); },
             { count: true });
 
         mappings.add(myModes, ["J", "<Tab>"],
             "Select next unread message",
-            function ({ count }) { mail.selectMessage(function (msg) !msg.isRead, true, true, false, count); },
+            function ({ count }) { mail.selectMessage(msg => !msg.isRead, true, true, false, count); },
             { count: true });
 
         mappings.add(myModes, ["k", "<Left>"],
             "Select previous message",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, false, true, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, false, true, count); },
             { count: true });
 
         mappings.add(myModes, ["gk"],
             "Select previous message",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, true, true, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, true, true, count); },
             { count: true });
 
         mappings.add(myModes, ["K"],
             "Select previous unread message",
-            function ({ count }) { mail.selectMessage(function (msg) !msg.isRead, true, true, true, count); },
+            function ({ count }) { mail.selectMessage(msg => !msg.isRead, true, true, true, count); },
             { count: true });
 
         mappings.add(myModes, ["*"],
             "Select next message from the same sender",
             function ({ count }) {
                 let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase();
-                mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, count);
+                mail.selectMessage(msg => msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, false, count);
             },
             { count: true });
 
@@ -558,7 +558,7 @@ var Mail = Module("mail", {
             "Select previous message from the same sender",
             function ({ count }) {
                 let author = gDBView.hdrForFirstSelectedMessage.mime2DecodedAuthor.toLowerCase();
-                mail.selectMessage(function (msg) msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, count);
+                mail.selectMessage(msg => msg.mime2DecodedAuthor.toLowerCase().indexOf(author) == 0, true, true, true, count);
             },
             { count: true });
 
@@ -603,12 +603,12 @@ var Mail = Module("mail", {
 
         mappings.add([modes.MESSAGE], ["<Left>"],
             "Select previous message",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, false, true, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, false, true, count); },
             { count: true });
 
         mappings.add([modes.MESSAGE], ["<Right>"],
             "Select next message",
-            function ({ count }) { mail.selectMessage(function (msg) true, false, false, false, count); },
+            function ({ count }) { mail.selectMessage(msg => true, false, false, false, count); },
             { count: true });
 
         // UNDO/REDO
@@ -657,22 +657,22 @@ var Mail = Module("mail", {
 
         mappings.add(myModes, ["]s"],
             "Select next starred message",
-            function ({ count }) { mail.selectMessage(function (msg) msg.isFlagged, true, true, false, count); },
+            function ({ count }) { mail.selectMessage(msg => msg.isFlagged, true, true, false, count); },
             { count: true });
 
         mappings.add(myModes, ["[s"],
             "Select previous starred message",
-            function ({ count }) { mail.selectMessage(function (msg) msg.isFlagged, true, true, true, count); },
+            function ({ count }) { mail.selectMessage(msg => msg.isFlagged, true, true, true, count); },
             { count: true });
 
         mappings.add(myModes, ["]a"],
             "Select next message with an attachment",
-            function ({ count }) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, false, count); },
+            function ({ count }) { mail.selectMessage(msg => gDBView.db.HasAttachments(msg.messageKey), true, true, false, count); },
             { count: true });
 
         mappings.add(myModes, ["[a"],
             "Select previous message with an attachment",
-            function ({ count }) { mail.selectMessage(function (msg) gDBView.db.HasAttachments(msg.messageKey), true, true, true, count); },
+            function ({ count }) { mail.selectMessage(msg => gDBView.db.HasAttachments(msg.messageKey), true, true, true, count); },
             { count: true });
 
         // FOLDER SWITCHING
@@ -774,14 +774,14 @@ var Mail = Module("mail", {
                     return void dactyl.beep();
 
                 switch (arg) {
-                    case "r": MsgMarkMsgAsRead(); break;
-                    case "s": MsgMarkAsFlagged(); break;
-                    case "i": ToggleMessageTagKey(1); break; // Important
-                    case "w": ToggleMessageTagKey(2); break; // Work
-                    case "p": ToggleMessageTagKey(3); break; // Personal
-                    case "t": ToggleMessageTagKey(4); break; // TODO
-                    case "l": ToggleMessageTagKey(5); break; // Later
-                    default:  dactyl.beep();
+                case "r": MsgMarkMsgAsRead(); break;
+                case "s": MsgMarkAsFlagged(); break;
+                case "i": ToggleMessageTagKey(1); break; // Important
+                case "w": ToggleMessageTagKey(2); break; // Work
+                case "p": ToggleMessageTagKey(3); break; // Personal
+                case "t": ToggleMessageTagKey(4); break; // TODO
+                case "l": ToggleMessageTagKey(5); break; // Later
+                default:  dactyl.beep();
                 }
             },
             {
@@ -885,10 +885,10 @@ var Mail = Module("mail", {
             {
                 setter: function (value) {
                     switch (value) {
-                        case "classic":  ChangeMailLayout(0); break;
-                        case "wide":     ChangeMailLayout(1); break;
-                        case "vertical": ChangeMailLayout(2); break;
-                        // case "inherit" just does nothing
+                    case "classic":  ChangeMailLayout(0); break;
+                    case "wide":     ChangeMailLayout(1); break;
+                    case "vertical": ChangeMailLayout(2); break;
+                    // case "inherit" just does nothing
                     }
 
                     return value;
@@ -907,7 +907,7 @@ var Mail = Module("mail", {
             {
                 getter: function () services.smtp.defaultServer.key,
                 setter: function (value) {
-                    let server = mail.smtpServers.filter(function (s) s.key == value)[0];
+                    let server = mail.smtpServers.filter(s => s.key == value)[0];
                     services.smtp.defaultServer = server;
                     return value;
                 },