tex: escape command with addresses - neatvi - [fork] simple vi-type editor with UTF-8 support
HTML git clone git://src.adamsgaard.dk/neatvi
DIR Log
DIR Files
DIR Refs
DIR README
---
DIR commit 6aeab587bb3e6603d53567d8b231b36c72ad194b
DIR parent 2b3a43ce720dab6d6687230a408f414ced631888
HTML Author: Ali Gholami Rudi <ali@rudi.ir>
Date: Thu, 9 Jan 2020 01:20:05 +0330
ex: escape command with addresses
Suggested and tested by Aaron G <mastaag@gmail.com>.
Diffstat:
M ex.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
---
DIR diff --git a/ex.c b/ex.c
t@@ -735,13 +735,27 @@ static int ec_substitute(char *ec)
static int ec_exec(char *ec)
{
+ char loc[EXLEN];
char arg[EXLEN];
+ int beg, end;
+ char *text;
+ char *rep;
ex_modifiedbuffer(NULL);
+ ex_loc(ec, loc);
if (ex_expand(arg, ex_argeol(ec)))
return 1;
- ex_print(NULL);
- if (cmd_exec(arg))
+ if (!loc[0]) {
+ ex_print(NULL);
+ return cmd_exec(arg);
+ }
+ if (ex_region(loc, &beg, &end))
return 1;
+ text = lbuf_cp(xb, beg, end);
+ rep = cmd_pipe(arg, text, 1, 1);
+ if (rep)
+ lbuf_edit(xb, rep, beg, end);
+ free(text);
+ free(rep);
return 0;
}