From xemacs-m  Sun Feb  9 20:40:05 1997
Received: from crystal.WonderWorks.COM (crystal.WonderWorks.com [192.203.206.1])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id UAA26228
	for <xemacs-beta@xemacs.org>; Sun, 9 Feb 1997 20:39:56 -0600 (CST)
Received: by crystal.WonderWorks.COM 
	id QQccfq10731; Sun, 9 Feb 1997 21:39:46 -0500 (EST)
Date: Sun, 9 Feb 1997 21:39:46 -0500 (EST)
Message-Id: <QQccfq10731.199702100239@crystal.WonderWorks.COM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Kyle Jones <kyle_jones@wonderworks.com>
To: xemacs-beta@xemacs.org
Subject: 19.15b92: dubious code in `undo'

This code from lisp/simple.el in the `undo' function looks wrong:

    ;; Don't specify a position in the undo record for the undo command.
    ;; Instead, undoing this should move point to where the change is.
    (let ((tail buffer-undo-list)
	  done)
      (while (and tail (not done) (not (null (car tail))))
	(if (integerp (car tail))
	    (progn
	      (setq done t)
	      (setq buffer-undo-list (delq (car tail) buffer-undo-list))))
	(setq tail (cdr tail))))

The delq call will traverse the whole undo list and remove all
position references matching (car tail).  I don't think the code
ought to go past the first undo boundary that it encounters.

This code looks more like what is required.  It is what I do in
the `redo' package I sent out earlier.

    (let ((list buffer-undo-list)
    	  (prev nil))
      (while (and list (not (null (car list))))
    	(if (integerp (car list))
    	    (if prev
    		(setcdr prev (cdr list))
    	      ;; impossible now, but maybe not in the future 
    	      (setq buffer-undo-list (cdr list))))
    	(setq prev list
    	      list (cdr list))))

