]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix marker adjustment for undo (Bug#29118)
authorNoam Postavsky <npostavs@gmail.com>
Wed, 15 Nov 2017 12:03:23 +0000 (07:03 -0500)
committerNoam Postavsky <npostavs@gmail.com>
Wed, 15 Nov 2017 12:05:35 +0000 (07:05 -0500)
* lisp/simple.el (primitive-undo): Compare marker against absolute
value of POS, because the sign of POS is irrelevant to markers.

lisp/simple.el

index 4db81071b589ec160d80bb47f94826b21ad951d3..65906c886931585ba0050667a5cdd6db08d35ef1 100644 (file)
@@ -2565,10 +2565,10 @@ Return what remains of the list."
              (setq did-apply t)))
           ;; Element (STRING . POS) means STRING was deleted.
           (`(,(and string (pred stringp)) . ,(and pos (pred integerp)))
-           (when (let ((apos (abs pos)))
-                   (or (< apos (point-min)) (> apos (point-max))))
-             (error "Changes to be undone are outside visible portion of buffer"))
-           (let (valid-marker-adjustments)
+           (let ((valid-marker-adjustments nil)
+                 (apos (abs pos)))
+             (when (or (< apos (point-min)) (> apos (point-max)))
+               (error "Changes to be undone are outside visible portion of buffer"))
              ;; Check that marker adjustments which were recorded
              ;; with the (STRING . POS) record are still valid, ie
              ;; the markers haven't moved.  We check their validity
@@ -2579,7 +2579,7 @@ Return what remains of the list."
                (let* ((marker-adj (pop list))
                       (m (car marker-adj)))
                  (and (eq (marker-buffer m) (current-buffer))
-                      (= pos m)
+                      (= apos m)
                       (push marker-adj valid-marker-adjustments))))
              ;; Insert string and adjust point
              (if (< pos 0)