Skip to content

Latest commit

 

History

History
29 lines (24 loc) · 1.62 KB

Disabling Whitespace Mode in Magit Buffers.md

File metadata and controls

29 lines (24 loc) · 1.62 KB

Tags: #emacs #git #magit

The following Lisp code disables whitespace-mode in Magit's log, revision, and status modes:

;; don't highlight whitespace when we're using Magit.  commit messages, long
;; lines in diffs, and commit metadata regularly have long lines and we don't
;; need to have them flagged (since we can't do anything about them).
(setq whitespace-global-modes '(not magit-diff-mode
                                    magit-log-mode
                                    magit-refs-mode
                                    magit-revision-mode
                                    magit-status-mode))

We need to directly configure whitespace-mode to ignore Magit-related buffers as it runs its hooks after Magit's mode hooks are evaluated. If one is was to do the following, then whitespace-mode would be disabled for each Magit buffer and then immediately re-enabled:

(eval-after-load "magit"
  '(progn
     (add-hook 'magit-status-mode-hook 'turn-off-whitespace-mode)
     (add-hook 'magit-revision-mode-hook 'turn-off-whitespace-mode)
     (add-hook 'magit-log-mode-hook 'turn-off-whitespace-mode)))

The Magit magit-*-section-hook's are not the right answer as those are used for adding content into the Magit buffers, rather than when a buffer is created.

Unfortunately these easily found references are red herrings: