diff options
author | Georgi Kirilov <> | 2020-11-22 15:10:49 +0200 |
---|---|---|
committer | Georgi Kirilov <> | 2023-10-04 18:24:59 +0800 |
commit | 9f8638398ca198d04b5b52651126eae6dfcd888a (patch) | |
tree | 0f967d7ab710c420efa3e1b8311429d330237001 | |
parent | 74a0b19e67af736dc55624a01b1c07f32e6a5fe2 (diff) | |
download | vis-pairs-9f8638398ca198d04b5b52651126eae6dfcd888a.tar.gz |
More DRY
-rw-r--r-- | pairs.lua | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -248,7 +248,7 @@ local function bail_early() return false end -local function handler(func) +local function prep(func) return function(win, pos) if bail_early() then return pos end local content = win.file:content(0, win.file.size) @@ -257,7 +257,7 @@ local function handler(func) end local function new(execute, register, prefix, handler, help) - local id = register(vis, handler) + local id = register(vis, prep(handler)) if id < 0 then return false end @@ -289,12 +289,12 @@ end vis.events.subscribe(vis.events.INIT, function() M.motion = { - opening = new(vis.motion, vis.motion_register, M.prefix.opening, handler(opening), "Move cursor to the beginning of a delimited block"), - closing = new(vis.motion, vis.motion_register, M.prefix.closing, handler(closing), "Move cursor to the end of a delimited block"), + opening = new(vis.motion, vis.motion_register, M.prefix.opening, opening, "Move cursor to the beginning of a delimited block"), + closing = new(vis.motion, vis.motion_register, M.prefix.closing, closing, "Move cursor to the end of a delimited block"), } M.textobject = { - inner = new(vis.textobject, vis.textobject_register, M.prefix.inner, handler(inner), "Delimited block (inner variant)"), - outer = new(vis.textobject, vis.textobject_register, M.prefix.outer, handler(outer), "Delimited block (outer variant)"), + inner = new(vis.textobject, vis.textobject_register, M.prefix.inner, inner, "Delimited block (inner variant)"), + outer = new(vis.textobject, vis.textobject_register, M.prefix.outer, outer, "Delimited block (outer variant)"), } local function cmp(_, _, c1, c2) return c1 == c2 end |