From 8ba727a0310b2e87d6a2c310580d368b1e3cc791 Mon Sep 17 00:00:00 2001
From: Marijn Haverbeke <marijnh@gmail.com>
Date: Tue, 12 May 2015 01:02:28 +0200
Subject: [PATCH] Fix a number of lint warnings from new-improved-blint

---
 addon/display/rulers.js       |  3 +-
 addon/search/searchcursor.js  |  4 +-
 addon/tern/worker.js          |  2 +-
 keymap/vim.js                 |  3 +-
 lib/codemirror.js             |  9 ++--
 mode/apl/apl.js               |  3 +-
 mode/asterisk/asterisk.js     |  6 +--
 mode/cypher/cypher.js         |  2 +-
 mode/dylan/dylan.js           | 44 ++++++++-----------
 mode/ecl/ecl.js               |  3 +-
 mode/eiffel/eiffel.js         |  2 -
 mode/htmlmixed/htmlmixed.js   |  4 +-
 mode/julia/julia.js           |  2 -
 mode/livescript/livescript.js |  4 +-
 mode/pig/pig.js               | 40 +++++++----------
 mode/tiddlywiki/tiddlywiki.js | 83 +++++++++++++++--------------------
 mode/tiki/tiki.js             | 27 ++++--------
 mode/xquery/xquery.js         | 70 +++++++++++++----------------
 18 files changed, 124 insertions(+), 187 deletions(-)

