[Top][All Lists]

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

C/C++/ObjC Modes: Right thing now done with unbalanced string quotes and

From: Alan Mackenzie
Subject: C/C++/ObjC Modes: Right thing now done with unbalanced string quotes and unmatched parens in CPP lines.
Date: Tue, 19 Feb 2008 23:04:06 +0000
User-agent: Mutt/1.5.9i

Hi, Emacs and Richard!

I have just amended CC Mode (in the EMACS_22 branch, but not yet in the
trunk) so that it does the Right Thing with code such as:

1 #ifdef 0 /* comment
2             second line of comment. */
3 #warning for isn't a keyword here. (
4 //#warning for isnt a keyword here.
5 void foo (bar)
6 {
7 #error }
8     printf ("Hello, world!\n") ; /* the famous one liner! */
9 }

In particular:
L3: the apostrophe no longer disturbs the fontification after EOL.
L3: the pseudo-paren doesn't mess up paren-matching.  C-M-n here has no
L6,7: The L6 brace doesn't match with the L7 pseudo-brace.
L9: The brace correctly matches that on L6.

The fix works by setting syntax-table properties on all syntactically
"obtrusive" characters in preprocessor lines.  Balanced constructs within
these lines retain their syntactic identity.

However, the unterminated comment on L1 is allowed remain a comment -
there are lots of places in the Emacs C source where this occurs.

As always with such changes, byte-compile first cc-defs.el, then
cc-langs.el, then the rest.  After a change to cc-langs.el, it is always
necessary to recompile cc-{engine,mode}.el, but they've been changed

If this change doesn't work, or causes any problems, please let me know!

Alan Mackenzie (Nuremberg, Germany).

reply via email to

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