branch: elpa/mastodon
commit 137bfcdbf047af828fda0ef5ac66fcea2b8004ae
Author: marty hiatt <martianhia...@disroot.org>
Commit: marty hiatt <martianhia...@disroot.org>

    add a followed_tags view (no pagination as yet).
---
 lisp/mastodon-tl.el | 28 +++++++++++++++++++++++++---
 lisp/mastodon.el    |  1 +
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 75341b6831..a6afe11601 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2281,7 +2281,10 @@ call this function after it is set or use something 
else."
           ((mastodon-tl--endpoint-str-= "timelines/link")
            'link-timeline)
           ((mastodon-tl--endpoint-str-= "announcements")
-           'announcements))))
+           'announcements)
+          ;; followed hashtags
+          ((mastodon-tl--endpoint-str-= "followed_tags")
+           'followed-hashtags))))
 
 (defun mastodon-tl--buffer-type-eq (type)
   "Return t if current buffer type is equal to symbol TYPE."
@@ -2989,8 +2992,8 @@ If TAG is provided, unfollow it."
                            (lambda (_)
                              (message "tag #%s unfollowed!" tag)))))
 
-(defun mastodon-tl-list-followed-tags (&optional prefix)
-  "List followed tags. View timeline of tag user choses.
+(defun mastodon-tl-jump-to-followed-tag (&optional prefix)
+  "Prompt for a followed tag and view its timeline.
 PREFIX is sent to `mastodon-tl-get-tag-timeline', which see."
   (interactive "p")
   (let* ((followed-tags-json (mastodon-tl--followed-tags))
@@ -3000,6 +3003,25 @@ PREFIX is sent to `mastodon-tl-get-tag-timeline', which 
see."
         (user-error "You have to follow some tags first")
       (mastodon-tl-get-tag-timeline prefix tag))))
 
+(defun mastodon-tl-list-followed-tags ()
+  "List followed tags. View timeline of tag user choses.
+PREFIX is sent to `mastodon-tl-get-tag-timeline', which see."
+  (interactive)
+  (let* ((json (mastodon-tl--followed-tags))
+         (sorted (sort json :key (lambda (x)
+                                   (downcase (alist-get 'name x)))))
+         (buf "*mastodon-followed-tags*"))
+    (if (null sorted)
+        (user-error "You have to follow some tags first")
+      (with-mastodon-buffer (get-buffer-create buf)
+          #'mastodon-mode nil
+        (mastodon-tl--set-buffer-spec
+         buf "followed_tags" #'mastodon-tl-list-followed-tags)
+        (mastodon-search--insert-heading "followed tags")
+        (insert "\n")
+        (mastodon-search--print-tags sorted)
+        (goto-char (point-min))))))
+
 (defun mastodon-tl-followed-tags-timeline (&optional prefix)
   "Open a timeline of multiple tags.
 With a single PREFIX arg, only show posts with media.
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index 1e973d78de..7e797fec4c 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -228,6 +228,7 @@ Also nil `mastodon-auth--token-alist'."
     ;; navigation between timelines
     (define-key map (kbd "#")      #'mastodon-tl-get-tag-timeline)
     (define-key map (kbd "\"")     #'mastodon-tl-list-followed-tags)
+    (define-key map (kbd "C-\"")     #'mastodon-tl-jump-to-followed-tag)
     (define-key map (kbd "'")      #'mastodon-tl-followed-tags-timeline)
     (define-key map (kbd "C-'")   #'mastodon-tl-tag-group-timeline)
     (define-key map (kbd "A")      #'mastodon-profile-get-toot-author)

Reply via email to