diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/insdel.c | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/insdel.c b/src/insdel.c index 5cee99f89cd..2d84ae1de62 100644 --- a/src/insdel.c +++ b/src/insdel.c | |||
| @@ -27,6 +27,9 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |||
| 27 | 27 | ||
| 28 | static void insert_1 (); | 28 | static void insert_1 (); |
| 29 | static void insert_from_string_1 (); | 29 | static void insert_from_string_1 (); |
| 30 | static void gap_left (); | ||
| 31 | static void gap_right (); | ||
| 32 | static void adjust_markers (); | ||
| 30 | 33 | ||
| 31 | /* Move gap to position `pos'. | 34 | /* Move gap to position `pos'. |
| 32 | Note that this can quit! */ | 35 | Note that this can quit! */ |
| @@ -43,6 +46,7 @@ move_gap (pos) | |||
| 43 | /* Move the gap to POS, which is less than the current GPT. | 46 | /* Move the gap to POS, which is less than the current GPT. |
| 44 | If NEWGAP is nonzero, then don't update beg_unchanged and end_unchanged. */ | 47 | If NEWGAP is nonzero, then don't update beg_unchanged and end_unchanged. */ |
| 45 | 48 | ||
| 49 | static void | ||
| 46 | gap_left (pos, newgap) | 50 | gap_left (pos, newgap) |
| 47 | register int pos; | 51 | register int pos; |
| 48 | int newgap; | 52 | int newgap; |
| @@ -125,6 +129,7 @@ gap_left (pos, newgap) | |||
| 125 | QUIT; | 129 | QUIT; |
| 126 | } | 130 | } |
| 127 | 131 | ||
| 132 | static void | ||
| 128 | gap_right (pos) | 133 | gap_right (pos) |
| 129 | register int pos; | 134 | register int pos; |
| 130 | { | 135 | { |
| @@ -206,6 +211,7 @@ gap_right (pos) | |||
| 206 | of adjustment, are first moved back to the near end of the interval | 211 | of adjustment, are first moved back to the near end of the interval |
| 207 | and then adjusted by `amount'. */ | 212 | and then adjusted by `amount'. */ |
| 208 | 213 | ||
| 214 | static void | ||
| 209 | adjust_markers (from, to, amount) | 215 | adjust_markers (from, to, amount) |
| 210 | register int from, to, amount; | 216 | register int from, to, amount; |
| 211 | { | 217 | { |
| @@ -290,7 +296,7 @@ insert (string, length) | |||
| 290 | if (length > 0) | 296 | if (length > 0) |
| 291 | { | 297 | { |
| 292 | insert_1 (string, length); | 298 | insert_1 (string, length); |
| 293 | signal_after_change (point-length, 0, length); | 299 | signal_after_change (PT-length, 0, length); |
| 294 | } | 300 | } |
| 295 | } | 301 | } |
| 296 | 302 | ||
| @@ -306,26 +312,26 @@ insert_1 (string, length) | |||
| 306 | if (length + Z != XINT (temp)) | 312 | if (length + Z != XINT (temp)) |
| 307 | error ("maximum buffer size exceeded"); | 313 | error ("maximum buffer size exceeded"); |
| 308 | 314 | ||
| 309 | prepare_to_modify_buffer (point, point); | 315 | prepare_to_modify_buffer (PT, PT); |
| 310 | 316 | ||
| 311 | if (point != GPT) | 317 | if (PT != GPT) |
| 312 | move_gap (point); | 318 | move_gap (PT); |
| 313 | if (GAP_SIZE < length) | 319 | if (GAP_SIZE < length) |
| 314 | make_gap (length - GAP_SIZE); | 320 | make_gap (length - GAP_SIZE); |
| 315 | 321 | ||
| 316 | record_insert (point, length); | 322 | record_insert (PT, length); |
| 317 | MODIFF++; | 323 | MODIFF++; |
| 318 | 324 | ||
| 319 | bcopy (string, GPT_ADDR, length); | 325 | bcopy (string, GPT_ADDR, length); |
| 320 | 326 | ||
| 321 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ | 327 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ |
| 322 | offset_intervals (current_buffer, point, length); | 328 | offset_intervals (current_buffer, PT, length); |
| 323 | 329 | ||
| 324 | GAP_SIZE -= length; | 330 | GAP_SIZE -= length; |
| 325 | GPT += length; | 331 | GPT += length; |
| 326 | ZV += length; | 332 | ZV += length; |
| 327 | Z += length; | 333 | Z += length; |
| 328 | SET_PT (point + length); | 334 | SET_PT (PT + length); |
| 329 | } | 335 | } |
| 330 | 336 | ||
| 331 | /* Insert the part of the text of STRING, a Lisp object assumed to be | 337 | /* Insert the part of the text of STRING, a Lisp object assumed to be |
| @@ -345,7 +351,7 @@ insert_from_string (string, pos, length, inherit) | |||
| 345 | if (length > 0) | 351 | if (length > 0) |
| 346 | { | 352 | { |
| 347 | insert_from_string_1 (string, pos, length, inherit); | 353 | insert_from_string_1 (string, pos, length, inherit); |
| 348 | signal_after_change (point-length, 0, length); | 354 | signal_after_change (PT-length, 0, length); |
| 349 | } | 355 | } |
| 350 | } | 356 | } |
| 351 | 357 | ||
| @@ -364,21 +370,21 @@ insert_from_string_1 (string, pos, length, inherit) | |||
| 364 | error ("maximum buffer size exceeded"); | 370 | error ("maximum buffer size exceeded"); |
| 365 | 371 | ||
| 366 | GCPRO1 (string); | 372 | GCPRO1 (string); |
| 367 | prepare_to_modify_buffer (point, point); | 373 | prepare_to_modify_buffer (PT, PT); |
| 368 | 374 | ||
| 369 | if (point != GPT) | 375 | if (PT != GPT) |
| 370 | move_gap (point); | 376 | move_gap (PT); |
| 371 | if (GAP_SIZE < length) | 377 | if (GAP_SIZE < length) |
| 372 | make_gap (length - GAP_SIZE); | 378 | make_gap (length - GAP_SIZE); |
| 373 | 379 | ||
| 374 | record_insert (point, length); | 380 | record_insert (PT, length); |
| 375 | MODIFF++; | 381 | MODIFF++; |
| 376 | UNGCPRO; | 382 | UNGCPRO; |
| 377 | 383 | ||
| 378 | bcopy (XSTRING (string)->data, GPT_ADDR, length); | 384 | bcopy (XSTRING (string)->data, GPT_ADDR, length); |
| 379 | 385 | ||
| 380 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ | 386 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ |
| 381 | offset_intervals (current_buffer, point, length); | 387 | offset_intervals (current_buffer, PT, length); |
| 382 | 388 | ||
| 383 | GAP_SIZE -= length; | 389 | GAP_SIZE -= length; |
| 384 | GPT += length; | 390 | GPT += length; |
| @@ -386,10 +392,10 @@ insert_from_string_1 (string, pos, length, inherit) | |||
| 386 | Z += length; | 392 | Z += length; |
| 387 | 393 | ||
| 388 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ | 394 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ |
| 389 | graft_intervals_into_buffer (XSTRING (string)->intervals, point, length, | 395 | graft_intervals_into_buffer (XSTRING (string)->intervals, PT, length, |
| 390 | current_buffer, inherit); | 396 | current_buffer, inherit); |
| 391 | 397 | ||
| 392 | SET_PT (point + length); | 398 | SET_PT (PT + length); |
| 393 | } | 399 | } |
| 394 | 400 | ||
| 395 | /* Insert the character C before point */ | 401 | /* Insert the character C before point */ |
| @@ -421,10 +427,10 @@ insert_before_markers (string, length) | |||
| 421 | { | 427 | { |
| 422 | if (length > 0) | 428 | if (length > 0) |
| 423 | { | 429 | { |
| 424 | register int opoint = point; | 430 | register int opoint = PT; |
| 425 | insert_1 (string, length); | 431 | insert_1 (string, length); |
| 426 | adjust_markers (opoint - 1, opoint, length); | 432 | adjust_markers (opoint - 1, opoint, length); |
| 427 | signal_after_change (point-length, 0, length); | 433 | signal_after_change (PT-length, 0, length); |
| 428 | } | 434 | } |
| 429 | } | 435 | } |
| 430 | 436 | ||
| @@ -437,10 +443,10 @@ insert_from_string_before_markers (string, pos, length, inherit) | |||
| 437 | { | 443 | { |
| 438 | if (length > 0) | 444 | if (length > 0) |
| 439 | { | 445 | { |
| 440 | register int opoint = point; | 446 | register int opoint = PT; |
| 441 | insert_from_string_1 (string, pos, length, inherit); | 447 | insert_from_string_1 (string, pos, length, inherit); |
| 442 | adjust_markers (opoint - 1, opoint, length); | 448 | adjust_markers (opoint - 1, opoint, length); |
| 443 | signal_after_change (point-length, 0, length); | 449 | signal_after_change (PT-length, 0, length); |
| 444 | } | 450 | } |
| 445 | } | 451 | } |
| 446 | 452 | ||
| @@ -482,12 +488,12 @@ del_range_1 (from, to, prepare) | |||
| 482 | MODIFF++; | 488 | MODIFF++; |
| 483 | 489 | ||
| 484 | /* Relocate point as if it were a marker. */ | 490 | /* Relocate point as if it were a marker. */ |
| 485 | if (from < point) | 491 | if (from < PT) |
| 486 | { | 492 | { |
| 487 | if (point < to) | 493 | if (PT < to) |
| 488 | SET_PT (from); | 494 | SET_PT (from); |
| 489 | else | 495 | else |
| 490 | SET_PT (point - numdel); | 496 | SET_PT (PT - numdel); |
| 491 | } | 497 | } |
| 492 | 498 | ||
| 493 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ | 499 | /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */ |