diff src/window.c @ 5798:b94d6e89ea5b

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.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 18 Jun 2014 09:26:54 +0100
parents a1808d52a34a
children
line wrap: on
line diff
--- a/src/window.c	Tue Jun 17 20:55:45 2014 +0100
+++ b/src/window.c	Wed Jun 18 09:26:54 2014 +0100
@@ -2206,6 +2206,14 @@
     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.
@@ -2319,6 +2327,11 @@
       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;
@@ -3725,7 +3738,7 @@
   {
     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;