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: Fri, 31 Dec 2004 17:56:44 +0100 Message-ID: <20041231165644.GB25972@apps.cwi.nl> References: <200411281656.iASGuMP15956@apps.cwi.nl> <5bact1lwp5.fsf@lister.roxen.com> <20041128202015.GA821@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 1104512239 6598 80.91.229.6 (31 Dec 2004 16:57:19 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 31 Dec 2004 16:57:19 +0000 (UTC) Cc: bug-cc-mode@gnu.org, acm@muc.de, Andries.Brouwer@cwi.nl, monnier@iro.umontreal.ca, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 31 17:57:10 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 1CkQ5O-0004P4-00 for ; Fri, 31 Dec 2004 17:57:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CkQGO-0002LJ-CK for ged-emacs-devel@m.gmane.org; Fri, 31 Dec 2004 12:08:32 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CkQGH-0002L6-7b for emacs-devel@gnu.org; Fri, 31 Dec 2004 12:08:25 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CkQGG-0002Kf-Cg for emacs-devel@gnu.org; Fri, 31 Dec 2004 12:08:24 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CkQGG-0002KV-5T for emacs-devel@gnu.org; Fri, 31 Dec 2004 12:08:24 -0500 Original-Received: from [192.16.191.8] (helo=hera.cwi.nl) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CkQ54-0004dL-0f; Fri, 31 Dec 2004 11:56:50 -0500 Original-Received: from apps.cwi.nl (apps.cwi.nl [192.16.191.34]) by hera.cwi.nl with ESMTP id iBVGul9L014144 for ; Fri, 31 Dec 2004 17:56:47 +0100 (MET) Original-Received: (from aeb@localhost) by apps.cwi.nl (8.11.7p1+Sun/8.12.2) id iBVGui717175; Fri, 31 Dec 2004 17:56:44 +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:31646 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:31646 On Fri, Dec 31, 2004 at 10:26:03AM -0500, Richard Stallman wrote: > The current situation, where (after 0 changes) save-buffer > returns "(No changes need to be saved)" and write-file > nevertheless writes a different file, is unfortunate and messy. > > I looked at changing this, but couldn't find a good way to do it. > I tried to provide values of require-final-newline > that only add a newline if the file is really changed. > > But it is hard to distinguish use of write-file from "really changed" > because write-file operates by marking the buffer as modified > (that is how it forces a save). > > Do you have any ideas? It would not be hard to make a further > change here. I do not have the source in front of me so can only make vague remarks. Also, I do not know precisely how much and in what way this final newline handling has changed. 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. Andries [And please, have defaults such that a file is never changed unless the user explicitly asks for the change. That is, newlines must be added only if .emacs contains settings that ask for such a behaviour.]