emacs-devel
[Top][All Lists]
Advanced

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

Re: cc-mode adds newlines


From: Andries Brouwer
Subject: Re: cc-mode adds newlines
Date: Sat, 20 Nov 2004 00:13:43 +0100
User-agent: Mutt/1.4i

On Fri, Nov 19, 2004 at 08:27:48PM +0000, Alan Mackenzie wrote:
> On Fri, 19 Nov 2004, Jari Aalto wrote:
> 
> >| Working with emacs 21.3.
> >| Struggled for a while to get emacs to save a file without final newline.
> >| ...The point is: emacs must not start changing my files without
> >| being asked.
> 
> >I agree. The problem is not just in CC mode, but also in other modes as
> >well. Could someone from the dev team address these below.
> 
> In CC mode, there is the (customisable) variable c-require-final-newline,
> an association list, which you can set to either t, nil, or "don't
> touch!" for each language independently.  The thinking is that some
> languages' syntaxes absolutely require a final newline (I haven't myself
> checked if this is true), and that only in those languages (C, C++,
> Objective-C) is c-require-final-newline set to t. 

But of course this thinking is flawed. In many ways.
It is not the goal of an editor to force the user to
write syntactically correct programs.
It is excellent if the editor helps the user, warns for
things that often are mistakes, etc. But the user is the
final authority.
In this case of newlines emacs considers itself as final
authority. That is a serious bug. It must ask by default.

Andries

# cat > hi.c
main(){ printf("hi!\n");}# 
# cat hi.c
main(){ printf("hi!\n");}# cc hi.c
# a.out
hi!
# 

It is not true that all dialects of C require a final newline.


The introduction of this alist was a bug.
The introduction of c-require-final-newline was a bug.
The variable require-final-newline expresses well what the user wants.




reply via email to

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