comparison src/insdel.c @ 32601:f9b498650e20

(adjust_markers_for_delete): Handle before-insertion markers correctly.
author Miles Bader <miles@gnu.org>
date Wed, 18 Oct 2000 06:19:58 +0000
parents 43566b0aec59
children 5bf4bcc0f936
comparison
equal deleted inserted replaced
32600:faadf96091b5 32601:f9b498650e20
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 Free Software Foundation, Inc. 2 Copyright (C) 1985, 86,93,94,95,97,98, 1999, 2000 Free Software Foundation, Inc.
3 3
4 This file is part of GNU Emacs. 4 This file is part of GNU Emacs.
5 5
6 GNU Emacs is free software; you can redistribute it and/or modify 6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
364 if (charpos > to) 364 if (charpos > to)
365 { 365 {
366 m->charpos -= to - from; 366 m->charpos -= to - from;
367 m->bytepos -= to_byte - from_byte; 367 m->bytepos -= to_byte - from_byte;
368 } 368 }
369
370 /* Here's the case where a marker is inside text being deleted. */ 369 /* Here's the case where a marker is inside text being deleted. */
371 else if (charpos > from) 370 else if (charpos > from)
372 { 371 {
373 record_marker_adjustment (marker, from - charpos); 372 if (! m->insertion_type)
373 /* Normal markers will end up at the beginning of the
374 re-inserted text after undoing a deletion, and must be
375 adjusted to move them to the correct place. */
376 record_marker_adjustment (marker, from - charpos);
377 else if (charpos < to)
378 /* Before-insertion markers will automatically move forward
379 upon re-inserting the deleted text, so we have to arrange
380 for them to move backward to the correct position. */
381 record_marker_adjustment (marker, charpos - to);
382
374 m->charpos = from; 383 m->charpos = from;
375 m->bytepos = from_byte; 384 m->bytepos = from_byte;
385 }
386 /* Here's the case where a before-insertion marker is immediately
387 before the deleted region. */
388 else if (charpos == from && m->insertion_type)
389 {
390 /* Undoing the change uses normal insertion, which will
391 incorrectly make MARKER move forward, so we arrange for it
392 to then move backward to the correct place at the beginning
393 of the deleted region. */
394 record_marker_adjustment (marker, to - from);
376 } 395 }
377 396
378 marker = m->chain; 397 marker = m->chain;
379 } 398 }
380 } 399 }