From 1deefa36970207c865354c20b8cb0eed98f79ade Mon Sep 17 00:00:00 2001 From: Stefan Monnier Date: Tue, 18 Feb 2025 10:05:34 -0500 Subject: [PATCH] (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. (cherry picked from commit 41624d94cec98c1239c4fc9bb624e55ce0606068) --- src/cmds.c | 2 +- src/editfns.c | 5 ++--- src/insdel.c | 8 ++++---- src/lisp.h | 2 +- src/search.c | 2 +- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/cmds.c b/src/cmds.c index 7179822c21c..20893e85647 100644 --- a/src/cmds.c +++ b/src/cmds.c @@ -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) diff --git a/src/editfns.c b/src/editfns.c index 5a5db32cc68..8fe2ecf1a03 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -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); diff --git a/src/insdel.c b/src/insdel.c index 57e98018872..d3917bf668c 100644 --- a/src/insdel.c +++ b/src/insdel.c @@ -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); diff --git a/src/lisp.h b/src/lisp.h index 5704c7fa7f1..ff999c7731d 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -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); diff --git a/src/search.c b/src/search.c index 81466be323a..c8eb04e388b 100644 --- a/src/search.c +++ b/src/search.c @@ -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]), -- 2.39.5