aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2025-02-18 09:52:35 -0500
committerStefan Monnier2025-02-18 09:52:35 -0500
commit9854103b52a666db258bd10e4cd7f1291fb3bd6e (patch)
tree77c2f6668ced1c967b7d38c6cc51c4cc1a8af4b4 /src
parent37fad0483025b0eeaa33c5418b07bf6a14937ebf (diff)
downloademacs-9854103b52a666db258bd10e4cd7f1291fb3bd6e.tar.gz
emacs-9854103b52a666db258bd10e4cd7f1291fb3bd6e.zip
* src/editfns.c (Fsubst_char_in_region): Delete left-over code
This code was missed back in 2000 (commit 1b16afa45bb6).
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c65
1 files changed, 5 insertions, 60 deletions
diff --git a/src/editfns.c b/src/editfns.c
index f9258392146..5a5db32cc68 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -2230,11 +2230,6 @@ Both characters must have the same length of multi-byte form. */)
2230 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH]; 2230 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2231 unsigned char *p; 2231 unsigned char *p;
2232 specpdl_ref count = SPECPDL_INDEX (); 2232 specpdl_ref count = SPECPDL_INDEX ();
2233#define COMBINING_NO 0
2234#define COMBINING_BEFORE 1
2235#define COMBINING_AFTER 2
2236#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2237 int maybe_byte_combining = COMBINING_NO;
2238 ptrdiff_t last_changed = 0; 2233 ptrdiff_t last_changed = 0;
2239 bool multibyte_p 2234 bool multibyte_p
2240 = !NILP (BVAR (current_buffer, enable_multibyte_characters)); 2235 = !NILP (BVAR (current_buffer, enable_multibyte_characters));
@@ -2253,17 +2248,6 @@ Both characters must have the same length of multi-byte form. */)
2253 len = CHAR_STRING (fromc, fromstr); 2248 len = CHAR_STRING (fromc, fromstr);
2254 if (CHAR_STRING (toc, tostr) != len) 2249 if (CHAR_STRING (toc, tostr) != len)
2255 error ("Characters in `subst-char-in-region' have different byte-lengths"); 2250 error ("Characters in `subst-char-in-region' have different byte-lengths");
2256 if (!ASCII_CHAR_P (*tostr))
2257 {
2258 /* If *TOSTR is in the range 0x80..0x9F and TOCHAR is not a
2259 complete multibyte character, it may be combined with the
2260 after bytes. If it is in the range 0xA0..0xFF, it may be
2261 combined with the before and after bytes. */
2262 if (!CHAR_HEAD_P (*tostr))
2263 maybe_byte_combining = COMBINING_BOTH;
2264 else if (BYTES_BY_CHAR_HEAD (*tostr) > len)
2265 maybe_byte_combining = COMBINING_AFTER;
2266 }
2267 } 2251 }
2268 else 2252 else
2269 { 2253 {
@@ -2338,53 +2322,14 @@ Both characters must have the same length of multi-byte form. */)
2338 goto restart; 2322 goto restart;
2339 } 2323 }
2340 2324
2341 /* Take care of the case where the new character 2325 if (NILP (noundo))
2342 combines with neighboring bytes. */ 2326 record_change (pos, 1);
2343 if (maybe_byte_combining 2327 for (i = 0; i < len; i++) *p++ = tostr[i];
2344 && (maybe_byte_combining == COMBINING_AFTER
2345 ? (pos_byte_next < Z_BYTE
2346 && ! CHAR_HEAD_P (FETCH_BYTE (pos_byte_next)))
2347 : ((pos_byte_next < Z_BYTE
2348 && ! CHAR_HEAD_P (FETCH_BYTE (pos_byte_next)))
2349 || (pos_byte > BEG_BYTE
2350 && ! ASCII_CHAR_P (FETCH_BYTE (pos_byte - 1))))))
2351 {
2352 Lisp_Object tem, string;
2353
2354 tem = BVAR (current_buffer, undo_list);
2355
2356 /* Make a multibyte string containing this single character. */
2357 string = make_multibyte_string ((char *) tostr, 1, len);
2358 /* replace_range is less efficient, because it moves the gap,
2359 but it handles combining correctly. */
2360 replace_range (pos, pos + 1, string,
2361 false, false, true, false, false);
2362 pos_byte_next = CHAR_TO_BYTE (pos);
2363 if (pos_byte_next > pos_byte)
2364 /* Before combining happened. We should not increment
2365 POS. So, to cancel the later increment of POS,
2366 decrease it now. */
2367 pos--;
2368 else
2369 pos_byte_next += next_char_len (pos_byte_next);
2370
2371 if (! NILP (noundo))
2372 bset_undo_list (current_buffer, tem);
2373 }
2374 else
2375 {
2376 if (NILP (noundo))
2377 record_change (pos, 1);
2378 for (i = 0; i < len; i++) *p++ = tostr[i];
2379 2328
2380#ifdef HAVE_TREE_SITTER 2329#ifdef HAVE_TREE_SITTER
2381 /* In the previous branch, replace_range() notifies 2330 /* FIXME: Why not do it when we `signal_after_change`? */
2382 changes to tree-sitter, but in this branch, we 2331 treesit_record_change (pos_byte, pos_byte + len, pos_byte + len);
2383 modified buffer content manually, so we need to
2384 notify tree-sitter manually. */
2385 treesit_record_change (pos_byte, pos_byte + len, pos_byte + len);
2386#endif 2332#endif
2387 }
2388 last_changed = pos + 1; 2333 last_changed = pos + 1;
2389 } 2334 }
2390 pos_byte = pos_byte_next; 2335 pos_byte = pos_byte_next;