diff options
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r-- | lisp/mastodon-search.el | 57 |
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))) |