vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 543afb8b1cd6b3abcdab1f303340a9193c24709a
parent a60eb781ce133af92c4265a41a64e6044c030b81
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Mon, 19 Sep 2016 14:24:09 +0200

vis-lua: expose file save event to lua

Triggered after the new file content has been written to disk.

Diffstat:
MREADME.md | 1+
Mvis-lua.c | 8+++++++-
2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md @@ -586,6 +586,7 @@ At this time there exists no API stability guarantees. - `start()` - `quit()` - `file_open(file)` + - `file_save(file)` - `win_open(win)` - `win_close(win)` - `theme_change(name)` diff --git a/vis-lua.c b/vis-lua.c @@ -1513,7 +1513,13 @@ void vis_lua_file_open(Vis *vis, File *file) { } void vis_lua_file_save(Vis *vis, File *file) { - + lua_State *L = vis->lua; + vis_lua_event_get(L, "file_save"); + if (lua_isfunction(L, -1)) { + obj_ref_new(L, file, "vis.file"); + pcall(vis, L, 1, 0); + } + lua_pop(L, 1); } void vis_lua_file_close(Vis *vis, File *file) {