aboutsummaryrefslogtreecommitdiff
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
parente50c9a28ebd2987f2a186f2dc6098df2435cc75d (diff)
parent907a28bca6c1e281183f24dd1f5c618fdbb85065 (diff)
Merge branch 'develop'
-rw-r--r--README.org2
-rw-r--r--lisp/mastodon-search.el57
-rw-r--r--lisp/mastodon-tl.el10
3 files changed, 55 insertions, 14 deletions
diff --git a/README.org b/README.org
index a2b047a..ffd66e6 100644
--- a/README.org
+++ b/README.org
@@ -207,6 +207,8 @@ You can download and use your instance's custom emoji
*** Other commands and account settings:
- =mastodon-tl-view-instance-description=: View information about the instance that the author of the toot at point is on.
+- =mastodon-tl-view-own-instance=: View information about your own instance.
+- =mastodon-search-trending-tags=: View a list of trending hashtags on your instance.
- =mastodon-profile-update-display-name=: Update the display name for your account.
- =mastodon-profile-set-default-toot-visibility=: Set the default visibility for your toots.
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")