emacs-devel
[Top][All Lists]
Advanced

[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: Sun, 2 Jan 2005 19:02:20 +0100
User-agent: Mutt/1.4i

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]