emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bug in undo-elt-crosses-region


From: Johan Bockgård
Subject: Bug in undo-elt-crosses-region
Date: Sun, 01 Oct 2006 19:16:39 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

$ emacs -Q

Insert 12
Insert yy between 1 and 2
Move to the beginning of the line
Delete four characters
Insert xxxx
Put point and mark around the two middle characters
That is
    1 2 <left> y y <home> <delete> <delete> <delete> <delete>
    x x x x <left> C-SPC <left> <left>

Now invoke selective undo, C-u C-/ (1).
Repeat (2).
Repeat (3).
Repeat => error.

The buffer contents are the nonsensical:

xxyxx      (1)
xx1yxx     (2)
xx1x       (3)

(The expected behavior is that undo stops at step (1) since the last
insertion crosses the edge of the undo region.)


The logic in undo-elt-crosses-region is wrong:

    (undo-elt-crosses-region '(2 . 7) 1 5) => nil


I believe that the

    (not (or (< (car FOO) end)
             (> (cdr FOO) start)))

tests should be

    (and (< (car FOO) end)
         (> (cdr FOO) start))

(Equivalently,

    (not (or (>= (car FOO) end)
             (<= (cdr FOO) start)))
)




*** simple.el   01 Oct 2006 18:07:42 +0200      1.830
--- simple.el   01 Oct 2006 19:08:06 +0200      
***************
*** 1648,1659 ****
        ((null (car undo-elt))
         ;; (nil PROPERTY VALUE BEG . END)
         (let ((tail (nthcdr 3 undo-elt)))
!          (not (or (< (car tail) end)
!                   (> (cdr tail) start)))))
        ((integerp (car undo-elt))
         ;; (BEGIN . END)
!        (not (or (< (car undo-elt) end)
!                 (> (cdr undo-elt) start))))))
  
  ;; Return the first affected buffer position and the delta for an undo element
  ;; delta is defined as the change in subsequent buffer positions if we *did*
--- 1648,1659 ----
        ((null (car undo-elt))
         ;; (nil PROPERTY VALUE BEG . END)
         (let ((tail (nthcdr 3 undo-elt)))
!          (and (< (car tail) end)
!               (> (cdr tail) start))))
        ((integerp (car undo-elt))
         ;; (BEGIN . END)
!        (and (< (car undo-elt) end)
!             (> (cdr undo-elt) start)))))
  
  ;; Return the first affected buffer position and the delta for an undo element
  ;; delta is defined as the change in subsequent buffer positions if we *did*


-- 
Johan Bockgård




reply via email to

[Prev in Thread] Current Thread [Next in Thread]