emacs-devel
[Top][All Lists]
Advanced

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

Re: cc-mode adds newlines


From: Martin Stjernholm
Subject: Re: cc-mode adds newlines
Date: Sun, 28 Nov 2004 15:45:00 +0100
User-agent: Gnus/5.090016 (Oort Gnus v0.16) Emacs/20.7 (gnu/linux)

A late response to a tiresome discussion, but as the primary
maintainer of CC Mode I think I ought to give my input to the
discussion about c-require-final-newlines:

One goal of CC Mode is to set up a buffer suitably for writing
C/C++/Java/etc code. That means modifying a number of variables - the
syntax table, comment-start and comment-end to name just a few. There
are great many dialects of these languages, so CC Mode uses the
current language standards as the authorative sources to determine its
settings. For C that standard is ISO C99, for C++ it's ISO C++ 97, for
Java it's the 2.0 language spec from Sun (since I've not yet adapted
CC Mode for the additional syntax in the upcoming J2SE 5.0), etc. I
plan to continue to update CC Mode to comply with the latest standards
as they become available.

For the languages where the standards mandate a trailing newline, CC
Mode therefore sets require-final-newline to t by default, just like
it configures the comment syntax according to the standard, recognizes
"#" for preprocessor directives in the languages that uses cpp, etc.
This to make the defaults reflect the most common editing situations.
It's of course often necessary to override them to suit a specific
situation, and just like other major modes CC Mode provides plenty of
ways to do that.

Regarding the argument that setting require-final-newline to t by
default (as opposed to setting the multitude of other variables to
various defaults) makes things happen "behind the back" of the user, I
believe it's only a subjective perception: It's a sign that something
happened that a specific user didn't expect; in reality there are lots
of stuff that happens "behind the back", but as long as they agree to
the user's expectations they aren't percieved that way. Therefore it
can just as well be due to lack of knowledge from the user as it is
counterintuitive behavior in the program. Other arguments are
necessary to discern where the fault is.

Anyway, I've now explained the policy behind the default used by CC
Mode, and so far I haven't seen any good arguments to depart from it
in this specific case.

As for c-require-final-newlines, I think in hindsight that it's an
ugly kludge and that it was a mistake. I agree with Stefan Monnier:
The generic way to override a variable in a specific mode is to set it
in a mode hook (or by using file local variables), and that ought to
work in this case too. If the problem is that mode hooks are too
difficult to use by many users then a simpler generic way to do mode
specific variable overrides should be added. A growing plethora of
special case variables like c-require-final-newlines does not make
things easy to understand.

I don't intend to remove c-require-final-newlines again, however.
Instead I'll be happy to deprecate it when a better tool is available.




reply via email to

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