From 1681bfbaf05587efc9a63667d25652701ae6103c Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 23 Apr 2025 20:19:52 -0400 Subject: [PATCH] refactor: move doom-highlight-non-default-indentation-h out of core This functionality falls under the umbrella of "better defaults" rather than essential defaults, and so belongs in :config default. Whats more, the naming convention (+emacs-...) was intentional, because this function (and the :config default module) will be moved to :doom emacs in the near future. This also indirectly fixes #8373. Fix: #8373 --- lisp/doom-ui.el | 22 ---------------------- modules/config/default/config.el | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/lisp/doom-ui.el b/lisp/doom-ui.el index 944b49e10..ca1469fb7 100644 --- a/lisp/doom-ui.el +++ b/lisp/doom-ui.el @@ -152,27 +152,6 @@ the frame through some other means.") "Don't kill the scratch buffer. Meant for `kill-buffer-query-functions'." (not (eq (current-buffer) (doom-fallback-buffer)))) -(defun doom-highlight-non-default-indentation-h () - "Highlight whitespace at odds with `indent-tabs-mode'. -That is, highlight tabs if `indent-tabs-mode' is `nil', and highlight spaces at -the beginnings of lines if `indent-tabs-mode' is `t'. The purpose is to make -incorrect indentation in the current buffer obvious to you. - -Does nothing if `whitespace-mode' or `global-whitespace-mode' is already active -or if the current buffer is read-only or not file-visiting." - (unless (or (eq major-mode 'fundamental-mode) - (bound-and-true-p global-whitespace-mode) - (null buffer-file-name)) - (require 'whitespace) - (set (make-local-variable 'whitespace-style) - (cl-union (if indent-tabs-mode - '(indentation) - '(tabs tab-mark)) - (when whitespace-mode - (remq 'face whitespace-active-style)))) - (cl-pushnew 'face whitespace-style) ; must be first - (whitespace-mode +1))) - ;; ;;; General UX @@ -706,7 +685,6 @@ triggering hooks during startup." (doom-run-hooks 'doom-init-ui-hook) (add-hook 'kill-buffer-query-functions #'doom-protect-fallback-buffer-h) - (add-hook 'after-change-major-mode-hook #'doom-highlight-non-default-indentation-h 'append) ;; Make `next-buffer', `other-buffer', etc. ignore unreal buffers. (push '(buffer-predicate . doom-buffer-frame-predicate) default-frame-alist) diff --git a/modules/config/default/config.el b/modules/config/default/config.el index cf399b3b3..9a47242fa 100644 --- a/modules/config/default/config.el +++ b/modules/config/default/config.el @@ -83,6 +83,31 @@ (setq tramp-default-method "ssh")) ; faster than the default scp +;;;###package whitespace +(add-hook! 'after-change-major-mode-hook :append + (defun +emacs-highlight-non-default-indentation-h () + "Highlight whitespace at odds with `indent-tabs-mode'. +That is, highlight tabs if `indent-tabs-mode' is `nil', and highlight spaces at +the beginnings of lines if `indent-tabs-mode' is `t'. The purpose is to make +incorrect indentation in the current buffer obvious to you. + +Does nothing if `whitespace-mode' or `global-whitespace-mode' is already active +or if the current buffer is read-only or not file-visiting." + (unless (or (eq major-mode 'fundamental-mode) + (bound-and-true-p global-whitespace-mode) + (null buffer-file-name) + buffer-read-only) + (require 'whitespace) + (set (make-local-variable 'whitespace-style) + (cl-union (if indent-tabs-mode + '(indentation) + '(tabs tab-mark)) + (when whitespace-mode + (remq 'face whitespace-active-style)))) + (cl-pushnew 'face whitespace-style) ; must be first + (whitespace-mode +1)))) + + ;; ;;; Smartparens config