aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-search.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-25 17:12:57 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2022-11-25 17:12:57 +0100
commita85c2c349af9f0d08f3f7c2ed2d6dcea22c71860 (patch)
tree7576e3f57bf91a33464dd28a31b76ba110a63935 /lisp/mastodon-search.el
parent0e06be9ffae90962aa18e7d6bfb40e7007028705 (diff)
parent28b73ab054b15de2cdc4943dea125431c1866a5b (diff)
Merge branch 'capf-completion' into develop
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r--lisp/mastodon-search.el19
1 files changed, 13 insertions, 6 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index b037faa..9d8ee65 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -49,21 +49,29 @@
;; functions for company completion of mentions in mastodon-toot
+(defun mastodon-search--get-user-info-@-capf (account)
+ "Get user handle, display name and account URL from ACCOUNT."
+ (list (concat "@" (cdr (assoc 'acct account)))
+ (cdr (assoc 'url account))
+ (cdr (assoc 'display_name account))))
+
(defun mastodon-search--get-user-info-@ (account)
"Get user handle, display name and account URL from ACCOUNT."
(list (cdr (assoc 'display_name account))
(concat "@" (cdr (assoc 'acct account)))
(cdr (assoc 'url account))))
-(defun mastodon-search--search-accounts-query (query)
+(defun mastodon-search--search-accounts-query (query &optional capf)
"Prompt for a search QUERY and return accounts synchronously.
Returns a nested list containing user handle, display name, and URL."
(interactive "sSearch mastodon for: ")
(let* ((url (mastodon-http--api "accounts/search"))
(response (if (equal mastodon-toot--completion-style-for-mentions "following")
- (mastodon-http--get-json url `(("q" . ,query) ("following" . "true")))
- (mastodon-http--get-json url `(("q" . ,query))))))
- (mapcar #'mastodon-search--get-user-info-@ response)))
+ (mastodon-http--get-json url `(("q" . ,query) ("following" . "true")) :silent)
+ (mastodon-http--get-json url `(("q" . ,query)) :silent))))
+ (if capf
+ (mapcar #'mastodon-search--get-user-info-@-capf response)
+ (mapcar #'mastodon-search--get-user-info-@ response))))
;; functions for tags completion:
@@ -72,10 +80,9 @@ Returns a nested list containing user handle, display name, and URL."
QUERY is the string to search."
(interactive "sSearch for hashtag: ")
(let* ((url (format "%s/api/v2/search" mastodon-instance-url))
- ;; (type-param '(("type" . "hashtags")))
(params `(("q" . ,query)
("type" . "hashtags")))
- (response (mastodon-http--get-json url params))
+ (response (mastodon-http--get-json url params :silent))
(tags (alist-get 'hashtags response)))
(mapcar #'mastodon-search--get-hashtag-info tags)))