aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-16 01:13:12 -0500
committerCraig Jennings <c@cjennings.net>2026-06-16 01:13:12 -0500
commit202cf4306d10128de79fefad26d14a1719f04d1e (patch)
treed3e5200bccaeb4bb1dbe672ab36396fb173ecc8b
parentc1869fb1a320cf11a92ddf422136cbe450deaf5e (diff)
downloaddotemacs-202cf4306d10128de79fefad26d14a1719f04d1e.tar.gz
dotemacs-202cf4306d10128de79fefad26d14a1719f04d1e.zip
fix(dashboard): exclude dashboard-mode from global font-lock
The dashboard banner title and section headings render in the default face instead of their theme colors. The faces are defined correctly. Global font-lock fontifies the dashboard buffer and strips the `face' text properties dashboard sets by hand: it owns `face' and clears props it didn't apply. Items and the navigator survive because their color rides a dashboard-items-face overlay, which font-lock leaves alone. Excluding dashboard-mode from global font-lock keeps the banner and heading faces. I set it at top level so it applies regardless of the use-package body.
-rw-r--r--modules/dashboard-config.el9
-rw-r--r--tests/test-dashboard-config-font-lock.el35
2 files changed, 44 insertions, 0 deletions
diff --git a/modules/dashboard-config.el b/modules/dashboard-config.el
index 43e2182ee..3f3b1996e 100644
--- a/modules/dashboard-config.el
+++ b/modules/dashboard-config.el
@@ -161,6 +161,15 @@ system-defaults) are preserved rather than overwritten."
(require 'recentf)
(add-to-list 'recentf-exclude "/emms/history"))
+;; Keep global font-lock out of the dashboard buffer. Dashboard colors its
+;; banner title (`dashboard-banner-logo-title') and section headings
+;; (`dashboard-heading') with the `face' text property; `global-font-lock-mode'
+;; owns `face' and strips manually-applied ones it didn't set, so with font-lock
+;; running the banner and headings fall back to the default face. Excluding
+;; dashboard-mode lets those text-property faces survive. (Item and navigator
+;; colors ride a `dashboard-items-face' overlay, which font-lock leaves alone.)
+(setq font-lock-global-modes '(not dashboard-mode))
+
(use-package dashboard
:demand t
:hook (emacs-startup . cj/dashboard-only)
diff --git a/tests/test-dashboard-config-font-lock.el b/tests/test-dashboard-config-font-lock.el
new file mode 100644
index 000000000..d55909723
--- /dev/null
+++ b/tests/test-dashboard-config-font-lock.el
@@ -0,0 +1,35 @@
+;;; test-dashboard-config-font-lock.el --- dashboard-mode excluded from global font-lock -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; `global-font-lock-mode' fontifies the *dashboard* buffer and strips the
+;; manually-applied `face' text properties dashboard puts on the banner title
+;; (`dashboard-banner-logo-title') and the section headings
+;; (`dashboard-heading'), so they render in the default face instead of the
+;; theme colors. dashboard-config excludes dashboard-mode from global
+;; font-lock so those text-property faces survive.
+
+;;; Code:
+
+(require 'ert)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
+
+;; Stub package-level deps dashboard-config pulls transitively.
+(unless (fboundp 'cj/kill-all-other-buffers-and-windows)
+ (defun cj/kill-all-other-buffers-and-windows () nil))
+(unless (fboundp 'cj/make-buffer-undead)
+ (defun cj/make-buffer-undead (_name) nil))
+
+(require 'dashboard-config)
+
+(ert-deftest test-dashboard-config-excludes-dashboard-mode-from-global-font-lock ()
+ "Normal: dashboard-mode is excluded from `font-lock-global-modes'.
+Global font-lock must not run in the dashboard buffer, or it strips the
+manual face text properties dashboard applies to the banner and headings."
+ (should (consp font-lock-global-modes))
+ (should (eq (car font-lock-global-modes) 'not))
+ (should (memq 'dashboard-mode (cdr font-lock-global-modes))))
+
+(provide 'test-dashboard-config-font-lock)
+;;; test-dashboard-config-font-lock.el ends here