[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 40c00bf 189/468: lua-font-lock-keywords: fontify
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 40c00bf 189/468: lua-font-lock-keywords: fontify constants/builtins first |
Date: |
Thu, 5 Aug 2021 04:58:33 -0400 (EDT) |
branch: elpa/lua-mode
commit 40c00bfc66e8edaa0fbeb2222746cd467e42bf35
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
lua-font-lock-keywords: fontify constants/builtins first
Move constant/builtin fontification rules to the beginning so that they
have more priority than regular rules and can only be explicitly
overridden.
---
lua-mode.el | 57 +++++++++++++++++++++++++++++++--------------------------
1 file changed, 31 insertions(+), 26 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 38a1f65..442c6cf 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -417,45 +417,50 @@ index of respective Lua reference manuals.")
(list
;; highlight the hash-bang line "#!/foo/bar/lua" as comment
'("^#!.*$" . font-lock-comment-face)
- ;; Handle variable names
- ;; local blalba =
- ;; ^^^^^^
- '("\\(local[ \t]+\\(\\sw+\\)[ \t]*=\\)"
- (2 font-lock-variable-name-face))
- ;; 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))
+ ;; 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))
- ;; Handle function names in assignments
- '("\\([[:alnum:]_]+\\(?:[:.][[:alnum:]_]+\\)*\\)[ \t]*=[ \t]*function\\_>"
- (1 font-lock-function-name-face))
-
- ;; octal numbers
+ ;; 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
- `(,(concat "\\_<\\(?1:"
- ;; make a digit on either side of dot mandatory
- "\\(?:[0-9]+\\.?[0-9]*\\|[0-9]*\\.?[0-9]+\\)"
- "\\(?:[eE][+-]?[0-9]+\\)?"
- "\\)\\_>")
- . font-lock-constant-face)
+ `(, (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)
+
+ ;; Handle variable names
+ ;; local blalba =
+ ;; ^^^^^^
+ '("local[ \t]+\\([[:alnum:]_]+\\)\\(?:[ \t]*,[
\t]*\\([[:alnum:]_]+\\)\\)[ \t]*="
+ (1 font-lock-variable-name-face)
+ (2 font-lock-variable-name-face))
+
+ ;; 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\\_>"
+ (1 font-lock-function-name-face))
- ;; Keywords.
- (concat "\\_<"
- (regexp-opt '("and" "break" "do" "else" "elseif" "end" "false"
- "for" "function" "if" "in" "local" "nil" "not"
- "or" "repeat" "return" "then" "true" "until"
- "while") t)
- "\\_>")
"Default expressions to highlight in Lua mode.")))
- [nongnu] elpa/lua-mode 509700f 130/468: lua--automark-update-start-pos: rewind to beginning of line to make sure newly inserted multiline literal delimiters are recognized, (continued)
- [nongnu] elpa/lua-mode 509700f 130/468: lua--automark-update-start-pos: rewind to beginning of line to make sure newly inserted multiline literal delimiters are recognized, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 066d042 139/468: Merge pull request #12 from vhallac/vh-indentation-mods, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 39cf29e 141/468: Whoops! Add missing parenthesis, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 66cd58a 171/468: Fix test_indentation.sh, add basic_blocks.lua indentation test, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4b27305 097/468: Add safe default target to makefile, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ddcd8b8 102/468: Makefile: specify dist contents explicitly, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode aa10440 148/468: Bump TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8638475 174/468: Fix use of flet for Emacs > 24.1, and enable assert., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode f926323 180/468: Extend and unify backward compatibility code, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6245e50 190/468: Add helper functions for reimplementation of font-lock-keywords, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 40c00bf 189/468: lua-font-lock-keywords: fontify constants/builtins first,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 3a3f0b0 193/468: Improve local var assignment matching, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode af50eca 195/468: Bump copyright information (no luck with FSF), rephrase comment, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 918f297 072/468: rename: lua-calculate-indentation-left-shift -> lua-calculate-unindentation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode cf2f42a 076/468: .gitignore: ignore emacs backups, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 9384855 093/468: lua-mark-all-multiline-literals: run when during lua-mode initialization, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 6de08c0 090/468: Update TODO, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e3a8282 099/468: Make URL/Version fields in lua-mode.el prettier, update parse expression in Makefile, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1c37d0d 114/468: Bump version, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode e17a48c 126/468: Give credit to people participated recently, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode dcf5fc1 138/468: Indentation fixes and tidy up., Philip Kaludercic, 2021/08/05