Subject: Re: bug#65864: [PATCH] Add option to save a buffer without running save hooks

From: Stefan Monnier <[email-masked]>
Date: Wed, 12 Feb 2025 10:51:56 -0500

> My use case for disabling `before-save-hook` with a prefix argument is
> that in `emacs-lisp-mode`, I have this `before-save-hook`:
>
>     (aggressive-indent--process-changed-list-and-indent
>      ws-butler-before-save time-stamp)
>
> Sometimes, I would really like to disable all three when saving.
> Now, I can of course disable the modes, run special commands for
> time-stamp, and so on.  It just seems less convenient.

Maybe a `grep before-save-hook Emacs (Non)GNU ELPA MELPA` would be
a good way to see how whether `before-save-hook` is used only for such
"optional" functionality, which would be a good argument in favor of the
patch (tho I'd then update the doc of `before-save-hook` to mention that
it's not guaranteed it's run, so it's meant for "nice to have but not
indispensable" processing).

Also, Daniel's patch does the same with `after-save-hook` so we'd need
to do the same analysis with that hook.

> That could work, but yes hackish, and wouldn't it mean that we'd have to
> potentially reproduce the hack in `ws-butler-mode`, `check-parens`,
> `delete-trailing-whitespace`, and so on?

Maybe.  Then again, if people have `time-stamp` and `check-parens` on
their hook and they use `C-u - C-x C-s` to "save without bumping
time-stamp", they might be disappointed if the parens happen to be
unbalanced.

        Stefan