diff --git a/core/core-editor.el b/core/core-editor.el index fcd88a23e..0382d924e 100644 --- a/core/core-editor.el +++ b/core/core-editor.el @@ -36,16 +36,7 @@ modes are active and the buffer is read-only.") tabify-regexp "^\t* [ \t]+" ; for :retab ;; Wrapping truncate-lines t - truncate-partial-width-windows 50 - ;; whitespace-mode - whitespace-line-column nil - whitespace-style - '(face indentation tabs tab-mark spaces space-mark newline newline-mark - trailing lines-tail) - whitespace-display-mappings - '((tab-mark ?\t [?› ?\t]) - (newline-mark ?\n [?¬ ?\n]) - (space-mark ?\ [?·] [?.]))) + truncate-partial-width-windows 50) ;; ediff (setq ediff-diff-options "-w" diff --git a/core/core-ui.el b/core/core-ui.el index a6292cd8a..cfe5b95c6 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -279,6 +279,31 @@ DEFAULT is non-nil, set the default mode-line for all buffers." (remove-hook 'kill-buffer-query-functions 'server-kill-buffer-query-function)) (add-hook 'server-visit-hook 'server-remove-kill-buffer-hook) +;; whitespace-mode settings +(setq whitespace-line-column nil + whitespace-style + '(face indentation tabs tab-mark spaces space-mark newline newline-mark + trailing lines-tail) + whitespace-display-mappings + '((tab-mark ?\t [?› ?\t]) + (newline-mark ?\n [?¬ ?\n]) + (space-mark ?\ [?·] [?.]))) + +(defun doom|show-whitespace-maybe () + "Show whitespace-mode when file has an `indent-tabs-mode' that is different +from the default." + (unless (eq indent-tabs-mode (default-value 'indent-tabs-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 '(tabs tab-mark) '(spaces space-mark)) + whitespace-style) + `(face ,@(if indent-tabs-mode '(tabs tab-mark) '(spaces space-mark)) + trailing-lines tail))) + (whitespace-mode +1))) +(add-hook 'after-change-major-mode-hook #'doom|show-whitespace-maybe) + ;; ;; Custom hooks