vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit e5f7a1529fa7cc268a90fc950be02f1ad5eded37 parent 8d395ba4f4a762b8fc910fd4c78b455f7aa9017f Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 22 Nov 2016 14:02:29 +0100 vis-lua: also emit save events when writing to stdout The path argument will be nil. Diffstat:
| M | sam.c | | | 6 | ++++++ |
1 file changed, 6 insertions(+), 0 deletions(-)
diff --git 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; }