diff options
| author | Craig Jennings <c@cjennings.net> | 2026-07-02 00:00:41 -0400 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-07-02 00:00:41 -0400 |
| commit | 37d92510afbaea8609e8aa3612c6e9d27edba12d (patch) | |
| tree | 78820bdb59e4f8334528dcc490b63151e619d0ac /tests/test-modeline-config-flycheck-render.el | |
| parent | 60560d1eb346c76de355a524e78ae389e8e07807 (diff) | |
| download | dotemacs-37d92510afbaea8609e8aa3612c6e9d27edba12d.tar.gz dotemacs-37d92510afbaea8609e8aa3612c6e9d27edba12d.zip | |
feat(modeline): mode icons, status segments, and a repair command
I rebuilt the custom modeline as pure segment helpers with thin :eval wiring:
- The nerd-icons mode icon replaces the mode-name text (cached per buffer, plain name on terminal frames), with the full mode name in the help-echo.
- New left-side segments: modified dot / read-only lock (file buffers only), remote @host tag, Narrow tag that widens on click, point-based percentage, region selection info, and a MACRO tag while a keyboard macro records.
- New right-side segments: mode-line-process (eat and compilation state was invisible) and flycheck per-severity counts with click-through to the error list, replacing the stock status text. Glyphs are nerd-icons private-use codepoints so emojify can't rewrite them, with text fallbacks when icons are unavailable.
- cj/modeline-reset kills a hijacked buffer-local mode-line-format (two-column mode, ediff, calc).
- Optional taller bar via cj/modeline-height-factor, a display height property on the padding space so the theme's mode-line faces stay untouched.
- Housekeeping: the dead user-constants require and stale commentary are gone, cj/modeline-vc-faces left the risky-local-variable list, and the cache-key defun is cj/--modeline-vc-cache-key so it no longer shadows the same-named defvar.
Percent signs from :eval strings go through the mode-line %-construct pass, so the position segment emits %% for a literal percent.
Diffstat (limited to 'tests/test-modeline-config-flycheck-render.el')
| -rw-r--r-- | tests/test-modeline-config-flycheck-render.el | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/test-modeline-config-flycheck-render.el b/tests/test-modeline-config-flycheck-render.el new file mode 100644 index 00000000..46d0cdef --- /dev/null +++ b/tests/test-modeline-config-flycheck-render.el @@ -0,0 +1,51 @@ +;;; test-modeline-config-flycheck-render.el --- flycheck counts rendering -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for `cj/--modeline-flycheck-render', the pure formatter that +;; turns a flycheck counts alist ((error . N) (warning . M) ...) into a +;; propertized modeline string. Errors carry the error face, warnings +;; the warning face; zero-count severities are omitted; an all-clean +;; alist (or nil) renders nothing. Glyphs come from nerd-icons when +;; available (private-use codepoints, safe from emojify) with plain-text +;; fallbacks in batch mode. + +;;; Code: + +(require 'ert) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +(require 'modeline-config) + +(ert-deftest test-modeline-config-flycheck-render-errors-and-warnings () + "Normal: both counts render, error face on errors, warning on warnings." + (let ((s (cj/--modeline-flycheck-render '((error . 2) (warning . 5))))) + (should (stringp s)) + (should (string-match-p "2" s)) + (should (string-match-p "5" s)) + (let ((epos (string-match "2" s)) + (wpos (string-match "5" s))) + (should (eq (get-text-property epos 'face s) 'error)) + (should (eq (get-text-property wpos 'face s) 'warning))))) + +(ert-deftest test-modeline-config-flycheck-render-errors-only () + "Normal: warnings absent when their count is zero or missing." + (let ((s (cj/--modeline-flycheck-render '((error . 3))))) + (should (stringp s)) + (should (string-match-p "3" s)) + (should-not (text-property-any 0 (length s) 'face 'warning s)))) + +(ert-deftest test-modeline-config-flycheck-render-clean-nil () + "Boundary: zero counts render nothing." + (should-not (cj/--modeline-flycheck-render '((error . 0) (warning . 0))))) + +(ert-deftest test-modeline-config-flycheck-render-nil-input () + "Boundary: nil counts alist renders nothing." + (should-not (cj/--modeline-flycheck-render nil))) + +(ert-deftest test-modeline-config-flycheck-render-info-ignored () + "Boundary: info-level counts alone render nothing (errors/warnings only)." + (should-not (cj/--modeline-flycheck-render '((info . 4))))) + +(provide 'test-modeline-config-flycheck-render) +;;; test-modeline-config-flycheck-render.el ends here |
