From adee44df124e8983084737c50e9c767edd70aea8 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sat, 6 Jun 2026 07:38:46 -0500 Subject: feat(render): make heading glyphs configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/test-pearl-glyphs.el | 67 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 57 insertions(+), 10 deletions(-) (limited to 'tests') 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 -- cgit v1.2.3