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

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

[nongnu] elpa/lua-mode 4141c85 222/468: Make builtin font-locking more s


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 4141c85 222/468: Make builtin font-locking more stable; enable it after ".." operator
Date: Thu, 5 Aug 2021 04:58:40 -0400 (EDT)

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

    Make builtin font-locking more stable; enable it after ".." operator
    
    Instability was caused by an attempt to handle multiline 'funcname'
    nonterminals which is useless unless font-lock region is expanded
    properly.
---
 ert-tests/test-builtin-font-lock.el | 30 ++++++++++++++++++++++++++++++
 lua-mode.el                         | 10 ++++++----
 2 files changed, 36 insertions(+), 4 deletions(-)

diff --git a/ert-tests/test-builtin-font-lock.el 
b/ert-tests/test-builtin-font-lock.el
index f170c83..3f35940 100644
--- a/ert-tests/test-builtin-font-lock.el
+++ b/ert-tests/test-builtin-font-lock.el
@@ -6,6 +6,36 @@
                  "lua-font-lock-test-helpers.el"))
 
 
+(ert-deftest lua-font-lock-builtins ()
+  (should-lua-font-lock-equal
+   "\
+table.sort(foobar)
+   table.sort(foobar)
+   table  .sort(foobar)
+   table.  sort(foobar)"
+   '(("table" builtin "sort" builtin)
+     ("table" builtin "sort" builtin)
+     ("table" builtin "sort" builtin)
+     ("table" builtin "sort" builtin)))
+
+  (should-lua-font-lock-equal
+   ;; Neither of these should be highlighted, thing that looks like a builtin
+   ;; is in fact a member of some user table.
+   "\
+foo.table.sort(foobar)
+foo.  table.sort(foobar)
+foo  .table.sort(foobar)
+foo:table.sort(foobar)
+foo:  table.sort(foobar)
+foo  :table.sort(foobar)"
+   '(nil nil nil nil nil nil))
+
+  (should-lua-font-lock-equal
+   ;; After concatenation operator builtins should be highlighted too.
+   "a .. table.concat(foobar, delim)"
+   '(("table" builtin "concat" builtin))))
+
+
 (ert-deftest lua-font-lock-builtin-constants()
   (should-lua-font-lock-equal
    "a = { nil, true, false}"
diff --git a/lua-mode.el b/lua-mode.el
index bf20c05..59a6a0a 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -394,11 +394,13 @@ traceback location."
                                  "")))
 
        (concat
-        ;; common prefix - beginning-of-line or neither of [ '.', ':' ] to
-        ;; exclude "foo.string.rep"
-        "\\(?:\\`\\|[^:. \n\t]\\)"
+        ;; common prefix:
+        ;; - beginning-of-line
+        ;; - or neither of [ '.', ':' ] to exclude "foo.string.rep"
+        ;; - or concatenation operator ".."
+        "\\(?:^\\|[^:. \t]\\|[.][.]\\)"
         ;; optional whitespace
-        "[ \n\t]*"
+        "[ \t]*"
         "\\(?:"
         ;; any of modules/functions
         (mapconcat (lambda (x) (concat (module-name-re x)



reply via email to

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