[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: cc-mode adds newlines
From: |
Andries Brouwer |
Subject: |
Re: cc-mode adds newlines |
Date: |
Fri, 31 Dec 2004 17:56:44 +0100 |
User-agent: |
Mutt/1.4i |
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.]