From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.devel Subject: Re: cc-mode adds newlines Date: Sat, 20 Nov 2004 15:14:24 +0000 (GMT) Message-ID: References: <20041119231343.GA19603@apps.cwi.nl> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1100964274 1084 80.91.229.6 (20 Nov 2004 15:24:34 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sat, 20 Nov 2004 15:24:34 +0000 (UTC) Cc: emacs-devel@gnu.org, Jari Aalto Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Nov 20 16:24:24 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 1CVX67-0000u9-00 for ; Sat, 20 Nov 2004 16:24:23 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVXF4-0005f7-VG for ged-emacs-devel@m.gmane.org; Sat, 20 Nov 2004 10:33:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CVXEr-0005dK-AD for emacs-devel@gnu.org; Sat, 20 Nov 2004 10:33:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CVXEp-0005c2-4U for emacs-devel@gnu.org; Sat, 20 Nov 2004 10:33:23 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVXEo-0005bT-Vf for emacs-devel@gnu.org; Sat, 20 Nov 2004 10:33:23 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CVX5e-0004jM-9O for emacs-devel@gnu.org; Sat, 20 Nov 2004 10:23:55 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id PAA00367; Sat, 20 Nov 2004 15:14:26 GMT X-Sender: root@acm.acm Original-To: Andries Brouwer In-Reply-To: <20041119231343.GA19603@apps.cwi.nl> 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:30125 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30125 Hi, Andries! On Sat, 20 Nov 2004, Andries Brouwer wrote: >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. Well, that is debateable. I'd tend to agree with you, whilst pointing out that in this case, there was no "force" used [see below]. An equally valid argument is that of the programmer who hacks through the night and sets off a build (which takes several hours to complete), goes home for some sleep, then comes back into the office the following afternoon. He then finds that the build failed for lack of a final newline in one of the files. Then he expostulates "FAQ! Why couldn't that stupid editor have put that stupid newline in for me?". >It is excellent if the editor helps the user, warns for things that >often are mistakes, etc. But the user is the final authority. You'll note that, for example, CC Mode warns you about unterminated strings and unterminated comments. [Don't laugh - before the days of syntax highlighting, unterminated comments were the utter devil to find - often the resulting source was syntactically valid, but the "else" bit of an "if" got commented out, for example.] >In this case of newlines emacs considers itself as final authority. That >is a serious bug. It must ask by default. No. It is _your_ copy of Emacs, and it is _your_ choice how you configure it. You can actually set Emacs up to ask about final-newlines first (see the Emacs manual, page "Saving", then use that information to set c-require-final-newline), but you've probably found that out already. You'd be surprised just how much people's ideas vary about what the Obviously Right Thing is. To me, it's inconceivable that anybody would want scrolling past the end of a file to add new lines to it, but that was the default Emacs behaviour until recently. Right at the moment, I'm having a discussion with somebody on gnu.emacs.help who can't understand why anybody would _choose_ to use a text console rather than an X windows display. This is the reason that Emacs is so highly customizable. I think your complaint here is that you didn't know about the setting, and had no reason to suspect it might exist, and therefore no reason to spend weeks meticulously searching through the manual for anything random which might mess up your files. That's a fair complaint. It's also fair for me to ask, did you suffer any actual damage (as opposed to having your sense of what's proper put out of joint) from this terminating newline? Something like the source file being an input to some scriptfile, rather than just being compiled, and that script fouling up? >It is not true that all dialects of C require a final newline. Yes, but _some_ of them do, and more importantly the C standard does. >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. Go out and either (i) spend the night at a disco; or (ii) go for a swim, or a game of squash; or (ii) get blind drunk for the evening. By the time you get back home, c-require-final-newline won't seem so important. All the best! >Andries -- Alan Mackenzie (Munich, Germany)