tex: escape command with addresses - neatvi - [fork] simple vi-type editor with… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit 6aeab587bb3e6603d53567d8b231b36c72ad194b | |
parent 2b3a43ce720dab6d6687230a408f414ced631888 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Thu, 9 Jan 2020 01:20:05 +0330 | |
ex: escape command with addresses | |
Suggested and tested by Aaron G <[email protected]>. | |
Diffstat: | |
M ex.c | 18 ++++++++++++++++-- | |
1 file changed, 16 insertions(+), 2 deletions(-) | |
--- | |
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; | |
} | |