From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andries Brouwer Newsgroups: gmane.emacs.devel Subject: Re: cc-mode adds newlines Date: Sat, 20 Nov 2004 00:13:43 +0100 Message-ID: <20041119231343.GA19603@apps.cwi.nl> References: <7joiybt7.fsf@blue.sea.net> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1100906076 32676 80.91.229.6 (19 Nov 2004 23:14:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 19 Nov 2004 23:14:36 +0000 (UTC) Cc: Andries.Brouwer@cwi.nl, emacs-devel@gnu.org, Jari Aalto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 20 00:14:25 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CVHxR-0000ZU-00 for ; Sat, 20 Nov 2004 00:14:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVI6L-0003rA-Un for ged-emacs-devel@m.gmane.org; Fri, 19 Nov 2004 18:23:37 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CVI6E-0003qy-Ok for emacs-devel@gnu.org; Fri, 19 Nov 2004 18:23:30 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CVI6D-0003qZ-W0 for emacs-devel@gnu.org; Fri, 19 Nov 2004 18:23:30 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVI6D-0003qW-Rw for emacs-devel@gnu.org; Fri, 19 Nov 2004 18:23:29 -0500 Original-Received: from [192.16.191.8] (helo=hera.cwi.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CVHwq-0007zS-A6 for emacs-devel@gnu.org; Fri, 19 Nov 2004 18:13:48 -0500 Original-Received: from apps.cwi.nl (apps.cwi.nl [192.16.191.34]) by hera.cwi.nl with ESMTP id iAJNDk6e016597 for ; Sat, 20 Nov 2004 00:13:46 +0100 (MET) Original-Received: (from aeb@localhost) by apps.cwi.nl (8.11.7p1+Sun/8.12.2) id iAJNDh607183; Sat, 20 Nov 2004 00:13:43 +0100 (MET) Original-To: Alan Mackenzie Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30109 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30109 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.