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-segments.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-segments.el')
| -rw-r--r-- | tests/test-modeline-config-segments.el | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/tests/test-modeline-config-segments.el b/tests/test-modeline-config-segments.el new file mode 100644 index 00000000..580a7711 --- /dev/null +++ b/tests/test-modeline-config-segments.el @@ -0,0 +1,122 @@ +;;; test-modeline-config-segments.el --- small modeline segments -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for the small pure segment helpers added in the 2026-07-01 +;; modeline overhaul: macro indicator, remote-host tag, narrowing +;; indicator, position/region info, and the padding space. + +;;; Code: + +(require 'ert) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +(require 'modeline-config) + +;; ---------------------------- Macro Indicator -------------------------------- + +(ert-deftest test-modeline-config-macro-indicator-shows-when-defining () + "Normal: MACRO text with the error face while a macro is recording." + (let ((defining-kbd-macro t)) + (let ((s (cj/--modeline-macro-indicator))) + (should (stringp s)) + (should (string-match-p "MACRO" s)) + (should (eq (get-text-property (string-match "MACRO" s) 'face s) + 'error))))) + +(ert-deftest test-modeline-config-macro-indicator-nil-when-idle () + "Boundary: nil when no macro is being defined." + (let ((defining-kbd-macro nil)) + (should-not (cj/--modeline-macro-indicator)))) + +;; ---------------------------- Remote Host Tag -------------------------------- + +(ert-deftest test-modeline-config-remote-host-shows-host () + "Normal: remote default-directory yields an @host tag." + (with-temp-buffer + (setq default-directory "/ssh:velox:/home/cjennings/") + (let ((s (cj/--modeline-remote-host))) + (should (stringp s)) + (should (string-match-p "@velox" s))))) + +(ert-deftest test-modeline-config-remote-host-nil-when-local () + "Boundary: nil for a local directory." + (with-temp-buffer + (setq default-directory "/tmp/") + (should-not (cj/--modeline-remote-host)))) + +;; --------------------------- Narrowing Indicator ----------------------------- + +(ert-deftest test-modeline-config-narrow-indicator-shows-when-narrowed () + "Normal: narrowed buffer yields the Narrow tag." + (with-temp-buffer + (insert "line one\nline two\nline three\n") + (narrow-to-region 1 9) + (let ((s (cj/--modeline-narrow-indicator))) + (should (stringp s)) + (should (string-match-p "Narrow" s))))) + +(ert-deftest test-modeline-config-narrow-indicator-nil-when-widened () + "Boundary: nil when the buffer is not narrowed." + (with-temp-buffer + (insert "text") + (should-not (cj/--modeline-narrow-indicator)))) + +;; --------------------------- Position / Region Info --------------------------- + +(ert-deftest test-modeline-config-position-info-line-column-percent () + "Normal: no region yields L: C: plus a percentage-through-buffer." + (with-temp-buffer + (insert (make-string 200 ?x)) + (goto-char (point-min)) + (deactivate-mark) + (let ((s (cj/--modeline-position-info))) + (should (stringp s)) + (should (string-match-p "L:" s)) + (should (string-match-p "C:" s)) + ;; point-based percent, %%-escaped for the mode-line construct pass + (should (string-match-p "%" s))))) + +(ert-deftest test-modeline-config-position-info-region-lines-chars () + "Normal: an active region yields selection info instead of position." + (with-temp-buffer + (insert "one\ntwo\nthree\n") + (goto-char (point-min)) + (push-mark (point) t t) + (goto-char 9) ; through "one\ntwo\n" + (let ((transient-mark-mode t)) + (let ((s (cj/--modeline-position-info))) + (should (stringp s)) + (should (string-match-p "2 lines" s)) + (should (string-match-p "8 chars" s)))))) + +(ert-deftest test-modeline-config-position-info-single-char-region () + "Boundary: a one-char region reports 1 line, 1 char." + (with-temp-buffer + (insert "abc") + (goto-char 1) + (push-mark (point) t t) + (goto-char 2) + (let ((transient-mark-mode t)) + (let ((s (cj/--modeline-position-info))) + (should (string-match-p "1 line" s)) + (should (string-match-p "1 char" s)))))) + +;; ------------------------------- Padding -------------------------------------- + +(ert-deftest test-modeline-config-padding-carries-height-display () + "Normal: padding space carries a display height property." + (let ((cj/modeline-height-factor 1.2)) + (let ((s (cj/--modeline-padding))) + (should (stringp s)) + (should (get-text-property 0 'display s))))) + +(ert-deftest test-modeline-config-padding-plain-at-factor-one () + "Boundary: factor 1.0 (or nil) yields a plain space, no display prop." + (let ((cj/modeline-height-factor 1.0)) + (let ((s (cj/--modeline-padding))) + (should (stringp s)) + (should-not (get-text-property 0 'display s))))) + +(provide 'test-modeline-config-segments) +;;; test-modeline-config-segments.el ends here |
