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#5747: 24.0.50; Unstable C-mode indentation Date: Mon, 22 Mar 2010 11:36:31 +0000 Message-ID: <20100322113631.GA1741@muc.de> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1269258924 16606 80.91.229.12 (22 Mar 2010 11:55:24 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 22 Mar 2010 11:55:24 +0000 (UTC) Cc: Paul Pogonyshev , Chong Yidong , 5747@debbugs.gnu.org To: Ari Roponen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 22 12:55:20 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NtgE2-0004SD-Rf for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Mar 2010 12:55:19 +0100 Original-Received: from localhost ([127.0.0.1]:42214 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtgE2-0006su-Cv for geb-bug-gnu-emacs@m.gmane.org; Mon, 22 Mar 2010 07:55:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NtgDx-0006sa-Fy for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2010 07:55:13 -0400 Original-Received: from [140.186.70.92] (port=38634 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NtgDv-0006sK-Ov for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2010 07:55:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NtgDt-0001MW-Og for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2010 07:55:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45018) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NtgDt-0001MS-Ls for bug-gnu-emacs@gnu.org; Mon, 22 Mar 2010 07:55:09 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Ntfoc-0001Lv-7u; Mon, 22 Mar 2010 07:29:02 -0400 X-Loop: bug-gnu-emacs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 22 Mar 2010 11:29:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-GNU-PR-Message: followup 5747 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 5747-submit@debbugs.gnu.org id=B5747.12692573175193 (code B ref 5747); Mon, 22 Mar 2010 11:29:02 +0000 Original-Received: (at 5747) by debbugs.gnu.org; 22 Mar 2010 11:28:37 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NtfoC-0001Li-QU for submit@debbugs.gnu.org; Mon, 22 Mar 2010 07:28:37 -0400 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NtfoB-0001Ld-Ci for 5747@debbugs.gnu.org; Mon, 22 Mar 2010 07:28:36 -0400 Original-Received: (qmail 75343 invoked by uid 3782); 22 Mar 2010 11:28:29 -0000 Original-Received: from acm.muc.de (pD9E2385A.dip.t-dialin.net [217.226.56.90]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Mon, 22 Mar 2010 12:28:26 +0100 Original-Received: (qmail 1861 invoked by uid 1000); 22 Mar 2010 11:36:31 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 22 Mar 2010 07:29:02 -0400 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:35688 Archived-At: Hi, Ari and everybody else! On Sun, Mar 21, 2010 at 02:48:34PM +0200, Ari Roponen wrote: > Hi, the indentation of C-mode is not stable. Here is the recipe > to reproduce the problem: > 1. Eval this form in "emacs -Q": > (progn > (switch-to-buffer "tmp.c") > (erase-buffer) > (c-mode) > (insert "int fun (void)\n{\n int a = foo ();\n}") > (c-indent-line-or-region) > (backward-sexp) > (c-indent-line-or-region)) > 2. Now every time you press TAB-key the indentation of the > bracket alternates between two positions. > By bisecting the source (using the GIT-repo) I found that the > problem comes from: > acm@muc.de-20091203160210-5u4g9gppsv3zts3e > committer: Alan Mackenzie > timestamp: Thu 2009-12-03 16:02:10 +0000 > message: > Enhance `c-parse-state' to run efficiently in "brace desserts". > After reverting that the problem goes away. That is one absolutely tremendous bug report! Thank you very much indeed for it! With all the information you've given me, I was able to track down an off-by-one error very quickly. Would you please (all) try the following patch, which I'm hopeful will fix all the recent instabilities in CC Modes indentation. *** cc-engine.el~ 2010-03-22 11:15:40.248931952 +0000 --- cc-engine.el 2010-03-22 11:24:04.981200984 +0000 *************** *** 2624,2630 **** (< (point-max) c-state-old-cpp-end))) (point-max) (min (point-max) c-state-old-cpp-beg))) ! (while (and c-state-cache (> (c-state-cache-top-lparen) upper-lim)) (setq c-state-cache (cdr c-state-cache))) ;; If `upper-lim' is inside the last recorded brace pair, remove its ;; RBrace and indicate we'll need to search backwards for a previous --- 2624,2630 ---- (< (point-max) c-state-old-cpp-end))) (point-max) (min (point-max) c-state-old-cpp-beg))) ! (while (and c-state-cache (>= (c-state-cache-top-lparen) upper-lim)) (setq c-state-cache (cdr c-state-cache))) ;; If `upper-lim' is inside the last recorded brace pair, remove its ;; RBrace and indicate we'll need to search backwards for a previous > -- > Ari Roponen -- Alan Mackenzie (Nuremberg, Germany).