diff --git a/addon/display/rulers.js b/addon/display/rulers.js
index 13185d30b..01f65667c 100644
--- a/addon/display/rulers.js
+++ b/addon/display/rulers.js
@@ -38,7 +38,7 @@
     for (var i = 0; i < val.length; i++) {
       var elt = document.createElement("div");
       elt.className = "CodeMirror-ruler";
-      var col, cls = null, conf = val[i];
+      var col, conf = val[i];
       if (typeof conf == "number") {
         col = conf;
       } else {
@@ -47,7 +47,6 @@
         if (conf.color) elt.style.borderColor = conf.color;
         if (conf.lineStyle) elt.style.borderLeftStyle = conf.lineStyle;
         if (conf.width) elt.style.borderLeftWidth = conf.width;
-        cls = val[i].className;
       }
       elt.style.left = (left + col * cw) + "px";
       elt.style.top = "-50px";
diff --git a/addon/search/searchcursor.js b/addon/search/searchcursor.js
index 97088bf1c..b70242ee4 100644
--- a/addon/search/searchcursor.js
+++ b/addon/search/searchcursor.js
@@ -177,9 +177,9 @@
   });
 
   CodeMirror.defineExtension("selectMatches", function(query, caseFold) {
-    var ranges = [], next;
+    var ranges = [];
     var cur = this.getSearchCursor(query, this.getCursor("from"), caseFold);
-    while (next = cur.findNext()) {
+    while (cur.findNext()) {
       if (CodeMirror.cmpPos(cur.to(), this.getCursor("to")) > 0) break;
       ranges.push({anchor: cur.from(), head: cur.to()});
     }
diff --git a/addon/tern/worker.js b/addon/tern/worker.js
index 48277af8e..887f906a4 100644
--- a/addon/tern/worker.js
+++ b/addon/tern/worker.js
@@ -39,6 +39,6 @@ function startServer(defs, plugins, scripts) {
   });
 }
 
-var console = {
+this.console = {
   log: function(v) { postMessage({type: "debug", message: v}); }
 };
diff --git a/keymap/vim.js b/keymap/vim.js
index 6a4f3879d..f93774271 100644
--- a/keymap/vim.js
+++ b/keymap/vim.js
@@ -4581,10 +4581,9 @@
         searchCursor.replace(newText);
       }
       function next() {
-        var found;
         // The below only loops to skip over multiple occurrences on the same
         // line when 'global' is not true.
-        while(found = searchCursor.findNext() &&
+        while(searchCursor.findNext() &&
               isInRange(searchCursor.from(), lineStart, lineEnd)) {
           if (!global && lastPos && searchCursor.from().line == lastPos.line) {
             continue;
diff --git a/lib/codemirror.js b/lib/codemirror.js
index b8b879b78..4bae807df 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -728,12 +728,9 @@
   }
 
   function postUpdateDisplay(cm, update) {
-    var force = update.force, viewport = update.viewport;
+    var viewport = update.viewport;
     for (var first = true;; first = false) {
-      if (first && cm.options.lineWrapping && update.oldDisplayWidth != displayWidth(cm)) {
-        force = true;
-      } else {
-        force = false;
+      if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
         // Clip forced viewport to actual scrollable area.
         if (viewport && viewport.top != null)
           viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)};
@@ -1844,7 +1841,7 @@
       var partPos = getBidiPartAt(order, pos.ch);
       side = partPos % 2 ? "right" : "left";
     }
-    var result = nodeAndOffsetInLineMap(info.map, pos.ch, "left");
+    var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
     result.offset = result.collapse == "right" ? result.end : result.start;
     return result;
   }
diff --git a/mode/apl/apl.js b/mode/apl/apl.js
index 4357bed47..caafe4e91 100644
--- a/mode/apl/apl.js
+++ b/mode/apl/apl.js
@@ -102,7 +102,7 @@ CodeMirror.defineMode("apl", function() {
       };
     },
     token: function(stream, state) {
-      var ch, funcName, word;
+      var ch, funcName;
       if (stream.eatSpace()) {
         return null;
       }
@@ -163,7 +163,6 @@ CodeMirror.defineMode("apl", function() {
         return "function jot-dot";
       }
       stream.eatWhile(/[\w\$_]/);
-      word = stream.current();
       state.prev = true;
       return "keyword";
     }
diff --git a/mode/asterisk/asterisk.js b/mode/asterisk/asterisk.js
index a1ead1157..b7ebfc5ad 100644
--- a/mode/asterisk/asterisk.js
+++ b/mode/asterisk/asterisk.js
@@ -65,8 +65,7 @@ CodeMirror.defineMode("asterisk", function() {
 
   function basicToken(stream,state){
     var cur = '';
-    var ch  = '';
-    ch = stream.next();
+    var ch = stream.next();
     // comment
     if(ch == ";") {
       stream.skipToEnd();
@@ -136,7 +135,6 @@ CodeMirror.defineMode("asterisk", function() {
     token: function(stream, state) {
 
       var cur = '';
-      var ch  = '';
       if(stream.eatSpace()) return null;
       // extension started
       if(state.extenStart){
@@ -170,7 +168,7 @@ CodeMirror.defineMode("asterisk", function() {
       } else if(state.extenPriority) {
         state.extenPriority = false;
         state.extenApplication = true;
-        ch = stream.next(); // get comma
+        stream.next(); // get comma
         if(state.extenSame) return null;
         stream.eatWhile(/[^,]/);
         return "number";
diff --git a/mode/cypher/cypher.js b/mode/cypher/cypher.js
index 9decf3075..e218d4730 100644
--- a/mode/cypher/cypher.js
+++ b/mode/cypher/cypher.js
@@ -19,7 +19,7 @@
 
   CodeMirror.defineMode("cypher", function(config) {
     var tokenBase = function(stream/*, state*/) {
-      var ch = stream.next(), curPunc = null;
+      var ch = stream.next();
       if (ch === "\"" || ch === "'") {
         stream.match(/.+?["']/);
         return "string";
diff --git a/mode/dylan/dylan.js b/mode/dylan/dylan.js
index be2986adb..85f0166c1 100644
--- a/mode/dylan/dylan.js
+++ b/mode/dylan/dylan.js
@@ -154,20 +154,12 @@ CodeMirror.defineMode("dylan", function(_config) {
     return f(stream, state);
   }
 
-  var type, content;
-
-  function ret(_type, style, _content) {
-    type = _type;
-    content = _content;
-    return style;
-  }
-
   function tokenBase(stream, state) {
     // String
     var ch = stream.peek();
     if (ch == "'" || ch == '"') {
       stream.next();
-      return chain(stream, state, tokenString(ch, "string", "string"));
+      return chain(stream, state, tokenString(ch, "string"));
     }
     // Comment
     else if (ch == "/") {
@@ -176,16 +168,16 @@ CodeMirror.defineMode("dylan", function(_config) {
         return chain(stream, state, tokenComment);
       } else if (stream.eat("/")) {
         stream.skipToEnd();
-        return ret("comment", "comment");
+        return "comment";
       } else {
         stream.skipTo(" ");
-        return ret("operator", "operator");
+        return "operator";
       }
     }
     // Decimal
     else if (/\d/.test(ch)) {
       stream.match(/^\d*(?:\.\d*)?(?:e[+\-]?\d+)?/);
-      return ret("number", "number");
+      return "number";
     }
     // Hash
     else if (ch == "#") {
@@ -194,33 +186,33 @@ CodeMirror.defineMode("dylan", function(_config) {
       ch = stream.peek();
       if (ch == '"') {
         stream.next();
-        return chain(stream, state, tokenString('"', "symbol", "string-2"));
+        return chain(stream, state, tokenString('"', "string-2"));
       }
       // Binary number
       else if (ch == "b") {
         stream.next();
         stream.eatWhile(/[01]/);
-        return ret("number", "number");
+        return "number";
       }
       // Hex number
       else if (ch == "x") {
         stream.next();
         stream.eatWhile(/[\da-f]/i);
-        return ret("number", "number");
+        return "number";
       }
       // Octal number
       else if (ch == "o") {
         stream.next();
         stream.eatWhile(/[0-7]/);
-        return ret("number", "number");
+        return "number";
       }
       // Hash symbol
       else {
         stream.eatWhile(/[-a-zA-Z]/);
-        return ret("hash", "keyword");
+        return "keyword";
       }
     } else if (stream.match("end")) {
-      return ret("end", "keyword");
+      return "keyword";
     }
     for (var name in patterns) {
       if (patterns.hasOwnProperty(name)) {
@@ -228,21 +220,21 @@ CodeMirror.defineMode("dylan", function(_config) {
         if ((pattern instanceof Array && pattern.some(function(p) {
           return stream.match(p);
         })) || stream.match(pattern))
-          return ret(name, patternStyles[name], stream.current());
+          return patternStyles[name];
       }
     }
     if (stream.match("define")) {
-      return ret("definition", "def");
+      return "def";
     } else {
       stream.eatWhile(/[\w\-]/);
       // Keyword
       if (wordLookup[stream.current()]) {
-        return ret(wordLookup[stream.current()], styleLookup[stream.current()], stream.current());
+        return styleLookup[stream.current()];
       } else if (stream.current().match(symbol)) {
-        return ret("variable", "variable");
+        return "variable";
       } else {
         stream.next();
-        return ret("other", "variable-2");
+        return "variable-2";
       }
     }
   }
@@ -257,10 +249,10 @@ CodeMirror.defineMode("dylan", function(_config) {
       }
       maybeEnd = (ch == "*");
     }
-    return ret("comment", "comment");
+    return "comment";
   }
 
-  function tokenString(quote, type, style) {
+  function tokenString(quote, style) {
     return function(stream, state) {
       var next, end = false;
       while ((next = stream.next()) != null) {
@@ -271,7 +263,7 @@ CodeMirror.defineMode("dylan", function(_config) {
       }
       if (end)
         state.tokenize = tokenBase;
-      return ret(type, style);
+      return style;
     };
   }
 
diff --git a/mode/ecl/ecl.js b/mode/ecl/ecl.js
index 18778f169..8df7ebe4a 100644
--- a/mode/ecl/ecl.js
+++ b/mode/ecl/ecl.js
@@ -34,7 +34,6 @@ CodeMirror.defineMode("ecl", function(config) {
   var blockKeywords = words("catch class do else finally for if switch try while");
   var atoms = words("true false null");
   var hooks = {"#": metaHook};
-  var multiLineStrings;
   var isOperatorChar = /[+\-*&%=<>!?|\/]/;
 
   var curPunc;
@@ -112,7 +111,7 @@ CodeMirror.defineMode("ecl", function(config) {
         if (next == quote && !escaped) {end = true; break;}
         escaped = !escaped && next == "\\";
       }
-      if (end || !(escaped || multiLineStrings))
+      if (end || !escaped)
         state.tokenize = tokenBase;
       return "string";
     };
diff --git a/mode/eiffel/eiffel.js b/mode/eiffel/eiffel.js
index fcdf295cb..b8b70e36e 100644
--- a/mode/eiffel/eiffel.js
+++ b/mode/eiffel/eiffel.js
@@ -84,7 +84,6 @@ CodeMirror.defineMode("eiffel", function() {
     'or'
   ]);
   var operators = wordObj([":=", "and then","and", "or","<<",">>"]);
-  var curPunc;
 
   function chain(newtok, stream, state) {
     state.tokenize.push(newtok);
@@ -92,7 +91,6 @@ CodeMirror.defineMode("eiffel", function() {
   }
 
   function tokenBase(stream, state) {
-    curPunc = null;
     if (stream.eatSpace()) return null;
     var ch = stream.next();
     if (ch == '"'||ch == "'") {
diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js
index 1cc438f01..24552e2d8 100644
--- a/mode/htmlmixed/htmlmixed.js
+++ b/mode/htmlmixed/htmlmixed.js
@@ -57,9 +57,9 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
   }
   function maybeBackup(stream, pat, style) {
     var cur = stream.current();
-    var close = cur.search(pat), m;
+    var close = cur.search(pat);
     if (close > -1) stream.backUp(cur.length - close);
-    else if (m = cur.match(/<\/?$/)) {
+    else if (cur.match(/<\/?$/)) {
       stream.backUp(cur.length);
       if (!stream.match(pat, false)) stream.match(cur);
     }
diff --git a/mode/julia/julia.js b/mode/julia/julia.js
index e854988aa..d0a74cef5 100644
--- a/mode/julia/julia.js
+++ b/mode/julia/julia.js
@@ -34,7 +34,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
   var closers = wordRegexp(blockClosers);
   var macro = /^@[_A-Za-z][_A-Za-z0-9]*/;
   var symbol = /^:[_A-Za-z][_A-Za-z0-9]*/;
-  var indentInfo = null;
 
   function in_array(state) {
     var ch = cur_scope(state);
@@ -247,7 +246,6 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
   }
 
   function tokenLexer(stream, state) {
-    indentInfo = null;
     var style = state.tokenize(stream, state);
     var current = stream.current();
 
diff --git a/mode/livescript/livescript.js b/mode/livescript/livescript.js
index 55882efc3..4b26e0461 100644
--- a/mode/livescript/livescript.js
+++ b/mode/livescript/livescript.js
@@ -24,8 +24,8 @@
         var nr = Rules[next_rule];
         if (nr.splice) {
           for (var i$ = 0; i$ < nr.length; ++i$) {
-            var r = nr[i$], m;
-            if (r.regex && (m = stream.match(r.regex))) {
+            var r = nr[i$];
+            if (r.regex && stream.match(r.regex)) {
               state.next = r.next || state.next;
               return r.token;
             }
diff --git a/mode/pig/pig.js b/mode/pig/pig.js
index c74b2cc86..5b567272e 100644
--- a/mode/pig/pig.js
+++ b/mode/pig/pig.js
@@ -30,12 +30,6 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
     return f(stream, state);
   }
 
-  var type;
-  function ret(tp, style) {
-    type = tp;
-    return style;
-  }
-
   function tokenComment(stream, state) {
     var isEnd = false;
     var ch;
@@ -46,7 +40,7 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
       }
       isEnd = (ch == "*");
     }
-    return ret("comment", "comment");
+    return "comment";
   }
 
   function tokenString(quote) {
@@ -60,10 +54,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
       }
       if (end || !(escaped || multiLineStrings))
         state.tokenize = tokenBase;
-      return ret("string", "error");
+      return "error";
     };
   }
 
+
   function tokenBase(stream, state) {
     var ch = stream.next();
 
@@ -72,11 +67,11 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
       return chain(stream, state, tokenString(ch));
     // is it one of the special chars
     else if(/[\[\]{}\(\),;\.]/.test(ch))
-      return ret(ch);
+      return null;
     // is it a number?
     else if(/\d/.test(ch)) {
       stream.eatWhile(/[\w\.]/);
-      return ret("number", "number");
+      return "number";
     }
     // multi line comment or operator
     else if (ch == "/") {
@@ -85,47 +80,42 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
       }
       else {
         stream.eatWhile(isOperatorChar);
-        return ret("operator", "operator");
+        return "operator";
       }
     }
     // single line comment or operator
     else if (ch=="-") {
       if(stream.eat("-")){
         stream.skipToEnd();
-        return ret("comment", "comment");
+        return "comment";
       }
       else {
         stream.eatWhile(isOperatorChar);
-        return ret("operator", "operator");
+        return "operator";
       }
     }
     // is it an operator
     else if (isOperatorChar.test(ch)) {
       stream.eatWhile(isOperatorChar);
-      return ret("operator", "operator");
+      return "operator";
     }
     else {
       // get the while word
       stream.eatWhile(/[\w\$_]/);
       // is it one of the listed keywords?
       if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
-        if (stream.eat(")") || stream.eat(".")) {
-          //keywords can be used as variables like flatten(group), group.$0 etc..
-        }
-        else {
-          return ("keyword", "keyword");
-        }
+        //keywords can be used as variables like flatten(group), group.$0 etc..
+        if (!stream.eat(")") && !stream.eat("."))
+          return "keyword";
       }
       // is it one of the builtin functions?
       if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
-      {
-        return ("keyword", "variable-2");
-      }
+        return "variable-2";
       // is it one of the listed types?
       if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
-        return ("keyword", "variable-3");
+        return "variable-3";
       // default is a 'variable'
-      return ret("variable", "pig-word");
+      return "variable";
     }
   }
 
diff --git a/mode/tiddlywiki/tiddlywiki.js b/mode/tiddlywiki/tiddlywiki.js
index 88c9768a7..1df01647a 100644
--- a/mode/tiddlywiki/tiddlywiki.js
+++ b/mode/tiddlywiki/tiddlywiki.js
@@ -71,16 +71,6 @@ CodeMirror.defineMode("tiddlywiki", function () {
     return f(stream, state);
   }
 
-  // Used as scratch variables to communicate multiple values without
-  // consing up tons of objects.
-  var type, content;
-
-  function ret(tp, style, cont) {
-    type = tp;
-    content = cont;
-    return style;
-  }
-
   function jsTokenBase(stream, state) {
     var sol = stream.sol(), ch;
 
@@ -95,16 +85,16 @@ CodeMirror.defineMode("tiddlywiki", function () {
         return chain(stream, state, twTokenCode);
       }
       if (stream.match(reBlockQuote)) {
-        return ret('quote', 'quote');
+        return 'quote';
       }
       if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
-        return ret('code', 'comment');
+        return 'comment';
       }
       if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
-        return ret('code', 'comment');
+        return 'comment';
       }
       if (stream.match(reHR)) {
-        return ret('hr', 'hr');
+        return 'hr';
       }
     } // sol
     ch = stream.next();
@@ -112,30 +102,30 @@ CodeMirror.defineMode("tiddlywiki", function () {
     if (sol && /[\/\*!#;:>|]/.test(ch)) {
       if (ch == "!") { // tw header
         stream.skipToEnd();
-        return ret("header", "header");
+        return "header";
       }
       if (ch == "*") { // tw list
         stream.eatWhile('*');
-        return ret("list", "comment");
+        return "comment";
       }
       if (ch == "#") { // tw numbered list
         stream.eatWhile('#');
-        return ret("list", "comment");
+        return "comment";
       }
       if (ch == ";") { // definition list, term
         stream.eatWhile(';');
-        return ret("list", "comment");
+        return "comment";
       }
       if (ch == ":") { // definition list, description
         stream.eatWhile(':');
-        return ret("list", "comment");
+        return "comment";
       }
       if (ch == ">") { // single line quote
         stream.eatWhile(">");
-        return ret("quote", "quote");
+        return "quote";
       }
       if (ch == '|') {
-        return ret('table', 'header');
+        return 'header';
       }
     }
 
@@ -146,29 +136,29 @@ CodeMirror.defineMode("tiddlywiki", function () {
     // rudimentary html:// file:// link matching. TW knows much more ...
     if (/[hf]/i.test(ch)) {
       if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
-        return ret("link", "link");
+        return "link";
       }
     }
     // just a little string indicator, don't want to have the whole string covered
     if (ch == '"') {
-      return ret('string', 'string');
+      return 'string';
     }
     if (ch == '~') {    // _no_ CamelCase indicator should be bold
-      return ret('text', 'brace');
+      return 'brace';
     }
     if (/[\[\]]/.test(ch)) { // check for [[..]]
       if (stream.peek() == ch) {
         stream.next();
-        return ret('brace', 'brace');
+        return 'brace';
       }
     }
     if (ch == "@") {    // check for space link. TODO fix @@...@@ highlighting
       stream.eatWhile(isSpaceName);
-      return ret("link", "link");
+      return "link";
     }
     if (/\d/.test(ch)) {        // numbers
       stream.eatWhile(/\d/);
-      return ret("number", "number");
+      return "number";
     }
     if (ch == "/") { // tw invisible comment
       if (stream.eat("%")) {
@@ -191,7 +181,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
           return chain(stream, state, twTokenStrike);
         // mdash
         if (stream.peek() == ' ')
-          return ret('text', 'brace');
+          return 'brace';
       }
     }
     if (ch == "'") { // tw bold
@@ -205,7 +195,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
     }
     else {
-      return ret(ch);
+      return null;
     }
 
     // core macro handling
@@ -213,8 +203,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
     var word = stream.current(),
     known = textwords.propertyIsEnumerable(word) && textwords[word];
 
-    return known ? ret(known.type, known.style, word) : ret("text", null, word);
-
+    return known ? known.style : null;
   } // jsTokenBase()
 
   // tw invisible comment
@@ -228,7 +217,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
       maybeEnd = (ch == "%");
     }
-    return ret("comment", "comment");
+    return "comment";
   }
 
   // tw strong / bold
@@ -242,29 +231,29 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
       maybeEnd = (ch == "'");
     }
-    return ret("text", "strong");
+    return "strong";
   }
 
   // tw code
   function twTokenCode(stream, state) {
-    var ch, sb = state.block;
+    var sb = state.block;
 
     if (sb && stream.current()) {
-      return ret("code", "comment");
+      return "comment";
     }
 
     if (!sb && stream.match(reUntilCodeStop)) {
       state.tokenize = jsTokenBase;
-      return ret("code", "comment");
+      return "comment";
     }
 
     if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
       state.tokenize = jsTokenBase;
-      return ret("code", "comment");
+      return "comment";
     }
 
-    ch = stream.next();
-    return (sb) ? ret("code", "comment") : ret("code", "comment");
+    stream.next();
+    return "comment";
   }
 
   // tw em / italic
@@ -278,7 +267,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
       maybeEnd = (ch == "/");
     }
-    return ret("text", "em");
+    return "em";
   }
 
   // tw underlined text
@@ -292,7 +281,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
       maybeEnd = (ch == "_");
     }
-    return ret("text", "underlined");
+    return "underlined";
   }
 
   // tw strike through text looks ugly
@@ -307,7 +296,7 @@ CodeMirror.defineMode("tiddlywiki", function () {
       }
       maybeEnd = (ch == "-");
     }
-    return ret("text", "strikethrough");
+    return "strikethrough";
   }
 
   // macro
@@ -315,19 +304,19 @@ CodeMirror.defineMode("tiddlywiki", function () {
     var ch, word, known;
 
     if (stream.current() == '<<') {
-      return ret('brace', 'macro');
+      return 'macro';
     }
 
     ch = stream.next();
     if (!ch) {
       state.tokenize = jsTokenBase;
-      return ret(ch);
+      return null;
     }
     if (ch == ">") {
       if (stream.peek() == '>') {
         stream.next();
         state.tokenize = jsTokenBase;
-        return ret("brace", "macro");
+        return "macro";
       }
     }
 
@@ -336,10 +325,10 @@ CodeMirror.defineMode("tiddlywiki", function () {
     known = keywords.propertyIsEnumerable(word) && keywords[word];
 
     if (known) {
-      return ret(known.type, known.style, word);
+      return known.style, word;
     }
     else {
-      return ret("macro", null, word);
+      return null, word;
     }
   }
 
diff --git a/mode/tiki/tiki.js b/mode/tiki/tiki.js
index c90aac9ec..5e05b1ff0 100644
--- a/mode/tiki/tiki.js
+++ b/mode/tiki/tiki.js
@@ -52,35 +52,27 @@ CodeMirror.defineMode('tiki', function(config) {
     case "{": //plugin
       stream.eat("/");
       stream.eatSpace();
-      var tagName = "";
-      var c;
-      while ((c = stream.eat(/[^\s\u00a0=\"\'\/?(}]/))) tagName += c;
+      stream.eatWhile(/[^\s\u00a0=\"\'\/?(}]/);
       state.tokenize = inPlugin;
       return "tag";
-      break;
     case "_": //bold
-      if (stream.eat("_")) {
+      if (stream.eat("_"))
         return chain(inBlock("strong", "__", inText));
-      }
       break;
     case "'": //italics
-      if (stream.eat("'")) {
-        // Italic text
+      if (stream.eat("'"))
         return chain(inBlock("em", "''", inText));
-      }
       break;
     case "(":// Wiki Link
-      if (stream.eat("(")) {
+      if (stream.eat("("))
         return chain(inBlock("variable-2", "))", inText));
-      }
       break;
     case "[":// Weblink
       return chain(inBlock("variable-3", "]", inText));
       break;
     case "|": //table
-      if (stream.eat("|")) {
+      if (stream.eat("|"))
         return chain(inBlock("comment", "||"));
-      }
       break;
     case "-":
       if (stream.eat("=")) {//titleBar
@@ -90,22 +82,19 @@ CodeMirror.defineMode('tiki', function(config) {
       }
       break;
     case "=": //underline
-      if (stream.match("==")) {
+      if (stream.match("=="))
         return chain(inBlock("tw-underline", "===", inText));
-      }
       break;
     case ":":
-      if (stream.eat(":")) {
+      if (stream.eat(":"))
         return chain(inBlock("comment", "::"));
-      }
       break;
     case "^": //box
       return chain(inBlock("tw-box", "^"));
       break;
     case "~": //np
-      if (stream.match("np~")) {
+      if (stream.match("np~"))
         return chain(inBlock("meta", "~/np~"));
-      }
       break;
     }
 
diff --git a/mode/xquery/xquery.js b/mode/xquery/xquery.js
index c8f3d90a9..c642ee58f 100644
--- a/mode/xquery/xquery.js
+++ b/mode/xquery/xquery.js
@@ -68,15 +68,6 @@ CodeMirror.defineMode("xquery", function() {
     return kwObj;
   }();
 
-  // Used as scratch variables to communicate multiple values without
-  // consing up tons of objects.
-  var type, content;
-
-  function ret(tp, style, cont) {
-    type = tp; content = cont;
-    return style;
-  }
-
   function chain(stream, state, f) {
     state.tokenize = f;
     return f(stream, state);
@@ -95,7 +86,7 @@ CodeMirror.defineMode("xquery", function() {
 
       if(stream.match("![CDATA", false)) {
         state.tokenize = tokenCDATA;
-        return ret("tag", "tag");
+        return "tag";
       }
 
       if(stream.match("?", false)) {
@@ -112,28 +103,28 @@ CodeMirror.defineMode("xquery", function() {
     // start code block
     else if(ch == "{") {
       pushStateStack(state,{ type: "codeblock"});
-      return ret("", null);
+      return null;
     }
     // end code block
     else if(ch == "}") {
       popStateStack(state);
-      return ret("", null);
+      return null;
     }
     // if we're in an XML block
     else if(isInXmlBlock(state)) {
       if(ch == ">")
-        return ret("tag", "tag");
+        return "tag";
       else if(ch == "/" && stream.eat(">")) {
         popStateStack(state);
-        return ret("tag", "tag");
+        return "tag";
       }
       else
-        return ret("word", "variable");
+        return "variable";
     }
     // if a number
     else if (/\d/.test(ch)) {
       stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
-      return ret("number", "atom");
+      return "atom";
     }
     // comment start
     else if (ch === "(" && stream.eat(":")) {
@@ -149,27 +140,27 @@ CodeMirror.defineMode("xquery", function() {
     }
     // assignment
     else if(ch ===":" && stream.eat("=")) {
-      return ret("operator", "keyword");
+      return "keyword";
     }
     // open paren
     else if(ch === "(") {
       pushStateStack(state, { type: "paren"});
-      return ret("", null);
+      return null;
     }
     // close paren
     else if(ch === ")") {
       popStateStack(state);
-      return ret("", null);
+      return null;
     }
     // open paren
     else if(ch === "[") {
       pushStateStack(state, { type: "bracket"});
-      return ret("", null);
+      return null;
     }
     // close paren
     else if(ch === "]") {
       popStateStack(state);
-      return ret("", null);
+      return null;
     }
     else {
       var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
@@ -204,15 +195,14 @@ CodeMirror.defineMode("xquery", function() {
       // if the previous word was element, attribute, axis specifier, this word should be the name of that
       if(isInXmlConstructor(state)) {
         popStateStack(state);
-        return ret("word", "variable", word);
+        return "variable";
       }
       // as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
       // push the stack so we know to look for it on the next word
       if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
 
       // if the word is known, return the details of that else just call this a generic 'word'
-      return known ? ret(known.type, known.style, word) :
-                     ret("word", "variable", word);
+      return known ? known.style : "variable";
     }
   }
 
@@ -235,7 +225,7 @@ CodeMirror.defineMode("xquery", function() {
       maybeNested = (ch == "(");
     }
 
-    return ret("comment", "comment");
+    return "comment";
   }
 
   // tokenizer for string literals
@@ -247,7 +237,7 @@ CodeMirror.defineMode("xquery", function() {
       if(isInString(state) && stream.current() == quote) {
         popStateStack(state);
         if(f) state.tokenize = f;
-        return ret("string", "string");
+        return "string";
       }
 
       pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
@@ -255,7 +245,7 @@ CodeMirror.defineMode("xquery", function() {
       // if we're in a string and in an XML block, allow an embedded code block
       if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
         state.tokenize = tokenBase;
-        return ret("string", "string");
+        return "string";
       }
 
 
@@ -269,13 +259,13 @@ CodeMirror.defineMode("xquery", function() {
           // if we're in a string and in an XML block, allow an embedded code block in an attribute
           if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
             state.tokenize = tokenBase;
-            return ret("string", "string");
+            return "string";
           }
 
         }
       }
 
-      return ret("string", "string");
+      return "string";
     };
   }
 
@@ -293,7 +283,7 @@ CodeMirror.defineMode("xquery", function() {
     }
     stream.eatWhile(isVariableChar);
     state.tokenize = tokenBase;
-    return ret("variable", "variable");
+    return "variable";
   }
 
   // tokenizer for XML tags
@@ -303,19 +293,19 @@ CodeMirror.defineMode("xquery", function() {
       if(isclose && stream.eat(">")) {
         popStateStack(state);
         state.tokenize = tokenBase;
-        return ret("tag", "tag");
+        return "tag";
       }
       // self closing tag without attributes?
       if(!stream.eat("/"))
         pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
       if(!stream.eat(">")) {
         state.tokenize = tokenAttribute;
-        return ret("tag", "tag");
+        return "tag";
       }
       else {
         state.tokenize = tokenBase;
       }
-      return ret("tag", "tag");
+      return "tag";
     };
   }
 
@@ -326,14 +316,14 @@ CodeMirror.defineMode("xquery", function() {
     if(ch == "/" && stream.eat(">")) {
       if(isInXmlAttributeBlock(state)) popStateStack(state);
       if(isInXmlBlock(state)) popStateStack(state);
-      return ret("tag", "tag");
+      return "tag";
     }
     if(ch == ">") {
       if(isInXmlAttributeBlock(state)) popStateStack(state);
-      return ret("tag", "tag");
+      return "tag";
     }
     if(ch == "=")
-      return ret("", null);
+      return null;
     // quoted string
     if (ch == '"' || ch == "'")
       return chain(stream, state, tokenString(ch, tokenAttribute));
@@ -351,7 +341,7 @@ CodeMirror.defineMode("xquery", function() {
       state.tokenize = tokenBase;
     }
 
-    return ret("attribute", "attribute");
+    return "attribute";
   }
 
   // handle comments, including nested
@@ -360,7 +350,7 @@ CodeMirror.defineMode("xquery", function() {
     while (ch = stream.next()) {
       if (ch == "-" && stream.match("->", true)) {
         state.tokenize = tokenBase;
-        return ret("comment", "comment");
+        return "comment";
       }
     }
   }
@@ -372,7 +362,7 @@ CodeMirror.defineMode("xquery", function() {
     while (ch = stream.next()) {
       if (ch == "]" && stream.match("]", true)) {
         state.tokenize = tokenBase;
-        return ret("comment", "comment");
+        return "comment";
       }
     }
   }
@@ -383,7 +373,7 @@ CodeMirror.defineMode("xquery", function() {
     while (ch = stream.next()) {
       if (ch == "?" && stream.match(">", true)) {
         state.tokenize = tokenBase;
-        return ret("comment", "comment meta");
+        return "comment meta";
       }
     }
   }
-- 
GitLab