emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mastodon ab62022b50 15/47: implement following "accounts"


From: ELPA Syncer
Subject: [nongnu] elpa/mastodon ab62022b50 15/47: implement following "accounts" search. FIX #493.
Date: Fri, 13 Oct 2023 19:00:55 -0400 (EDT)

branch: elpa/mastodon
commit ab62022b50ba5d005d6da5d4bdec4f83ce673bc7
Author: marty hiatt <martianhiatus [a t] riseup [d o t] net>
Commit: marty hiatt <martianhiatus [a t] riseup [d o t] net>

    implement following "accounts" search. FIX #493.
---
 lisp/mastodon-search.el | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 40cf15a1e8..436041defb 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -149,21 +149,28 @@ PRINT-FUN is the function used to print the data from the 
response."
                                       &optional type following account-id)
   "Prompt for a search QUERY and return accounts, statuses, and hashtags.
 TYPE is a member of `mastodon-search-types'.
-FOLLOWING means limit search to accounts followed.
-ACCOUNT-ID means limit search to that account."
+FOLLOWING means limit to accounts followed, for \"accounts\" type only.
+A single prefix arg also sets FOLLOWING to true.
+ACCOUNT-ID means limit search to that account, for \"statuses\" type only."
   ;; TODO: handle account search, buffer name etc.
   ;; TODO: handle no results
   (interactive "sSearch mastodon for: ")
   (let* ((url (format "%s/api/v2/search" mastodon-instance-url))
+         (following (when (or following
+                              (equal current-prefix-arg '(4)))
+                      "true"))
          (type (or type
-                   (completing-read "Search type: "
-                                    mastodon-search-types
-                                    nil t)))
+                   (if (equal current-prefix-arg '(4))
+                       "accounts" ; if FOLLOWING, must be "accounts"
+                     (completing-read "Search type: "
+                                      mastodon-search-types
+                                      nil t))))
          (buffer (format "*mastodon-search-%s-%s*" type query))
-         (params `(("q" . ,query)
-                   ,(when type `("type" . ,type))
-                   ,(when following `("following" . ,following))
-                   ,(when account-id `("account_id" . ,account-id))))
+         (params (cl-remove nil
+                            `(("q" . ,query)
+                              ,(when type `("type" . ,type))
+                              ,(when following `("following" . ,following))
+                              ,(when account-id `("account_id" . 
,account-id)))))
          (response (mastodon-http--get-json url params))
          (accts (when (equal type "accounts")
                   (alist-get 'accounts response)))
@@ -215,6 +222,11 @@ ACCOUNT-ID means limit search to that account."
           ((equal type "statuses")
            (mastodon-search--search-query query "hashtags")))))
 
+(defun mastodon-serach--query-accounts-followed (query)
+  "Run an accounts search QUERY, limited to your followers."
+  (interactive "sSearch mastodon for: ")
+  (mastodon-search--search-query query "accounts" :following))
+
 (defun mastodon-search--insert-users-propertized (json &optional note)
   "Insert users list into the buffer.
 JSON is the data from the server. If NOTE is non-nil, include



reply via email to

[Prev in Thread] Current Thread [Next in Thread]