GNU bug report logs - #731
23.0.60; Varying point position after undo

Previous Next

Package: emacs;

Reported by: Markus Triska <markus.triska <at> gmx.at>

Date: Sat, 16 Aug 2008 17:05:07 UTC

Severity: normal

Done: martin rudalics <rudalics <at> gmx.at>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 731 in the body.
You can then email your comments to 731 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.60; Varying point position after undo
Date: Sat, 16 Aug 2008 18:59:05 +0200 (CEST)
When you put the following two forms in undo1.el:

   (progn
     (goto-char (point-max))
     (insert "test line\n"))

   (defun mytest ()
     (message "hi"))

then do "$ emacs -Q undo1.el", place point after the first form, press
C-x C-e then C-_, point is placed at the original end of buffer. In
contrast, every further time you do the same, point is placed at the
end of the second form after the insertion is undone. When you then
switch to the *scratch* buffer and then switch back and do the same,
point is again placed at the original end of the buffer exactly the
first time you do it, and placed at the other spot every further time.

I find it desirable that point position after undo become more
predictable in this case. I have also seen cases where point after
undo is completely misplaced (i.e., neither at the place where point
originally was, nor where the inserted text started), though I cannot
yet reproduce it reliably.

In GNU Emacs 23.0.60.1 (i386-apple-darwin8.11.1, GTK+ Version 2.12.9)
 of 2008-08-15 on mt-computer.local
Windowing system distributor `The XFree86 Project, Inc', version 11.0.40400000
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to cyd <at> MIT.EDU:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #10 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: cyd <at> MIT.EDU
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org
Subject: Re: 23.0.60; Varying point position after undo
Date: Thu, 18 Sep 2008 23:26:37 -0400
> When you put the following two forms in undo1.el:
>
>   (progn
>     (goto-char (point-max))
>     (insert "test line\n"))
>
>   (defun mytest ()
>     (message "hi"))
>
> then do "$ emacs -Q undo1.el", place point after the first form, press
> C-x C-e then C-_, point is placed at the original end of buffer. In
> contrast, every further time you do the same, point is placed at the
> end of the second form after the insertion is undone.

I can't reproduce this with latest CVS.  Do you still see this problem?




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #15 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: cyd <at> MIT.EDU
Cc: 731 <at> debbugs.gnu.org
Subject: Re: 23.0.60; Varying point position after undo
Date: Fri, 19 Sep 2008 06:31:47 +0200
cyd <at> MIT.EDU writes:

> Do you still see this problem?

Yes; it also works if I place point anywhere within the first top-level
form and then press C-M-x, followed by C-_. The first time I do that,
point is moved to the original end of buffer, i.e., after the second
form. Every further time, point isn't moved, until I visit a different
buffer. I can reproduce this with today's Emacs 23 CVS on OSX 10.4 and
Ubuntu Intrepid. Emacs 22.2 never moves point on both systems.

undo1.el is also available from: http://www.logic.at/prolog/undo1.el

As mentioned, the file must be specified on the command line - opening
it with C-x C-f and then doing the above does not move point. However,
you can open undo1.el with C-x C-f, then do C-x b, switch to *scratch*,
then return to undo1.el. If you then do C-M-x C-_, point should move.




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #20 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Markus Triska <markus.triska <at> gmx.at>, 731 <at> debbugs.gnu.org
Cc: cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Fri, 19 Sep 2008 10:42:44 +0200
> As mentioned, the file must be specified on the command line - opening
> it with C-x C-f and then doing the above does not move point. However,
> you can open undo1.el with C-x C-f, then do C-x b, switch to *scratch*,
> then return to undo1.el. If you then do C-M-x C-_, point should move.

So the initial values of `buffer-undo-list' differ wrt when you open the
file via the command line or `find-file'.  Can you tell us how?

martin




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #25 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org, cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Fri, 19 Sep 2008 15:23:24 +0200
martin rudalics <rudalics <at> gmx.at> writes:

> So the initial values of `buffer-undo-list' differ wrt when you open the
> file via the command line or `find-file'.  Can you tell us how?

buffer-undo-list is initially nil regardless of how I open the file.
When I open the file from the command line and then press C-M-x on the
first form, `buffer-undo-list' is with CVS trunk:

   (nil
    (96 . 106)
    (t 18643 . 10108))

whereas with Emacs 22.2, it is:

   (nil
    (96 . 106)
    1
    (t 18643 . 10108))

Starting anew with CVS trunk, after I do C-M-x C-_ M-< C-M-x, it is:

   (nil
    (96 . 106)
    1
    (t 18643 . 10108)
    nil
    (#("test line\n" 0 10
       (fontified t))
     . 96)
    nil
    (96 . 106)
    (t 18643 . 10108))

When I do the same with Emacs 22.2, it is:

   (nil
    (96 . 106)
    1
    (t 18643 . 10108)
    nil
    (#("test line\n" 0 10
       (fontified t))
     . 96)
    nil
    (96 . 106)
    1
    (t 18643 . 10108))

