tex: xit command - neatvi - [fork] simple vi-type editor with UTF-8 support
(HTM) git clone git://src.adamsgaard.dk/neatvi
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) commit 6a4f7acda55fd2175a268b20b308ee70ae2fa38b
(DIR) parent 88384358c2852c6b9b994bbd98307712f1c0588d
(HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Wed, 17 Jun 2015 19:35:41 +0430
ex: xit command
Diffstat:
M ex.c | 9 ++++++---
M lbuf.c | 1 +
2 files changed, 7 insertions(+), 3 deletions(-)
---
(DIR) diff --git a/ex.c b/ex.c
t@@ -324,7 +324,6 @@ static int ec_edit(char *ec)
ex_show(msg);
}
xrow = MAX(0, MIN(xrow, lbuf_len(xb) - 1));
- lbuf_modified(xb);
lbuf_saved(xb, path[0] != '\0');
return 0;
}
t@@ -376,6 +375,8 @@ static int ec_write(char *ec)
ex_arg(ec, arg);
ex_loc(ec, loc);
path = arg[0] ? arg : ex_path();
+ if (cmd[0] == 'x' && !lbuf_modified(xb))
+ return ec_quit(cmd);
if (ex_region(loc, &beg, &end))
return 1;
if (!loc[0]) {
t@@ -407,8 +408,8 @@ static int ec_write(char *ec)
}
if (!strcmp(ex_path(), path))
lbuf_saved(xb, 0);
- if (!strcmp("wq", cmd))
- ec_quit("wq");
+ if (cmd[0] == 'x' || (cmd[0] == 'w' && cmd[1] == 'q'))
+ ec_quit(cmd);
return 0;
}
t@@ -727,6 +728,8 @@ static struct excmd {
{"r", "redo", ec_redo},
{"se", "set", ec_set},
{"s", "substitute", ec_substitute},
+ {"x", "xit", ec_write},
+ {"x!", "xit!", ec_write},
{"ya", "yank", ec_yank},
{"!", "!", ec_exec},
{"make", "make", ec_make},
(DIR) diff --git a/lbuf.c b/lbuf.c
t@@ -308,6 +308,7 @@ void lbuf_saved(struct lbuf *lb, int clear)
lb->useq_last = lb->useq;
}
lb->useq_zero = lbuf_seq(lb);
+ lbuf_modified(xb);
}
/* was the file modified since the last lbuf_modreset() */