emacs-devel
[Top][All Lists]
Advanced

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

Re: Mysterious fontification/C++ context issue


From: Alan Mackenzie
Subject: Re: Mysterious fontification/C++ context issue
Date: 10 Dec 2006 01:35:14 +0100
Date: Sun, 10 Dec 2006 01:45:26 +0000
User-agent: Mutt/1.5.9i

Hi, Richard!

On Wed, Dec 06, 2006 at 11:59:26PM -0500, Richard Stallman wrote:
>     Could we set open-paren-in-column-0-is-defun-start to t for c mode?

This would nullify the fix for the bug reported by Martin a few weeks
ago, namely: Load syntax.c and immediately jump forward to a certain
function.  The fontification was seriously wrong.

> If no one sees a better alternative, let's do that.  But let's wait
> a few days and see what else is suggested.

Currently CC Mode sets open-paren-in-column-0-is-defun-start
unconditionally to nil.  I now think this isn't necessarily a good idea.

The optimal setting of opic0ids depends on what your source file looks
like:

(i) (eq opic0ids nil) is good for small to medium sized source files,
(probably) for files with hanging defun braces, and for files (like
syntax.c) with syntactical anomalies.

(ii) (eq opic0ids t) is good for large source files with defun braces in
column 0.
 
I think I now agree with Martin R: opic0ids should become a fully user
settable option, and CC Mode should respect it.  However, I think it
needs more than two values, t and nil; it should have three values,
"definitely nil", "definitely t" and "don't really care".  The last of
these would be an instruction to the major mode to use a mode-dependent
default value, the latter defaulting to non-nil.  Should it not also
become a buffer local variable?

I'm not 100% sure what effect this would have on CC Mode, but it'll be
something like this: c-beginning-of-defun will continue to look for an
unnested {, but with (eq opic0ids t), its results will be probabalistic
rather than rigorous.  But it worked well enough before, when
beginning-of-defun was a bit squidgy.

I'll need to amend cc-mode.texi.

I think the CC Mode default for opic0ids should be nil, and a typical
Emacs hacker's .emacs would contain something like this:

(setq open-paren-in-column-0-is-default-start
  (and (not equal (filename-nondirectory
                   (filename-sans-extension (buffer-file-name)))
                  "syntax.c")
       (> (buffer-size) 200000)))

What do people think?

-- 
Alan.




reply via email to

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