]> git.donarmstrong.com Git - dactyl.git/blobdiff - common/content/abbreviations.js
Imported Upstream version 1.1+hg7904
[dactyl.git] / common / content / abbreviations.js
index f0cd06d17747011ec4441a5505354031505086cc..7ceb5e9afe57e8a994e96982f8c48610085a6552 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-2013 Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2010-2014 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.
@@ -105,7 +105,7 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
     },
 
     /** @property {boolean} True if there are no abbreviations. */
-    get empty() !values(this._store).nth(util.identity, 0),
+    get empty() !values(this._store).find(util.identity),
 
     /**
      * Adds a new abbreviation.
@@ -132,7 +132,8 @@ var AbbrevHive = Class("AbbrevHive", Contexts.Hive, {
      */
     get: function (mode, lhs) {
         let abbrevs = this._store[mode];
-        return abbrevs && Set.has(abbrevs, lhs) ? abbrevs[lhs] : null;
+        return abbrevs && hasOwnProperty(abbrevs, lhs) ? abbrevs[lhs]
+                                                       : null;
     },
 
     /**
@@ -232,10 +233,10 @@ var Abbreviations = Module("abbreviations", {
 
     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 }),
-    removeAll: deprecated("group.abbrevs.clear", { get: function removeAll() this.user.closure.clear }),
+    get: deprecated("group.abbrevs.get", { get: function get() this.user.bound.get }),
+    set: deprecated("group.abbrevs.set", { get: function set() this.user.bound.set }),
+    remove: deprecated("group.abbrevs.remove", { get: function remove() this.user.bound.remove }),
+    removeAll: deprecated("group.abbrevs.clear", { get: function removeAll() this.user.bound.clear }),
 
     /**
      * Returns the abbreviation for the given *mode* if *text* matches the
@@ -250,7 +251,7 @@ var Abbreviations = Module("abbreviations", {
         let match = this._match.exec(text);
         if (match)
             return this.hives.map(h => h.get(mode, match[2] || match[4] || match[6]))
-                       .nth(util.identity, 0);
+                       .find(util.identity);
         return null;
     },
 
@@ -266,7 +267,7 @@ var Abbreviations = Module("abbreviations", {
         let hives = (hives || this.userHives).filter(h => !h.empty);
 
         function abbrevs(hive)
-            hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.indexOf(lhs) == 0));
+            hive.merged.filter(ab => (ab.inModes(modes) && ab.lhs.startsWith(lhs)));
 
         let list = ["table", {},
                 ["tr", { highlight: "Title" },