help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Temporarily suppress a hook?


From: Óscar Fuentes
Subject: Re: Temporarily suppress a hook?
Date: Mon, 09 Jul 2018 07:21:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Skip Montanaro <skip.montanaro@gmail.com> writes:

> I have before-save-hook defined in ~/.emacs
>
> (add-hook 'before-save-hook 'delete-trailing-whitespace)
>
> This is useful almost all the time. I just discovered a case where
> it's not so helpful (a file full of regular expressions to feed into
> "grep -E -f ..."
>
> I can think of various ways to tweak the regular expressions to not
> require trailing whitespace, but let's assume for a moment that's not
> possible. Is it possible to suppress the before-save-hook on a
> per-file basis?

AFAIK, no. But you can use your own function instead of
delete-trailing-whitespace:

(defun my-delete-trailing-whitespace ()
  (interactive)
  (unless my-special-buffer
    (delete-trailing-whitespace)))

(add-hook 'before-save-hook 'my-delete-trailing-whitespace)

Or advice delete-trailing-whitespace.




reply via email to

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