Subject: bug#40481: 26.3; whitespace-enable-predicate: consider using derived-mode-p

From: Jack Kelly <[email-masked]>
Date: Tue, 07 Apr 2020 19:25:56 +1000

I use whitespace-global-mode to turn on whitespace highlighting in most
buffers. In my version of emacs, modes can be blacklisted by setting
`whitespace-global-modes' to e.g., `(not foo-mode bar-mode)'.

This is implemented by `whitespace-enable-predicate', which calls
`(not (memq major-mode (cdr whitespace-global-modes)))`.

I am a heavy user of magit, and find whitespace highlighting distracting
when using it. Magit implements a lot of modes, all inheriting from a
common `magit-mode'. I would like to blacklist all such modes from
`whitespace-mode', which I have currently done with the following
advice:

(add-function :filter-return whitespace-enable-predicate
   (lambda (ret) (and ret (not (derived-mode-p 'magit-mode)))))

It would be quite convenient if `whitespace-enable-predicate' called
`derived-mode-p' instead of `memq major-mode'.