]> git.eshelyaron.com Git - emacs.git/commitdiff
Centralize Bug#30931 fix
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Mar 2018 21:23:55 +0000 (14:23 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Mar 2018 21:26:26 +0000 (14:26 -0700)
* src/marker.c (detach_marker): New function.
* src/editfns.c (save_restriction_restore):
* src/insdel.c (signal_before_change): Use it.

src/editfns.c
src/insdel.c
src/lisp.h
src/marker.c

index 84de67927383bc0d3ce3873037a72a28b6211672..608304c09ad8b3b1899a7562e18beb022d035003 100644 (file)
@@ -3899,12 +3899,9 @@ save_restriction_restore (Lisp_Object data)
 
          buf->clip_changed = 1; /* Remember that the narrowing changed. */
        }
-      /* This isn’t needed anymore, so don’t wait for GC.  Do not call
-         free_marker on XCAR (data) or XCDR (data), though, since
-         record_marker_adjustments may have put them on the buffer’s
-         undo list (Bug#30931).  Just detach them instead.  */
-      Fset_marker (XCAR (data), Qnil, Qnil);
-      Fset_marker (XCDR (data), Qnil, Qnil);
+      /* Detach the markers, and free the cons instead of waiting for GC.  */
+      detach_marker (XCAR (data));
+      detach_marker (XCDR (data));
       free_cons (XCONS (data));
     }
   else
index 697395c507b3417e6c35e6fd9c618a25974f98df..173c2438347ebe598d7e8de88b798f8ef3c9a6db 100644 (file)
@@ -2148,13 +2148,10 @@ signal_before_change (ptrdiff_t start_int, ptrdiff_t end_int,
                                   FETCH_START, FETCH_END, Qnil);
     }
 
-  /* Detach the markers now that we're done with them.  Don't directly
-     free them, since the change functions could have caused them to
-     be inserted into the undo list (Bug#30931).  */
   if (! NILP (start_marker))
-    Fset_marker (start_marker, Qnil, Qnil);
+    detach_marker (start_marker);
   if (! NILP (end_marker))
-    Fset_marker (end_marker, Qnil, Qnil);
+    detach_marker (end_marker);
   RESTORE_VALUE;
 
   unbind_to (count, Qnil);
index f471b2165872cd913b62bd7c263b3c35bcd40019..c931d9c8f05d0f43750cbb7a42b8056f9580fdb9 100644 (file)
@@ -4104,7 +4104,8 @@ extern ptrdiff_t marker_byte_position (Lisp_Object);
 extern void clear_charpos_cache (struct buffer *);
 extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t);
 extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t);
-extern void unchain_marker (struct Lisp_Marker *marker);
+extern void detach_marker (Lisp_Object);
+extern void unchain_marker (struct Lisp_Marker *);
 extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
 extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t);
 extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
index 2a45ae636ed5823474b0cb07ec3552d97e65e9d0..2d5b05cc2b8e6a3c15a3fd3cc36a9a9ecfe2fd9b 100644 (file)
@@ -560,7 +560,7 @@ POSITION is nil, makes marker point nowhere so it no longer slows down
 editing in any buffer.  Returns MARKER.  */)
   (Lisp_Object marker, Lisp_Object position, Lisp_Object buffer)
 {
-  return set_marker_internal (marker, position, buffer, 0);
+  return set_marker_internal (marker, position, buffer, false);
 }
 
 /* Like the above, but won't let the position be outside the visible part.  */
@@ -569,7 +569,7 @@ Lisp_Object
 set_marker_restricted (Lisp_Object marker, Lisp_Object position,
                       Lisp_Object buffer)
 {
-  return set_marker_internal (marker, position, buffer, 1);
+  return set_marker_internal (marker, position, buffer, true);
 }
 
 /* Set the position of MARKER, specifying both the
@@ -616,6 +616,15 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer,
   return marker;
 }
 
+/* Detach a marker so that it no longer points anywhere and no longer
+   slows down editing.  Do not free the marker, though, as a change
+   function could have inserted it into an undo list (Bug#30931).  */
+void
+detach_marker (Lisp_Object marker)
+{
+  Fset_marker (marker, Qnil, Qnil);
+}
+
 /* Remove MARKER from the chain of whatever buffer it is in,
    leaving it points to nowhere.  This is called during garbage
    collection, so we must be careful to ignore and preserve