comparison src/editfns.c @ 5130:ddee29e260d2

(make_buffer_string): Don't copy intervals if we don't really have any properties. (Finsert_buffer_substring): Pass graft_intervals_into_buffer the current buffer. Pass it the extra arg LENGTH. (Fsubst_char_in_region): Call modify_region only if a change has to be made. Call signal_after_change just once, at end.
author Richard M. Stallman <rms@gnu.org>
date Tue, 23 Nov 1993 10:38:59 +0000
parents 7a6aea972b7e
children 0e99ea9941e2
comparison
equal deleted inserted replaced
5129:d48d18e20316 5130:ddee29e260d2
888 888
889 Lisp_Object 889 Lisp_Object
890 make_buffer_string (start, end) 890 make_buffer_string (start, end)
891 int start, end; 891 int start, end;
892 { 892 {
893 Lisp_Object result; 893 Lisp_Object result, tem;
894 894
895 if (start < GPT && GPT < end) 895 if (start < GPT && GPT < end)
896 move_gap (start); 896 move_gap (start);
897 897
898 result = make_uninit_string (end - start); 898 result = make_uninit_string (end - start);
899 bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start); 899 bcopy (&FETCH_CHAR (start), XSTRING (result)->data, end - start);
900 900
901 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ 901 tem = Fnext_property_change (make_number (start), Qnil, make_number (end));
902 copy_intervals_to_string (result, current_buffer, start, end - start); 902
903 #ifdef USE_TEXT_PROPERTIES
904 if (XINT (tem) != end)
905 copy_intervals_to_string (result, current_buffer, start, end - start);
906 #endif
903 907
904 return result; 908 return result;
905 } 909 }
906 910
907 DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0, 911 DEFUN ("buffer-substring", Fbuffer_substring, Sbuffer_substring, 2, 2, 0,
989 if (beg < end) 993 if (beg < end)
990 insert (BUF_CHAR_ADDRESS (bp, beg), end - beg); 994 insert (BUF_CHAR_ADDRESS (bp, beg), end - beg);
991 995
992 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ 996 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
993 graft_intervals_into_buffer (copy_intervals (bp->intervals, start, len), 997 graft_intervals_into_buffer (copy_intervals (bp->intervals, start, len),
994 opoint, bp, 0); 998 opoint, len, current_buffer, 0);
995 999
996 return Qnil; 1000 return Qnil;
997 } 1001 }
998 1002
999 DEFUN ("compare-buffer-substrings", Fcompare_buffer_substrings, Scompare_buffer_substrings, 1003 DEFUN ("compare-buffer-substrings", Fcompare_buffer_substrings, Scompare_buffer_substrings,
1125 and don't mark the buffer as really changed.") 1129 and don't mark the buffer as really changed.")
1126 (start, end, fromchar, tochar, noundo) 1130 (start, end, fromchar, tochar, noundo)
1127 Lisp_Object start, end, fromchar, tochar, noundo; 1131 Lisp_Object start, end, fromchar, tochar, noundo;
1128 { 1132 {
1129 register int pos, stop, look; 1133 register int pos, stop, look;
1134 int changed = 0;
1130 1135
1131 validate_region (&start, &end); 1136 validate_region (&start, &end);
1132 CHECK_NUMBER (fromchar, 2); 1137 CHECK_NUMBER (fromchar, 2);
1133 CHECK_NUMBER (tochar, 3); 1138 CHECK_NUMBER (tochar, 3);
1134 1139
1135 pos = XINT (start); 1140 pos = XINT (start);
1136 stop = XINT (end); 1141 stop = XINT (end);
1137 look = XINT (fromchar); 1142 look = XINT (fromchar);
1138 1143
1139 modify_region (current_buffer, pos, stop);
1140 if (! NILP (noundo)) 1144 if (! NILP (noundo))
1141 { 1145 {
1142 if (MODIFF - 1 == current_buffer->save_modified) 1146 if (MODIFF - 1 == current_buffer->save_modified)
1143 current_buffer->save_modified++; 1147 current_buffer->save_modified++;
1144 if (MODIFF - 1 == current_buffer->auto_save_modified) 1148 if (MODIFF - 1 == current_buffer->auto_save_modified)
1147 1151
1148 while (pos < stop) 1152 while (pos < stop)
1149 { 1153 {
1150 if (FETCH_CHAR (pos) == look) 1154 if (FETCH_CHAR (pos) == look)
1151 { 1155 {
1156 if (! changed)
1157 {
1158 modify_region (current_buffer, XINT (start), stop);
1159 changed = 1;
1160 }
1161
1152 if (NILP (noundo)) 1162 if (NILP (noundo))
1153 record_change (pos, 1); 1163 record_change (pos, 1);
1154 FETCH_CHAR (pos) = XINT (tochar); 1164 FETCH_CHAR (pos) = XINT (tochar);
1155 if (NILP (noundo))
1156 signal_after_change (pos, 1, 1);
1157 } 1165 }
1158 pos++; 1166 pos++;
1159 } 1167 }
1168
1169 if (changed)
1170 signal_after_change (XINT (start),
1171 stop - XINT (start), stop - XINT (start));
1160 1172
1161 return Qnil; 1173 return Qnil;
1162 } 1174 }
1163 1175
1164 DEFUN ("translate-region", Ftranslate_region, Stranslate_region, 3, 3, 0, 1176 DEFUN ("translate-region", Ftranslate_region, Stranslate_region, 3, 3, 0,