Subject: bug#4803 closed by Stefan Monnier <[email-masked]> (Re: Undo fails to restore marker position correctly)

From: [email-masked] (Emacs bug Tracking System)
Date: Tue, 24 Nov 2009 21:40:05 +0000

This is an automatic notification regarding your bug report
which was filed against the emacs package:

#4803: Undo fails to restore marker position correctly

It has been closed by Stefan Monnier <[email-masked]>.

Their explanation is attached below along with your original report.
If this explanation is unsatisfactory and you have not received a
better one in a separate message then please contact Stefan Monnier <[email-masked]> by
replying to this email.

-- 
4803: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=4803
Emacs Bug Tracking System
Contact [email-masked] with problems

Subject: Re: Undo fails to restore marker position correctly
From: Stefan Monnier <[email-masked]>
To: Toby Cubitt <[email-masked]>
Date: Tue, 24 Nov 2009 16:33:39 -0500

> (switch-to-buffer "*scratch*")  ; any buffer containing some text will do
> (setq mrk (make-marker))
> (move-marker mrk 5)             ; any position within text will do
> (set-marker-insertion-type mrk t)
> (delete-region 1 10)
> (undo)

> Marker mrk is now at position 15 in *scratch* instead of 5.

I've just installed the patch below should should fix it.
Thanks for catching it!

        Stefan

=== modified file 'src/insdel.c'
--- src/insdel.c	2009-11-24 15:30:54 +0000
+++ src/insdel.c	2009-11-24 21:28:22 +0000
@@ -377,7 +377,7 @@
 	       upon re-inserting the deleted text, so we have to arrange
 	       for them to move backward to the correct position.  */
 	      XSETMISC (marker, m);
-	    record_marker_adjustment (marker, charpos - to);
+	      record_marker_adjustment (marker, to - charpos);
 	    }
 	  m->charpos = from;
 	  m->bytepos = from_byte;

Subject: Undo fails to restore marker position correctly
From: Toby Cubitt <[email-masked]>
To: [email-masked]
Date: Sat, 24 Oct 2009 17:18:48 -0700

In GNU Emacs 23.1.50.1 (i686-pc-linux-gnu, GTK+ Version 2.16.6)
  of 2009-10-17

Steps to reproduce:
-------------------
(switch-to-buffer "*scratch*")  ; any buffer containing some text will do
(setq mrk (make-marker))
(move-marker mrk 5)             ; any position within text will do
(set-marker-insertion-type mrk t)
(delete-region 1 10)
(undo)

Marker mrk is now at position 15 in *scratch* instead of 5.

Toby
--
Dr T. S. Cubitt
Quantum Information Theory group
Department of Mathematics
University of Bristol
United Kingdom

email: [email-masked]
web: www.dr-qubit.org