emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon 8f8c461e01 20/63: wrap --thread in with-item macr


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon 8f8c461e01 20/63: wrap --thread in with-item macro
Date: Sun, 4 Aug 2024 04:00:31 -0400 (EDT)

branch: elpa/mastodon
commit 8f8c461e01a9cd85624b40bb158607f4240c80e6
Author: marty hiatt <martianhiatus@riseup.net>
Commit: marty hiatt <martianhiatus@riseup.net>

    wrap --thread in with-item macro
---
 lisp/mastodon-tl.el | 73 +++++++++++++++++++++++++++--------------------------
 1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index c4585b82e8..a82d437b57 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1979,42 +1979,43 @@ view all branches of a thread."
 (defun mastodon-tl--thread (&optional id)
   "Open thread buffer for toot at point or with ID."
   (interactive)
-  (let* ((id (or id (mastodon-tl--property 'base-item-id :no-move)))
-         (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json 
:no-move))))
-    (if (or (string= type "follow_request")
-            (string= type "follow")) ; no can thread these
-        (user-error "No thread")
-      (let* ((endpoint (format "statuses/%s/context" id))
-             (url (mastodon-http--api endpoint))
-             (buffer (format "*mastodon-thread-%s*" id))
-             (toot (mastodon-http--get-json ; refetch in case we just 
faved/boosted:
-                    (mastodon-http--api (concat "statuses/" id))
-                    nil :silent))
-             (context (mastodon-http--get-json url nil :silent)))
-        (if (equal (caar toot) 'error)
-            (user-error "Error: %s" (cdar toot))
-          (when (member (alist-get 'type toot) '("reblog" "favourite"))
-            (setq toot (alist-get 'status toot)))
-          (if (> (+ (length (alist-get 'ancestors context))
-                    (length (alist-get 'descendants context)))
-                 0)
-              ;; if we have a thread:
-              (with-mastodon-buffer buffer #'mastodon-mode nil
-                (let ((marker (make-marker)))
-                  (mastodon-tl--set-buffer-spec buffer endpoint
-                                                #'mastodon-tl--thread)
-                  (mastodon-tl--timeline (alist-get 'ancestors context) 
:thread)
-                  (goto-char (point-max))
-                  (move-marker marker (point))
-                  ;; print re-fetched toot:
-                  (mastodon-tl--toot toot :detailed-p :thread)
-                  (mastodon-tl--timeline (alist-get 'descendants context)
-                                         :thread)
-                  ;; put point at the toot:
-                  (goto-char (marker-position marker))
-                  (mastodon-tl--goto-next-item)))
-            ;; else just print the lone toot:
-            (mastodon-tl--single-toot id)))))))
+  (mastodon-tl--with-toot-item
+   (let* ((id (or id (mastodon-tl--property 'base-item-id :no-move)))
+          (type (mastodon-tl--field 'type (mastodon-tl--property 'item-json 
:no-move))))
+     (if (or (string= type "follow_request")
+             (string= type "follow")) ; no can thread these
+         (user-error "No thread")
+       (let* ((endpoint (format "statuses/%s/context" id))
+              (url (mastodon-http--api endpoint))
+              (buffer (format "*mastodon-thread-%s*" id))
+              (toot (mastodon-http--get-json ; refetch in case we just 
faved/boosted:
+                     (mastodon-http--api (concat "statuses/" id))
+                     nil :silent))
+              (context (mastodon-http--get-json url nil :silent)))
+         (if (equal (caar toot) 'error)
+             (user-error "Error: %s" (cdar toot))
+           (when (member (alist-get 'type toot) '("reblog" "favourite"))
+             (setq toot (alist-get 'status toot)))
+           (if (> (+ (length (alist-get 'ancestors context))
+                     (length (alist-get 'descendants context)))
+                  0)
+               ;; if we have a thread:
+               (with-mastodon-buffer buffer #'mastodon-mode nil
+                 (let ((marker (make-marker)))
+                   (mastodon-tl--set-buffer-spec buffer endpoint
+                                                 #'mastodon-tl--thread)
+                   (mastodon-tl--timeline (alist-get 'ancestors context) 
:thread)
+                   (goto-char (point-max))
+                   (move-marker marker (point))
+                   ;; print re-fetched toot:
+                   (mastodon-tl--toot toot :detailed-p :thread)
+                   (mastodon-tl--timeline (alist-get 'descendants context)
+                                          :thread)
+                   ;; put point at the toot:
+                   (goto-char (marker-position marker))
+                   (mastodon-tl--goto-next-item)))
+             ;; else just print the lone toot:
+             (mastodon-tl--single-toot id))))))))
 
 (defun mastodon-tl--mute-thread ()
   "Mute the thread displayed in the current buffer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]