aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2022-11-23 00:49:13 +0100
committerMatěj Cepl <mcepl@cepl.eu>2022-11-23 00:49:13 +0100
commit9688caed346cdde5a5546f9a6c722eccf3b7ede1 (patch)
treea4f095274f0b7281888cbcb64a28648f57ab0f49
parent872ac619fdf8891869667d9dbd583971a23c9a0b (diff)
downloadvis-open_rej-9688caed346cdde5a5546f9a6c722eccf3b7ede1.tar.gz
Use Lua 5.4 close attribute.
-rw-r--r--init.lua18
1 files changed, 8 insertions, 10 deletions
diff --git a/init.lua b/init.lua
index 64c3064..da70464 100644
--- a/init.lua
+++ b/init.lua
@@ -1,20 +1,18 @@
local function file_exists(path)
- local f = io.open(path)
- if f == nil then return false
- else f:close() return true
- end
+ local f <close> = io.open(path)
+ return f ~= nil
end
local function open_rej_file(file)
if file then
- local rejfile = file .. '.rej'
- if file_exists(rejfile) then
- vis:command('open ' .. rejfile)
- end
- end
+ local rejfile = file .. '.rej'
+ if file_exists(rejfile) then
+ vis:command('open ' .. rejfile)
+ end
+ end
end
vis.events.subscribe(vis.events.FILE_OPEN, function (file)
- open_rej_file(file.path)
+ open_rej_file(file.path)
end)