From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#16526: 24.3.50; scroll-conservatively & c-mode regression Date: Sun, 26 Jan 2014 20:43:10 +0000 Message-ID: <20140126204310.GA3937@acm.acm> References: <838uu4cq11.fsf@gnu.org> <52E3D131.2090705@gmx.at> <83r47wausm.fsf@gnu.org> <52E3EAC2.2040100@gmx.at> <83lhy4as2l.fsf@gnu.org> <52E4019C.5080905@gmx.at> <83k3dnc3rl.fsf@gnu.org> <83iot7c3bq.fsf@gnu.org> <52E4EF61.3050404@gmx.at> <831tzubqxw.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1390769242 27070 80.91.229.3 (26 Jan 2014 20:47:22 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 26 Jan 2014 20:47:22 +0000 (UTC) Cc: 16526@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 26 21:47:28 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1W7Wc3-000326-Mj for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 21:47:27 +0100 Original-Received: from localhost ([::1]:56287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7Wc3-0001E2-BX for geb-bug-gnu-emacs@m.gmane.org; Sun, 26 Jan 2014 15:47:27 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7Wbt-0001Dk-GC for bug-gnu-emacs@gnu.org; Sun, 26 Jan 2014 15:47:24 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W7Wbm-0005lH-5J for bug-gnu-emacs@gnu.org; Sun, 26 Jan 2014 15:47:17 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51166) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W7Wbe-0005ko-46; Sun, 26 Jan 2014 15:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1W7Wbd-0003Mw-Ki; Sun, 26 Jan 2014 15:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 26 Jan 2014 20:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16526 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 16526-submit@debbugs.gnu.org id=B16526.139076918612902 (code B ref 16526); Sun, 26 Jan 2014 20:47:01 +0000 Original-Received: (at 16526) by debbugs.gnu.org; 26 Jan 2014 20:46:26 +0000 Original-Received: from localhost ([127.0.0.1]:36952 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7Wb3-0003M1-VW for submit@debbugs.gnu.org; Sun, 26 Jan 2014 15:46:26 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:52112 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W7Wb1-0003Ls-Ex for 16526@debbugs.gnu.org; Sun, 26 Jan 2014 15:46:24 -0500 Original-Received: (qmail 57663 invoked by uid 3782); 26 Jan 2014 20:46:21 -0000 Original-Received: from acm.muc.de (pD951B5E9.dip0.t-ipconnect.de [217.81.181.233]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 26 Jan 2014 21:46:20 +0100 Original-Received: (qmail 3987 invoked by uid 1000); 26 Jan 2014 20:43:10 -0000 Content-Disposition: inline In-Reply-To: <831tzubqxw.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:84063 Archived-At: Hi, Eli. On Sun, Jan 26, 2014 at 07:20:27PM +0200, Eli Zaretskii wrote: > You are right, sorry. (I wasn't wrong, either: recenter does call the > same find_defun_start around EOB, which is what I saw. But those > calls are very few and aren't responsible for the slowdown. I also > wasn't wrong about point being at EOB, see below. But I described > what happens incorrectly.) > Here's what I see in the debugger: > After beginning-of-buffer jumps to point-min, redisplay kicks in. > Since scroll-conservatively is set to a large value, redisplay first > tries to see whether it can bring point into view by scrolling the > window as little as possible. It calls try_scrolling, which at some > point (around line 15000) tries to see whether the new location of > point is close enough to the current window start. It does so by > calling move_it_to, which simulates the display. While doing so, > move_it_to hits a portion of text with font-lock properties, and calls > JIT Lock to fontify them. > And here's where things go awry: For some reason, the CC Mode > fontification code decides it needs to scan the buffer backwards, > starting from EOB. The @dfn{state cache}, a list of certain brace/paren/bracket positions around some position, is set for a position near EOB. With the switch to a different position, CC Mode tweaks the state cache rather than calculating it anew starting at BOB. When the new position is nearer BOB, the code searches backwards for the appropriate braces. However, it shouldn't be scanning the entire buffer backwards. There is clearly a bug here. > So it goes temporarily to EOB (this is why I saw point being there), > and scans all the way back, I think in this loop from > c-append-lower-brace-pair-to-state-cache, which is called with its > first argument FROM set to EOB: > ;; In the next pair of nested loops, the inner one moves back past a > ;; pair of (mis-)matching parens or brackets; the outer one moves > ;; back over a sequence of unmatched close brace/paren/bracket each > ;; time round. > (while > (progn > (c-safe > (while > (and (setq ce (scan-lists bra -1 -1)) ; back past )/]/}; might signal > (setq bra (scan-lists ce -1 1)) ; back past (/[/{; might signal > (or (> bra here) ;(> ce here) > (and > (< ce here) > (or (not (eq (char-after bra) ?\{)) > (and (goto-char bra) > (c-beginning-of-macro) > (< (point) macro-start-or-from)))))))) > (and ce (< ce bra))) > (setq bra ce)) ; If we just backed over an unbalanced closing > ; brace, ignore it. The backward scan-lists calls will be causing continual forward searches from BOB in syntax.c, every time the backward scan hits a comment ender. > This loop takes a lot of time, of course, and is a waste of time, > since eventually try_scrolling comes to the correct conclusion that > scrolling is impossible, and instead recenters at BOB. > Why does CC Mode decide to go from EOB backwards, I don't know; > presumably, this is decided by c-parse-state-get-strategy as part of > c-parse-state-1. Yes. There is a bug here. I have a strong suspicion where. [ .... ] > I hope this information will allow Alan to find the culprit and solve > the problem. Yes indeed, thanks. But I'm not going to be able to resolve it in a scale of hours. It's going to be days. Sorry! -- Alan Mackenzie (Nuremberg, Germany).