From 03ab8921a811be962c0fc0b6879fb59e08e7952c Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Fri, 29 Apr 2011 21:03:00 +0300 Subject: [PATCH] Fix bug #7952 with vertical motion in Grep buffers. src/window.c (window_scroll_line_based): Use a marker instead of simple variables to record original value of point. --- src/ChangeLog | 3 +++ src/window.c | 20 ++++++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bb660036c1..f029daa684 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-04-29 Eli Zaretskii + * window.c (window_scroll_line_based): Use a marker instead of + simple variables to record original value of point. (Bug#7952) + * doprnt.c (doprnt): Fix the case where a multibyte sequence produced by %s or %c overflows available buffer space. (Bug#8545) diff --git a/src/window.c b/src/window.c index b56ed84bc6..4dbee41c5f 100644 --- a/src/window.c +++ b/src/window.c @@ -5076,7 +5076,12 @@ static void window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) { register struct window *w = XWINDOW (window); - register EMACS_INT opoint = PT, opoint_byte = PT_BYTE; + /* Fvertical_motion enters redisplay, which can trigger + fontification, which in turn can modify buffer text (e.g., if the + fontification functions replace escape sequences with faces, as + in `grep-mode-font-lock-keywords'). So we use a marker to record + the old point position, to prevent crashes in SET_PT_BOTH. */ + Lisp_Object opoint_marker = Fpoint_marker (); register EMACS_INT pos, pos_byte; register int ht = window_internal_height (w); register Lisp_Object tem; @@ -5126,7 +5131,8 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) pos = PT; pos_byte = PT_BYTE; bolp = Fbolp (); - SET_PT_BOTH (opoint, opoint_byte); + SET_PT_BOTH (marker_position (opoint_marker), + marker_byte_position (opoint_marker)); if (lose) { @@ -5177,8 +5183,9 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) else top_margin = pos; - if (top_margin <= opoint) - SET_PT_BOTH (opoint, opoint_byte); + if (top_margin <= marker_position (opoint_marker)) + SET_PT_BOTH (marker_position (opoint_marker), + marker_byte_position (opoint_marker)); else if (!NILP (Vscroll_preserve_screen_position)) { SET_PT_BOTH (pos, pos_byte); @@ -5200,8 +5207,9 @@ window_scroll_line_based (Lisp_Object window, int n, int whole, int noerror) else bottom_margin = PT + 1; - if (bottom_margin > opoint) - SET_PT_BOTH (opoint, opoint_byte); + if (bottom_margin > marker_position (opoint_marker)) + SET_PT_BOTH (marker_position (opoint_marker), + marker_byte_position (opoint_marker)); else { if (!NILP (Vscroll_preserve_screen_position)) -- 2.20.1