With CVS trunk, when I open the file with C-x C-f and do C-M-x, it is:

   (nil
    (96 . 106)
    1
    (t 18643 . 10108))





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #30 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Markus Triska <markus.triska <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org, cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Sun, 21 Sep 2008 13:58:37 +0200
[Message part 1 (text/plain, inline)]
> buffer-undo-list is initially nil regardless of how I open the file.
> When I open the file from the command line and then press C-M-x on the
> first form, `buffer-undo-list' is with CVS trunk:
>
>    (nil
>     (96 . 106)
>     (t 18643 . 10108))
>
> whereas with Emacs 22.2, it is:
>
>    (nil
>     (96 . 106)
>     1
>     (t 18643 . 10108))

Hmmm...  Can you try the attached patch?

martin
[731.diff (text/plain, inline)]
*** undo.c.~1.85.~	2008-05-14 09:49:54.000000000 +0200
--- undo.c	2008-09-21 13:44:44.468750000 +0200
***************
*** 79,85 ****
    if (NILP (pending_boundary))
      pending_boundary = Fcons (Qnil, Qnil);
  
!   if (current_buffer != last_undo_buffer)
      Fundo_boundary ();
    last_undo_buffer = current_buffer;
  
--- 79,88 ----
    if (NILP (pending_boundary))
      pending_boundary = Fcons (Qnil, Qnil);
  
!   if ((current_buffer != last_undo_buffer)
!       /* Don't make an undo boundary when record_first_change will do it
! 	 anyway.  */
!       && (MODIFF > SAVE_MODIFF))
      Fundo_boundary ();
    last_undo_buffer = current_buffer;
  

Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Markus Triska <markus.triska <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #35 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Markus Triska <markus.triska <at> gmx.at>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org, cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Sun, 21 Sep 2008 14:31:35 +0200
martin rudalics <rudalics <at> gmx.at> writes:

> Hmmm...  Can you try the attached patch?

It fixes this problem for me, thank you!





Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #40 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org, Markus Triska <markus.triska <at> gmx.at>,
        cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Sun, 21 Sep 2008 15:30:04 -0400
> !   if ((current_buffer != last_undo_buffer)
> !       /* Don't make an undo boundary when record_first_change will do it
> ! 	 anyway.  */
> !       && (MODIFF > SAVE_MODIFF))

Hmm.. the comment seems to say that calling it is just redundant,
whereas this thread shows that it can actually be harmful.
Could you improve the comment so as to explain why it's harmful?


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to Stefan Monnier <monnier <at> IRO.UMontreal.CA>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #45 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 731 <at> debbugs.gnu.org, Markus Triska <markus.triska <at> gmx.at>,
        cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Mon, 22 Sep 2008 13:40:40 -0400
> I checked it in with a slightly more accurate comment.  IMHO, however,

Thank you.

> last_boundary_buffer and last_boundary_position should be documented
> better.  In particular, I don't understand the comment near the end of
> record_point saying

>   /* If we are just after an undo boundary, and
>      point wasn't at start of deleted range, record where it was.  */

> BTW, why isn't there a separate last_boundary_position for each buffer?

Maybe Richard knows a bit more, but I suspect, nobody knows.


        Stefan




Information forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#731; Package emacs. Full text and rfc822 format available.

Acknowledgement sent to martin rudalics <rudalics <at> gmx.at>:
Extra info received and forwarded to list. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. Full text and rfc822 format available.

Message #50 received at 731 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 731 <at> debbugs.gnu.org, Markus Triska <markus.triska <at> gmx.at>,
        cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Mon, 22 Sep 2008 17:59:14 +0200
> Hmm.. the comment seems to say that calling it is just redundant,
> whereas this thread shows that it can actually be harmful.
> Could you improve the comment so as to explain why it's harmful?

I checked it in with a slightly more accurate comment.  IMHO, however,
last_boundary_buffer and last_boundary_position should be documented
better.  In particular, I don't understand the comment near the end of
record_point saying

  /* If we are just after an undo boundary, and
     point wasn't at start of deleted range, record where it was.  */

BTW, why isn't there a separate last_boundary_position for each buffer?

martin




Reply sent to martin rudalics <rudalics <at> gmx.at>:
You have taken responsibility. Full text and rfc822 format available.

Notification sent to Markus Triska <markus.triska <at> gmx.at>:
bug acknowledged by developer. Full text and rfc822 format available.

Message #55 received at 731-done <at> emacsbugs.donarmstrong.com (full text, mbox):

From: martin rudalics <rudalics <at> gmx.at>
To: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Cc: 731-done <at> debbugs.gnu.org, Markus Triska <markus.triska <at> gmx.at>,
        cyd <at> MIT.EDU
Subject: Re: bug#731: 23.0.60; Varying point position after undo
Date: Tue, 23 Sep 2008 08:33:31 +0200
Fixed as

2008-09-22  Martin Rudalics  <rudalics <at> gmx.at>

	* undo.c (record_point): Don't call Fundo_boundary for first
	change.  (Bug#731)

martin




bug archived. Request was from Debbugs Internal Request <don <at> donarmstrong.com> to internal_control <at> emacsbugs.donarmstrong.com. (Tue, 21 Oct 2008 14:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 16 years and 323 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.