[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#5747: 24.0.50; Unstable C-mode indentation
From: |
Alan Mackenzie |
Subject: |
bug#5747: 24.0.50; Unstable C-mode indentation |
Date: |
Mon, 22 Mar 2010 11:36:31 +0000 |
User-agent: |
Mutt/1.5.9i |
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 <acm@muc.de>
> 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).