all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#5747: 24.0.50; Unstable C-mode indentation
@ 2010-03-21 12:48 Ari Roponen
  2010-03-22 11:36 ` Alan Mackenzie
  0 siblings, 1 reply; 3+ messages in thread
From: Ari Roponen @ 2010-03-21 12:48 UTC (permalink / raw)
  To: 5747

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.


In GNU Emacs 24.0.50.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.19.7)
 of 2010-03-18 on arirop
Windowing system distributor `Fedora Project', version 11.0.10799901

-- 
Ari Roponen







^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#5747: 24.0.50; Unstable C-mode indentation
  2010-03-21 12:48 bug#5747: 24.0.50; Unstable C-mode indentation Ari Roponen
@ 2010-03-22 11:36 ` Alan Mackenzie
  2010-03-22 12:03   ` Ari Roponen
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Mackenzie @ 2010-03-22 11:36 UTC (permalink / raw)
  To: Ari Roponen; +Cc: Paul Pogonyshev, Chong Yidong, 5747

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).






^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#5747: 24.0.50; Unstable C-mode indentation
  2010-03-22 11:36 ` Alan Mackenzie
@ 2010-03-22 12:03   ` Ari Roponen
  0 siblings, 0 replies; 3+ messages in thread
From: Ari Roponen @ 2010-03-22 12:03 UTC (permalink / raw)
  To: Alan Mackenzie; +Cc: Paul, 5747, Chong Yidong, Pogonyshev


Hi,

> Would you please (all) try the following patch, which I'm hopeful will
> fix all the recent instabilities in CC Modes indentation.
>

this patch fixes the problem I reported. Thank you.

>
> *** 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






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-03-22 12:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-21 12:48 bug#5747: 24.0.50; Unstable C-mode indentation Ari Roponen
2010-03-22 11:36 ` Alan Mackenzie
2010-03-22 12:03   ` Ari Roponen

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.