GNU bug report logs - #6688
23.2; Auto-fill broken in C/C++ modes.

Previous Next

Packages: emacs, cc-mode;

Reported by: Matthieu Moy <Matthieu.Moy <at> imag.fr>

Date: Wed, 21 Jul 2010 15:05:02 UTC

Severity: normal

Found in version 23.2

Done: Alan Mackenzie <acm <at> muc.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 6688 in the body.
You can then email your comments to 6688 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6688; Package emacs. (Wed, 21 Jul 2010 15:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Matthieu Moy <Matthieu.Moy <at> imag.fr>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 21 Jul 2010 15:05:02 GMT) Full text and rfc822 format available.

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

From: Matthieu Moy <Matthieu.Moy <at> imag.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.2; Auto-fill broken in C/C++ modes.
Date: Wed, 21 Jul 2010 15:33:07 +0200
Hi,

I've had problems with auto-fill-mode in C and C++ comments for a while,
I finally managed to find a small test-case: let this be a C program.

/*
  Test

*/
#include <foo>
#include <bar>

If I put my cursor on the blank line below "Test", activate
M-x auto-fill-mode RET (other than that, it's a plain "emacs -Q")
and type SPC, I get this:

/*
  Test
*include <foo>
#include <bar>

with my cursor in the middle of the "*include".

I can't reproduce on Emacs 22.

Thanks,



In GNU Emacs 23.2.1 (i686-pc-linux-gnu, GTK+ Version 2.12.12)
 of 2010-05-10 on thabor
Windowing system distributor `The X.Org Foundation', version 11.0.10402000
configured using `configure  '--prefix=/usr/local/soft/emacs23/23.2' 'LDFLAGS=-L/local/berthier/usr/lib -L/usr/lib' 'CPPFLAGS=-I/local/berthier/usr/include -I/usr/include ''

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  value of $XMODIFIERS: nil
  locale-coding-system: utf-8-unix
  default enable-multibyte-characters: t

Major mode: C/l

Minor modes in effect:
  tooltip-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t
  abbrev-mode: t

Recent input:
M-x a u t o - c i <tab> <backspace> <backspace> f i 
<tab> <return> C-n C-n SPC C-_ M-x r e p o r t <tab> 
<return>

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Undo!

Load-path shadows:
None found.

Features:
(shadow sort mail-extr message sendmail ecomplete rfc822 mml mml-sec
password-cache mm-decode mm-bodies mm-encode mailcap mail-parse rfc2231
rfc2047 rfc2045 qp ietf-drums mailabbrev nnheader gnus-util netrc
time-date mm-util mail-prsvr gmm-utils wid-edit mailheader canlock sha1
hex-util hashcash mail-utils emacsbug cc-mode cc-fonts easymenu cc-menus
cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs regexp-opt tooltip
ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd font-setting
tool-bar dnd fontset image fringe lisp-mode register page menu-bar
rfn-eshadow timer select scroll-bar mldrag mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev loaddefs button
minibuffer faces cus-face files text-properties overlay md5 base64
format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process font-render-setting gtk x-toolkit x
multi-tty emacs)

-- 
Matthieu




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org:
bug#6688; Package emacs. (Wed, 21 Jul 2010 17:28:02 GMT) Full text and rfc822 format available.

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

From: Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
To: 6688 <at> debbugs.gnu.org
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Wed, 21 Jul 2010 19:27:37 +0200
Digging a bit further, I found out in this example:

/*
  Test

*/

* The problems seems to be that the last */ is at the beginning of
  line. If I add a space before, the problem disapears. It seems to be
  a problem with `c-mask-paragraph', around this

		(let* ((ender-start (save-excursion
				      (goto-char (cdr c-lit-limits))
				      (skip-syntax-backward "^w ")
				      (point)))

  since the skip-syntax-backward will skip the newline and move out of
  the line of the */.

* If I download version 5.31.3 of cc-mode and install it, the problem
  goes away.

Hope this helps,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Sat, 24 Jul 2010 20:16:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>,
	martin rudalics <rudalics <at> gmx.at>
Cc: 6688 <at> debbugs.gnu.org
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Sat, 24 Jul 2010 20:26:05 +0000
Hi, Matthieu,

thanks for such a wonderfully helpful bug report!

On Wed, Jul 21, 2010 at 07:27:37PM +0200, Matthieu Moy wrote:
> Digging a bit further, I found out in this example:

> /*
>   Test

> */

> * The problems seems to be that the last */ is at the beginning of
>   line. If I add a space before, the problem disapears. It seems to be
>   a problem with `c-mask-paragraph', around this

> 		(let* ((ender-start (save-excursion
> 				      (goto-char (cdr c-lit-limits))
> 				      (skip-syntax-backward "^w ")
> 				      (point)))

The problem is indeed nearby, in c-mask-paragraph.  Would you please try
out the patch below, indeed please test it as intensively as possible
and let me know if there are any remaining problems.  The code here is
complicated enough for me not to be totally confident about the patch.

>   since the skip-syntax-backward will skip the newline and move out of
>   the line of the */.

> * If I download version 5.31.3 of cc-mode and install it, the problem
>   goes away.

> Hope this helps,

Very much so!

#########################################################################

Hi, Martin,

would you please try this patch out on the test case for which you
committed change 83096, and let me know if that bug remains fixed.
83096 is this one:

------------------------------------------------------------
revno: 83096
committer: Martin Rudalics <rudalics <at> gmx.at>
timestamp: Sat 2007-12-08 09:55:18 +0000
message:
  (c-mask-paragraph): Avoid invalid search
    bound error in block comment branch.
    
Thanks!

#########################################################################

> -- 
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/

-- 
Alan Mackenzie (Nuremberg, Germany).





Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Sun, 25 Jul 2010 09:51:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Sun, 25 Jul 2010 11:50:32 +0200
Hi, Alan!

> Hi, Martin,
>
> would you please try this patch out on the test case for which you
> committed change 83096, and let me know if that bug remains fixed.
> 83096 is this one:

What is "this patch"?  I didn't receive any attachment and I see no
patch of you in rev 100893.

martin




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Sun, 25 Jul 2010 13:36:01 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Sun, 25 Jul 2010 15:35:10 +0200
> Apologies for omitting the patch.  Here it is:

Thank you, applied.  Is it sufficient to just recompile cc-cmds.el or do
we have to recompile all cc-*.el files?

martin




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Sun, 25 Jul 2010 16:08:01 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Sun, 25 Jul 2010 16:18:56 +0000
Hi, Martin,

On Sun, Jul 25, 2010 at 03:35:10PM +0200, martin rudalics wrote:
> > Apologies for omitting the patch.  Here it is:

> Thank you, applied.  Is it sufficient to just recompile cc-cmds.el or
> do we have to recompile all cc-*.el files?

No, just compiling cc-cmds.el should do, since it's a "top level" file
which doesn't suply macros etc. to the rest of cc-*.el.  

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Mon, 26 Jul 2010 05:51:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Mon, 26 Jul 2010 07:50:58 +0200
Morning, Alan

> No, just compiling cc-cmds.el should do, since it's a "top level" file
> which doesn't suply macros etc. to the rest of cc-*.el.

OK.  So the warnings ...

In toplevel form:
C:/emacs/trunk/lisp/progmodes/cc-langs.el:135:1:Warning: cl package required
    at runtime

In c-before-change-check-<>-operators:
C:/emacs/trunk/lisp/progmodes/cc-engine.el:5076:25:Warning: reference to free
    variable `c-new-BEG'
C:/emacs/trunk/lisp/progmodes/cc-engine.el:5076:42:Warning: assignment to free
    variable `c-new-BEG'
C:/emacs/trunk/lisp/progmodes/cc-engine.el:5079:42:Warning: reference to free
    variable `c-new-END'
C:/emacs/trunk/lisp/progmodes/cc-engine.el:5079:42:Warning: assignment to free
    variable `c-new-END'

In c-common-init:
C:/emacs/trunk/lisp/progmodes/cc-mode.el:643:11:Warning: assignment to free
    variable `c-new-BEG'
C:/emacs/trunk/lisp/progmodes/cc-mode.el:644:11:Warning: assignment to free
    variable `c-new-END'

... I currently see are due to something else.  How can I get rid of
them?

martin




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Mon, 26 Jul 2010 08:28:01 GMT) Full text and rfc822 format available.

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

From: Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
To: Alan Mackenzie <acm <at> muc.de>
Cc: martin rudalics <rudalics <at> gmx.at>, 6688 <at> debbugs.gnu.org
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Mon, 26 Jul 2010 10:27:20 +0200
Alan Mackenzie <acm <at> muc.de> writes:

> Hi, M & M,
>
> Apologies for omitting the patch.  Here it is:

That works for me, yes.

Thanks,

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Mon, 26 Jul 2010 19:24:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Mon, 26 Jul 2010 19:34:35 +0000
And a jolly evening to you too, Martin!

On Mon, Jul 26, 2010 at 07:50:58AM +0200, martin rudalics wrote:
> Morning, Alan

> > No, just compiling cc-cmds.el should do, since it's a "top level" file
> > which doesn't suply macros etc. to the rest of cc-*.el.

> OK.  So the warnings ...

Hey, stop turning up the guilt machine!  They suddenly "appeared" with
either Emacs 22 or Emacs 23 (I can't remember any more) because of more
rigorous checking by the byte compiler.

> In toplevel form:
> C:/emacs/trunk/lisp/progmodes/cc-langs.el:135:1:Warning: cl package required
>     at runtime

That's an awkward one.  I'm not sure I quite believe it, but I'm almost
sure.

> In c-before-change-check-<>-operators:
> C:/emacs/trunk/lisp/progmodes/cc-engine.el:5076:25:Warning: reference to 
> free
>     variable `c-new-BEG'
> C:/emacs/trunk/lisp/progmodes/cc-engine.el:5076:42:Warning: assignment to 
> free
>     variable `c-new-BEG'
> C:/emacs/trunk/lisp/progmodes/cc-engine.el:5079:42:Warning: reference to 
> free
>     variable `c-new-END'
> C:/emacs/trunk/lisp/progmodes/cc-engine.el:5079:42:Warning: assignment to 
> free
>     variable `c-new-END'

> In c-common-init:
> C:/emacs/trunk/lisp/progmodes/cc-mode.el:643:11:Warning: assignment to free
>     variable `c-new-BEG'
> C:/emacs/trunk/lisp/progmodes/cc-mode.el:644:11:Warning: assignment to free
>     variable `c-new-END'

These are working variables, properly declared "in the right place",
until I found I needed to use them in initialisation routines too.
There're quite a few variables like this.

> ... I currently see are due to something else.  How can I get rid of
> them?

Ask me nicely?  ;-)  They're the sort of problem which never seems high
priority to fix, yet definitely needs doing.  All together there are
about 55 warning messages to fix.  It would probably take an evening to
do so.  Give me a few days!

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Tue, 27 Jul 2010 07:24:02 GMT) Full text and rfc822 format available.

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

From: martin rudalics <rudalics <at> gmx.at>
To: Alan Mackenzie <acm <at> muc.de>
Cc: 6688 <at> debbugs.gnu.org, Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Tue, 27 Jul 2010 09:23:08 +0200
>> OK.  So the warnings ...
>
> Hey, stop turning up the guilt machine!  They suddenly "appeared" with
> either Emacs 22 or Emacs 23 (I can't remember any more) because of more
> rigorous checking by the byte compiler.
[...]
> Ask me nicely?  ;-)  They're the sort of problem which never seems high
> priority to fix, yet definitely needs doing.  All together there are
> about 55 warning messages to fix.  It would probably take an evening to
> do so.  Give me a few days!

Sorry.  It's the first time I had a closer look into compiler warnings
for some time and I thought they might be related to the change at hand.
Looking at compile logs is currently much too confusing for me with all
the save-excursion/set-buffer warnings.

The only thing about cc-* that really annoys me is an "old-style
backquotes detected!" warning I get when I load cc-menus.el (don't ask
me why I load it, I need the functionality somewhere).

