branch: master
commit 88a921f641dccc268b3b35f07abbea1d1d8e30a6
Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>

    Improve defun regexp.
---
 context-coloring.el |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/context-coloring.el b/context-coloring.el
index ae5ed90..ead1a79 100644
--- a/context-coloring.el
+++ b/context-coloring.el
@@ -389,14 +389,26 @@ generated by `js2-mode'."
 (defun context-coloring-stack-depth-equal (stack depth)
   (= (plist-get (car stack) :depth) depth))
 
+(defun context-coloring-exact-regexp (word)
+  "Create a regexp that matches exactly WORD."
+  (concat "\\`" (regexp-quote word) "\\'"))
+
+(defun context-coloring-exact-or-regexp (words)
+  "Create a regexp that matches any exact word in WORDS."
+  (context-coloring-join
+   (mapcar 'context-coloring-exact-regexp words) "\\|"))
+
 (defconst context-coloring-defun-regexp
-  "\\`defun\\'\\|\\`defmacro\\'\\|\\`defsubst\\'")
+  (context-coloring-exact-or-regexp
+   '("defun" "defun*" "defsubst" "defmacro"
+     "cl-defun" "cl-defsubst" "cl-defmacro")))
 
 (defconst context-coloring-arglist-arg-regexp
   "\\`[^&:]")
 
 (defconst context-coloring-ignored-word-regexp
-  "\\`[-+]?[0-9]\\|\\`t\\'\\|\\`nil\\'\\|\\`\\.\\'\\|\\`\\?\\'")
+  (concat "\\`[-+]?[0-9]\\|" (context-coloring-exact-or-regexp
+                              '("t" "nil" "." "?"))))
 
 (defconst context-coloring-COMMA-CHAR 44)
 (defconst context-coloring-BACKTICK-CHAR 96)

Reply via email to