GNU bug report logs - #65864
[PATCH] Add option to save a buffer without running save hooks

Previous Next

Package: emacs;

Reported by: Daniel Martín <mardani29 <at> yahoo.es>

Date: Mon, 11 Sep 2023 10:28:02 UTC

Severity: wishlist

Tags: patch

Full log


View this message in rfc822 format

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Daniel Martín <mardani29 <at> yahoo.es>
Cc: 65864 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>
Subject: bug#65864: [PATCH] Add option to save a buffer without running save hooks
Date: Tue, 12 Sep 2023 08:59:39 -0400
> For example, I have `delete-trailing-whitespace' in my
> `before-save-hook', but for a particular buffer I wanted to save it
> without removing the trailing whitespace, because trailing whitespace
> was syntactically meaningful in that case (the buffer contained some
> Markdown-like source code).

So you needed it for use by a human rather than for use by ELisp code?

> I searched the Internet for some solutions and what I ended up doing is
> C-x C-q (to make the buffer read-only), C-x C-s, and C-x C-q to make the
> buffer writable again (from
> https://stackoverflow.com/questions/14913398/in-emacs-how-do-i-save-without-running-save-hooks).
> It felt a bit like a "hack".

It's a hack, indeed, and it could fail if the hook function was careful to
let-bind `inhibit-read-only`.

Personally I think I would have used `C-x h M-x write-region RET` (or
fixed my config since clearly having this hook function active for this
file is wrong).


        Stefan





This bug report was last modified 122 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.