unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Alan Mackenzie <acm@muc.de>
To: emacs-devel@gnu.org, Richard Stallman <rms@gnu.org>
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	[thread overview]
Message-ID: <20080219230406.GC1106@muc.de> (raw)

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
  effect.
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
anyway.

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

-- 
Alan Mackenzie (Nuremberg, Germany).




             reply	other threads:[~2008-02-19 23:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-19 23:04 Alan Mackenzie [this message]
2008-02-19 23:48 ` C/C++/ObjC Modes: Right thing now done with unbalanced string quotes and unmatched parens in CPP lines Glenn Morris
2008-02-20 16:44   ` Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080219230406.GC1106@muc.de \
    --to=acm@muc.de \
    --cc=emacs-devel@gnu.org \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).