GNU bug report logs - #5649
23.1.92; Indentation problems in C mode

Previous Next

Packages: emacs, cc-mode;

Reported by: mwd <at> md5i.com

Date: Thu, 25 Feb 2010 16:18:02 UTC

Severity: serious

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #21 received at 5649 <at> debbugs.gnu.org (full text, mbox):

From: Michael Welsh Duggan <mwd <at> cert.org>
To: Alan Mackenzie <acm <at> muc.de>
Cc: Chong Yidong <cyd <at> stupidchicken.com>,
	"5649 <at> debbugs.gnu.org" <5649 <at> debbugs.gnu.org>
Subject: Re: bug#5649: 23.1.92; Indentation problems in C mode
Date: Mon, 01 Mar 2010 10:17:00 -0500
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, Michael and Yidong
>
> On Fri, Feb 26, 2010 at 07:12:06PM -0500, Chong Yidong wrote:
>> Michael Welsh Duggan <mwd <at> cert.org> writes:
>
>> > I'm getting some screwy indentation behavior from C mode.  From a
>> > current bzr checkout/install of emacs, try the following recipe:
>
>> > emacs -Q foo.c                 | starts emacs on foo.c (included below)
>> > C-u 7 C-n                      | move down 7 lines
>> > TAB                            | indent, nothing changes (good)
>> > C-p C-p                        | move up 2 lines
>> > TAB C-n TAB C-n                | indent 2 lines, nothing changes (good)
>> > TAB                            | line unindents by 2 (bad)
>> > TAB                            | line re-indents (good, but strange)
>> > TAB                            | no change this time
>
>> Thanks.  This is a regression vs Emacs 23.1, so we should definitely fix
>> it before releasing Emacs 23.2.
>
>> I can reproduce the bug with the Emacs 23.0.90, so it's be around since
>> at lease 12-09 last year.  However, I haven't yet had the time to do a
>> proper bisect.
>
> I've just committed the folowing patch, which should fix the bug:

I'm afraid this causes a much more serious bug.  Recipe:

emacs -Q
Open a new C-mode file.  Then type the following:
#if FOO
#endif

int bar;

For me the following happens:  The #endif is not fontified.  The "int
bar" is not fontified.  The semicolon causes an error.  I have verified
that reverting the patch below goes back to the old behavior, so this
patch is what is causing the bug.


> === modified file 'lisp/progmodes/cc-engine.el'
> --- lisp/progmodes/cc-engine.el	2010-02-25 21:21:25 +0000
> +++ lisp/progmodes/cc-engine.el	2010-03-01 11:23:59 +0000
> @@ -2641,7 +2641,8 @@
>  	;; (car c-state-cache).  There can be no open parens/braces/brackets
>  	;; between `good-pos'/`good-pos-actual-macro-start' and (point-max),
>  	;; due to the interface spec to this function.
> -	(setq pos (if good-pos-actual-macro-end
> +	(setq pos (if (and good-pos-actual-macro-end
> +			   (> in-macro-start good-pos-actual-macro-start))
>  		      (1+ good-pos-actual-macro-end) ; get outside the macro as
>  					; marked by a `category' text property.
>  		    good-pos))
>
>
> Thanks for the clean and concise bug report!

-- 
Michael Welsh Duggan
(mwd <at> cert.org)




This bug report was last modified 15 years and 85 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.