diff options
| -rw-r--r-- | modules/flycheck-config.el | 5 | ||||
| -rw-r--r-- | modules/modeline-config.el | 7 | ||||
| -rw-r--r-- | tests/test-modeline-config-flycheck-segment.el | 36 |
3 files changed, 48 insertions, 0 deletions
diff --git a/modules/flycheck-config.el b/modules/flycheck-config.el index 8c3e2a7b8..e6dfb25e2 100644 --- a/modules/flycheck-config.el +++ b/modules/flycheck-config.el @@ -56,6 +56,11 @@ (checkdoc-arguments '(("sentence-end-double-space" nil) ("warn-escape" nil))) + ;; Modeline customization (rendered via mode-line-format in modeline-config.el). + ;; The count portion picks up `error' / `warning' faces because + ;; `flycheck-mode-line-color' stays t (the default). + (flycheck-mode-line-prefix "🐛") + (flycheck-mode-success-indicator " ✓") :config ;; use the load-path of the currently running Emacs instance diff --git a/modules/modeline-config.el b/modules/modeline-config.el index 7fc755949..771d960f0 100644 --- a/modules/modeline-config.el +++ b/modules/modeline-config.el @@ -231,6 +231,13 @@ Shows only in active window.") mode-line-format-right-align (:eval (when (fboundp 'cj/recording-modeline-indicator) (cj/recording-modeline-indicator))) + ;; Flycheck status: prefix + counts (or success indicator). Gated + ;; to the active window, and to buffers where flycheck has loaded + ;; and turned on, so the call is safe even before flycheck loads. + (:eval (when (and (mode-line-window-selected-p) + (bound-and-true-p flycheck-mode)) + (flycheck-mode-line-status-text))) + " " cj/modeline-vc-branch " " cj/modeline-misc-info diff --git a/tests/test-modeline-config-flycheck-segment.el b/tests/test-modeline-config-flycheck-segment.el new file mode 100644 index 000000000..208deaa72 --- /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 |
