vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 8fb3d6c8248a8d840d6bb2abf5102fce8738ba7c parent b0bb9ad72ee4dd4012590b1b917fe8b9a43495e9 Author: Marc André Tanner <mat@brain-dump.org> Date: Sat, 27 Sep 2014 16:03:09 +0200 Factor out common user info message Diffstat:
| M | vis.c | | | 17 | ++++++++--------- |
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/vis.c b/vis.c @@ -1194,12 +1194,15 @@ static bool is_window_closeable(EditorWin *win) { return false; } +static void info_unsaved_changes(void) { + editor_info_show(vis, "No write since last change (add ! to override)"); +} + static bool cmd_edit(const char *argv[]) { EditorWin *oldwin = vis->win; bool force = strchr(argv[0], '!') != NULL; if (!force && !is_window_closeable(oldwin)) { - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return false; } if (!argv[1]) @@ -1213,8 +1216,7 @@ static bool cmd_edit(const char *argv[]) { static bool cmd_quit(const char *argv[]) { bool force = strchr(argv[0], '!') != NULL; if (!force && !is_window_closeable(vis->win)) { - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return false; } editor_window_close(vis->win); @@ -1227,8 +1229,7 @@ static bool cmd_bdelete(const char *argv[]) { bool force = strchr(argv[0], '!') != NULL; Text *txt = vis->win->text; if (text_modified(txt) && !force) { - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return false; } for (EditorWin *next, *win = vis->windows; win; win = next) { @@ -1236,7 +1237,6 @@ static bool cmd_bdelete(const char *argv[]) { if (win->text == txt) editor_window_close(win); } - if (!vis->windows) quit(NULL); return true; @@ -1252,8 +1252,7 @@ static bool cmd_qall(const char *argv[]) { if (!vis->windows) quit(NULL); else - editor_info_show(vis, "No write since last change " - "(add ! to override)"); + info_unsaved_changes(); return vis->windows == NULL; }