aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-16 02:12:56 -0500
committerCraig Jennings <c@cjennings.net>2026-05-16 02:12:56 -0500
commitadca2736e2e3ef1eef1aaf62542aa2189a560463 (patch)
tree8c3b6449e08869eda05aba1da2544b3b5be4c291 /tests
parent19240036f89422dcaba3f0e3c3a822c92b0f35c1 (diff)
downloaddotemacs-adca2736e2e3ef1eef1aaf62542aa2189a560463.tar.gz
dotemacs-adca2736e2e3ef1eef1aaf62542aa2189a560463.zip
feat(modeline): surface flycheck status in the custom modeline
The custom modeline builds `mode-line-format` from explicit segments and skips `minor-mode-alist`, so flycheck's lighter never appears. That hid error and warning counts even in buffers where flycheck was auto-enabling (every emacs-lisp and sh buffer). The fix is Option 4 from the design doc: customize the flycheck modeline variables, then add a single guarded `(:eval ...)` form to `mode-line-format`. Five new lines total, two-file change. `modules/flycheck-config.el` :custom block gets: (flycheck-mode-line-prefix "🐛") (flycheck-mode-success-indicator " ✓") `flycheck-mode-line-color` stays default-t so error / warning counts pick up their faces automatically. `modules/modeline-config.el` `mode-line-format` gets an `(:eval ...)` between the recording indicator and `cj/modeline-vc-branch`: (:eval (when (and (mode-line-window-selected-p) (bound-and-true-p flycheck-mode)) (flycheck-mode-line-status-text))) The `mode-line-window-selected-p` guard mirrors `cj/modeline-vc-branch` and `cj/modeline-misc-info` -- segments hide in inactive windows. The `bound-and-true-p flycheck-mode` guard keeps the form silent in buffers where flycheck hasn't loaded or isn't enabled, which is safer than referencing `flycheck-mode` directly. The `(:eval ...)` is inline rather than a named `defvar-local`, so no addition to the risky-local-variable list is needed. `tests/test-modeline-config-flycheck-segment.el` -- 3 smoke tests asserting the segment is present and both guards are in place. All existing tests stay green. Manual verification (per the design doc) is the user's call -- the emoji prefix and the colored count behavior need a running GUI Emacs to observe.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-modeline-config-flycheck-segment.el36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test-modeline-config-flycheck-segment.el b/tests/test-modeline-config-flycheck-segment.el
new file mode 100644
index 00000000..208deaa7
--- /dev/null
+++ b/tests/test-modeline-config-flycheck-segment.el
@@ -0,0 +1,36 @@
+;;; test-modeline-config-flycheck-segment.el --- Flycheck segment in modeline -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Smoke test that the custom modeline's `mode-line-format' includes
+;; a guarded reference to `flycheck-mode-line-status-text', and that
+;; the guard requires both `mode-line-window-selected-p' and
+;; `bound-and-true-p flycheck-mode'. See
+;; docs/design/flycheck-modeline-customization.org for the design.
+
+;;; Code:
+
+(require 'ert)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+
+(require 'modeline-config)
+
+(ert-deftest test-modeline-config-flycheck-segment-present ()
+ "`mode-line-format' contains an :eval form invoking flycheck-mode-line-status-text."
+ (let ((printed (format "%S" (default-value 'mode-line-format))))
+ (should (string-match-p "flycheck-mode-line-status-text" printed))))
+
+(ert-deftest test-modeline-config-flycheck-segment-guarded-by-active-window ()
+ "Flycheck segment gates on `mode-line-window-selected-p'."
+ (let ((printed (format "%S" (default-value 'mode-line-format))))
+ (should (string-match-p "mode-line-window-selected-p" printed))))
+
+(ert-deftest test-modeline-config-flycheck-segment-guarded-by-flycheck-mode ()
+ "Flycheck segment gates on `bound-and-true-p flycheck-mode'.
+The `bound-and-true-p' guard makes the form safe in buffers where
+flycheck never loaded."
+ (let ((printed (format "%S" (default-value 'mode-line-format))))
+ (should (string-match-p "bound-and-true-p flycheck-mode" printed))))
+
+(provide 'test-modeline-config-flycheck-segment)
+;;; test-modeline-config-flycheck-segment.el ends here