diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-11-21 23:32:28 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-11-22 14:57:26 +0100 |
| commit | f555c00e0b0be14cd553c7c803d6136b86f2012b (patch) | |
| tree | 30cc25c10c18cd70b585ebc2c3b27b1631049ec5 /vis-lua.c | |
| parent | a7115b12267f6165426d0540da6ab0ae6f90a191 (diff) | |
| download | vis-f555c00e0b0be14cd553c7c803d6136b86f2012b.tar.gz vis-f555c00e0b0be14cd553c7c803d6136b86f2012b.tar.xz | |
vis-lua: pass path as second argument to file_save_post event hook
The passed path can be different from file.name for instance when
opening a file `a` and then doing `:w b` where file.name will be the
former and path the latter.
Diffstat (limited to 'vis-lua.c')
| -rw-r--r-- | vis-lua.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -128,7 +128,7 @@ void vis_lua_init(Vis *vis) { } void vis_lua_start(Vis *vis) { } void vis_lua_quit(Vis *vis) { } void vis_lua_file_open(Vis *vis, File *file) { } -void vis_lua_file_save_post(Vis *vis, File *file) { } +void vis_lua_file_save_post(Vis *vis, File *file, const char *path) { } void vis_lua_file_close(Vis *vis, File *file) { } void vis_lua_win_open(Vis *vis, Win *win) { } void vis_lua_win_close(Vis *vis, Win *win) { } @@ -1544,12 +1544,16 @@ void vis_lua_file_open(Vis *vis, File *file) { lua_pop(L, 1); } -void vis_lua_file_save_post(Vis *vis, File *file) { +void vis_lua_file_save_post(Vis *vis, File *file, const char *path) { lua_State *L = vis->lua; vis_lua_event_get(L, "file_save_post"); if (lua_isfunction(L, -1)) { obj_ref_new(L, file, "vis.file"); - pcall(vis, L, 1, 0); + if (path) + lua_pushstring(L, path); + else + lua_pushnil(L); + pcall(vis, L, 2, 0); } lua_pop(L, 1); } |
