[Top][All Lists]

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

bug#17893: 24.4.50; (error "Marker does not point anywhere")

From: Charles A. Roelli
Subject: bug#17893: 24.4.50; (error "Marker does not point anywhere")
Date: Sun, 19 Nov 2017 20:31:06 +0100

> From: Stefan Monnier <address@hidden>
> Date: Tue, 14 Nov 2017 15:08:08 -0500
> > I was not careful to make sure that the mark-ring contains valid
> > markers, so it may be an error in my code.  On the other hand, looking
> > at the definition of `clone-buffer' (which my patch uses), I don't see
> > anything that would update the markers of the mark-ring in the newly
> > cloned buffer to point to the new buffer instead of the old one.
> > Maybe that is also a problem?
> Yup, sounds like we have a bug in clone-buffer, at least.
>         Stefan

Right-o, here's a fix with respect to the emacs-26 branch:

diff --git a/lisp/simple.el b/lisp/simple.el
index 7d47d0f..64b7bde 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -8518,6 +8518,15 @@ clone-buffer
                (error nil)))
+      ;; Update markers in the copied mark ring to refer to the new buffer.
+      (setq mark-ring
+            (mapcar (lambda (m)
+                      (let ((new-marker))
+                        (setq new-marker (copy-marker m))
+                        (move-marker new-marker new-marker (current-buffer))
+                        new-marker))
+                    mark-ring))
       ;; Run any hooks (typically set up by the major mode
       ;; for cloning to work properly).
       (run-hooks 'clone-buffer-hook))

It fixes the minimal recipe to reproduce this bug:

> 1. C-h i
> 2. Click/drag a few times in the *info* buffer to set some marks
> 3. M-n C-x o C-x k RET
> 4. Click in the remaining *info*<2> buffer:
>   set-transient-map PCH: (error "Marker does not point anywhere")

reply via email to

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