[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/lua-mode 8aa98ae 185/468: Non-functional refactoring
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/lua-mode 8aa98ae 185/468: Non-functional refactoring |
Date: |
Thu, 5 Aug 2021 04:58:33 -0400 (EDT) |
branch: elpa/lua-mode
commit 8aa98aeb511082c47408a08f39626381271fd054
Author: immerrr <immerrr+lua@gmail.com>
Commit: immerrr <immerrr+lua@gmail.com>
Non-functional refactoring
- reflow lua--builtins initialization code to fit in 80 cols
- reorder lua-mode-syntax-table entries for readability
- alter comments
---
lua-mode.el | 122 +++++++++++++++++++++++++++++++++---------------------------
1 file changed, 68 insertions(+), 54 deletions(-)
diff --git a/lua-mode.el b/lua-mode.el
index 50d1bb0..8fd0b23 100644
--- a/lua-mode.el
+++ b/lua-mode.el
@@ -345,29 +345,33 @@ traceback location."
lua--builtins
(let*
((modules
- '("_G" "_VERSION" "assert" "collectgarbage" "dofile" "error"
"getfenv" "getmetatable"
- "ipairs" "load" "loadfile" "loadstring" "module" "next" "pairs"
"pcall" "print"
- "rawequal" "rawget" "rawlen" "rawset" "require" "select" "setfenv"
"setmetatable"
- "tonumber" "tostring" "type" "unpack" "xpcall"
- ("bit32" . ("arshift" "band" "bnot" "bor" "btest" "bxor" "extract"
"lrotate" "lshift"
- "replace" "rrotate" "rshift"))
+ '("_G" "_VERSION" "assert" "collectgarbage" "dofile" "error"
"getfenv"
+ "getmetatable" "ipairs" "load" "loadfile" "loadstring" "module"
+ "next" "pairs" "pcall" "print" "rawequal" "rawget" "rawlen"
"rawset"
+ "require" "select" "setfenv" "setmetatable" "tonumber" "tostring"
+ "type" "unpack" "xpcall"
+ ("bit32" . ("arshift" "band" "bnot" "bor" "btest" "bxor" "extract"
+ "lrotate" "lshift" "replace" "rrotate" "rshift"))
("coroutine" . ("create" "resume" "running" "status" "wrap"
"yield"))
- ("debug" . ("debug" "getfenv" "gethook" "getinfo" "getlocal"
"getmetatable"
- "getregistry" "getupvalue" "getuservalue" "setfenv"
"sethook" "setlocal"
- "setmetatable" "setupvalue" "setuservalue" "traceback"
"upvalueid"
+ ("debug" . ("debug" "getfenv" "gethook" "getinfo" "getlocal"
+ "getmetatable" "getregistry" "getupvalue"
"getuservalue"
+ "setfenv" "sethook" "setlocal" "setmetatable"
+ "setupvalue" "setuservalue" "traceback" "upvalueid"
"upvaluejoin"))
- ("io" . ("close" "flush" "input" "lines" "open" "output" "popen"
"read" "stderr"
- "stdin" "stdout" "tmpfile" "type" "write"))
- ("math" . ("abs" "acos" "asin" "atan" "atan2" "ceil" "cos" "cosh"
"deg" "exp" "floor"
- "fmod" "frexp" "huge" "ldexp" "log" "log10" "max" "min"
"modf" "pi" "pow"
- "rad" "random" "randomseed" "sin" "sinh" "sqrt" "tan"
"tanh"))
- ("os" . ("clock" "date" "difftime" "execute" "exit" "getenv"
"remove" "rename"
- "setlocale" "time" "tmpname"))
- ("package" . ("config" "cpath" "loaded" "loaders" "loadlib" "path"
"preload"
- "searchers" "searchpath" "seeall"))
- ("string" . ("byte" "char" "dump" "find" "format" "gmatch" "gsub"
"len" "lower"
- "match" "rep" "reverse" "sub" "upper"))
- ("table" . ("concat" "insert" "maxn" "pack" "remove" "sort"
"unpack")))))
+ ("io" . ("close" "flush" "input" "lines" "open" "output" "popen"
+ "read" "stderr" "stdin" "stdout" "tmpfile" "type"
"write"))
+ ("math" . ("abs" "acos" "asin" "atan" "atan2" "ceil" "cos" "cosh"
+ "deg" "exp" "floor" "fmod" "frexp" "huge" "ldexp" "log"
+ "log10" "max" "min" "modf" "pi" "pow" "rad" "random"
+ "randomseed" "sin" "sinh" "sqrt" "tan" "tanh"))
+ ("os" . ("clock" "date" "difftime" "execute" "exit" "getenv"
+ "remove" "rename" "setlocale" "time" "tmpname"))
+ ("package" . ("config" "cpath" "loaded" "loaders" "loadlib" "path"
+ "preload" "searchers" "searchpath" "seeall"))
+ ("string" . ("byte" "char" "dump" "find" "format" "gmatch" "gsub"
+ "len" "lower" "match" "rep" "reverse" "sub" "upper"))
+ ("table" . ("concat" "insert" "maxn" "pack" "remove" "sort"
"unpack"
+ )))))
;; This code uses \\< and \\> to delimit builtin symbols instead of
;; \\_< and \\_>, because -- a necessity -- '.' syntax class is hacked
@@ -378,30 +382,30 @@ traceback location."
;; that indentation won't get hurt. --immerrr
;;
(lua--cl-labels
- ((module-name-re (x)
- (concat "\\(?1:\\<"
- (if (listp x) (car x) x)
- "\\>\\)"))
- (module-members-re (x) (if (listp x)
- (concat "\\(?:[ \t]*\\.[ \t]*"
- "\\<\\(?2:"
- (regexp-opt (cdr x))
- "\\)\\>\\)?")
- "")))
-
- (concat
- ;; common prefix - beginning-of-line or neither of [ '.', ':' ] to
- ;; exclude "foo.string.rep"
- "\\(?:\\`\\|[^:. \n\t]\\)"
- ;; optional whitespace
- "[ \n\t]*"
- "\\(?:"
- ;; any of modules/functions
- (mapconcat (lambda (x) (concat (module-name-re x)
- (module-members-re x)))
- modules
- "\\|")
- "\\)"))))
+ ((module-name-re (x)
+ (concat "\\(?1:\\<"
+ (if (listp x) (car x) x)
+ "\\>\\)"))
+ (module-members-re (x) (if (listp x)
+ (concat "\\(?:[ \t]*\\.[ \t]*"
+ "\\<\\(?2:"
+ (regexp-opt (cdr x))
+ "\\)\\>\\)?")
+ "")))
+
+ (concat
+ ;; common prefix - beginning-of-line or neither of [ '.', ':' ] to
+ ;; exclude "foo.string.rep"
+ "\\(?:\\`\\|[^:. \n\t]\\)"
+ ;; optional whitespace
+ "[ \n\t]*"
+ "\\(?:"
+ ;; any of modules/functions
+ (mapconcat (lambda (x) (concat (module-name-re x)
+ (module-members-re x)))
+ modules
+ "\\|")
+ "\\)"))))
"A regexp that matches lua builtin functions & variables.
@@ -493,23 +497,29 @@ index of respective Lua reference manuals.")
(defvar lua-mode-syntax-table
(with-syntax-table (copy-syntax-table)
- (modify-syntax-entry ?+ ".")
+ ;; main comment syntax: begins with "--", ends with "\n"
(modify-syntax-entry ?- ". 12")
+ (modify-syntax-entry ?\n ">")
+
+ ;; main string syntax: bounded by ' or "
+ (modify-syntax-entry ?\' "\"")
+ (modify-syntax-entry ?\" "\"")
+
+ ;; single-character binary operators: punctuation
+ (modify-syntax-entry ?+ ".")
(modify-syntax-entry ?* ".")
(modify-syntax-entry ?/ ".")
(modify-syntax-entry ?^ ".")
- ;; This might be better as punctuation, as for C, but this way you
- ;; can treat table index as symbol.
- (modify-syntax-entry ?. "_") ; e.g. `io.string'
(modify-syntax-entry ?> ".")
(modify-syntax-entry ?< ".")
(modify-syntax-entry ?= ".")
(modify-syntax-entry ?~ ".")
- (modify-syntax-entry ?\n ">")
- (modify-syntax-entry ?\' "\"")
- (modify-syntax-entry ?\" "\"")
+
+ ;; '.' character might be better as punctuation, as in C, but this way you
+ ;; can treat table index as symbol, e.g. `io.string'
+ (modify-syntax-entry ?. "_")
(syntax-table))
- "Syntax table used while in `lua-mode'.")
+ "`lua-mode' syntax table.")
;;;###autoload
(define-derived-mode lua-mode lua--prog-mode "Lua"
@@ -529,7 +539,11 @@ index of respective Lua reference manuals.")
(set (make-local-variable 'comment-start-skip) lua-comment-start-skip)
(set (make-local-variable 'font-lock-defaults)
'(lua-font-lock-keywords
- nil nil ((?_ . "w"))))
+ nil
+ nil
+ ;; Not sure, why '_' is a word constituent only when font-locking.
+ ;; --immerrr
+ ((?_ . "w"))))
(set (make-local-variable 'imenu-generic-expression)
lua-imenu-generic-expression)
(make-local-variable 'lua-default-eval)
- [nongnu] elpa/lua-mode ded7566 151/468: Add lua-with-silent-modifications macro, use it to fix the undo history issue (#21), (continued)
- [nongnu] elpa/lua-mode ded7566 151/468: Add lua-with-silent-modifications macro, use it to fix the undo history issue (#21), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 37f51cb 152/468: Fix multiline literal highlighting for long strings (#20), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode b33f255 154/468: Make lua-mode-hook customizable., Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ec26ea4 155/468: Fix: Single-line conditionals can confuse indenting (#22), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode fa3470e 157/468: Merge pull request #28 from rrthomas/master, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode ced5226 161/468: lua-with-silent-modifications: fix old style backquotes in fallback implementation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode bba7fc0 163/468: Fix byte-compilation, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d128a74 170/468: Add initial version of test/indentation/README.md, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4399254 177/468: Merge pull request #39, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 08ff6ea 183/468: Merge remote-tracking branch 'origin/master', Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 8aa98ae 185/468: Non-functional refactoring,
Philip Kaludercic <=
- [nongnu] elpa/lua-mode 7605d2c 186/468: lua-font-lock-keywords: rewrite poorly written regexp (issue #47), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode c24f16e 188/468: Put Lua reference resources into TODO file, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 5d81110 196/468: Wrap symbols required during compilation into (eval-when compile ...), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 040bc8f 213/468: Bump NEWS, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1d8dc55 214/468: Rename lua--function-name-rx, use it in font-lock keywords init, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode d552910 218/468: Add a test for defun font-locking; add make check target to run it, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4141c85 222/468: Make builtin font-locking more stable; enable it after ".." operator, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 1716660 223/468: Fix interaction with electric-pair-mode (issue #54), Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 4217513 230/468: Remove highlighting of numbers for consistency with other major-modes, Philip Kaludercic, 2021/08/05
- [nongnu] elpa/lua-mode 248bea3 233/468: Remove syntax hacks for '.' & '_' characters, Philip Kaludercic, 2021/08/05