[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode b684790 219/468: Revert "Rename lua--function-nam
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode b684790 219/468: Revert "Rename lua--function-name-rx, use it in font-lock keywords init" |
Date: |
Thu, 5 Aug 2021 04:58:40 -0400 (EDT) |
branch: elpa/lua-mode
commit b684790f8bf38e52c95fe481c38f6a3ecee25e2f
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Revert "Rename lua--function-name-rx, use it in font-lock keywords init"
This reverts commit 1d8dc5572be40071b61c5027a9c7fdcb68495e5c.
---
lua-mode.el | 190 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 99 insertions(+), 91 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 08862ec..ca99bb8 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -493,94 +493,92 @@ Groups 6-9 can be used in any of argument regexps."
(re-search-forward "\\(?1:\\(?2:[^ \t]+\\)\\)" parse-stop
'skip)
(prog1 nil (goto-char end)))))))))
-(eval-and-compile
- (defconst lua--function-name-rx
- '(seq symbol-start
- (+ (any alnum "_"))
- (* "." (+ (any alnum "_")))
- (? ":" (+ (any alnum "_")))
- symbol-end)
- "Lua function name regexp in `rx'-SEXP format."))
+(defconst lua-local-defun-regexp
+ ;; Function matchers are very crude, need rewrite at some point.
+ (rx (or (seq (regexp "\\(?:\\_<function\\_>\\)")
+ (* blank)
+ (? (regexp "\\(?1:\\_<[[:alpha:]][[:alnum:]]*\\_>\\)"))
+ (regexp "\\(?2:.*\\)"))
+ (seq (? (regexp "\\(?1:\\_<[[:alpha:]][[:alnum:]]*\\_>\\)"))
+ (* blank) "=" (* blank)
+ (regexp "\\(?:\\_<function\\_>\\)")
+ (regexp "\\(?2:.*\\)")))))
+
+(defvar lua-font-lock-keywords
+ `(;; highlight the hash-bang line "#!/foo/bar/lua" as comment
+ ("^#!.*$" . font-lock-comment-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"
+ "while")
+ symbol-end)
+ . font-lock-keyword-face)
+
+ ;; Highlight lua builtin functions and variables
+ (,lua--builtins
+ (1 font-lock-builtin-face) (2 font-lock-builtin-face nil noerror))
+
+ ;; hexadecimal numbers
+ ("\\_<0x[[:xdigit:]]+\\_>" . font-lock-constant-face)
+
+ ;; regular numbers
+ ;;
+ ;; This regexp relies on '.' being symbol constituent. Whenever this
+ ;; changes, the regexp needs revisiting --immerrr
+ (, (rx symbol-start
+ ;; make a digit on either side of dot mandatory
+ (or (seq (+ num) (? ".") (* num))
+ (seq (* num) (? ".") (+ num)))
+ (? (regexp "[eE][+-]?") (+ num))
+ symbol-end)
+ . font-lock-constant-face)
+
+ ("^[ \t]*\\_<for\\_>"
+ (,(lua-make-delimited-matcher "\\_<[[:alpha:]_][[:alnum:]_]*\\_>" ","
+ "\\(?:\\_<in\\_>\\|=\\(?:[^=]\\|$\\)\\)")
+ nil nil
+ (1 font-lock-variable-name-face nil noerror)
+ (2 font-lock-warning-face t noerror)
+ (3 font-lock-warning-face t noerror)))
+
+ ;; Handle local variable/function names
+ ;; local blalba, xyzzy =
+ ;; ^^^^^^ ^^^^^
+ ;;
+ ;; local function foobar(x,y,z)
+ ;; ^^^^^^
+ ;; local foobar = function(x,y,z)
+ ;; ^^^^^^
+ ("^[ \t]*\\_<local\\_>"
+ (0 font-lock-keyword-face)
+
+ ((lambda (end)
+ (re-search-forward
+ (rx point (* blank) (regexp ,lua-local-defun-regexp)) end t))
+ nil nil
+ (1 font-lock-function-name-face nil noerror))
+
+ (,(lua-make-delimited-matcher "\\_<[[:alpha:]_][[:alnum:]_]*\\_>" ","
+ "=\\(?:[^=]\\|$\\)")
+ nil nil
+ (1 font-lock-variable-name-face nil noerror)
+ (2 font-lock-warning-face t noerror)
+ (3 font-lock-warning-face t noerror)))
-(eval-and-compile
- (defconst lua-defun-intro-regexp
;; Function matchers are very crude, need rewrite at some point.
- (rx
- (or (seq (regexp "\\(?:\\_<function\\_>\\)")
- (* blank)
- (? (regexp "\\(?1:") (eval lua--function-name-rx) (regexp
"\\)")))
- (seq (? (regexp "\\(?1:") (eval lua--function-name-rx) (regexp "\\)"))
- (* blank) "=" (* blank)
- (regexp "\\(?:\\_<function\\_>\\)")))))
-
- (defvar lua-font-lock-keywords
- `( ;; highlight the hash-bang line "#!/foo/bar/lua" as comment
- ("^#!.*$" . font-lock-comment-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"
- "while")
- symbol-end)
- . font-lock-keyword-face)
-
- ;; Highlight lua builtin functions and variables
- (,lua--builtins
- (1 font-lock-builtin-face) (2 font-lock-builtin-face nil noerror))
-
- ;; hexadecimal numbers
- ("\\_<0x[[:xdigit:]]+\\_>" . font-lock-constant-face)
-
- ;; regular numbers
- ;;
- ;; This regexp relies on '.' being symbol constituent. Whenever this
- ;; changes, the regexp needs revisiting --immerrr
- (, (rx symbol-start
- ;; make a digit on either side of dot mandatory
- (or (seq (+ num) (? ".") (* num))
- (seq (* num) (? ".") (+ num)))
- (? (regexp "[eE][+-]?") (+ num))
- symbol-end)
- . font-lock-constant-face)
-
- ("^[ \t]*\\_<for\\_>"
- (,(lua-make-delimited-matcher "\\_<[[:alpha:]_][[:alnum:]_]*\\_>" ","
- "\\(?:\\_<in\\_>\\|=\\(?:[^=]\\|$\\)\\)")
- nil nil
- (1 font-lock-variable-name-face nil noerror)
- (2 font-lock-warning-face t noerror)
- (3 font-lock-warning-face t noerror)))
-
- ;; Handle local variable/function names
- ;; local blalba, xyzzy =
- ;; ^^^^^^ ^^^^^
- ;;
- ;; local function foobar(x,y,z)
- ;; ^^^^^^
- ;; local foobar = function(x,y,z)
- ;; ^^^^^^
- ("^[ \t]*\\_<local\\_>"
- (0 font-lock-keyword-face)
-
- ((lambda (end)
- (re-search-forward
- (rx point (* blank) (regexp ,lua-defun-intro-regexp)) end t))
- nil nil
- (1 font-lock-function-name-face nil noerror))
-
- (,(lua-make-delimited-matcher "\\_<[[:alpha:]_][[:alnum:]_]*\\_>" ","
- "=\\(?:[^=]\\|$\\)")
- nil nil
- (1 font-lock-variable-name-face nil noerror)
- (2 font-lock-warning-face t noerror)
- (3 font-lock-warning-face t noerror)))
-
- (,lua-defun-intro-regexp
- (1 font-lock-function-name-face)))
-
- "Default expressions to highlight in Lua mode."))
+ ;; Function name declarations.
+ ("^[ \t]*\\_<function\\_>[
\t]+\\([[:alnum:]_]+\\(?:\\.[[:alnum:]_]+\\)*\\(?::[[:alnum:]_]+\\)?\\)"
+ (1 font-lock-function-name-face))
+
+ ;; Function matchers are very crude, need rewrite at some point.
+ ;; Handle function names in assignments
+ ("^[
\t]*\\([[:alnum:]_]+\\(?:\\.[[:alnum:]_]+\\)*\\(?::[[:alnum:]_]+\\)?\\)[ \t]*=[
\t]*\\_<function\\_>"
+ (1 font-lock-function-name-face)))
+
+ "Default expressions to highlight in Lua mode.")
(defvar lua-imenu-generic-expression
;; This regexp matches expressions which look like function
@@ -1364,8 +1362,18 @@ one."
(cdr indentation-info))))
-(eval-and-compile
- (defconst lua--left-shifter-regexp
+(eval-when-compile
+ (defconst lua--function-name-rx
+ '(seq symbol-start
+ (+ (any alnum "_"))
+ (* "." (+ (any alnum "_")))
+ (? ":" (+ (any alnum "_")))
+ symbol-end)
+ "Lua function name regexp in `rx'-SEXP format."))
+
+
+(defconst lua--left-shifter-regexp
+ (eval-when-compile
(rx
;; This regexp should answer the following questions:
;; 1. is there a left shifter regexp on that line?
@@ -1388,9 +1396,9 @@ one."
"function"
(seq
(eval lua--function-name-rx) (* blank)
- (regexp "\\(?1:\\)") (any "({"))))))
+ (regexp "\\(?1:\\)") (any "({")))))))
- "Regular expression that matches left-shifter expression.
+ "Regular expression that matches left-shifter expression.
Left-shifter expression is defined as follows. If a block
follows a left-shifter expression, its contents & block-close
@@ -1412,7 +1420,7 @@ The following left-shifter expressions are currently
handled:
3. assignment/return statement with
- table constructor block, {}
- function call arguments block, () or {} block
- - function expression a.k.a. lambda, begin-end block."))
+ - function expression a.k.a. lambda, begin-end block.")
(defun lua-point-is-after-left-shifter-p ()
- [nongnu] elpa/lua-mode 0407042 153/468: Make lua-with-silent-modifications available during byte-compilation, (continued)
- [nongnu] elpa/lua-mode 0407042 153/468: Make lua-with-silent-modifications available during byte-compilation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b1dc70c 158/468: lua-font-lock-keywords: highlight builtin symbols (issue #15), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 52dcf7b 167/468: Merge pull request #35 from vhallac/fix-34, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a3016a2 176/468: Avoid polluting "global namespace" when striving for backward compatibility, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b124dd0 194/468: Add field containing commit SHA expanded during archive creation., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 64c1e94 197/468: lua--builtins: add "self" as keyword, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d6c8419 202/468: Fix incorrect error highlighting in 'for x = ...' statements, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2d94dee 204/468: Don't unindent comment close-bracket if it doesn't match open-bracket, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c1fcfb6 211/468: Add NEWS file, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d0fa50d 217/468: lua-make-delimited-matcher: wrap into eval-and-compile, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b684790 219/468: Revert "Rename lua--function-name-rx, use it in font-lock keywords init",
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 8e19d23 231/468: Add basic indentation tests, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6729533 234/468: Rewrite lua-send-buffer function (should fix issue #60), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode afc1ea0 235/468: Send init-code in lua-start-process, enable compilation-shell-minor-mode, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1ede907 242/468: Fix several cases for `indent-new-comment-line' (M-j), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6c55abb 245/468: Add lua-rx/-to-string wrappers to simplify writing Lua-specific regexps, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1452f8e 244/468: should-lua-indent: accept strings rather than lists to simplify writing tests, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a0f3a6f 250/468: Simplify font-lock & imenu regexps with lua-rx, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e430d01 252/468: Remove deprecated test code from test/, put current code there instead, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1d21a10 259/468: Reorganize test structure, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dc55356 261/468: lua-forward-regexp: make sure direction is `forward', Philip Kaludercic, 2021/08/05