aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-search.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-10-21 22:01:02 +0200
committermousebot <mousebot@riseup.net>2021-10-21 22:01:02 +0200
commit7ba038a8c356ff7df4885485a2f4fe69e67cfc34 (patch)
treef081e94c0602b1ed2d4774c2f09f197bbfbecc60 /lisp/mastodon-search.el
parent6d6c0a1c2b105e8adfdb24e6d6a2a65ebe78d1f3 (diff)
parent39bf919327a03b8e34ff28f08422b2cb6d3eab26 (diff)
Merge branch 'develop' into imgcaching
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r--lisp/mastodon-search.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 537a746..40f134d 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -43,6 +43,27 @@
(defvar mastodon-tl--link-keymap)
(defvar mastodon-http--timeout)
+;; functions for company completion of mentions in mastodon-toot
+
+(defun mastodon-search--get-user-info-no-url (account)
+ "Get user handle, display name and account URL from ACCOUNT."
+ (list (cdr (assoc 'display_name account))
+ (concat "@" (cdr (assoc 'acct account)))))
+
+(defun mastodon-search--search-accounts-query (query)
+ "Prompt for a search QUERY and return accounts.
+Returns a nested list containing user handle, display name, and URL."
+ (interactive "sSearch mastodon for: ")
+ (let* ((url (format "%s/api/v1/accounts/search" mastodon-instance-url))
+ (buffer (format "*mastodon-search-%s*" query))
+ (response (if (equal mastodon-toot--enable-completion-for-mentions "followers")
+ (mastodon-http--get-search-json url query "following=true")
+ (mastodon-http--get-search-json url query))))
+ (mapcar #'mastodon-search--get-user-info-no-url
+ response)))
+
+;; functions for mastodon search
+
(defun mastodon-search--search-query (query)
"Prompt for a search QUERY and return accounts, statuses, and hashtags."
(interactive "sSearch mastodon for: ")