emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HEAD cc-mode bug: /* */ {}


From: Alan Mackenzie
Subject: Re: HEAD cc-mode bug: /* */ {}
Date: Fri, 6 Feb 2004 09:55:09 +0000 (GMT)


On Sat, 31 Jan 2004, Karl Chen wrote:

>Dear Emacs, cc-mode developers:

>I believe this is a bug in cc-mode's c-electric-brace: if you type
>a brace ('{' or '}') without a preceding newline, any preceding
>comments are deleted.

Indeed, so.

>Steps to reproduce:

>C-x C-f /tmp/a.c (or .cc, .java, etc)

>foo
>// line comment
>/* block comment */   {


>Typing the '{' (or '}') deletes the comments such that the buffer
>now looks like:

>foo {


>This occurs with cc-mode 5.30.8 from Emacs CVS HEAD but not in
>Emacs 21.3.

Emacs 21.3 contains CC Mode 5.28.

>I suppose the fix would be to change the call to
>`c-backward-syntactic-ws'.

Absolutely!  Here's a patch which does exactly that.   Thanks for
investigating and reporting this bug.

Index: cc-cmds.el
===================================================================
RCS file: /cvsroot/cc-mode/cc-mode/cc-cmds.el,v
retrieving revision 5.268.2.4
diff -c -r5.268.2.4 cc-cmds.el
*** cc-cmds.el  1 Nov 2003 00:51:56 -0000       5.268.2.4
--- cc-cmds.el  6 Feb 2004 09:44:35 -0000
***************
*** 479,485 ****
          ;; end up before it.
          (setq delete-temp-newline
                (cons (save-excursion
!                       (c-backward-syntactic-ws)
                        (copy-marker (point) t))
                      (point-marker))))
        (unwind-protect
--- 479,486 ----
          ;; end up before it.
          (setq delete-temp-newline
                (cons (save-excursion
!                       (end-of-line 0)
!                       (skip-chars-backward " \t")
                        (copy-marker (point) t))
                      (point-marker))))
        (unwind-protect

>Karl 2004-01-30 23:46

-- 
Alan Mackenzie (Munich, Germany)






reply via email to

[Prev in Thread] Current Thread [Next in Thread]