branch: elpa/mastodon
commit 94f310c78dd6204176425f3805ec8b67d30c9c92
Author: marty hiatt <martianhia...@riseup.net>
Commit: marty hiatt <martianhia...@riseup.net>

    add toggle-spoiler-in-thread cmd
---
 lisp/mastodon-tl.el | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 856325e8a5..18aaccc90b 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -389,12 +389,14 @@ Optionally start from POS."
           (funcall refresh)
         (error "No more items")))))
 
-(defun mastodon-tl--goto-next-item ()
+(defun mastodon-tl--goto-next-item (&optional no-refresh)
   "Jump to next item.
-Load more items it no next item."
+Load more items it no next item.
+NO-REFRESH means do no not try to load more items if no next item
+found."
   (interactive)
   (mastodon-tl--goto-item-pos 'next-single-property-change
-                              'mastodon-tl--more))
+                              (unless no-refresh 'mastodon-tl--more)))
 
 (defun mastodon-tl--goto-prev-item ()
   "Jump to previous item.
@@ -989,6 +991,18 @@ content should be hidden."
           (t
            (mastodon-tl--toggle-spoiler-text (car spoiler-range))))))
 
+(defun mastodon-tl--toggle-spoiler-in-thread ()
+  "Toggler content warning for all posts in current thread."
+  (interactive)
+  (let ((thread-p (eq (mastodon-tl--buffer-property 'update-function)
+                      'mastodon-tl--thread)))
+    (if (not thread-p)
+        (user-error "Not in a thread")
+      (goto-char (point-min))
+      (while (not (equal "No more items" ; improve this hack test!
+                         (mastodon-tl--goto-next-item :no-refresh)))
+        (mastodon-tl--toggle-spoiler-text-in-toot)))))
+
 (defun mastodon-tl--clean-tabs-and-nl (string)
   "Remove tabs and newlines from STRING."
   (replace-regexp-in-string "[\t\n ]*\\'" "" string))

Reply via email to