Mercurial > hg > xemacs-beta
comparison src/window.c @ 5797:a1808d52a34a
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 .
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Tue, 17 Jun 2014 20:55:45 +0100 |
parents | 3fde0e346ad7 |
children | b94d6e89ea5b |
comparison
equal
deleted
inserted
replaced
5796:acf1c26e3019 | 5797:a1808d52a34a |
---|---|
39 | 39 |
40 #include "buffer.h" | 40 #include "buffer.h" |
41 #include "commands.h" | 41 #include "commands.h" |
42 #include "device-impl.h" | 42 #include "device-impl.h" |
43 #include "elhash.h" | 43 #include "elhash.h" |
44 #include "extents.h" | |
44 #include "faces.h" | 45 #include "faces.h" |
45 #include "frame-impl.h" | 46 #include "frame-impl.h" |
46 #include "glyphs.h" | 47 #include "glyphs.h" |
47 #include "gutter.h" | 48 #include "gutter.h" |
48 #include "fontcolor.h" | 49 #include "fontcolor.h" |
2045 (BUF_BEGV (b), | 2046 (BUF_BEGV (b), |
2046 marker_position (w->pointm[CURRENT_DISP]), | 2047 marker_position (w->pointm[CURRENT_DISP]), |
2047 BUF_ZV (b))); | 2048 BUF_ZV (b))); |
2048 | 2049 |
2049 { | 2050 { |
2050 Lisp_Object marker = Fgethash (buf, w->saved_point_cache, Qnil); | 2051 Lisp_Object marker; |
2052 Lisp_Object saved_point = Fgethash (buf, w->saved_point_cache, Qnil); | |
2051 int selected = EQ (wrap_window (w), Fselected_window (Qnil)); | 2053 int selected = EQ (wrap_window (w), Fselected_window (Qnil)); |
2052 | 2054 |
2053 if (NILP (marker)) | 2055 if (NILP (saved_point)) |
2054 { | 2056 { |
2055 marker = Fmake_marker (); | 2057 saved_point = Fmake_extent (Qnil, Qnil, buf); |
2056 Fputhash (buf, marker, w->saved_point_cache); | 2058 Fset_extent_property (saved_point, Qstart_open, Qt); |
2059 Fputhash (buf, saved_point, w->saved_point_cache); | |
2057 } | 2060 } |
2058 Fset_marker (marker, | 2061 |
2059 selected ? make_fixnum (BUF_PT (b)) : w->pointm[CURRENT_DISP], | 2062 if (selected) |
2060 buf); | 2063 { |
2064 set_extent_endpoints (XEXTENT (saved_point), | |
2065 BYTE_BUF_PT (b), BYTE_BUF_PT (b), buf); | |
2066 } | |
2067 else | |
2068 { | |
2069 set_extent_endpoints (XEXTENT (saved_point), | |
2070 byte_marker_position (w->pointm[CURRENT_DISP]), | |
2071 byte_marker_position (w->pointm[CURRENT_DISP]), | |
2072 buf); | |
2073 } | |
2061 | 2074 |
2062 marker = Fgethash (buf, w->saved_last_window_start_cache, Qnil); | 2075 marker = Fgethash (buf, w->saved_last_window_start_cache, Qnil); |
2063 | 2076 |
2064 if (NILP (marker)) | 2077 if (NILP (marker)) |
2065 { | 2078 { |
3708 set_marker_restricted (w->start[CURRENT_DISP], | 3721 set_marker_restricted (w->start[CURRENT_DISP], |
3709 make_fixnum (XBUFFER (buffer)->last_window_start), | 3722 make_fixnum (XBUFFER (buffer)->last_window_start), |
3710 buffer); | 3723 buffer); |
3711 #else | 3724 #else |
3712 { | 3725 { |
3713 Lisp_Object marker = Fgethash (buffer, w->saved_point_cache, Qnil); | 3726 Lisp_Object saved_point = Fgethash (buffer, w->saved_point_cache, Qnil); |
3714 Lisp_Object newpoint = | 3727 Lisp_Object newpoint = |
3715 !NILP (marker) ? make_fixnum (marker_position (marker)) : | 3728 (EXTENTP (saved_point) && !NILP (Fextent_detached_p (saved_point))) |
3716 make_fixnum (BUF_PT (XBUFFER (buffer))); | 3729 ? Fextent_start_position (saved_point) |
3730 : make_fixnum (BUF_PT (XBUFFER (buffer))); | |
3731 Lisp_Object marker; | |
3717 /* Previously, we had in here set-window-point, which did one of the | 3732 /* Previously, we had in here set-window-point, which did one of the |
3718 following two, but not both. However, that could result in pointm | 3733 following two, but not both. However, that could result in pointm |
3719 being in a different buffer from the window's buffer! Probably | 3734 being in a different buffer from the window's buffer! Probably |
3720 not a travesty since it always occurred when the window was | 3735 not a travesty since it always occurred when the window was |
3721 selected, meaning its value of point was ignored in favor of the | 3736 selected, meaning its value of point was ignored in favor of the |