unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "Óscar Fuentes" <ofv@wanadoo.es>
To: help-gnu-emacs@gnu.org
Subject: Re: Temporarily suppress a hook?
Date: Mon, 09 Jul 2018 07:21:12 +0200	[thread overview]
Message-ID: <87tvp97znb.fsf@telefonica.net> (raw)
In-Reply-To: CANc-5UxyGsbj91g9YH9fMhOQrT5fP_Zc2gybJzFxDeOrH8KXkw@mail.gmail.com

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.




  parent reply	other threads:[~2018-07-09  5:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-09  0:02 Temporarily suppress a hook? Skip Montanaro
2018-07-09  0:43 ` Drew Adams
2018-07-09  1:39   ` Skip Montanaro
2018-07-09 12:07     ` João Távora
2018-07-09  4:43 ` Bob Proulx
2018-07-09  5:21 ` Óscar Fuentes [this message]
2018-07-09  6:00   ` tomas
2018-07-09  7:53     ` Óscar Fuentes
2018-07-09 11:01     ` Skip Montanaro
2018-07-09 17:33       ` Marcin Borkowski
2018-07-09 14:41 ` Stefan Monnier
     [not found] <mailman.3286.1531094567.1292.help-gnu-emacs@gnu.org>
2018-07-12 17:43 ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvp97znb.fsf@telefonica.net \
    --to=ofv@wanadoo.es \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).