GNU bug report logs -
#5747
24.0.50; Unstable C-mode indentation
Previous Next
Reported by: Ari Roponen <ari.roponen <at> gmail.com>
Date: Sun, 21 Mar 2010 13:31:02 UTC
Severity: normal
Merged with 5741
Done: Chong Yidong <cyd <at> stupidchicken.com>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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 <at> muc.de-20091203160210-5u4g9gppsv3zts3e
> committer: Alan Mackenzie <acm <at> 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).
This bug report was last modified 15 years and 117 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.