From 0dbe0ef55d50734818325bbbc211f47c21c3c0ed Mon Sep 17 00:00:00 2001
From: TDaglis <ath.daglis@gmail.com>
Date: Tue, 15 Dec 2015 11:39:14 +0000
Subject: [PATCH] [django mode] better highlighting of in/and/or/not

Currently operators in most themes look like normal text because
cm-operator doesn't usually get special styling. This patch highlights
word operators (in/and/or/not) to make them stand out better.
---
 mode/django/django.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/mode/django/django.js b/mode/django/django.js
index 7fae876c1..eb8d65914 100644
--- a/mode/django/django.js
+++ b/mode/django/django.js
@@ -35,11 +35,13 @@
                    "truncatechars_html", "truncatewords", "truncatewords_html",
                    "unordered_list", "upper", "urlencode", "urlize",
                    "urlizetrunc", "wordcount", "wordwrap", "yesno"],
-        operators = ["==", "!=", "<", ">", "<=", ">=", "in", "not", "or", "and"];
+        operators = ["==", "!=", "<", ">", "<=", ">="],
+        wordOperators = ["in", "not", "or", "and"];
 
     keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
     filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
     operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
+    wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");
 
     // We have to return "null" instead of null, in order to avoid string
     // styling as the default, when using Django templates inside HTML
@@ -270,6 +272,11 @@
         return "operator";
       }
 
+      // Attempt to match a word operator
+      if (stream.match(wordOperators)) {
+        return "keyword";
+      }
+
       // Attempt to match a keyword
       var keywordMatch = stream.match(keywords);
       if (keywordMatch) {
-- 
GitLab