aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Monnier2003-06-26 23:17:29 +0000
committerStefan Monnier2003-06-26 23:17:29 +0000
commitdab0b04d496348fbc42155b3970ef4f322a4e972 (patch)
tree2932c9de57679fd64f3b1d19c1662067f9ef1ccc /src
parent12038f9fc9a5642ec5185ddfb2f37cdd15debfd3 (diff)
downloademacs-dab0b04d496348fbc42155b3970ef4f322a4e972.tar.gz
emacs-dab0b04d496348fbc42155b3970ef4f322a4e972.zip
(check_markers, adjust_markers_for_delete)
(adjust_markers_for_insert, adjust_markers_for_replace) (prepare_to_modify_buffer, RESTORE_VALUE): Update for new types.
Diffstat (limited to 'src')
-rw-r--r--src/insdel.c57
1 files changed, 21 insertions, 36 deletions
diff --git a/src/insdel.c b/src/insdel.c
index d4921b5f1ce..85f1d537290 100644
--- a/src/insdel.c
+++ b/src/insdel.c
@@ -1,5 +1,5 @@
1/* Buffer insertion/deletion and gap motion for GNU Emacs. 1/* Buffer insertion/deletion and gap motion for GNU Emacs.
2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 2001 2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000, 01, 2003
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -79,23 +79,19 @@ static int check_markers_debug_flag;
79void 79void
80check_markers () 80check_markers ()
81{ 81{
82 register Lisp_Object tail; 82 register struct Lisp_Marker *tail;
83 int multibyte = ! NILP (current_buffer->enable_multibyte_characters); 83 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
84 84
85 tail = BUF_MARKERS (current_buffer); 85 for (tail = BUF_MARKERS (current_buffer); tail; tail = tail->next)
86
87 while (! NILP (tail))
88 { 86 {
89 if (XMARKER (tail)->buffer->text != current_buffer->text) 87 if (tail->buffer->text != current_buffer->text)
90 abort (); 88 abort ();
91 if (XMARKER (tail)->charpos > Z) 89 if (tail->charpos > Z)
92 abort (); 90 abort ();
93 if (XMARKER (tail)->bytepos > Z_BYTE) 91 if (tail->bytepos > Z_BYTE)
94 abort (); 92 abort ();
95 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (XMARKER (tail)->bytepos))) 93 if (multibyte && ! CHAR_HEAD_P (FETCH_BYTE (tail->bytepos)))
96 abort (); 94 abort ();
97
98 tail = XMARKER (tail)->chain;
99 } 95 }
100} 96}
101 97
@@ -350,11 +346,8 @@ adjust_markers_for_delete (from, from_byte, to, to_byte)
350 register struct Lisp_Marker *m; 346 register struct Lisp_Marker *m;
351 register int charpos; 347 register int charpos;
352 348
353 marker = BUF_MARKERS (current_buffer); 349 for (m = BUF_MARKERS (current_buffer); m; m = m->next)
354
355 while (!NILP (marker))
356 { 350 {
357 m = XMARKER (marker);
358 charpos = m->charpos; 351 charpos = m->charpos;
359 352
360 if (charpos > Z) 353 if (charpos > Z)
@@ -371,16 +364,19 @@ adjust_markers_for_delete (from, from_byte, to, to_byte)
371 else if (charpos > from) 364 else if (charpos > from)
372 { 365 {
373 if (! m->insertion_type) 366 if (! m->insertion_type)
374 /* Normal markers will end up at the beginning of the 367 { /* Normal markers will end up at the beginning of the
375 re-inserted text after undoing a deletion, and must be 368 re-inserted text after undoing a deletion, and must be
376 adjusted to move them to the correct place. */ 369 adjusted to move them to the correct place. */
370 XSETMISC (marker, m);
377 record_marker_adjustment (marker, from - charpos); 371 record_marker_adjustment (marker, from - charpos);
372 }
378 else if (charpos < to) 373 else if (charpos < to)
379 /* Before-insertion markers will automatically move forward 374 { /* Before-insertion markers will automatically move forward
380 upon re-inserting the deleted text, so we have to arrange 375 upon re-inserting the deleted text, so we have to arrange
381 for them to move backward to the correct position. */ 376 for them to move backward to the correct position. */
377 XSETMISC (marker, m);
382 record_marker_adjustment (marker, charpos - to); 378 record_marker_adjustment (marker, charpos - to);
383 379 }
384 m->charpos = from; 380 m->charpos = from;
385 m->bytepos = from_byte; 381 m->bytepos = from_byte;
386 } 382 }
@@ -392,10 +388,9 @@ adjust_markers_for_delete (from, from_byte, to, to_byte)
392 incorrectly make MARKER move forward, so we arrange for it 388 incorrectly make MARKER move forward, so we arrange for it
393 to then move backward to the correct place at the beginning 389 to then move backward to the correct place at the beginning
394 of the deleted region. */ 390 of the deleted region. */
391 XSETMISC (marker, m);
395 record_marker_adjustment (marker, to - from); 392 record_marker_adjustment (marker, to - from);
396 } 393 }
397
398 marker = m->chain;
399 } 394 }
400} 395}
401 396
@@ -413,17 +408,13 @@ adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers)
413 register int from, from_byte, to, to_byte; 408 register int from, from_byte, to, to_byte;
414 int before_markers; 409 int before_markers;
415{ 410{
416 Lisp_Object marker; 411 struct Lisp_Marker *m;
417 int adjusted = 0; 412 int adjusted = 0;
418 int nchars = to - from; 413 int nchars = to - from;
419 int nbytes = to_byte - from_byte; 414 int nbytes = to_byte - from_byte;
420 415
421 marker = BUF_MARKERS (current_buffer); 416 for (m = BUF_MARKERS (current_buffer); m; m = m->next)
422
423 while (!NILP (marker))
424 { 417 {
425 register struct Lisp_Marker *m = XMARKER (marker);
426
427 /* In a single-byte buffer, a marker's two positions must be 418 /* In a single-byte buffer, a marker's two positions must be
428 equal. */ 419 equal. */
429 if (Z == Z_BYTE) 420 if (Z == Z_BYTE)
@@ -447,8 +438,6 @@ adjust_markers_for_insert (from, from_byte, to, to_byte, before_markers)
447 m->bytepos += nbytes; 438 m->bytepos += nbytes;
448 m->charpos += nchars; 439 m->charpos += nchars;
449 } 440 }
450
451 marker = m->chain;
452 } 441 }
453 442
454 /* Adjusting only markers whose insertion-type is t may result in 443 /* Adjusting only markers whose insertion-type is t may result in
@@ -490,15 +479,13 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
490 new_chars, new_bytes) 479 new_chars, new_bytes)
491 int from, from_byte, old_chars, old_bytes, new_chars, new_bytes; 480 int from, from_byte, old_chars, old_bytes, new_chars, new_bytes;
492{ 481{
493 Lisp_Object marker = BUF_MARKERS (current_buffer); 482 register struct Lisp_Marker *m;
494 int prev_to_byte = from_byte + old_bytes; 483 int prev_to_byte = from_byte + old_bytes;
495 int diff_chars = new_chars - old_chars; 484 int diff_chars = new_chars - old_chars;
496 int diff_bytes = new_bytes - old_bytes; 485 int diff_bytes = new_bytes - old_bytes;
497 486
498 while (!NILP (marker)) 487 for (m = BUF_MARKERS (current_buffer); m; m = m->next)
499 { 488 {
500 register struct Lisp_Marker *m = XMARKER (marker);
501
502 if (m->bytepos >= prev_to_byte) 489 if (m->bytepos >= prev_to_byte)
503 { 490 {
504 m->charpos += diff_chars; 491 m->charpos += diff_chars;
@@ -509,8 +496,6 @@ adjust_markers_for_replace (from, from_byte, old_chars, old_bytes,
509 m->charpos = from; 496 m->charpos = from;
510 m->bytepos = from_byte; 497 m->bytepos = from_byte;
511 } 498 }
512
513 marker = m->chain;
514 } 499 }
515 500
516 CHECK_MARKERS (); 501 CHECK_MARKERS ();
@@ -1930,7 +1915,7 @@ prepare_to_modify_buffer (start, end, preserve_ptr)
1930 GCPRO1 (preserve_marker); 1915 GCPRO1 (preserve_marker);
1931 verify_interval_modification (current_buffer, start, end); 1916 verify_interval_modification (current_buffer, start, end);
1932 *preserve_ptr = marker_position (preserve_marker); 1917 *preserve_ptr = marker_position (preserve_marker);
1933 unchain_marker (preserve_marker); 1918 unchain_marker (XMARKER (preserve_marker));
1934 UNGCPRO; 1919 UNGCPRO;
1935 } 1920 }
1936 else 1921 else
@@ -1978,7 +1963,7 @@ prepare_to_modify_buffer (start, end, preserve_ptr)
1978 if (! NILP (preserve_marker)) \ 1963 if (! NILP (preserve_marker)) \
1979 { \ 1964 { \
1980 *preserve_ptr = marker_position (preserve_marker); \ 1965 *preserve_ptr = marker_position (preserve_marker); \
1981 unchain_marker (preserve_marker); \ 1966 unchain_marker (XMARKER (preserve_marker)); \
1982 } 1967 }
1983 1968
1984#define PRESERVE_START_END \ 1969#define PRESERVE_START_END \