aboutsummaryrefslogtreecommitdiff
path: root/pearl.el
diff options
context:
space:
mode:
Diffstat (limited to 'pearl.el')
-rw-r--r--pearl.el93
1 files changed, 61 insertions, 32 deletions
diff --git a/pearl.el b/pearl.el
index 880e7ed..d2941aa 100644
--- a/pearl.el
+++ b/pearl.el
@@ -295,10 +295,35 @@ overlay on the space after the stars, so it sits ahead of the TODO keyword --
where a literal text prefix can't go, since Org needs the keyword first.
Display-only: the buffer text is untouched, so parsing, sync, and merge keep
working. The overlay goes stale after a manual heading edit until the next
-fetch/refresh. Set to nil to omit the glyphs."
+fetch/refresh. Set to nil to omit the glyphs. The glyph strings themselves
+are `pearl-ticket-glyph', `pearl-comment-glyph', and
+`pearl-comments-header-glyph'."
:type 'boolean
:group 'pearl)
+(defcustom pearl-ticket-glyph "🎫"
+ "Glyph overlaid on issue headings (those carrying a `LINEAR-ID').
+Shown only when `pearl-show-glyphs' is non-nil. Set to the empty string to
+omit the issue glyph while keeping the others."
+ :type 'string
+ :group 'pearl)
+
+(defcustom pearl-comment-glyph "🗨️"
+ "Glyph overlaid on each comment heading (those carrying a `LINEAR-COMMENT-ID').
+Shown only when `pearl-show-glyphs' is non-nil. Set to the empty string to
+omit the per-comment glyph."
+ :type 'string
+ :group 'pearl)
+
+(defcustom pearl-comments-header-glyph "💬"
+ "Glyph overlaid on the `Comments' container heading of an issue's thread.
+The container carries no Linear id, so it is matched by heading text rather than
+a drawer id. Like the other glyphs it rides a `display' overlay -- the buffer
+text stays a bare `Comments', so parsing, sync, and merge are untouched. Shown
+only when `pearl-show-glyphs' is non-nil. Set to the empty string to omit it."
+ :type 'string
+ :group 'pearl)
+
(defcustom pearl-assignee-tag-short nil
"When non-nil, shorten the assignee @-tag to the first name only.
The default slugs Linear's full @-mention handle (e.g. `first.last' becomes
@@ -2784,6 +2809,15 @@ newest, like an email thread, and a new comment appends at the bottom."
(const :tag "Oldest first (chronological)" oldest-first))
:group 'pearl)
+(defconst pearl--comments-heading-regexp
+ "^\\*+ \\(?:[^ \t\n]+ \\)?Comments\\(?:[ \t].*\\)?$"
+ "Regexp matching an issue's `Comments' container heading.
+Glyph-agnostic: the optional leading token tolerates any header glyph a buffer
+was rendered with -- the current overlay form leaves the text a bare
+`Comments', but older buffers carry a literal `💬 ' prefix (the 2026-05 layout)
+or a trailing `Comments 💬 N/N' (the pre-2026-05 layout). The optional tail
+covers the ` N/M[+]' count marker.")
+
(defun pearl--format-comments (comments &optional count-info level)
"Format COMMENTS (a list of normalized comment plists) as a Comments subtree.
LEVEL is the parent issue's heading depth (default 2): the `Comments' heading
@@ -3586,12 +3620,7 @@ 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
- ;; Match the new no-emoji form, the prior `💬 ' leading-glyph
- ;; layout (rendered between 2026-05-26 and the de-emoji
- ;; revert), and the pre-2026-05 trailing-glyph layout
- ;; (`Comments 💬 N/N'). Buffers rendered in any of the three
- ;; states locate their Comments heading.
- (when (re-search-forward "^\\*+ \\(?:💬 \\)?Comments\\(?:[ \t].*\\)?$" issue-end t)
+ (when (re-search-forward pearl--comments-heading-regexp issue-end t)
(match-beginning 0)))))
(if comments-pos
(progn
@@ -3675,8 +3704,7 @@ survive."
(issue-end (save-excursion (org-end-of-subtree t t) (point)))
(comments-pos
(save-excursion
- (when (re-search-forward
- "^\\*+ \\(?:💬 \\)?Comments\\(?:[ \t].*\\)?$" issue-end t)
+ (when (re-search-forward pearl--comments-heading-regexp issue-end t)
(match-beginning 0))))
(n (length comments))
(count-info (and (> n 0) (list :shown n :total n :overflow nil)))
@@ -7537,31 +7565,29 @@ unlike `issueDelete' this is not a recoverable soft delete."
(list :success (eq t (cdr (assoc 'success payload)))))))
(lambda (_error _response _data) (funcall callback '(:success nil))))))
-(defconst pearl--ticket-glyph "🎫"
- "Glyph overlaid on issue headings (those carrying a `LINEAR-ID').")
-
-(defconst pearl--comment-glyph "💬"
- "Glyph overlaid on comment headings (those carrying a `LINEAR-COMMENT-ID').")
-
-(defun pearl--heading-glyph (comment-id issue-id)
- "Return the content glyph for a heading, or nil when it carries no Linear id.
-COMMENT-ID wins over ISSUE-ID so a comment heading shows the speech glyph; the
-two ids are disjoint in practice, but the order makes the precedence explicit."
- (cond (comment-id pearl--comment-glyph)
- (issue-id pearl--ticket-glyph)
+(defun pearl--heading-glyph (comment-id issue-id &optional header-p)
+ "Return the content glyph for a heading, or nil when it carries none.
+COMMENT-ID selects `pearl-comment-glyph' and outranks ISSUE-ID, which selects
+`pearl-ticket-glyph'. With no id, HEADER-P (the `Comments' container heading)
+selects `pearl-comments-header-glyph'. The id checks come first so a comment or
+issue heading never falls through to the header glyph."
+ (cond (comment-id pearl-comment-glyph)
+ (issue-id pearl-ticket-glyph)
+ (header-p pearl-comments-header-glyph)
(t nil)))
(defun pearl--apply-heading-glyphs (&optional buffer)
"Overlay a content glyph on the leading stars of Linear headings in BUFFER.
-An issue heading (`LINEAR-ID') gets `pearl--ticket-glyph'; a comment heading
-(`LINEAR-COMMENT-ID') gets `pearl--comment-glyph', chosen per heading from its
-drawer rather than per outline level. The glyph rides a `display' overlay on
-the space after the leading stars, so it renders ahead of the TODO keyword and
-leaves the stars (and any `org-superstar' / `org-modern' bullet composed from
-them) untouched. Buffer text is unchanged, so parsing and the merge rewrites
-keep working. Idempotent: clears prior glyph overlays first; with
-`pearl-show-glyphs' nil it just clears. Overlays go stale after a manual
-heading edit until the next fetch/refresh re-applies them."
+An issue heading (`LINEAR-ID') gets `pearl-ticket-glyph'; a comment heading
+(`LINEAR-COMMENT-ID') gets `pearl-comment-glyph'; the `Comments' container
+heading (no id, matched by `pearl--comments-heading-regexp') gets
+`pearl-comments-header-glyph'. The glyph rides a `display' overlay on the space
+after the leading stars, so it renders ahead of the TODO keyword and leaves the
+stars (and any `org-superstar' / `org-modern' bullet composed from them)
+untouched. Buffer text is unchanged, so parsing and the merge rewrites keep
+working. A glyph set to the empty string is skipped. Idempotent: clears prior
+glyph overlays first; with `pearl-show-glyphs' nil it just clears. Overlays go
+stale after a manual heading edit until the next fetch/refresh re-applies them."
(with-current-buffer (or buffer (current-buffer))
(save-excursion
(remove-overlays (point-min) (point-max) 'pearl-glyph t)
@@ -7574,8 +7600,11 @@ heading edit until the next fetch/refresh re-applies them."
(let ((stars-end (point))
(glyph (pearl--heading-glyph
(org-entry-get nil "LINEAR-COMMENT-ID")
- (org-entry-get nil "LINEAR-ID"))))
- (when (and glyph (eq (char-after) ?\s))
+ (org-entry-get nil "LINEAR-ID")
+ (save-excursion
+ (beginning-of-line)
+ (looking-at-p pearl--comments-heading-regexp)))))
+ (when (and glyph (not (string-empty-p glyph)) (eq (char-after) ?\s))
(let ((ov (make-overlay stars-end (1+ stars-end))))
(overlay-put ov 'pearl-glyph t)
(overlay-put ov 'evaporate t)