aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1999-12-15 00:10:23 +0000
committerKenichi Handa1999-12-15 00:10:23 +0000
commitd5c2c4034839d42055f1874e9446be28634fd833 (patch)
tree690593a5515c25e1b7629319a27be3c469a9ff9d /src
parent91f045dfa34e21bb6a722e15d1141cc3a4d86add (diff)
downloademacs-d5c2c4034839d42055f1874e9446be28634fd833.tar.gz
emacs-d5c2c4034839d42055f1874e9446be28634fd833.zip
(Fchar_to_string): Adjusted for the change of
CHAR_STRING. (general_insert_function): Likewise. (Finsert_char): Likewise. (Fsubst_char_in_region): Likewise. Call update_compositions. (Ftranslate_region): Call update_compositions. (Ftranspose_regions): Call update_compositions.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/src/editfns.c b/src/editfns.c
index ab73b51a160..3f713f1f134 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -132,11 +132,11 @@ DEFUN ("char-to-string", Fchar_to_string, Schar_to_string, 1, 1, 0,
132 Lisp_Object character; 132 Lisp_Object character;
133{ 133{
134 int len; 134 int len;
135 unsigned char workbuf[4], *str; 135 unsigned char str[MAX_MULTIBYTE_LENGTH];
136 136
137 CHECK_NUMBER (character, 0); 137 CHECK_NUMBER (character, 0);
138 138
139 len = CHAR_STRING (XFASTINT (character), workbuf, str); 139 len = CHAR_STRING (XFASTINT (character), str);
140 return make_string_from_bytes (str, 1, len); 140 return make_string_from_bytes (str, 1, len);
141} 141}
142 142
@@ -1712,17 +1712,16 @@ general_insert_function (insert_func, insert_from_string_func,
1712 retry: 1712 retry:
1713 if (INTEGERP (val)) 1713 if (INTEGERP (val))
1714 { 1714 {
1715 unsigned char workbuf[4], *str; 1715 unsigned char str[MAX_MULTIBYTE_LENGTH];
1716 int len; 1716 int len;
1717 1717
1718 if (!NILP (current_buffer->enable_multibyte_characters)) 1718 if (!NILP (current_buffer->enable_multibyte_characters))
1719 len = CHAR_STRING (XFASTINT (val), workbuf, str); 1719 len = CHAR_STRING (XFASTINT (val), str);
1720 else 1720 else
1721 { 1721 {
1722 workbuf[0] = (SINGLE_BYTE_CHAR_P (XINT (val)) 1722 str[0] = (SINGLE_BYTE_CHAR_P (XINT (val))
1723 ? XINT (val) 1723 ? XINT (val)
1724 : multibyte_char_to_unibyte (XINT (val), Qnil)); 1724 : multibyte_char_to_unibyte (XINT (val), Qnil));
1725 str = workbuf;
1726 len = 1; 1725 len = 1;
1727 } 1726 }
1728 (*insert_func) (str, len); 1727 (*insert_func) (str, len);
@@ -1843,15 +1842,15 @@ from adjoining text, if those properties are sticky.")
1843 register int strlen; 1842 register int strlen;
1844 register int i, n; 1843 register int i, n;
1845 int len; 1844 int len;
1846 unsigned char workbuf[4], *str; 1845 unsigned char str[MAX_MULTIBYTE_LENGTH];
1847 1846
1848 CHECK_NUMBER (character, 0); 1847 CHECK_NUMBER (character, 0);
1849 CHECK_NUMBER (count, 1); 1848 CHECK_NUMBER (count, 1);
1850 1849
1851 if (!NILP (current_buffer->enable_multibyte_characters)) 1850 if (!NILP (current_buffer->enable_multibyte_characters))
1852 len = CHAR_STRING (XFASTINT (character), workbuf, str); 1851 len = CHAR_STRING (XFASTINT (character), str);
1853 else 1852 else
1854 workbuf[0] = XFASTINT (character), str = workbuf, len = 1; 1853 str[0] = XFASTINT (character), len = 1;
1855 n = XINT (count) * len; 1854 n = XINT (count) * len;
1856 if (n <= 0) 1855 if (n <= 0)
1857 return Qnil; 1856 return Qnil;
@@ -2262,13 +2261,15 @@ Both characters must have the same length of multi-byte form.")
2262{ 2261{
2263 register int pos, pos_byte, stop, i, len, end_byte; 2262 register int pos, pos_byte, stop, i, len, end_byte;
2264 int changed = 0; 2263 int changed = 0;
2265 unsigned char fromwork[4], *fromstr, towork[4], *tostr, *p; 2264 unsigned char fromstr[MAX_MULTIBYTE_LENGTH], tostr[MAX_MULTIBYTE_LENGTH];
2265 unsigned char *p;
2266 int count = specpdl_ptr - specpdl; 2266 int count = specpdl_ptr - specpdl;
2267#define COMBINING_NO 0 2267#define COMBINING_NO 0
2268#define COMBINING_BEFORE 1 2268#define COMBINING_BEFORE 1
2269#define COMBINING_AFTER 2 2269#define COMBINING_AFTER 2
2270#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER) 2270#define COMBINING_BOTH (COMBINING_BEFORE | COMBINING_AFTER)
2271 int maybe_byte_combining = COMBINING_NO; 2271 int maybe_byte_combining = COMBINING_NO;
2272 int last_changed;
2272 2273
2273 validate_region (&start, &end); 2274 validate_region (&start, &end);
2274 CHECK_NUMBER (fromchar, 2); 2275 CHECK_NUMBER (fromchar, 2);
@@ -2276,8 +2277,8 @@ Both characters must have the same length of multi-byte form.")
2276 2277
2277 if (! NILP (current_buffer->enable_multibyte_characters)) 2278 if (! NILP (current_buffer->enable_multibyte_characters))
2278 { 2279 {
2279 len = CHAR_STRING (XFASTINT (fromchar), fromwork, fromstr); 2280 len = CHAR_STRING (XFASTINT (fromchar), fromstr);
2280 if (CHAR_STRING (XFASTINT (tochar), towork, tostr) != len) 2281 if (CHAR_STRING (XFASTINT (tochar), tostr) != len)
2281 error ("Characters in subst-char-in-region have different byte-lengths"); 2282 error ("Characters in subst-char-in-region have different byte-lengths");
2282 if (!ASCII_BYTE_P (*tostr)) 2283 if (!ASCII_BYTE_P (*tostr))
2283 { 2284 {
@@ -2294,8 +2295,8 @@ Both characters must have the same length of multi-byte form.")
2294 else 2295 else
2295 { 2296 {
2296 len = 1; 2297 len = 1;
2297 fromwork[0] = XFASTINT (fromchar), fromstr = fromwork; 2298 fromstr[0] = XFASTINT (fromchar);
2298 towork[0] = XFASTINT (tochar), tostr = towork; 2299 tostr[0] = XFASTINT (tochar);
2299 } 2300 }
2300 2301
2301 pos = XINT (start); 2302 pos = XINT (start);
@@ -2340,7 +2341,8 @@ Both characters must have the same length of multi-byte form.")
2340 { 2341 {
2341 if (! changed) 2342 if (! changed)
2342 { 2343 {
2343 modify_region (current_buffer, XINT (start), XINT (end)); 2344 changed = pos;
2345 modify_region (current_buffer, changed, XINT (end));
2344 2346
2345 if (! NILP (noundo)) 2347 if (! NILP (noundo))
2346 { 2348 {
@@ -2349,8 +2351,6 @@ Both characters must have the same length of multi-byte form.")
2349 if (MODIFF - 1 == current_buffer->auto_save_modified) 2351 if (MODIFF - 1 == current_buffer->auto_save_modified)
2350 current_buffer->auto_save_modified++; 2352 current_buffer->auto_save_modified++;
2351 } 2353 }
2352
2353 changed = 1;
2354 } 2354 }
2355 2355
2356 /* Take care of the case where the new character 2356 /* Take care of the case where the new character
@@ -2397,14 +2397,18 @@ Both characters must have the same length of multi-byte form.")
2397 record_change (pos, 1); 2397 record_change (pos, 1);
2398 for (i = 0; i < len; i++) *p++ = tostr[i]; 2398 for (i = 0; i < len; i++) *p++ = tostr[i];
2399 } 2399 }
2400 last_changed = pos + 1;
2400 } 2401 }
2401 pos_byte = pos_byte_next; 2402 pos_byte = pos_byte_next;
2402 pos++; 2403 pos++;
2403 } 2404 }
2404 2405
2405 if (changed) 2406 if (changed)
2406 signal_after_change (XINT (start), 2407 {
2407 XINT (end) - XINT (start), XINT (end) - XINT (start)); 2408 signal_after_change (changed,
2409 last_changed - changed, last_changed - changed);
2410 update_compositions (changed, last_changed, CHECK_ALL);
2411 }
2408 2412
2409 unbind_to (count, Qnil); 2413 unbind_to (count, Qnil);
2410 return Qnil; 2414 return Qnil;
@@ -2487,6 +2491,7 @@ It returns the number of characters changed.")
2487 record_change (pos, 1); 2491 record_change (pos, 1);
2488 *p = nc; 2492 *p = nc;
2489 signal_after_change (pos, 1, 1); 2493 signal_after_change (pos, 1, 1);
2494 update_compositions (pos, pos + 1, CHECK_BORDER);
2490 } 2495 }
2491 ++cnt; 2496 ++cnt;
2492 } 2497 }
@@ -3532,6 +3537,8 @@ Transposing beyond buffer boundaries is an error.")
3532 len1, current_buffer, 0); 3537 len1, current_buffer, 0);
3533 graft_intervals_into_buffer (tmp_interval2, start1, 3538 graft_intervals_into_buffer (tmp_interval2, start1,
3534 len2, current_buffer, 0); 3539 len2, current_buffer, 0);
3540 update_compositions (start1, start1 + len2, CHECK_BORDER);
3541 update_compositions (start1 + len2, end2, CHECK_TAIL);
3535 } 3542 }
3536 /* Non-adjacent regions, because end1 != start2, bleagh... */ 3543 /* Non-adjacent regions, because end1 != start2, bleagh... */
3537 else 3544 else
@@ -3632,6 +3639,9 @@ Transposing beyond buffer boundaries is an error.")
3632 graft_intervals_into_buffer (tmp_interval2, start1, 3639 graft_intervals_into_buffer (tmp_interval2, start1,
3633 len2, current_buffer, 0); 3640 len2, current_buffer, 0);
3634 } 3641 }
3642
3643 update_compositions (start1, start1 + len2, CHECK_BORDER);
3644 update_compositions (end2 - len1, end2, CHECK_BORDER);
3635 } 3645 }
3636 3646
3637 /* When doing multiple transpositions, it might be nice 3647 /* When doing multiple transpositions, it might be nice