(replace_range): Delete last arg, always the negation of the first bool

* src/insdel.c (replace_range): Merge last arg, with `prepare`.
Rename `prepare` to `run-mode-hooks`.
* src/lisp.h (replace_range): Adjust accordingly.
* src/editfns.c (Ftranslate_region_internal):
* src/cmds.c (internal_self_insert):
* src/search.c (Freplace_match): Adjust callers.
This commit is contained in:
Stefan Monnier 2025-02-18 10:05:34 -05:00
parent 19f5ccbf39
commit 41624d94ce
5 changed files with 9 additions and 10 deletions

View file

@ -458,7 +458,7 @@ internal_self_insert (int c, EMACS_INT n)
ptrdiff_t to;
if (ckd_add (&to, PT, chars_to_delete))
to = PTRDIFF_MAX;
replace_range (PT, to, string, 1, 1, 1, 0, false);
replace_range (PT, to, string, true, true, true, false);
Fforward_char (make_fixnum (n));
}
else if (n > 1)

View file

@ -2518,7 +2518,7 @@ It returns the number of characters changed. */)
but it should handle multibyte characters correctly. */
string = make_multibyte_string ((char *) str, 1, str_len);
replace_range (pos, pos + 1, string,
true, false, true, false, false);
true, false, true, false);
len = str_len;
}
else
@ -2562,8 +2562,7 @@ It returns the number of characters changed. */)
= (VECTORP (val)
? Fconcat (1, &val)
: Fmake_string (make_fixnum (1), val, Qnil));
replace_range (pos, pos + len, string, true, false, true, false,
false);
replace_range (pos, pos + len, string, true, false, true, false);
pos_byte += SBYTES (string);
pos += SCHARS (string);
characters_changed += SCHARS (string);

View file

@ -1425,8 +1425,8 @@ adjust_after_insert (ptrdiff_t from, ptrdiff_t from_byte,
void
replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
bool prepare, bool inherit, bool markers,
bool adjust_match_data, bool inhibit_mod_hooks)
bool run_mod_hooks, bool inherit, bool markers,
bool adjust_match_data)
{
ptrdiff_t inschars = SCHARS (new);
ptrdiff_t insbytes = SBYTES (new);
@ -1440,7 +1440,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
deletion = Qnil;
if (prepare)
if (run_mod_hooks)
{
ptrdiff_t range_length = to - from;
prepare_to_modify_buffer (from, to, &from);
@ -1584,7 +1584,7 @@ replace_range (ptrdiff_t from, ptrdiff_t to, Lisp_Object new,
if (adjust_match_data)
update_search_regs (from, to, from + SCHARS (new));
if (!inhibit_mod_hooks)
if (run_mod_hooks)
{
signal_after_change (from, nchars_del, GPT - from);
update_compositions (from, GPT, CHECK_BORDER);

View file

@ -4361,7 +4361,7 @@ extern void adjust_markers_for_insert (ptrdiff_t, ptrdiff_t,
extern void adjust_markers_bytepos (ptrdiff_t, ptrdiff_t,
ptrdiff_t, ptrdiff_t, int);
extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool,
bool, bool, bool);
bool, bool);
extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
const char *, ptrdiff_t, ptrdiff_t, bool);
extern void syms_of_insdel (void);

View file

@ -2761,7 +2761,7 @@ since only regular expressions have distinguished subexpressions. */)
newpoint = sub_start + SCHARS (newtext);
/* Replace the old text with the new in the cleanest possible way. */
replace_range (sub_start, sub_end, newtext, 1, 0, 1, true, false);
replace_range (sub_start, sub_end, newtext, true, false, true, true);
if (case_action == all_caps)
Fupcase_region (make_fixnum (search_regs.start[sub]),