diff options
| -rw-r--r-- | README.org | 2 | ||||
| -rw-r--r-- | pearl.el | 19 | ||||
| -rw-r--r-- | tests/test-pearl-comments.el | 4 | ||||
| -rw-r--r-- | tests/test-pearl-list-comments.el | 16 |
4 files changed, 22 insertions, 19 deletions
@@ -259,7 +259,7 @@ A fetched Pearl file is intentionally readable. The header records the source, r The issue description renders here as Org and can be edited in place. - *** Comments + *** 💬 Comments **** Author Name - 2026-05-23T10:00:00.000Z A comment, oldest first. #+end_src @@ -1763,11 +1763,12 @@ A null author renders as `(unknown)'." (if (string-empty-p body) "" (concat body "\n"))))) (defun pearl--comment-count-marker (count-info) - "Render COUNT-INFO as a ` 💬 shown/total[+]' suffix, or the empty string. + "Render COUNT-INFO as a ` shown/total[+]' suffix, or the empty string. COUNT-INFO is a plist (:shown N :total M :overflow BOOL) set on the bulk-list -path; nil (the single-issue thread) yields no marker." +path; nil (the single-issue thread) yields no marker. The 💬 glyph leads the +`Comments' heading itself (see `pearl--format-comments'), not this count." (if count-info - (format " 💬 %d/%d%s" + (format " %d/%d%s" (plist-get count-info :shown) (plist-get count-info :total) (if (plist-get count-info :overflow) "+" "")) @@ -1787,8 +1788,9 @@ newest, like an email thread, and a new comment appends at the bottom." Comments render under a level-3 `Comments' heading, ordered per `pearl-comment-sort-order'. Returns the empty string when COMMENTS is nil, so an issue with no comments -renders no subtree. COUNT-INFO, when non-nil, adds a `💬 shown/total' marker to -the heading (the bulk list passes the issue's `:comment-count')." +renders no subtree. The heading leads with a 💬 glyph; COUNT-INFO, when non-nil, +appends a ` shown/total' count (the bulk list passes the issue's +`:comment-count')." (if (null comments) "" (let* ((newest-first (eq pearl-comment-sort-order 'newest-first)) @@ -1797,7 +1799,7 @@ the heading (the bulk list passes the issue's `:comment-count')." (let ((ca (or (plist-get a :created-at) "")) (cb (or (plist-get b :created-at) ""))) (if newest-first (string> ca cb) (string< ca cb))))))) - (concat "*** Comments" (pearl--comment-count-marker count-info) "\n" + (concat "*** 💬 Comments" (pearl--comment-count-marker count-info) "\n" (mapconcat #'pearl--format-comment sorted ""))))) (defun pearl--format-issue-as-org-entry (issue) @@ -2481,8 +2483,9 @@ subtree at the end of the issue when it does not exist yet." (let* ((issue-end (save-excursion (org-end-of-subtree t t) (point))) (comments-pos (save-excursion - ;; tolerate a trailing "💬 shown/total" marker on the heading - (when (re-search-forward "^\\*+ Comments\\(?:[ \t].*\\)?$" issue-end t) + ;; tolerate the leading 💬 glyph and a trailing count marker; also + ;; match the pre-2026-05 "Comments 💬 N/N" layout in older files + (when (re-search-forward "^\\*+ \\(?:💬 \\)?Comments\\(?:[ \t].*\\)?$" issue-end t) (match-beginning 0))))) (if comments-pos (progn diff --git a/tests/test-pearl-comments.el b/tests/test-pearl-comments.el index 85d1c84..591b4ce 100644 --- a/tests/test-pearl-comments.el +++ b/tests/test-pearl-comments.el @@ -73,7 +73,7 @@ "With newest-first order, the most recent comment renders on top." (let* ((pearl-comment-sort-order 'newest-first) (out (pearl--format-comments test-pearl--two-comments))) - (should (string-match-p "^\\*\\*\\* Comments$" out)) + (should (string-match-p "^\\*\\*\\* 💬 Comments$" out)) (should (< (string-match "second" out) (string-match "first" out))))) (ert-deftest test-pearl-format-comments-oldest-first () @@ -92,7 +92,7 @@ :state (:name "Todo") :description "Body text." :comments ((:id "c1" :author "A" :created-at "2026-05-23T09:00:00.000Z" :body "a comment")))))) - (should (string-match-p "^\\*\\*\\* Comments$" out)) + (should (string-match-p "^\\*\\*\\* 💬 Comments$" out)) (should (< (string-match "Body text." out) (string-match "a comment" out)))))) ;;; --create-comment-async diff --git a/tests/test-pearl-list-comments.el b/tests/test-pearl-list-comments.el index be0880e..1e2b009 100644 --- a/tests/test-pearl-list-comments.el +++ b/tests/test-pearl-list-comments.el @@ -91,9 +91,9 @@ (ert-deftest test-pearl-comment-count-marker-forms () "The marker renders shown/total, with a `+' past the cap and nothing for nil." - (should (string= " 💬 5/18" (pearl--comment-count-marker '(:shown 5 :total 18 :overflow nil)))) - (should (string= " 💬 5/25+" (pearl--comment-count-marker '(:shown 5 :total 25 :overflow t)))) - (should (string= " 💬 3/3" (pearl--comment-count-marker '(:shown 3 :total 3 :overflow nil)))) + (should (string= " 5/18" (pearl--comment-count-marker '(:shown 5 :total 18 :overflow nil)))) + (should (string= " 5/25+" (pearl--comment-count-marker '(:shown 5 :total 25 :overflow t)))) + (should (string= " 3/3" (pearl--comment-count-marker '(:shown 3 :total 3 :overflow nil)))) (should (string= "" (pearl--comment-count-marker nil)))) ;;; --format-comments with a marker @@ -103,14 +103,14 @@ (let* ((pearl-comment-sort-order 'newest-first) (comments (test-pearl--comments 5)) ; newest-first as fetched (out (pearl--format-comments comments '(:shown 5 :total 12 :overflow nil)))) - (should (string-match-p "^\\*\\*\\* Comments 💬 5/12$" out)) + (should (string-match-p "^\\*\\*\\* 💬 Comments 5/12$" out)) ;; newest (comment 5) renders before oldest (comment 1) (should (< (string-match "comment 5\\b" out) (string-match "comment 1\\b" out))))) (ert-deftest test-pearl-format-comments-no-marker-without-count () "Without count-info (the single-issue thread), the heading has no marker." (let ((out (pearl--format-comments (test-pearl--comments 2)))) - (should (string-match-p "^\\*\\*\\* Comments$" out)))) + (should (string-match-p "^\\*\\*\\* 💬 Comments$" out)))) ;;; the marked heading is still found by the append locator @@ -128,15 +128,15 @@ (org-mode) (goto-char (point-min)) ;; the rendered Comments heading carries the marker - (should (re-search-forward "^\\*\\*\\* Comments 💬 5/8$" nil t)) + (should (re-search-forward "^\\*\\*\\* 💬 Comments 5/8$" nil t)) (goto-char (point-min)) (re-search-forward "issue") (pearl--append-comment-to-issue '(:id "cnew" :author "Z" :created-at "2026-06-01T00:00:00.000Z" :body "appended")) ;; exactly one Comments heading, and the new comment landed under it (goto-char (point-min)) - (should (re-search-forward "^\\*\\*\\* Comments" nil t)) - (should-not (re-search-forward "^\\*\\*\\* Comments" nil t)) + (should (re-search-forward "^\\*\\*\\* 💬 Comments" nil t)) + (should-not (re-search-forward "^\\*\\*\\* 💬 Comments" nil t)) (should (string-match-p "appended" (buffer-string))))))) (provide 'test-pearl-list-comments) |
