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

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

[nongnu] elpa/lua-mode 9e200e8 247/468: Fix font-locking of functions wi


From: Philip Kaludercic
Subject: [nongnu] elpa/lua-mode 9e200e8 247/468: Fix font-locking of functions with underscores (issue #63)
Date: Thu, 5 Aug 2021 04:58:46 -0400 (EDT)

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

    Fix font-locking of functions with underscores (issue #63)
---
 ert-tests/test-defun-font-lock.el | 17 +++++++++++++++++
 lua-mode.el                       | 10 ++++++----
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/ert-tests/test-defun-font-lock.el 
b/ert-tests/test-defun-font-lock.el
index d41acf1..125ebf7 100644
--- a/ert-tests/test-defun-font-lock.el
+++ b/ert-tests/test-defun-font-lock.el
@@ -60,3 +60,20 @@ end"
      ("local" keyword "function" keyword "foo" function-name)
      nil
      ("end" keyword))))
+
+(ert-deftest lua-funcnames-with-underscore ()
+  (should-lua-font-lock-equal
+   ;; Check all defun variants, check embedded defuns
+   "\
+function foo()
+  function bar_bar() end
+  local function baz_baz() end
+  qux_qux = function() end
+  local quux_quux = function() end
+end"
+   '(("function" keyword "foo" function-name)
+     ("function" keyword "bar_bar" function-name "end" keyword)
+     ("local" keyword "function" keyword "baz_baz" function-name "end" keyword)
+     ("qux_qux" function-name "function" keyword "end" keyword)
+     ("local" keyword "quux_quux" function-name "function" keyword "end" 
keyword)
+     ("end" keyword)))  )
diff --git a/lua-mode.el b/lua-mode.el
index a1c008a..5001801 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -144,7 +144,7 @@ element is itself expanded with `lua-rx-to-string'. "
     (let ((name (car form))
           (form-definition (cdr form)))
       (when (and (listp form-definition) (eq ':rx (car form-definition)))
-        (setcdr form (lua-rx-to-string (cadr form-definition) t)))
+        (setcdr form (lua-rx-to-string (cadr form-definition) 'nogroup)))
       (push form lua-rx-constituents)))
 
   (defun lua--rx-symbol (form)
@@ -169,8 +169,10 @@ element is itself expanded with `lua-rx-to-string'. "
            :rx (seq lua-name (* ws "." ws lua-name)
                     (opt ws ":" ws lua-name)))
           (lua-funcheader
-           :rx (or (seq (symbol "function") ws (group-n 1 lua-funcname))
-                   (seq (group-n 1 lua-funcname) ws "=" ws (symbol 
"function"))))
+           ;; Outer (seq ...) is here to shy-group the definition
+           :rx (seq (or (seq (symbol "function") ws (group-n 1 lua-funcname))
+                        (seq (group-n 1 lua-funcname) ws "=" ws
+                             (symbol "function")))))
           (lua-number
            :rx (seq (or (seq (+ digit) (opt ".") (* digit))
                         (seq (* digit) (opt ".") (+ digit)))
@@ -619,7 +621,7 @@ Groups 6-9 can be used in any of argument regexps."
 
      ((lambda (end)
         (re-search-forward
-         (rx point (* blank) (regexp ,lua-local-defun-regexp)) end t))
+         (lua-rx point ws lua-funcheader (* nonl)) end t))
       nil nil
       (1 font-lock-function-name-face nil noerror))
 



reply via email to

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