From e4a2ae7bb0ccbcebbf95f498c5edac2a0ed75ad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Tue, 22 Nov 2016 14:02:29 +0100 Subject: vis-lua: also emit save events when writing to stdout The path argument will be nil. --- sam.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sam.c') diff --git a/sam.c b/sam.c index 1b30258..641f653 100644 --- a/sam.c +++ b/sam.c @@ -1256,6 +1256,11 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs return false; } + if (!vis_event_emit(vis, VIS_EVENT_FILE_SAVE_PRE, file, (char*)NULL) && cmd->flags != '!') { + vis_info_show(vis, "Rejected write to stdout by pre-save hook"); + return false; + } + for (Cursor *c = view_cursors(win->view); c; c = view_cursors_next(c)) { Filerange range = view_cursors_selection_get(c); bool invalid_range = !text_range_valid(&range); @@ -1272,6 +1277,7 @@ static bool cmd_write(Vis *vis, Win *win, Command *cmd, const char *argv[], Curs /* make sure the file is marked as saved i.e. not modified */ text_save(text, NULL); + vis_event_emit(vis, VIS_EVENT_FILE_SAVE_POST, file, (char*)NULL); return true; } -- cgit v1.2.3