diff options
Diffstat (limited to 'src/insdel.c')
| -rw-r--r-- | src/insdel.c | 64 |
1 files changed, 7 insertions, 57 deletions
diff --git a/src/insdel.c b/src/insdel.c index 4bdcb4bc0b7..82dce13af98 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -48,7 +48,7 @@ static void adjust_markers_for_replace (EMACS_INT, EMACS_INT, EMACS_INT, | |||
| 48 | EMACS_INT, EMACS_INT, EMACS_INT); | 48 | EMACS_INT, EMACS_INT, EMACS_INT); |
| 49 | static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes); | 49 | static void adjust_point (EMACS_INT nchars, EMACS_INT nbytes); |
| 50 | 50 | ||
| 51 | Lisp_Object Fcombine_after_change_execute (void); | 51 | static Lisp_Object Fcombine_after_change_execute (void); |
| 52 | 52 | ||
| 53 | /* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT) | 53 | /* List of elements of the form (BEG-UNCHANGED END-UNCHANGED CHANGE-AMOUNT) |
| 54 | describing changes which happened while combine_after_change_calls | 54 | describing changes which happened while combine_after_change_calls |
| @@ -60,12 +60,14 @@ Lisp_Object Fcombine_after_change_execute (void); | |||
| 60 | END-UNCHANGED is the number of chars after the changed range, | 60 | END-UNCHANGED is the number of chars after the changed range, |
| 61 | and CHANGE-AMOUNT is the number of characters inserted by the change | 61 | and CHANGE-AMOUNT is the number of characters inserted by the change |
| 62 | (negative for a deletion). */ | 62 | (negative for a deletion). */ |
| 63 | Lisp_Object combine_after_change_list; | 63 | static Lisp_Object combine_after_change_list; |
| 64 | 64 | ||
| 65 | /* Buffer which combine_after_change_list is about. */ | 65 | /* Buffer which combine_after_change_list is about. */ |
| 66 | Lisp_Object combine_after_change_buffer; | 66 | static Lisp_Object combine_after_change_buffer; |
| 67 | 67 | ||
| 68 | Lisp_Object Qinhibit_modification_hooks; | 68 | Lisp_Object Qinhibit_modification_hooks; |
| 69 | |||
| 70 | static void signal_before_change (EMACS_INT, EMACS_INT, EMACS_INT *); | ||
| 69 | 71 | ||
| 70 | #define CHECK_MARKERS() \ | 72 | #define CHECK_MARKERS() \ |
| 71 | do \ | 73 | do \ |
| @@ -1222,7 +1224,7 @@ insert_from_buffer_1 (struct buffer *buf, | |||
| 1222 | 1224 | ||
| 1223 | PREV_TEXT nil means the new text was just inserted. */ | 1225 | PREV_TEXT nil means the new text was just inserted. */ |
| 1224 | 1226 | ||
| 1225 | void | 1227 | static void |
| 1226 | adjust_after_replace (EMACS_INT from, EMACS_INT from_byte, | 1228 | adjust_after_replace (EMACS_INT from, EMACS_INT from_byte, |
| 1227 | Lisp_Object prev_text, EMACS_INT len, EMACS_INT len_byte) | 1229 | Lisp_Object prev_text, EMACS_INT len, EMACS_INT len_byte) |
| 1228 | { | 1230 | { |
| @@ -1285,58 +1287,6 @@ adjust_after_replace (EMACS_INT from, EMACS_INT from_byte, | |||
| 1285 | CHARS_MODIFF = MODIFF; | 1287 | CHARS_MODIFF = MODIFF; |
| 1286 | } | 1288 | } |
| 1287 | 1289 | ||
| 1288 | /* Like adjust_after_replace, but doesn't require PREV_TEXT. | ||
| 1289 | This is for use when undo is not enabled in the current buffer. */ | ||
| 1290 | |||
| 1291 | void | ||
| 1292 | adjust_after_replace_noundo (EMACS_INT from, EMACS_INT from_byte, | ||
| 1293 | EMACS_INT nchars_del, EMACS_INT nbytes_del, | ||
| 1294 | EMACS_INT len, EMACS_INT len_byte) | ||
| 1295 | { | ||
| 1296 | #ifdef BYTE_COMBINING_DEBUG | ||
| 1297 | if (count_combining_before (GPT_ADDR, len_byte, from, from_byte) | ||
| 1298 | || count_combining_after (GPT_ADDR, len_byte, from, from_byte)) | ||
| 1299 | abort (); | ||
| 1300 | #endif | ||
| 1301 | |||
| 1302 | /* Update various buffer positions for the new text. */ | ||
| 1303 | GAP_SIZE -= len_byte; | ||
| 1304 | ZV += len; Z+= len; | ||
| 1305 | ZV_BYTE += len_byte; Z_BYTE += len_byte; | ||
| 1306 | GPT += len; GPT_BYTE += len_byte; | ||
| 1307 | if (GAP_SIZE > 0) *(GPT_ADDR) = 0; /* Put an anchor. */ | ||
| 1308 | |||
| 1309 | if (nchars_del > 0) | ||
| 1310 | adjust_markers_for_replace (from, from_byte, nchars_del, nbytes_del, | ||
| 1311 | len, len_byte); | ||
| 1312 | else | ||
| 1313 | adjust_markers_for_insert (from, from_byte, | ||
| 1314 | from + len, from_byte + len_byte, 0); | ||
| 1315 | |||
| 1316 | if (len > nchars_del) | ||
| 1317 | adjust_overlays_for_insert (from, len - nchars_del); | ||
| 1318 | else if (len < nchars_del) | ||
| 1319 | adjust_overlays_for_delete (from, nchars_del - len); | ||
| 1320 | if (BUF_INTERVALS (current_buffer) != 0) | ||
| 1321 | { | ||
| 1322 | offset_intervals (current_buffer, from, len - nchars_del); | ||
| 1323 | } | ||
| 1324 | |||
| 1325 | if (from < PT) | ||
| 1326 | adjust_point (len - nchars_del, len_byte - nbytes_del); | ||
| 1327 | |||
| 1328 | /* As byte combining will decrease Z, we must check this again. */ | ||
| 1329 | if (Z - GPT < END_UNCHANGED) | ||
| 1330 | END_UNCHANGED = Z - GPT; | ||
| 1331 | |||
| 1332 | CHECK_MARKERS (); | ||
| 1333 | |||
| 1334 | if (len == 0) | ||
| 1335 | evaporate_overlays (from); | ||
| 1336 | MODIFF++; | ||
| 1337 | CHARS_MODIFF = MODIFF; | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | /* Record undo information, adjust markers and position keepers for an | 1290 | /* Record undo information, adjust markers and position keepers for an |
| 1341 | insertion of a text from FROM (FROM_BYTE) to TO (TO_BYTE). The | 1291 | insertion of a text from FROM (FROM_BYTE) to TO (TO_BYTE). The |
| 1342 | text already exists in the current buffer but character length (TO | 1292 | text already exists in the current buffer but character length (TO |
| @@ -2049,7 +1999,7 @@ reset_var_on_error (Lisp_Object val) | |||
| 2049 | If PRESERVE_PTR is nonzero, we relocate *PRESERVE_PTR | 1999 | If PRESERVE_PTR is nonzero, we relocate *PRESERVE_PTR |
| 2050 | by holding its value temporarily in a marker. */ | 2000 | by holding its value temporarily in a marker. */ |
| 2051 | 2001 | ||
| 2052 | void | 2002 | static void |
| 2053 | signal_before_change (EMACS_INT start_int, EMACS_INT end_int, | 2003 | signal_before_change (EMACS_INT start_int, EMACS_INT end_int, |
| 2054 | EMACS_INT *preserve_ptr) | 2004 | EMACS_INT *preserve_ptr) |
| 2055 | { | 2005 | { |