summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorgi Kirilov <>2020-11-22 15:10:49 +0200
committerGeorgi Kirilov <>2023-10-04 18:24:59 +0800
commit8a69569980e4f24642cf4270a6be53c9957aea2b (patch)
tree15e90f72b8cc8a3ee65bb7a11ad519ed1a8f54f7
parent1425300e56e500d0cc61b4dfb14e10d59822686b (diff)
downloadvis-pairs-8a69569980e4f24642cf4270a6be53c9957aea2b.tar.gz
DRY fixes
-rw-r--r--pairs.lua12
1 files changed, 6 insertions, 6 deletions
diff --git a/pairs.lua b/pairs.lua
index 16b53c4..3b97ddf 100644
--- a/pairs.lua
+++ b/pairs.lua
@@ -297,15 +297,15 @@ vis.events.subscribe(vis.events.INIT, function()
outer = new(vis.textobject, vis.textobject_register, M.prefix.outer, handler(outer), "Delimited block (outer variant)"),
}
- local tex_environment = {"\\begin{" * l.Cg(l.R("az", "AZ")^1, "t") * "}", l.Cmt("\\end{" * l.Cb("t") * l.C((1 - l.P"}")^1) * "}", function(_, _, c1, c2) return c1 == c2 end), {"\\begin{\xef\xbf\xbd}", "\\end{\xef\xbf\xbd}"}, "environment name"}
+ local function cmp(_, _, c1, c2) return c1 == c2 end
+ local function casecmp(_, _, c1, c2) return c1:lower() == c2:lower() end
+ local function closing(cmpfunc, s1, s2) return l.Cmt(s1 * l.Cb("t") * l.C((1 - l.P(s2))^1) * s2, cmpfunc) end
+ local tex_environment = {"\\begin{" * l.Cg(l.R("az", "AZ")^1, "t") * "}", closing(cmp, "\\end{", "}"), {"\\begin{\xef\xbf\xbd}", "\\end{\xef\xbf\xbd}"}, "environment name"}
local function is(_, _, v) return v ~= 1 end
local tag_name = (l.S"_:" + l.R("az", "AZ")) * (l.R("az", "AZ", "09") + l.S"_:.-")^0
- local function closing(cmpfunc) return l.Cmt(l.Cb("t") * l.C((1 - l.P">")^1), cmpfunc) end
local noslash = l.Cmt(l.Cb("t") / string.lower / {--[[implicit:]] p=1, dt=1, dd=1, li=1, --[[void:]] img=1, input=1, hr=1, br=1, link=1, meta=1}, is)
- local function casecmp(_, _, c1, c2) return c1:lower() == c2:lower() end
- local html_tag = {"<" * l.Cg(tag_name, "t") * noslash * (1 - l.S"><")^0 * (">" - l.B"/"), "</" * closing(casecmp) * ">", {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
- local function cmp(_, _, c1, c2) return c1 == c2 end
- local xml_tag = {"<" * l.Cg(tag_name, "t") * (1 - l.S"><")^0 * (">" - l.B"/"), "</" * closing(cmp) * ">", {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
+ local html_tag = {"<" * l.Cg(tag_name, "t") * noslash * (1 - l.S"><")^0 * (">" - l.B"/"), closing(casecmp, "</", ">"), {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
+ local xml_tag = {"<" * l.Cg(tag_name, "t") * (1 - l.S"><")^0 * (">" - l.B"/"), closing(cmp, "</", ">"), {"<\xef\xbf\xbd>", "</\xef\xbf\xbd>"}, "tag name"}
local function any_pair(set, default) return {l.Cg(l.S(set), "s"), l.Cmt(l.Cb("s") * l.C(1), function(_, _, c1, c2) return builtin_textobjects[c1][2] == c2 end), builtin_textobjects[default]} end
local any_bracket = any_pair("({[", "(")
local presets = {