[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode b1ac542 191/468: Major refactoring of font-lock-k
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode b1ac542 191/468: Major refactoring of font-lock-keywords: |
Date: |
Thu, 5 Aug 2021 04:58:34 -0400 (EDT) |
branch: elpa/lua-mode
commit b1ac542988736aaa116a15c80f1ec87510d84344
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Major refactoring of font-lock-keywords:
- add highlighting of local var assignments with multiple variables
local x,y,z = ...
- simple on-fly syntax check in local var assignments
local 00xyz, foo, bar,, baz bux = ....
^^ ^ ^^^
these are syntax errors and will be highlighted
- faster and more precise function name matching
- fix docstring; it was inside (eval-when-compile ...) block and hence
considered one of the font-lock rules :)
---
lua-mode.el | 45 ++++++++++++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 13 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 039e7f4..a5fe56f 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -537,26 +537,45 @@ Groups 6-9 can be used in any of argument regexps."
symbol-end)
. font-lock-constant-face)
- ;; Handle variable names
- ;; local blalba =
+ ;; Handle local variable/function names
+ ;; local blalba, xyzzy =
+ ;; ^^^^^^ ^^^^^
+ ;;
+ ;; local function foobar(x,y,z)
+ ;; ^^^^^^
+ ;; local foobar = function(x,y,z)
;; ^^^^^^
- '("local[ \t]+\\([[:alnum:]_]+\\)\\(?:[ \t]*,[
\t]*\\([[:alnum:]_]+\\)\\)[ \t]*="
- (1 font-lock-variable-name-face)
- (2 font-lock-variable-name-face))
-
+ `("^[ \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)))
+
+ ;; Function matchers are very crude, need rewrite at some point.
;; Function name declarations.
- '("^[ \t]*\\_<\\(\\(local[ \t]+\\)?function\\)\\_>[
\t]+\\(\\(\\sw:\\|\\sw\\.\\|\\sw_\\|\\sw\\)+\\)"
- (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t))
-
- ;; Handle function names in assignments
- '("\\([[:alnum:]_]+\\(?:[:.][[:alnum:]_]+\\)*\\)[ \t]*=[ \t]*function\\_>"
+ '("^[ \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.")))
+ "Default expressions to highlight in Lua mode.")
(defvar lua-imenu-generic-expression
- '((nil "^[ \t]*\\(?:local[ \t]+\\)?function[
\t]+\\(\\(\\sw:\\|\\sw_\\|\\sw\\.\\|\\sw\\)+\\)" 1))
+ ;; Very rough expression, but probably it's for the best, since it's used for
+ ;; navigation. --immerrr
+ '((nil "^[ \t]*\\(?:local[ \t]+\\)?function[ \t]+[[:alnum:]_:.]" 1))
"Imenu generic expression for lua-mode. See `imenu-generic-expression'.")
(defvar lua-sexp-alist '(("then" . "end")
- [nongnu] elpa/lua-mode d742cae 116/468: lua-mark-all-multiline-literals: comment out debug message, (continued)
- [nongnu] elpa/lua-mode d742cae 116/468: lua-mark-all-multiline-literals: comment out debug message, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5542927 122/468: lua-automark-multiline: add function to enable automatical multiline construct marking when emacs is idle, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6beb586 123/468: Add customizable lua-automark-multiline-interval variable, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode eab8fc0 136/468: Move docstrings to the end of constants., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a5cc71f 149/468: Bump version & URL, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode caa3d0c 162/468: lua-jump-to-traceback: fix compilation warning about goto-line func, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fb53190 164/468: First part of the fix for #34, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 086736c 168/468: #36 Don't continue lines on some keywords, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b9541ce 173/468: lua-send-proc is now an alias to lua-send-defun, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8d28342 187/468: Revisit block-close unindentation logic (issue #26), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b1ac542 191/468: Major refactoring of font-lock-keywords:,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 57c696c 192/468: Add var name highlighting in "for x, y in ..." construct, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 97ce427 198/468: Restore compatibility with Emacs23 broken by commit 8d28342, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ff3f5e1 199/468: lua-font-lock-keywords: don't eval-when-compile initial value, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 2a0314b 200/468: Improve multiline highlighting via font-lock-syntactic-keywords, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cd5c071 201/468: Clean up lua-mode start-up function a bit, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b195cdc 205/468: Bump TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cee511c 206/468: for/local varname highlighting: match '=' at EOL properly, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode a1dc850 207/468: Post-refactoring fix: evaluate string variables in font-lock-defaults value, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8ffd075 208/468: lua-calculate-indentation-info: non-functional refactoring, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4484128 215/468: lua-calculate-indentation-override: unindent to the last block-close token, Philip Kaludercic, 2021/08/05