In any case I think you can check in the fix for 6688 now ;-)

martin




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs <at> gnu.org, bug-cc-mode <at> gnu.org:
bug#6688; Package emacs,cc-mode. (Sat, 31 Jul 2010 09:39:02 GMT) Full text and rfc822 format available.

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

From: Alan Mackenzie <acm <at> muc.de>
To: Matthieu Moy <Matthieu.Moy <at> grenoble-inp.fr>,
	martin rudalics <rudalics <at> gmx.at>
Cc: 6688 <at> debbugs.gnu.org
Subject: Re: bug#6688: Acknowledgement (23.2; Auto-fill broken in C/C++ modes.)
Date: Sat, 31 Jul 2010 09:49:54 +0000
Hi, Matthieu and Martin,

I've applied this patch to the Bazaar head at savannah.  That should fix
the bug.

Thanks once again for such a high quality bug report.

On Sun, Jul 25, 2010 at 01:09:39PM +0000, Alan Mackenzie wrote:

> === modified file 'lisp/progmodes/cc-cmds.el'
> *** lisp/progmodes/cc-cmds.el	2010-05-12 11:06:12 +0000
> --- lisp/progmodes/cc-cmds.el	2010-07-23 21:27:24 +0000
> ***************
> *** 3974,3989 ****
>   		    ;; "Invalid search bound (wrong side of point)"
>   		    ;; error in the subsequent re-search.  Maybe
>   		    ;; another fix would be needed (2007-12-08).
> ! 		    (and (> (- (cdr c-lit-limits) 2) (point))
>   			 (search-forward-regexp
>   			  (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
>   			  (- (cdr c-lit-limits) 2) t)
>   			 (not (search-forward-regexp
>   			       "\\(\\s \\|\\sw\\)"
>   			       (- (cdr c-lit-limits) 2) 'limit))
> ! 			     ;; The comment ender IS on its own line.  Exclude
> ! 			     ;; this line from the filling.
> ! 			 (set-marker end (c-point 'bol))))
>   
>   		;; The comment ender is hanging.  Replace all space between it
>   		;; and the last word either by one or two 'x's (when
> --- 3974,3990 ----
>   		    ;; "Invalid search bound (wrong side of point)"
>   		    ;; error in the subsequent re-search.  Maybe
>   		    ;; another fix would be needed (2007-12-08).
> ! 		    (or (<= (- (cdr c-lit-limits) 2) (point))
> ! 			(and 
>   			 (search-forward-regexp
>   			  (concat "\\=[ \t]*\\(" c-current-comment-prefix "\\)")
>   			  (- (cdr c-lit-limits) 2) t)
>   			 (not (search-forward-regexp
>   			       "\\(\\s \\|\\sw\\)"
>   			       (- (cdr c-lit-limits) 2) 'limit))
> ! 			 ;; The comment ender IS on its own line.  Exclude
> ! 			 ;; this line from the filling.
> ! 			 (set-marker end (c-point 'bol)))))
>   
>   		;; The comment ender is hanging.  Replace all space between it
>   		;; and the last word either by one or two 'x's (when
> 
> #########################################################################
> > http://www-verimag.imag.fr/~moy/

-- 
Alan Mackenzie (Nuremberg, Germany).
 




Reply sent to Alan Mackenzie <acm <at> muc.de>:
You have taken responsibility. (Wed, 04 Aug 2010 20:08:02 GMT) Full text and rfc822 format available.

Notification sent to Matthieu Moy <Matthieu.Moy <at> imag.fr>:
bug acknowledged by developer. (Wed, 04 Aug 2010 20:08:03 GMT) Full text and rfc822 format available.

Message #40 received at 6688-done <at> debbugs.gnu.org (full text, mbox):

From: Alan Mackenzie <acm <at> muc.de>
To: 6688-done <at> debbugs.gnu.org
Subject: bug #6688 fixed
Date: Wed, 4 Aug 2010 20:19:42 +0000
Bug fixed.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Thu, 02 Sep 2010 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 14 years and 291 days ago.

Previous Next


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