[Top][All Lists]

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

cc-mode adds newlines

From: Luc Teirlinck
Subject: cc-mode adds newlines
Date: Thu, 23 Jan 2003 19:36:29 -0600 (CST)

Benjamin Riefenstahl wrote:

     Was there a reason to want to have invalid C source originally, or was
     that just an aesthetic problem?

I myself have even the default value of require-final-newline set to t,
so in my personal usage I have no problem with what cc-mode does.  But
clearly Heinrich does.  He should tell you the details.  I do not know
whether he reads the news group or whether you included a cc to him.

However, maybe I am misunderstanding things, but is cc-mode not more
general than just C:

       CC Mode is a GNU Emacs mode for editing files containing C, C++,
    Objective-C, Java, CORBA IDL, and Pike code.

Also do not forget that, in addition to the above, people can use
cc-mode for just about any language for which no separate mode is
available.  Actually, the Emacs manual encourages them to do that:

       Ideally, Emacs should provide a major mode for each programming
    language that you might want to edit; if it doesn't have a mode for
    your favorite language, you can contribute one.  But often the mode
    for one language can serve for other syntactically similar languages. 

Users who know Elisp can write their own mode, but others may just
try to customize cc-mode the best they can. 

So, it is not clear that we are talking about invalid C source,
because it is not clear we are talking about C source.  Heinrich can
give you the details, but essentially I do have reservations about
overriding the user's global value of require-final-newline, without
any notice, if one does not even knows which language the user might
be programming.  (Overriding nil to 'maybe is OK, because it asks for
permission.)  Again, CC Mode's documentation seems to suggest that it
is for "C and other similar things", not just for C.

Also, people might want to test what the exact effect of forgetting
newlines in a language is, for whichever reason.  In that case, just
temporarily using the trivial hook function I suggested would be
sufficient, if one knows what is going on.  The problem is that people
might not be aware that you are correcting the mistakes they are
experimenting with.  Hence, they believe that they are not mistakes at
all, because everything works OK.  That is also part of why I believe
it is wrong to correct users's mistakes behind their back.  You can do
so, as long as you inform them about it.  Actually, you should inform
them about their mistakes, and if you do not automatically correct you
should at least offer to correct them (that is exactly what the 'maybe
value does).

The reservation I have is not just about automatically overriding the
default-value, that in itself could be OK, but about doing so without
clear notice, for instance in the C-h m output.  Just a small line in
the mode documentation might be helpful, maybe with a one-line
description of how they can override, if, for whichever reason, they
feel that need.  So what I am suggesting is not necessarily even
changing the current situation, but "change or inform".

We will have to wait for Heinrich's response to see what his concrete
problem is.



reply via email to

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