all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Skip Montanaro <skip.montanaro@gmail.com>
To: tomas@tuxteam.de
Cc: "Óscar Fuentes" <ofv@wanadoo.es>,
	"Help GNU Emacs" <help-gnu-emacs@gnu.org>
Subject: Re: Temporarily suppress a hook?
Date: Mon, 9 Jul 2018 06:01:16 -0500	[thread overview]
Message-ID: <CANc-5UyE2Z6pYcqz830jt+hzYnvdvT=V5qQtgHoUrmpbKKQL0A@mail.gmail.com> (raw)
In-Reply-To: <20180709060011.GB15665@tuxteam.de>

On Mon, Jul 9, 2018, 1:00 AM <tomas@tuxteam.de> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Mon, Jul 09, 2018 at 07:21:12AM +0200, Óscar Fuentes wrote:
> > Skip Montanaro <skip.montanaro@gmail.com> writes:
>
> [...]
>
> > 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.
>
> Or perhaps make the hook read a local variable you set in
> the file (see "file local variables") and act accordingly.
>
> This way you could declare whithin those special files that you
> don't want trailing space removed.
>

Thanks all. Óscar's idea seems to come closest to a solution. I might use
that to suppress the hook for files with, say, a ".txt" extension. Those
would benefit least from scrubbing all trailing whitespace. Or... I could
use a prefix argument and check to see if it's been set to a magic value.
C-u -7 C-x C-s. Assuming I can read any prefix arg set by the user.

Unfortunately, file local variables aren't too helpful here. "grep -f file"
reads a series of patterns from the named file, so interprets every line as
a pattern. While it might work to track on a file local variable section,
you run the risk of a line being a false positive match for a line in the
file(s) you're running grep against.

Skip

>


  parent reply	other threads:[~2018-07-09 11:01 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
2018-07-09  6:00   ` tomas
2018-07-09  7:53     ` Óscar Fuentes
2018-07-09 11:01     ` Skip Montanaro [this message]
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

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

  git send-email \
    --in-reply-to='CANc-5UyE2Z6pYcqz830jt+hzYnvdvT=V5qQtgHoUrmpbKKQL0A@mail.gmail.com' \
    --to=skip.montanaro@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=ofv@wanadoo.es \
    --cc=tomas@tuxteam.de \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.