emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/lua-mode 94aadfd 221/468: Font-lock "nil", "true" and "fal


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 94aadfd 221/468: Font-lock "nil", "true" and "false" as constants rather than keywords
Date: Thu, 5 Aug 2021 04:58:40 -0400 (EDT)

branch: elpa/lua-mode
commit 94aadfd8f7b0414ba58de2c10b0a52da5832f43f
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>

    Font-lock "nil", "true" and "false" as constants rather than keywords
---
 Makefile                            |  4 +++-
 ert-tests/test-builtin-font-lock.el | 18 ++++++++++++++++++
 lua-mode.el                         | 12 ++++++++----
 3 files changed, 29 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 921b196..18b230a 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,9 @@ DISTFILE = lua-mode-$(VERSION).zip
 # EMACS value may be overridden
 EMACS?=emacs
 
-TESTS=ert-tests/test-defun-font-lock.el
+TESTS=
+TESTS += ert-tests/test-defun-font-lock.el
+TESTS += ert-tests/test-builtin-font-lock.el
 
 default:
        @echo version is $(VERSION)
diff --git a/ert-tests/test-builtin-font-lock.el 
b/ert-tests/test-builtin-font-lock.el
new file mode 100644
index 0000000..f170c83
--- /dev/null
+++ b/ert-tests/test-builtin-font-lock.el
@@ -0,0 +1,18 @@
+(require 'ert)
+(require 'lua-font-lock-test-helpers
+         ;; let's try a bit to help Emacs find the helpers, just in case
+         (concat (file-name-directory (or load-file-name (buffer-file-name)
+                                          default-directory))
+                 "lua-font-lock-test-helpers.el"))
+
+
+(ert-deftest lua-font-lock-builtin-constants()
+  (should-lua-font-lock-equal
+   "a = { nil, true, false}"
+   '(("nil" constant "true" constant "false" constant)))
+
+  (should-lua-font-lock-equal
+   "a = { foo.true, foo:false }"
+   '(;; This case won't work while '.' has symbol syntax
+     ;; ("true" constant "false" constant)
+     ("false" constant))))
diff --git a/lua-mode.el b/lua-mode.el
index ca99bb8..bf20c05 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -508,11 +508,15 @@ Groups 6-9 can be used in any of argument regexps."
   `(;; highlight the hash-bang line "#!/foo/bar/lua" as comment
     ("^#!.*$" . font-lock-comment-face)
 
-    ;; Keywords.
+    ;; Builtin constants
+    (,(rx symbol-start (or "true" "false" "nil") symbol-end)
+     . font-lock-constant-face)
+
+    ;; Keywords
     (,(rx symbol-start
-          (or "and" "break" "do" "else" "elseif" "end" "false"
-              "for" "function" "if" "in" "local" "nil" "not"
-              "or" "repeat" "return" "then" "true" "until"
+          (or "and" "break" "do" "else" "elseif" "end"
+              "for" "function" "if" "in" "local" "not"
+              "or" "repeat" "return" "then" "until"
               "while")
           symbol-end)
      . font-lock-keyword-face)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]