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

From: Stefan Monnier <[email-masked]>
Date: Mon, 11 Sep 2023 18:28:59 -0400

>> Users can customize `before-save-hook' to add things like
>> `delete-trailing-whitespace' or `copyright-update'.  However, there are
>> cases where you want to save a buffer without running any save hooks
>> without changing your configuration and then changing it back.

Do you have concrete examples, to helps us assess what's really at stake
here?  Maybe there are other ways to look at the problem :-)

"without running any save hooks" at all really?  Like without running
`write-contents-functions`, nor `write-file-functions`, nor
`write-region-annotat-functions`, nor `make-backup-file-name-function`, ...?
How 'bout the file-name-handlers, then?

Maybe `write-region` would be a better starting point than `buffer-save`?

>> I've attached a patch to make `save-buffer', when invoked with a
>> negative argument (C-u - C-x C-s), temporarily avoid running any save
>> hooks.
>
> Should we perhaps consider a more general approach: run a command
> while disabling the hooks it calls?  It sounds strange to me to single
> out just this one command.

Hmm... sounds iffy.  I generally prefer ordering a plain burger than
ordering a "cheeseburger but hold the cheese" :-)

IOW, provide *another* function which performs the core operation.
[ And we usually do that.  ]

        Stefan