diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-25 17:31:51 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-25 17:31:51 +0100 |
commit | c182a0d4ad883cc7a1f85d09eb44366a1fd31611 (patch) | |
tree | 1c4a2a9171e65dce70b15de110264039732720a3 /lisp/mastodon-search.el | |
parent | c8a9683b61a207bf38fd76e337bf22a814b6cbf2 (diff) | |
parent | eca8401b6ed04ed0f787efcd8517b022c55f9ed7 (diff) |
Merge branch 'develop' into remove-from-followers
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r-- | lisp/mastodon-search.el | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el index b037faa..65c5aba 100644 --- a/lisp/mastodon-search.el +++ b/lisp/mastodon-search.el @@ -47,7 +47,13 @@ (defvar mastodon-toot--enable-completion-for-mentions) (defvar mastodon-tl--buffer-spec) -;; functions for company completion of mentions in mastodon-toot +;; functions for 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." @@ -55,15 +61,17 @@ (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))) |