Commits

Aidan Kehoe committed b94d6e8

Correct a couple of small things with my last change.

src/ChangeLog addition:

2014-06-18 Aidan Kehoe <kehoea@parhasard.net>

Correct a couple of things in my last change.
* extents.h:
Make #'delete-extent available.
* window.c:
* window.c (delete_saved_point): New.
* window.c (Fdelete_window): Delete the saved point extents on
deletion of the window, since otherwise they will only be
garbage-collected when the buffer is.
* window.c (Fset_window_buffer): Correct a thinko here, use a
saved point when it *hasn't* been detached.

Comments (0)

Files changed (3)

+2014-06-18  Aidan Kehoe  <kehoea@parhasard.net>
+
+	Correct a couple of things in my last change.
+	* extents.h:
+	Make #'delete-extent available.
+	* window.c:
+	* window.c (delete_saved_point): New.
+	* window.c (Fdelete_window): Delete the saved point extents on
+	deletion of the window, since otherwise they will only be
+	garbage-collected when the buffer is.
+	* window.c (Fset_window_buffer): Correct a thinko here, use a
+	saved point when it *hasn't* been detached.
+
 2014-06-17  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* extents.h:
 EXFUN (Fput_text_property, 5);
 
 EXFUN (Fextent_detached_p, 1);
+EXFUN (Fdelete_extent, 1);
 EXFUN (Fdetach_extent, 1);
 EXFUN (Fextent_end_position, 1);
 EXFUN (Fextent_object, 1);
     return 0;
 }
 
+static int
+delete_saved_point (Lisp_Object UNUSED (buffer), Lisp_Object saved_point,
+                    void *UNUSED (closure))
+{
+  Fdelete_extent (saved_point);
+  return 0;
+}
+
 DEFUN ("delete-window", Fdelete_window, 0, 2, "", /*
 Remove WINDOW from the display.  Default is selected window.
 If window is the only one on its frame, the frame is deleted as well.
       w->buffer = Qnil;
     }
 
+  /* Delete the saved point extents, since they will still be referenced
+     from the buffer and thus won't be garbage-collected until the buffer
+     is. */
+  elisp_maphash_unsafe (delete_saved_point, w->saved_point_cache, NULL);
+
   /* close up the hole in the sibling list */
   if (!NILP (w->next))
     XWINDOW (w->next)->prev = w->prev;
   {
     Lisp_Object saved_point = Fgethash (buffer, w->saved_point_cache, Qnil);
     Lisp_Object newpoint =
-      (EXTENTP (saved_point) && !NILP (Fextent_detached_p (saved_point)))
+      (EXTENTP (saved_point) && NILP (Fextent_detached_p (saved_point)))
       ? Fextent_start_position (saved_point)
       : make_fixnum (BUF_PT (XBUFFER (buffer)));
     Lisp_Object marker;