nano-devel
[Top][All Lists]
Advanced

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

[Nano-devel] [PATCH] syntax: lua: fix word boundaries on standard librar


From: Tom Levy
Subject: [Nano-devel] [PATCH] syntax: lua: fix word boundaries on standard library functions
Date: Thu, 28 Dec 2017 02:31:37 +1300

Hello nano devs,

I've attached a patch to fix a small bug in the syntax highlighting
rules for Lua files.

Functions such as "io.close" should only be highlighted when the
package name ("io") is at the beginning of a word, otherwise code such
as "fooio.close" gets unexpected partial highlighting.

Cheers,
Tom Levy

P.S. I've also tried to inline the patch below, but it will probably
get mangled. The attachment should be safe.

-------8<-------

>From 8b472aabb75014cef944b39db019a499bf72ed69 Mon Sep 17 00:00:00 2001
From: Tom Levy <address@hidden>
Date: Wed, 27 Dec 2017 13:26:06 +0000
Subject: [PATCH] syntax: lua: fix word boundaries on standard library
 functions

Functions such as "io.close" should only be highlighted when the
package name ("io") is at the beginning of a word, otherwise code such
as "fooio.close" gets unexpected partial highlighting.

Signed-off-by: Tom Levy <address@hidden>
---
 syntax/lua.nanorc | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/syntax/lua.nanorc b/syntax/lua.nanorc
index 90e9ea22..3692f615 100644
--- a/syntax/lua.nanorc
+++ b/syntax/lua.nanorc
@@ -21,16 +21,16 @@ color brightyellow
"\<(io|math|os|string|table|coroutine|debug)\>\."
 color brightyellow
"\<(_G|_VERSION|assert|collectgarbage|dofile|error|getfenv|getmetatable|ipairs|load|loadfile|module|next|pairs|pcall|print|rawequal|rawget|rawset|require|select|setfenv|setmetatable|tonumber|tostring|type|unpack|xpcall)\s*\("

 # Standard library
-color brightyellow
"io\.\<(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>"
-color brightyellow
"math\.\<(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
-color brightyellow
"math\.\<(max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
-color brightyellow
"os\.\<(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
-color brightyellow "package\.\<(cpath|loaded|loadlib|path|preload|seeall)\>"
-color brightyellow
"string\.\<(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
-color brightyellow "table\.\<(concat|insert|maxn|remove|sort)\>"
-color brightyellow "coroutine\.\<(create|resume|running|status|wrap|yield)\>"
-color brightyellow
"debug\.\<(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue)\>"
-color brightyellow
"debug\.\<(setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"
+color brightyellow
"\<io\.(close|flush|input|lines|open|output|popen|read|tmpfile|type|write|stdin|stdout|stderr)\>"
+color brightyellow
"\<math\.(abs|acos|asin|atan2|atan|ceil|cosh|cos|deg|exp|floor|fmod|frexp|huge|ldexp|log10|log)\>"
+color brightyellow
"\<math\.(max|min|mod|modf|pi|pow|rad|random|randomseed|sinh|tan)\>"
+color brightyellow
"\<os\.(clock|date|difftime|execute|exit|getenv|remove|rename|setlocale|time|tmpname)\>"
+color brightyellow "\<package\.(cpath|loaded|loadlib|path|preload|seeall)\>"
+color brightyellow
"\<string\.(byte|char|dump|find|format|gmatch|gsub|len|lower|match|rep|reverse|sub|upper)\>"
+color brightyellow "\<table\.(concat|insert|maxn|remove|sort)\>"
+color brightyellow "\<coroutine\.(create|resume|running|status|wrap|yield)\>"
+color brightyellow
"\<debug\.(debug|getfenv|gethook|getinfo|getlocal|getmetatable|getregistry|getupvalue)\>"
+color brightyellow
"\<debug\.(setfenv|sethook|setlocal|setmetatable|setupvalue|traceback)\>"

 # File handle methods
 color brightyellow "\:\<(close|flush|lines|read|seek|setvbuf|write)\>"
-- 
2.11.0

Attachment: 0001-syntax-lua-fix-word-boundaries-on-standard-library.patch
Description: Text Data


reply via email to

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