From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: delete-overlay causes recentering Date: Sat, 14 Apr 2007 21:44:23 -0400 Message-ID: <87fy72v2bs.fsf@stupidchicken.com> References: <25771086.79401173867519911.JavaMail.www@wwinf4104> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: sea.gmane.org 1176601348 11407 80.91.229.12 (15 Apr 2007 01:42:28 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 15 Apr 2007 01:42:28 +0000 (UTC) Cc: emacs-devel@gnu.org To: Kim F. Storm Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Apr 15 03:42:22 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hctkz-0008Jw-CX for ged-emacs-devel@m.gmane.org; Sun, 15 Apr 2007 03:42:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HctpQ-0000IN-Ms for ged-emacs-devel@m.gmane.org; Sat, 14 Apr 2007 21:46:56 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HctpN-0000I8-Id for emacs-devel@gnu.org; Sat, 14 Apr 2007 21:46:53 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HctpM-0000Hc-1w for emacs-devel@gnu.org; Sat, 14 Apr 2007 21:46:52 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HctpL-0000HZ-S6 for emacs-devel@gnu.org; Sat, 14 Apr 2007 21:46:51 -0400 Original-Received: from cyd.mit.edu ([18.19.1.138]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Hctkt-0001Dd-L8 for emacs-devel@gnu.org; Sat, 14 Apr 2007 21:42:15 -0400 Original-Received: by cyd.mit.edu (Postfix, from userid 1000) id 845744E46F; Sat, 14 Apr 2007 21:44:23 -0400 (EDT) In-Reply-To: ("Johan =?utf-8?Q?Bockg=C3=A5rd=22's?= message of "Fri\, 13 Apr 2007 15\:22\:01 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.97 (gnu/linux) X-detected-kernel: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:69446 Archived-At: bojohan+news@dd.chalmers.se (Johan Bockg=C3=A5rd) writes: > Evaluate the code below. Then press f8, f9, f8, f9, ... > > (defvar ov nil) > > (defun foo () > (interactive) > (set-window-start (selected-window) 834) > (goto-char 1237) > (setq ov (make-overlay 1237 1242)) > (overlay-put ov 'face 'highlight)) > > (defun bar () > (interactive) > (delete-overlay ov)) > > (global-set-key [f8] 'foo) > (global-set-key [f9] 'bar) > > (progn > (switch-to-buffer "*foo*") > (dotimes (n 30) > (insert "Emacs is the extensible, customizable, " > "self-documenting real-time display editor. ")) > (goto-char (point-min)) > (insert " ")) > > delete-overlay causes a recentering. (Actually, so do mouse clicks in > this case.) The behavior arose from the following change: 2006-04-20 Kim F. Storm * xdisp.c (redisplay_window): Fix last change. * xdisp.c (redisplay_window): If current window start is not at the beginning of a line, select a new window start if buffer is modified and window start is in the modified region, but the first change is before window start. *** emacs/src/xdisp.c 2006/04/13 01:21:48 1.1086 --- emacs/src/xdisp.c 2006/04/20 08:46:56 1.1088 *************** *** 12689,12696 **** /* IT may overshoot PT if text at PT is invisible. */ else if (IT_CHARPOS (it) > PT && CHARPOS (startp) <=3D PT) w->force_start =3D Qt; -=20 -=20 } =20=20 /* Handle case where place to start displaying has been specified, --- 12689,12694 ---- *************** *** 12860,12865 **** --- 12858,12892 ---- || (XFASTINT (w->last_modified) >=3D MODIFF && XFASTINT (w->last_overlay_modified) >=3D OVERLAY_MODIFF))) { +=20 + /* If first window line is a continuation line, and window start + is inside the modified region, but the first change is before + current window start, we must select a new window start.*/ + if (NILP (w->start_at_line_beg)) + { + /* Make sure beg_unchanged and end_unchanged are up to date. + Do it only if buffer has really changed. This may or may + not have been done by try_window_id (see which) already. */ + if (MODIFF > SAVE_MODIFF + /* This seems to happen sometimes after saving a buffer. */ + || BEG_UNCHANGED + END_UNCHANGED > Z_BYTE) + { + if (GPT - BEG < BEG_UNCHANGED) + BEG_UNCHANGED =3D GPT - BEG; + if (Z - GPT < END_UNCHANGED) + END_UNCHANGED =3D Z - GPT; + } +=20 + if (CHARPOS (startp) > BEG + BEG_UNCHANGED + && CHARPOS (startp) <=3D Z - END_UNCHANGED) + { + /* There doesn't seems to be a simple way to find a new + window start that is near the old window start, so + we just recenter. */ + goto recenter; + } + } +=20 #if GLYPH_DEBUG debug_method_add (w, "same window start"); #endif