mk = call_ret(mark2, "doc:point", ci->focus);
/* If selection is replacable, clear it and use mk */
- if (!clear_selection(ci->focus, NULL, mk, 3))
+ if (!clear_selection(ci->focus, NULL, mk, 3)) {
+ /* else clear any transient selection */
+ clear_selection(ci->focus, NULL, mk, 2);
mk = NULL;
+ }
m = mark_dup(ci->mark);
int ret;
char buf[2] = ".";
const char *str;
+ bool first = N2(ci) != N2_undo_insert;
if (!ci->mark)
return Enoarg;
+ if (clear_selection(ci->focus, NULL, ci->mark, 3)) {
+ call("Replace", ci->focus, 1, ci->mark, NULL, !first);
+ first = False;
+ } else
+ clear_selection(ci->focus, NULL, ci->mark, 2);
+
str = ksuffix(ci, "K:CQ-");
if (!str[0]) {
str = ksuffix(ci, "K:CQ:C-");
} else
str = "??";
}
- ret = call("Replace", ci->focus, 1, ci->mark, str,
- N2(ci) == N2_undo_insert);
+ ret = call("Replace", ci->focus, 1, ci->mark, str, !first);
call("Mode:set-num2", ci->focus, N2_undo_insert);
return ret;
int i;
struct mark *m = NULL;
struct mark *mk = call_ret(mark2, "doc:point", ci->focus);
+ bool first = N2(ci) != N2_undo_insert;
char *ins;
if (!ci->mark)
if (ins == NULL)
return Efallthrough;
- if (clear_selection(ci->focus, NULL, mk, 3))
- call("Replace", ci->focus, 1, mk);
+ if (clear_selection(ci->focus, NULL, mk, 3)) {
+ call("Replace", ci->focus, 1, mk, NULL, !first);
+ first = False;
+ } else
+ clear_selection(ci->focus, NULL, mk, 2);
if (!*ins) {
ins++;
mark_step(m, 0);
}
- ret = call("Replace", ci->focus, 1, m, ins,
- N2(ci) == N2_undo_insert, ci->mark);
+ ret = call("Replace", ci->focus, 1, m, ins, !first, ci->mark);
if (m) {
mark_to_mark(ci->mark, m);
mark_free(m);
* it calls this, and we set up for proper undo
*/
int ret;
+ bool first = N2(ci) != N2_undo_insert;
if (!ci->str)
return Enoarg;
+
+ if (clear_selection(ci->focus, NULL, ci->mark, 3)) {
+ call("Replace", ci->focus, 1, ci->mark, NULL, !first);
+ first = False;
+ } else
+ clear_selection(ci->focus, NULL, ci->mark, 2);
ret = call("Replace", ci->focus, 1, ci->mark, ci->str,
- N2(ci) == N2_undo_insert);
+ !first);
call("Mode:set-num2", ci->focus,
strchr(ci->str, '\n') ? 0 : N2_undo_insert);
return ret;