aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-search.el57
-rw-r--r--lisp/mastodon-tl.el10
2 files changed, 53 insertions, 14 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)))
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index b59be8b..8e3ab30 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1379,10 +1379,11 @@ BRIEF means show fewer details."
(interactive)
(mastodon-tl-view-instance-description nil :brief))
-(defun mastodon-tl-view-instance-description (&optional user brief)
+(defun mastodon-tl-view-instance-description (&optional user brief instance)
"View the details of the instance the current post's author is on.
USER means to show the instance details for the logged in user.
-BRIEF means to show fewer details."
+BRIEF means to show fewer details.
+INSTANCE is an instance domain name."
(interactive)
(mastodon-tl--do-if-toot
(let* ((toot (mastodon-tl--property 'toot-json))
@@ -1393,8 +1394,9 @@ BRIEF means to show fewer details."
(username (alist-get 'username account))
(instance
(concat "https://"
- (string-remove-prefix (concat username "@")
- acct)))
+ (or instance
+ (string-remove-prefix (concat username "@")
+ acct))))
(response (mastodon-http--get-json
(if user
(mastodon-http--api "instance")