diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-07 09:05:54 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-07 09:05:54 -0500 |
| commit | 4ece1ebb4487d3e565642e45d586f97172fe97ce (patch) | |
| tree | 5af6afbb683bcae92622b4c70922e5d6d27c6735 /tests/test-nerd-icons-config--color-dir.el | |
| parent | b3ef232a486382601b6788f0c1a1edeb3982075d (diff) | |
| download | dotemacs-4ece1ebb4487d3e565642e45d586f97172fe97ce.tar.gz dotemacs-4ece1ebb4487d3e565642e45d586f97172fe97ce.zip | |
fix: restore daemon icons and consolidate nerd-icons setup
I replaced the load-time icon-stub block in keyboard-compat with per-call :around advice that checks display-graphic-p against the rendering frame. The old block ran at module-load. Under daemon startup no frame exists yet, so display-graphic-p returned nil and the empty-string stubs installed permanently. Every GUI client connecting to that daemon then saw blanks. The new shape lets one daemon serve real icons to GUI clients and blanks to terminal clients.
I also pulled the nerd-icons-completion and nerd-icons-ibuffer integrations, the package install, and a new tint helper into modules/nerd-icons-config.el. Per-feature use stays in the consuming module (dashboard, dirvish, keyboard-compat). The malformed cons-cell on the marginalia hook in selection-framework.el got fixed in the move.
Added a default darkgoldenrod tint, a :filter-return advice on nerd-icons-icon-for-dir so dir icons pick up a color face, and a buffer-local face-remap in dired-mode-hook so plain files in dired render in shadow grey.
13 tests across 3 new files cover the per-call gate, the dir-color helper (idempotent under nerd-icons' memoized return strings), and the bulk-tint helper.
Diffstat (limited to 'tests/test-nerd-icons-config--color-dir.el')
| -rw-r--r-- | tests/test-nerd-icons-config--color-dir.el | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/test-nerd-icons-config--color-dir.el b/tests/test-nerd-icons-config--color-dir.el new file mode 100644 index 00000000..808c0dc3 --- /dev/null +++ b/tests/test-nerd-icons-config--color-dir.el @@ -0,0 +1,57 @@ +;;; test-nerd-icons-config--color-dir.el --- Tests for cj/--nerd-icons-color-dir -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for the :filter-return advice that attaches a color face to the +;; output of `nerd-icons-icon-for-dir'. Without this, directory icons render +;; in the buffer default face — so a face-remap of `default' (buffer-local +;; or global) catches the icons unintentionally. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'nerd-icons-config) + +(ert-deftest test-nerd-icons-config--color-dir-attaches-face () + "Normal: adds nerd-icons-yellow to the face stack of a propertized icon." + (let ((icon (propertize "X" 'face '(:family "Symbols Nerd Font Mono" :height 1.0)))) + (let ((result (cj/--nerd-icons-color-dir icon))) + (should (memq 'nerd-icons-yellow + (ensure-list (get-text-property 0 'face result))))))) + +(ert-deftest test-nerd-icons-config--color-dir-preserves-family () + "Normal: retains the original :family / :height attributes." + (let ((icon (propertize "X" 'face '(:family "Symbols Nerd Font Mono" :height 1.0)))) + (let* ((result (cj/--nerd-icons-color-dir icon)) + (face (get-text-property 0 'face result)) + (specs (ensure-list face)) + (plist (seq-find (lambda (x) (and (listp x) (plist-member x :family))) specs))) + (should (equal (plist-get plist :family) "Symbols Nerd Font Mono")) + (should (equal (plist-get plist :height) 1.0))))) + +(ert-deftest test-nerd-icons-config--color-dir-empty-string () + "Boundary: an empty icon string returns unchanged (no range to propertize)." + (let ((icon "")) + (should (equal (cj/--nerd-icons-color-dir icon) "")))) + +(ert-deftest test-nerd-icons-config--color-dir-non-string-passthrough () + "Error: a nil input returns nil rather than erroring." + (should-not (cj/--nerd-icons-color-dir nil))) + +(ert-deftest test-nerd-icons-config--color-dir-idempotent () + "Boundary: calling twice on the same icon adds the face only once. +nerd-icons memoizes its return strings — without this guard, repeated +renders would stack `nerd-icons-yellow' over and over on the cached string." + (let ((icon (propertize "X" 'face '(:family "Symbols Nerd Font Mono" :height 1.0)))) + (cj/--nerd-icons-color-dir icon) + (cj/--nerd-icons-color-dir icon) + (cj/--nerd-icons-color-dir icon) + (let* ((face (get-text-property 0 'face icon)) + (specs (ensure-list face)) + (yellows (cl-count 'nerd-icons-yellow specs))) + (should (= yellows 1))))) + +(provide 'test-nerd-icons-config--color-dir) +;;; test-nerd-icons-config--color-dir.el ends here |
