diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-11-22 14:02:29 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-11-22 15:02:12 +0100 |
| commit | e4a2ae7bb0ccbcebbf95f498c5edac2a0ed75ad6 (patch) | |
| tree | ff2c5dadec0be235bfffaa450f541b707a99d5ce | |
| parent | 0791cac97ee689195e593cfca89c0b63fb721479 (diff) | |
| download | vis-e4a2ae7bb0ccbcebbf95f498c5edac2a0ed75ad6.tar.gz vis-e4a2ae7bb0ccbcebbf95f498c5edac2a0ed75ad6.tar.xz | |
vis-lua: also emit save events when writing to stdout
The path argument will be nil.
| -rw-r--r-- | sam.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -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; } |
