Commits

Aidan Kehoe  committed a1808d5

If the position of a window's cached point is deleted, use buffer point instead

src/ChangeLog addition:

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

* extents.h:
* window.c:
* window.c (unshow_buffer):
* window.c (Fset_window_buffer):
Use extents, rather than markers, for the window buffer point
cache, so that when the text containing that window buffer point
is deleted, the window display code uses the buffer's actual point
instead of the position that the marker had been moved to.
Fixes Michael Heinrich's problem of
http://mid.gmane.org/6zr42uxtf5.fsf@elektra.science-computing.de ,
introduced by Ben's patch of
https://bitbucket.org/xemacs/xemacs/commits/047d37eb70d70f43803 .

  • Participants
  • Parent commits acf1c26

Comments (0)

Files changed (3)

File src/ChangeLog

+2014-06-17  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* extents.h:
+	* window.c:
+	* window.c (unshow_buffer):
+	* window.c (Fset_window_buffer):
+	Use extents, rather than markers, for the window buffer point
+	cache, so that when the text containing that window buffer point
+	is deleted, the window display code uses the buffer's actual point
+	instead of the position that the marker had been moved to.
+	Fixes Michael Heinrich's problem of
+	http://mid.gmane.org/6zr42uxtf5.fsf@elektra.science-computing.de ,
+	introduced by Ben's patch of
+	https://bitbucket.org/xemacs/xemacs/commits/047d37eb70d70f43803 . 
+
 2014-05-08  Jerry James  <james@xemacs.org>
 
 	* print.c (struct debug_bindings): Add print_circle field.

File src/extents.h

 EXFUN (Fextent_property, 3);
 EXFUN (Fput_text_property, 5);
 
+EXFUN (Fextent_detached_p, 1);
 EXFUN (Fdetach_extent, 1);
 EXFUN (Fextent_end_position, 1);
 EXFUN (Fextent_object, 1);

File src/window.c

 #include "commands.h"
 #include "device-impl.h"
 #include "elhash.h"
+#include "extents.h"
 #include "faces.h"
 #include "frame-impl.h"
 #include "glyphs.h"
 		 BUF_ZV (b)));
 
   {
-    Lisp_Object marker = Fgethash (buf, w->saved_point_cache, Qnil);
+    Lisp_Object marker;
+    Lisp_Object saved_point = Fgethash (buf, w->saved_point_cache, Qnil);
     int selected = EQ (wrap_window (w), Fselected_window (Qnil));
 
-    if (NILP (marker))
+    if (NILP (saved_point))
       {
-	marker = Fmake_marker ();
-	Fputhash (buf, marker, w->saved_point_cache);
+	saved_point = Fmake_extent (Qnil, Qnil, buf);
+        Fset_extent_property (saved_point, Qstart_open, Qt);
+	Fputhash (buf, saved_point, w->saved_point_cache);
       }
-    Fset_marker (marker,
-		 selected ? make_fixnum (BUF_PT (b)) : w->pointm[CURRENT_DISP],
-		 buf);
+
+    if (selected)
+      {
+        set_extent_endpoints (XEXTENT (saved_point),
+                              BYTE_BUF_PT (b), BYTE_BUF_PT (b), buf);
+      }
+    else
+      {
+        set_extent_endpoints (XEXTENT (saved_point),
+                              byte_marker_position (w->pointm[CURRENT_DISP]),
+                              byte_marker_position (w->pointm[CURRENT_DISP]),
+                              buf);
+      }
 
     marker = Fgethash (buf, w->saved_last_window_start_cache, Qnil);
 
 			 buffer);
 #else
   {
-    Lisp_Object marker = Fgethash (buffer, w->saved_point_cache, Qnil);
+    Lisp_Object saved_point = Fgethash (buffer, w->saved_point_cache, Qnil);
     Lisp_Object newpoint =
-      !NILP (marker) ? make_fixnum (marker_position (marker)) :
-      make_fixnum (BUF_PT (XBUFFER (buffer)));
+      (EXTENTP (saved_point) && !NILP (Fextent_detached_p (saved_point)))
+      ? Fextent_start_position (saved_point)
+      : make_fixnum (BUF_PT (XBUFFER (buffer)));
+    Lisp_Object marker;
     /* Previously, we had in here set-window-point, which did one of the
        following two, but not both.  However, that could result in pointm
        being in a different buffer from the window's buffer!  Probably