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: Sun, 21 Nov 2004 13:52:49 +0000 (GMT) Message-ID: References: <20041121122629.GE20436@apps.cwi.nl> Reply-To: Alan Mackenzie NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: sea.gmane.org 1101045810 5207 80.91.229.6 (21 Nov 2004 14:03:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 21 Nov 2004 14:03:30 +0000 (UTC) Cc: bug-cc-mode@gnu.org, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 21 15:03:22 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 1CVsJE-0008DF-00 for ; Sun, 21 Nov 2004 15:03:21 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVsSE-0003Sl-Ae for ged-emacs-devel@m.gmane.org; Sun, 21 Nov 2004 09:12:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CVsQv-00030e-PU for emacs-devel@gnu.org; Sun, 21 Nov 2004 09:11:17 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CVsQu-0002zn-Qg for emacs-devel@gnu.org; Sun, 21 Nov 2004 09:11:17 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CVsQu-0002zd-NJ for emacs-devel@gnu.org; Sun, 21 Nov 2004 09:11:16 -0500 Original-Received: from [193.149.49.134] (helo=acm.acm) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CVsHm-0003pU-OC; Sun, 21 Nov 2004 09:01:52 -0500 Original-Received: from localhost (root@localhost) by acm.acm (8.8.8/8.8.8) with SMTP id NAA00500; Sun, 21 Nov 2004 13:52:51 GMT X-Sender: root@acm.acm Original-To: Andries Brouwer In-Reply-To: <20041121122629.GE20436@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:30173 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30173 Hi, Andries! On Sun, 21 Nov 2004, Andries Brouwer wrote: >On Sun, Nov 21, 2004 at 11:41:34AM +0000, Alan Mackenzie wrote: >> I've had a search through the archives. I found your bug report in >> gnu.emacs.bug recently, and a previous bug report (strangely enough, with >> exactly the same subject, "cc-mode adds newlines" ;-), from >> Heinrich Rommerskirchen on Thu, 23 >> Jan 2003 13:17:12. Maybe you've read through that thread already. That >> also lead to discussion on the CC Mode mailing list (archived on >> somewhere), which led to the >> introduction of `c-require-final-newline'. >> Heinrich Rommerskirchen's complaint was that c-mode silently set >> require-final-newline to t without him being able to do anything about >> it. c-require-final-newline was the answer to that, giving people a way >> to "do something about it". It was given the default value ((c-mode . t) >> (c++-mode .t) (objc-mode .t)) so as not to change the behaviour for users >> used to the old way. >Yes, indeed. Heinrich Rommerskirchen wrote: > cc-mode tries to be smart and adds newlines to a file without > informing the user and without any easily found option to suppress > it. >You see - nobody wants c-require-final-newline. Untrue - Alfred M. Szmidt, for one, wants it. If nobody wanted it, it wouldn't have been implemented. >It is a misfeature. Heinrich Rommerskirchen hated getting a final >newline added by emacs behind his back. I hate it. Yes, I think that's clear by now. ;-) The difference is, Heinrich had no easy way of disabling this "feature". Thanks to his bug report, you do (assuming you've got CC Mode >= 5.30. If you haven't, get 5.30.9 from ). >One does not become happier if there is a complicated way to make emacs >not do it. Emacs should not do it in the first place. It is a simple way. The only difficult thing about it is discovering its existence. >This misfeature was only added because cc-mode had another misfeature: >it blindly overrides global variable settings. Yes indeed, but not blindly. For example, it changes the paragraph-start and paragraph-separate variables to recognise comment-prefices (the "* " you have at the beginning of each comment line), so that when you do M-q in a block comment, it doesn't just jumble the entire comment into a compact mess. >That makes life much more difficult for users. If they do something >globally, they also have to make the same change locally for all >major modes they will encounter, in order to have a uniform interface. Users often want these things set differently in different modes. >require-final-newline is a beautiful variable. Set it to ask by default >and some people will make it always true, some will make it always false. >Many will leave it to ask. And some will want it t in C Mode and nil in Text Mode, and really don't want to be bothered answering the question "Add one? (y or n)" twenty times a day. >c-require-final-newline is an ugly bug. Who will change its value? _You_ will. By putting the correct (for you) setting of it in your .emacs file. >Only people who have been bitten by the fact that emacs changed their >files, spent time in debugging, spent time in searching the docs, spent >time in searching the net. And when c-require-final-newline is just >equal to require-final-newline and the latter has default ask, then >nobody is ever bitten. OK, you've been bitten. Sorry. It's happened already and it can't now be undone. The criticism in the previous paragraph is fair. But read the threads from January 2003, the ones that lead to the creation of that variable, and see if you can come up with a better solution, given the conflicting demands of (i) full customizability; (ii) the need to maintain compatibility with existing behaviour; (iii) the need to keep users informed about what's being done; (iv) the need not to irritate users with excessive "are you sure?" type questions; ..... >If you insist that c-require-final-newline must exist, also that >must have default ask. But there is really no reason why >anybody would set it differently from require-final-newline. Yes there is - To have appropriate (but different) values in Text Mode, C Mode and AWK Mode, to name just three. And if we changed the default value to ask, complaints from other people would start rolling in. That's guaranteed. ;-( >If one only edits text files, set require-final-newline to true. >If one sometimes edits arbitrary files, set it to ask. >Also an arbitrary file can have a name ending in .c. >If one always knows what one is doing and never makes mistakes, >set it to false. Other people see things differently. Emacs tries to cater for all different tastes and preferences, and deciding on the Right defaults is difficult. Configure your .emacs file so that you won't get caught out again. Other than that, I don't think anybody can offer you much more help. >Andries -- Alan Mackenzie (Munich, Germany)