diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-06 07:38:46 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-06 07:38:46 -0500 |
| commit | adee44df124e8983084737c50e9c767edd70aea8 (patch) | |
| tree | a16536b472f309704bafe4edc389d343d92556d7 /tests | |
| parent | ecfc66294e57788df715c98297ef425fd9dbd9ef (diff) | |
| download | pearl-adee44df124e8983084737c50e9c767edd70aea8.tar.gz pearl-adee44df124e8983084737c50e9c767edd70aea8.zip | |
feat(render): make heading glyphs configurable
The Comments container heading rendered bare. It carries no Linear id, so the id-keyed overlay never glyphed it, while each comment already showed a balloon. I gave the container its own glyph and split them so the thread and its items read as a hierarchy: a filled balloon (๐ฌ) on the Comments header, an outline bubble (๐จ๏ธ) on each comment, the ticket (๐ซ) unchanged on issues.
I promoted the two glyph constants to defcustoms and added pearl-comments-header-glyph, so any glyph can be changed or dropped to empty while pearl-show-glyphs stays the master switch. The header glyph rides the same display overlay as the others, so the buffer text stays a bare Comments and sync and merge are untouched. The Comments header is now found by one glyph-agnostic regexp, replacing two copies of the old ๐ฌ-only matcher.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-pearl-glyphs.el | 67 |
1 files changed, 57 insertions, 10 deletions
diff --git a/tests/test-pearl-glyphs.el b/tests/test-pearl-glyphs.el index 78a4c2d..c2e9e7f 100644 --- a/tests/test-pearl-glyphs.el +++ b/tests/test-pearl-glyphs.el @@ -48,14 +48,23 @@ (ert-deftest test-pearl-heading-glyph-comment-wins () "A comment id selects the comment glyph even when an issue id is also present." - (should (equal (pearl--heading-glyph "c1" "i1") pearl--comment-glyph))) + (should (equal (pearl--heading-glyph "c1" "i1") pearl-comment-glyph))) (ert-deftest test-pearl-heading-glyph-issue () "An issue id with no comment id selects the ticket glyph." - (should (equal (pearl--heading-glyph nil "i1") pearl--ticket-glyph))) + (should (equal (pearl--heading-glyph nil "i1") pearl-ticket-glyph))) + +(ert-deftest test-pearl-heading-glyph-header () + "No id but the header flag selects the Comments-header glyph." + (should (equal (pearl--heading-glyph nil nil t) pearl-comments-header-glyph))) + +(ert-deftest test-pearl-heading-glyph-id-wins-over-header () + "A Linear id outranks the header flag." + (should (equal (pearl--heading-glyph "c1" nil t) pearl-comment-glyph)) + (should (equal (pearl--heading-glyph nil "i1" t) pearl-ticket-glyph))) (ert-deftest test-pearl-heading-glyph-none () - "A heading with neither id gets no glyph." + "A heading with no id and no header flag gets no glyph." (should (null (pearl--heading-glyph nil nil)))) ;;; --apply-heading-glyphs (overlay placement) @@ -68,7 +77,7 @@ (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) (should (= (length ovs) 1)) - (should (string-match-p (regexp-quote pearl--ticket-glyph) + (should (string-match-p (regexp-quote pearl-ticket-glyph) (overlay-get (car ovs) 'display))))))) (ert-deftest test-pearl-apply-glyphs-comment-heading () @@ -79,9 +88,30 @@ (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) (should (= (length ovs) 1)) - (should (string-match-p (regexp-quote pearl--comment-glyph) + (should (string-match-p (regexp-quote pearl-comment-glyph) (overlay-get (car ovs) 'display))))))) +(ert-deftest test-pearl-apply-glyphs-comments-header () + "The Comments container heading (no Linear id) gets the header-glyph overlay." + (test-pearl-glyphs--in-org + "*** Comments 2/2\n" + (let ((pearl-show-glyphs t) + (pearl-comments-header-glyph "๐ฌ")) + (pearl--apply-heading-glyphs) + (let ((ovs (test-pearl-glyphs--overlays))) + (should (= (length ovs) 1)) + (should (string-match-p (regexp-quote "๐ฌ") + (overlay-get (car ovs) 'display))))))) + +(ert-deftest test-pearl-apply-glyphs-empty-comment-glyph-none () + "An empty `pearl-comment-glyph' lays no overlay on a comment heading." + (test-pearl-glyphs--in-org + "**** Craig โ 2026-05-23\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n" + (let ((pearl-show-glyphs t) + (pearl-comment-glyph "")) + (pearl--apply-heading-glyphs) + (should (null (test-pearl-glyphs--overlays)))))) + (ert-deftest test-pearl-apply-glyphs-plain-heading-none () "A heading with no Linear drawer gets no glyph overlay." (test-pearl-glyphs--in-org @@ -110,17 +140,34 @@ (should (null (test-pearl-glyphs--overlays)))))) (ert-deftest test-pearl-apply-glyphs-mixed-buffer () - "Issue and comment headings each get their own glyph; the count matches." + "Issue, Comments container, and comment headings each get their own glyph." (test-pearl-glyphs--in-org (concat "* TODO SE-1: title\n:PROPERTIES:\n:LINEAR-ID: i1\n:END:\n" - "** ๐ฌ Comments\n" + "** Comments 1/1\n" "*** Craig โ 2026-05-23\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n") (let ((pearl-show-glyphs t)) (pearl--apply-heading-glyphs) (let ((ovs (test-pearl-glyphs--overlays))) - ;; Two glyphed headings: the issue and the one real comment. The - ;; "Comments" container carries no Linear id, so it gets nothing. - (should (= (length ovs) 2)))))) + ;; Three glyphed headings: the issue (ticket), the Comments container + ;; (header glyph, matched by regex since it carries no id), and the one + ;; real comment (speech). + (should (= (length ovs) 3)))))) + +;;; --comments-heading-regexp (glyph-agnostic Comments-header matcher) + +(ert-deftest test-pearl-comments-heading-regexp-tolerates-any-glyph () + "The Comments-heading regexp matches bare, glyphed, counted, and legacy forms." + (dolist (h '("*** Comments" + "*** Comments 2/2" + "*** Comments 2/2+" + "*** ๐ฌ Comments" + "*** ๐ฌ Comments 2/2" + "*** ๐จ๏ธ Comments 1/1" + "**** ๐งต Comments" + "*** Comments ๐ฌ 1/1")) ; pre-2026-05 trailing-glyph layout + (should (string-match-p pearl--comments-heading-regexp h))) + ;; Body prose that merely mentions Comments must not match. + (should-not (string-match-p pearl--comments-heading-regexp "Comments are nice"))) (provide 'test-pearl-glyphs) ;;; test-pearl-glyphs.el ends here |
