emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Defcustom write-file-functions and write-contents-functions?


From: Luc Teirlinck
Subject: Re: Defcustom write-file-functions and write-contents-functions?
Date: Sun, 4 Jan 2004 18:14:20 -0600 (CST)

Stefan Monnier wrote:

   Please don't.  There are already plenty of hooks run at that place
   and the code is hairy enough as it is.

It would add a line to the code, but it would not increase complexity.
Complexity is not measured in number of lines of code.

   >    * emacs-lisp/copyright.el: Use before-save-hook instead of
   >    write-file-functions.

   Better provide a copyright-auto-update-mode that will do the
   hook manipulation.

There might be other things users might want to have done before
saving a file and the proposed hook would very much _simplify_ this.
I realize that one always has to be extremely careful when running
something before saving _any_ file under _any_ conditions.  I
personally would not want to add, say, `delete-trailing-whitespace' to
`before-save-hook', because it would be too dangerous and would remove
wanted indentation in files that are saved while still being edited.
But certain things might be safe.  Certainly, anything that queries
the user is.  For instance, _detecting_ trailing whitespace and asking
the user is safe.

The only thing that _might_ work with the current hooks is to add
something to the front of `write-contents-functions'.  (The other
hooks in the `or' form are not guaranteed to run.)  But that solution
is not very solid, because `write-contents-functions' is not a normal
hook and something else (major modes for instance) might be playing
games with it.

Sincerely,

Luc.





reply via email to

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