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: Sun, 2 Jan 2005 19:02:20 +0100 Message-ID: <20050102180220.GE7647@apps.cwi.nl> References: <200411281656.iASGuMP15956@apps.cwi.nl> <5bact1lwp5.fsf@lister.roxen.com> <20041128202015.GA821@apps.cwi.nl> <20041231165644.GB25972@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 1104689043 11516 80.91.229.6 (2 Jan 2005 18:04:03 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 2 Jan 2005 18:04:03 +0000 (UTC) Cc: bug-cc-mode@gnu.org, acm@muc.de, Andries Brouwer , monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 02 19:03:56 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1ClA55-00008e-00 for ; Sun, 02 Jan 2005 19:03:56 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ClAGB-0004yg-O0 for ged-emacs-devel@m.gmane.org; Sun, 02 Jan 2005 13:15:23 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1ClAG0-0004xZ-7d for emacs-devel@gnu.org; Sun, 02 Jan 2005 13:15:12 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1ClAFx-0004wH-EA for emacs-devel@gnu.org; Sun, 02 Jan 2005 13:15:10 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1ClAFx-0004ve-4V for emacs-devel@gnu.org; Sun, 02 Jan 2005 13:15:09 -0500 Original-Received: from [192.16.191.8] (helo=hera.cwi.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1ClA3f-0003pe-3o; Sun, 02 Jan 2005 13:02:27 -0500 Original-Received: from apps.cwi.nl (apps.cwi.nl [192.16.191.34]) by hera.cwi.nl with ESMTP id j02I2P3n011429 for ; Sun, 2 Jan 2005 19:02:25 +0100 (MET) Original-Received: (from aeb@localhost) by apps.cwi.nl (8.11.7p1+Sun/8.12.2) id j02I2KM00929; Sun, 2 Jan 2005 19:02:20 +0100 (MET) Original-To: Richard Stallman 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:31694 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31694 On Sun, Jan 02, 2005 at 11:05:56AM -0500, Richard Stallman wrote: A happy 2005 to you! > Maybe I would be tempted to invent a prepare-write-file-hook > (if there is none already) that would do any required transformations > before the file is actually written. > > Both save-buffer and write-file could call this hook. > > This hook could set file-changed in case it adds a final newline. > > Now if save-buffer only tests file-changed after calling > prepare-write-file-hook it notices the change. > > Actually, save-buffer doesn't add a newline, or do much of anything, > unless the buffer is already marked "modified". The present problem, > or at least you've considered it one, is that write-file adds the > newline unconditionally. That is because write-file marks the buffer > modified before it calls save-buffer. > > I don't think your proposal would alter what happens in this case. I was of the opinion that write-file and save-buffer should show consistent behaviour; if write-file changes the contents of a file by adding an additional byte, even when so far the file was not modified, then save-buffer should also do that - this consistency is what is obtained by the above suggestion. Of course I consider silently changing a user's files to be something terrible, so this prepare-write-file-hook should do this adding of a newline only when there is some very explicit evidence that this is what the user wants, like a setting in .emacs. Certainly the chosen filename alone should not suffice. Andries