From e0519098d98fb114660fbc092972d711b6864853 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 17 Feb 2019 22:12:52 -0500 Subject: [PATCH] (Almost) always highlight non-default indentation The purpose of this is to highlight indentation characters that betray your indent-tabs-mode setting. i.e. If you're using tab indentation, highlight space indentation. If you're using spaces, highlight tab characters. --- core/core-ui.el | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/core/core-ui.el b/core/core-ui.el index d0fe3ba96..9a2b0ee58 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -459,19 +459,23 @@ instead). Meant for `kill-buffer-query-functions'." (not (eq (current-buffer) (doom-fallback-buffer)))) (defun doom|highlight-non-default-indentation () - "Highlight whitespace that doesn't match your `indent-tabs-mode' setting." + "Highlight whitespace that doesn't match your `indent-tabs-mode' setting. + +e.g. If you indent with spaces by default, tabs will be highlighted. If you +indent with tabs, spaces at BOL are highlighted. + +Does nothing if `whitespace-mode' is already active or the current major mode is +derived from `special-mode'." (unless (or (bound-and-true-p global-whitespace-mode) (bound-and-true-p whitespace-mode) - (eq indent-tabs-mode (default-value 'indent-tabs-mode)) (eq major-mode 'fundamental-mode) (derived-mode-p 'special-mode)) (require 'whitespace) (set (make-local-variable 'whitespace-style) - (if (or (bound-and-true-p whitespace-mode) - (bound-and-true-p whitespace-newline-mode)) - (cl-union (if indent-tabs-mode '(spaces space-mark) '(tabs tab-mark)) + (if (bound-and-true-p whitespace-newline-mode) + (cl-union (if indent-tabs-mode '(indentation) '(tabs tab-mark)) whitespace-style) - `(face ,@(if indent-tabs-mode '(spaces space-mark) '(tabs tab-mark)) + `(face ,@(if indent-tabs-mode '(indentation) '(tabs tab-mark)) trailing-lines tail))) (whitespace-mode +1)))