aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pearl.el28
-rw-r--r--tests/test-pearl-comment-editing.el24
2 files changed, 43 insertions, 9 deletions
diff --git a/pearl.el b/pearl.el
index 0cac082..33265ef 100644
--- a/pearl.el
+++ b/pearl.el
@@ -4444,8 +4444,11 @@ resolves to a single label."
:group 'pearl)
(defface pearl-readonly-comment
- '((t :inherit shadow))
- "Face for comment headings the current user cannot edit."
+ '((((background dark)) :foreground "gray40")
+ (((background light)) :foreground "gray60")
+ (t :inherit shadow))
+ "Face for comments the current user cannot edit, dimmed to read as disabled.
+Darker than the stock `shadow' grey so a read-only comment clearly recedes."
:group 'pearl)
(defun pearl--comment-editable-p (author-id viewer-id)
@@ -4524,19 +4527,26 @@ unlike `issueDelete' this is not a recoverable soft delete."
(defun pearl--apply-comment-highlights (viewer-id)
"Color every comment heading in the buffer by editability for VIEWER-ID.
-The viewer's own comments get `pearl-editable-comment'; all others get
-`pearl-readonly-comment'. Idempotent: clears prior highlights first."
+The viewer's own comments get `pearl-editable-comment' on the heading line; all
+others get `pearl-readonly-comment' over the whole comment subtree (heading and
+body) so a comment you cannot edit reads as disabled. Idempotent: clears prior
+highlights first."
(save-excursion
(remove-overlays (point-min) (point-max) 'pearl-comment t)
(goto-char (point-min))
(while (re-search-forward "^\\*+ " nil t)
(let ((comment-id (org-entry-get nil "LINEAR-COMMENT-ID")))
(when comment-id
- (let* ((author-id (org-entry-get nil "LINEAR-COMMENT-AUTHOR-ID"))
- (face (if (pearl--comment-editable-p author-id viewer-id)
- 'pearl-editable-comment
- 'pearl-readonly-comment))
- (ov (make-overlay (line-beginning-position) (line-end-position))))
+ (let* ((editable (pearl--comment-editable-p
+ (org-entry-get nil "LINEAR-COMMENT-AUTHOR-ID")
+ viewer-id))
+ (face (if editable 'pearl-editable-comment 'pearl-readonly-comment))
+ ;; Editable: heading line only, so your own comment text reads
+ ;; normally. Read-only: the whole subtree, dimming the body too.
+ (end (if editable
+ (line-end-position)
+ (save-excursion (org-end-of-subtree t t) (point))))
+ (ov (make-overlay (line-beginning-position) end)))
(overlay-put ov 'pearl-comment t)
(overlay-put ov 'face face)))))))
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index 29a5236..b8b4af4 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -257,6 +257,30 @@
(should (eq 'pearl-editable-comment (face-on "^\\*\\*\\*\\*\\* Me")))
(should (eq 'pearl-readonly-comment (face-on "^\\*\\*\\*\\*\\* Them"))))))
+(ert-deftest test-pearl-highlight-readonly-comment-dims-its-body ()
+ "A read-only comment's body carries the grey overlay so the whole comment reads
+as disabled; an editable comment's body is left uncovered so its text reads
+normally (only its heading is colored)."
+ (test-pearl--in-org
+ (concat "*** TODO [#B] Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nBody.\n"
+ "**** Comments\n"
+ "***** Me — 2026-05-24T09:00:00.000Z\n"
+ ":PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:LINEAR-COMMENT-AUTHOR-ID: u-me\n:END:\nmine body\n"
+ "***** Them — 2026-05-24T10:00:00.000Z\n"
+ ":PROPERTIES:\n:LINEAR-COMMENT-ID: c2\n:LINEAR-COMMENT-AUTHOR-ID: u-other\n:END:\ntheirs body\n")
+ (pearl--apply-comment-highlights "u-me")
+ (cl-flet ((face-at (pat)
+ (goto-char (point-min))
+ (re-search-forward pat)
+ (goto-char (match-beginning 0))
+ (let ((ov (cl-find-if (lambda (o) (overlay-get o 'pearl-comment))
+ (overlays-at (point)))))
+ (and ov (overlay-get ov 'face)))))
+ ;; the other person's comment body is dimmed with the read-only face
+ (should (eq 'pearl-readonly-comment (face-at "theirs body")))
+ ;; my own comment body is left uncovered (its heading carries the green)
+ (should (null (face-at "mine body"))))))
+
(ert-deftest test-pearl-update-org-highlights-comments-on-bulk-render ()
"The bulk render colors comment headings, so a list-issues fetch shows
editability without a follow-up refresh. Regression: highlighting ran only on