Subject: bug#12259: Add delete-trailing-whitespace to list of safe eval forms

From: Stefan Monnier <[email-masked]>
Date: Wed, 22 Aug 2012 10:36:29 -0400

> It seems as though, if evaluation forms that add 'time-stamp to various
> hooks that all run around the time a file is saved are deemed safe by
> default, surely evaluation forms that add 'delete-trailing-whitespace
> should equally be deemed safe by default.

Agreed, thanks.

> I have attached a patch at the end of this email that considers eval
> forms that add 'delete-trailing-whitespace to various hooks safe by
> default.

Actually, I wonder whether we want to accept/encourage those uses
instead of (add-hook 'before-save-hook 'delete-trailing-whitespace).

IOW I think we should only add the before-save-hook version but not
the others (and I guess the same holds for time-stamp, tho we'll
probably keep the other ones for time-stamp for backward-compatibility
reasons).

> But ideally this patch would be superseded by adding a mechanism that
> allows .dir-locals.el to add predefined functions to hooks (at least
> buffer local ones) without having to use eval.

Why?

> That way we wouldn't have to write patches such as this one for every
> new sensible stock function that people want to have executed on
> file saves.

You don't have to write patches like this one.  You can just customize
safe-local-eval-forms.  There is a problem, indeed, tho: if you
customize this var and we later add things to it, you'll keep using your
customized version and won't benefit from the expanded list.
So we should keep the default value of safe-local-eval-forms as nil, and
allow things like those add-hook some other way (e.g. a new var).

        Stefan