unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* HEAD cc-mode bug: /* */ {}
@ 2004-01-31  8:00 Karl Chen
  2004-02-06  9:55 ` Alan Mackenzie
  0 siblings, 1 reply; 2+ messages in thread
From: Karl Chen @ 2004-01-31  8:00 UTC (permalink / raw)


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.

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.

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

-- 
Karl 2004-01-30 23:46

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

* Re: HEAD cc-mode bug: /* */ {}
  2004-01-31  8:00 HEAD cc-mode bug: /* */ {} Karl Chen
@ 2004-02-06  9:55 ` Alan Mackenzie
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Mackenzie @ 2004-02-06  9:55 UTC (permalink / raw)
  Cc: Emacs Developement List, bug-cc-mode



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)




-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn


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

end of thread, other threads:[~2004-02-06  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-31  8:00 HEAD cc-mode bug: /* */ {} Karl Chen
2004-02-06  9:55 ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).