aboutsummaryrefslogtreecommitdiff
path: root/pearl.el
diff options
context:
space:
mode:
Diffstat (limited to 'pearl.el')
-rw-r--r--pearl.el31
1 files changed, 16 insertions, 15 deletions
diff --git a/pearl.el b/pearl.el
index 0c61e32..844b9f0 100644
--- a/pearl.el
+++ b/pearl.el
@@ -2177,11 +2177,12 @@ report the field as left in conflict."
pearl--conflict-backup-buffer)
(when cb (funcall cb))))
-(defun pearl--issue-body-at-point ()
- "Return the description body of the Linear issue subtree at point.
+(defun pearl--entry-body-at-point ()
+ "Return the body of the Org entry at point, before any child heading.
The body is the text after the property drawer and before the first child
-heading (so a Comments subtree is excluded), trimmed of surrounding
-whitespace. Returns the empty string when the entry has no body."
+heading (so an issue's Comments subtree is excluded), trimmed of surrounding
+whitespace. Returns the empty string when the entry has no body. Used for
+both issue descriptions and comment bodies -- hence \"entry\", not \"issue\"."
(save-excursion
(org-back-to-heading t)
;; Fix the body's end (the next heading: a Comments child or the next
@@ -2406,7 +2407,7 @@ proceeds and the subtree is replaced with Linear's version."
(when (pearl--subtree-dirty-p)
(pearl--stash-conflict-text
(format "%s description (pre-refresh)" issue-id)
- (pearl--org-to-md (pearl--issue-body-at-point))))
+ (pearl--org-to-md (pearl--entry-body-at-point))))
(pearl--progress "Refreshing %s from Linear..." issue-id)
(pearl--fetch-issue-async
issue-id
@@ -2542,7 +2543,7 @@ a dedicated buffer. Works from anywhere inside an issue subtree."
(pearl--compose-in-buffer
(format "description for %s" issue-id)
pearl--compose-description-instructions
- (org-with-point-at marker (pearl--issue-body-at-point))
+ (org-with-point-at marker (pearl--entry-body-at-point))
(lambda (org)
(org-with-point-at marker
(pearl--set-entry-body-at-point org)
@@ -3162,9 +3163,9 @@ fall back to the older markdown-round-trip comparison; those migrate to the
Org-baseline hash the next time the subtree is re-rendered."
(let ((org-hash (org-entry-get nil "LINEAR-DESC-ORG-SHA256")))
(if org-hash
- (not (string= (secure-hash 'sha256 (pearl--issue-body-at-point)) org-hash))
+ (not (string= (secure-hash 'sha256 (pearl--entry-body-at-point)) org-hash))
(let ((stored (org-entry-get nil "LINEAR-DESC-SHA256"))
- (local-md (pearl--org-to-md (pearl--issue-body-at-point))))
+ (local-md (pearl--org-to-md (pearl--entry-body-at-point))))
(not (string= (secure-hash 'sha256 local-md) (or stored "")))))))
(defun pearl--issue-subtree-markers ()
@@ -3207,7 +3208,7 @@ does). A candidate only means the body differs; ownership is decided later."
(when (and cid (not (string-empty-p cid)))
(let ((stored (or (org-entry-get nil "LINEAR-COMMENT-SHA256") ""))
(local (secure-hash 'sha256
- (pearl--org-to-md (pearl--issue-body-at-point)))))
+ (pearl--org-to-md (pearl--entry-body-at-point)))))
(unless (string= local stored)
(push (list :comment-id cid
:author-id (org-entry-get nil "LINEAR-COMMENT-AUTHOR-ID")
@@ -3338,7 +3339,7 @@ used by the local dirty scan), so the next scan sees the ticket as clean."
(org-with-point-at marker
(let* ((issue-id (org-entry-get nil "LINEAR-ID"))
(identifier (org-entry-get nil "LINEAR-IDENTIFIER"))
- (local (pearl--org-to-md (pearl--issue-body-at-point)))
+ (local (pearl--org-to-md (pearl--entry-body-at-point)))
(spec (list
:issue-id issue-id :identifier identifier :field 'description
:comment-id nil :marker marker :prop "LINEAR-DESC-SHA256"
@@ -3365,7 +3366,7 @@ used by the local dirty scan), so the next scan sees the ticket as clean."
(when (memq (plist-get outcome :status) '(pushed resolved-remote))
(org-with-point-at marker
(org-entry-put marker "LINEAR-DESC-ORG-SHA256"
- (secure-hash 'sha256 (pearl--issue-body-at-point)))))
+ (secure-hash 'sha256 (pearl--entry-body-at-point)))))
(funcall callback outcome))))))
(defun pearl--save-title-field (marker callback)
@@ -3405,7 +3406,7 @@ only the viewer's own comments are saved through the gate."
:issue-id (pearl--issue-id-at-point)
:identifier comment-id :field 'comment :comment-id comment-id
:marker marker :prop "LINEAR-COMMENT-SHA256"
- :local (pearl--org-to-md (pearl--issue-body-at-point))
+ :local (pearl--org-to-md (pearl--entry-body-at-point))
:stored (org-entry-get nil "LINEAR-COMMENT-SHA256")
:label (format "comment %s" comment-id)
:fetch (lambda (cb) (pearl--fetch-comment-body-async comment-id cb))
@@ -4195,10 +4196,10 @@ reported (refresh to reconcile)."
(unless comment-id
(user-error "Not on a Linear comment"))
;; No-op fast path before resolving the viewer: an unchanged comment
- ;; costs no viewer lookup. `pearl--issue-body-at-point' reads the text
+ ;; costs no viewer lookup. `pearl--entry-body-at-point' reads the text
;; after the drawer and before the first child heading -- a comment
;; subtree has that shape, so it serves the comment body unchanged.
- (let ((local-md (pearl--org-to-md (pearl--issue-body-at-point))))
+ (let ((local-md (pearl--org-to-md (pearl--entry-body-at-point))))
(if (string= (secure-hash 'sha256 local-md) (or stored ""))
(message "No comment changes to sync")
(pearl--viewer-async
@@ -4243,7 +4244,7 @@ body stay."
(string= (secure-hash 'sha256
(pearl--org-to-md
(org-with-point-at marker
- (pearl--issue-body-at-point))))
+ (pearl--entry-body-at-point))))
stored)))
(prompt (if clean
"Delete this comment from Linear and remove it here? "