From 37d92510afbaea8609e8aa3612c6e9d27edba12d Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Thu, 2 Jul 2026 00:00:41 -0400 Subject: 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. --- tests/test-modeline-config-buffer-status.el | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 tests/test-modeline-config-buffer-status.el (limited to 'tests/test-modeline-config-buffer-status.el') diff --git a/tests/test-modeline-config-buffer-status.el b/tests/test-modeline-config-buffer-status.el new file mode 100644 index 00000000..123f1062 --- /dev/null +++ b/tests/test-modeline-config-buffer-status.el @@ -0,0 +1,73 @@ +;;; test-modeline-config-buffer-status.el --- buffer-status segment -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for `cj/--modeline-buffer-status': the modified / read-only +;; indicator. Read-only wins over modified; the modified dot shows only +;; for file-visiting buffers (special buffers are perpetually modified +;; and would be noise); clean file buffers show nothing. + +;;; Code: + +(require 'ert) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) + +(require 'modeline-config) + +(ert-deftest test-modeline-config-buffer-status-modified-file-shows-dot () + "Normal: a modified file-visiting buffer returns the warning-faced dot." + (let ((file (make-temp-file "modeline-status-" nil ".txt"))) + (unwind-protect + (with-current-buffer (find-file-noselect file) + (insert "x") + (let ((status (cj/--modeline-buffer-status))) + (should (stringp status)) + (should (string-match-p "●" status)) + (should (eq (get-text-property + (string-match "●" status) 'face status) + 'warning))) + (set-buffer-modified-p nil) + (kill-buffer)) + (delete-file file)))) + +(ert-deftest test-modeline-config-buffer-status-clean-file-nil () + "Normal: an unmodified file-visiting buffer returns nil." + (let ((file (make-temp-file "modeline-status-" nil ".txt"))) + (unwind-protect + (with-current-buffer (find-file-noselect file) + (should-not (cj/--modeline-buffer-status)) + (kill-buffer)) + (delete-file file)))) + +(ert-deftest test-modeline-config-buffer-status-read-only-shows-lock () + "Normal: a read-only buffer returns the read-only indicator." + (with-temp-buffer + (setq buffer-read-only t) + (let ((status (cj/--modeline-buffer-status))) + (should (stringp status)) + (should (> (length status) 0))))) + +(ert-deftest test-modeline-config-buffer-status-read-only-wins-over-modified () + "Boundary: read-only + modified shows the read-only indicator, not the dot." + (let ((file (make-temp-file "modeline-status-" nil ".txt"))) + (unwind-protect + (with-current-buffer (find-file-noselect file) + (insert "x") + (setq buffer-read-only t) + (let ((status (cj/--modeline-buffer-status))) + (should (stringp status)) + (should-not (string-match-p "●" status))) + (setq buffer-read-only nil) + (set-buffer-modified-p nil) + (kill-buffer)) + (delete-file file)))) + +(ert-deftest test-modeline-config-buffer-status-modified-non-file-nil () + "Boundary: a modified non-file buffer (scratch-like) returns nil." + (with-temp-buffer + (insert "x") + (should (buffer-modified-p)) + (should-not (cj/--modeline-buffer-status)))) + +(provide 'test-modeline-config-buffer-status) +;;; test-modeline-config-buffer-status.el ends here -- cgit v1.2.3