aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-search.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-02 15:16:55 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-09-02 15:16:55 +0200
commit82ace133b0c254e92f08d0fb74d2a9c83faac363 (patch)
treee6c6786a160608a142906a0b93d7f39f2d9f52a4 /lisp/mastodon-search.el
parente50c9a28ebd2987f2a186f2dc6098df2435cc75d (diff)
parent907a28bca6c1e281183f24dd1f5c618fdbb85065 (diff)
Merge branch 'develop'
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r--lisp/mastodon-search.el57
1 files changed, 47 insertions, 10 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 10e12c3..1af49c1 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -45,6 +45,7 @@
(defvar mastodon-tl--link-keymap)
(defvar mastodon-http--timeout)
(defvar mastodon-toot--enable-completion-for-mentions)
+(defvar mastodon-tl--buffer-spec)
;; functions for company completion of mentions in mastodon-toot
@@ -76,6 +77,35 @@ QUERY is the string to search."
(tags (alist-get 'hashtags response)))
(mapcar #'mastodon-search--get-hashtag-info tags)))
+
+;; trending tags
+
+(defun mastodon-search-trending-tags ()
+ "Display a list of tags trending on your instance."
+ (interactive)
+ (let* ((url (mastodon-http--api "trends"))
+ (response (mastodon-http--get-json url))
+ (tags (mapcar #'mastodon-search--get-hashtag-info
+ response))
+ (buffer (get-buffer-create "*mastodon-trending*")))
+ (with-current-buffer buffer
+ (switch-to-buffer (current-buffer))
+ (mastodon-mode)
+ (let ((inhibit-read-only t))
+ (erase-buffer)
+ (setq mastodon-tl--buffer-spec
+ `(buffer-name ,buffer
+ endpoint ,(format "api/v1/trends")
+ update-function
+ (lambda (toot) (message "Trends."))))
+ ;; hashtag results:
+ (insert (mastodon-tl--set-face
+ (concat "\n ------------\n"
+ " TRENDING HASHTAGS\n"
+ " ------------\n\n")
+ 'success))
+ (mastodon-search--print-tags-list tags)))))
+
;; functions for mastodon search
(defun mastodon-search--search-query (query)
@@ -121,16 +151,7 @@ QUERY is the string to search."
" HASHTAGS\n"
" ------------\n\n")
'success))
- (mapc (lambda (el)
- (insert " : #"
- (propertize (car el)
- 'mouse-face 'highlight
- 'mastodon-tag (car el)
- 'mastodon-tab-stop 'hashtag
- 'help-echo (concat "Browse tag #" (car el))
- 'keymap mastodon-tl--link-keymap)
- " : \n\n"))
- tags-list)
+ (mastodon-search--print-tags-list tags-list)
;; status results:
(insert (mastodon-tl--set-face
(concat "\n ------------\n"
@@ -170,6 +191,22 @@ user's profile note. This is also called by
'toot-json acct)))) ; so named for compat w other processing functions
json))
+(defun mastodon-search--print-tags-list (tags)
+ "Insert a propertized list of TAGS."
+ (mapc (lambda (el)
+ (insert
+ " : "
+ (propertize (concat "#"
+ (car el))
+ 'face '(:box t)
+ 'mouse-face 'highlight
+ 'mastodon-tag (car el)
+ 'mastodon-tab-stop 'hashtag
+ 'help-echo (concat "Browse tag #" (car el))
+ 'keymap mastodon-tl--link-keymap)
+ " : \n\n"))
+ tags))
+
(defun mastodon-search--get-user-info (account)
"Get user handle, display name, account URL and profile note from ACCOUNT."
(list (if (not (equal "" (alist-get 'display_name account)))