aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-search.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-07 16:54:16 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-07 16:54:16 +0200
commitcf0b8bf2e40c880d00778a438ff0940b8362f495 (patch)
tree0b4a23ca1638689b3339a670a80448b0c7fa6684 /lisp/mastodon-search.el
parent7ca70346ac60436c359a754de56842fdc7280fe3 (diff)
parentaa6e9c55152ac1301efbdbdce9aa7fc3e8fea7c9 (diff)
Merge branch 'with-masto-buf-2' into develop
Diffstat (limited to 'lisp/mastodon-search.el')
-rw-r--r--lisp/mastodon-search.el86
1 files changed, 40 insertions, 46 deletions
diff --git a/lisp/mastodon-search.el b/lisp/mastodon-search.el
index 8cfa3cb..4b5f2e0 100644
--- a/lisp/mastodon-search.el
+++ b/lisp/mastodon-search.el
@@ -29,6 +29,8 @@
;;; Code:
(require 'json)
+(eval-when-compile
+ (require 'mastodon-tl))
(autoload 'mastodon-auth--access-token "mastodon-auth")
(autoload 'mastodon-http--api "mastodon-http")
@@ -118,22 +120,18 @@ PRINT-FUN is the function used to print the data from the response."
(message "todo"))))
(buffer (get-buffer-create
(format "*mastodon-trending-%s*" type))))
- (with-current-buffer buffer
- (switch-to-buffer (current-buffer))
- (mastodon-mode)
- (let ((inhibit-read-only t))
- (erase-buffer)
- (mastodon-tl--set-buffer-spec (buffer-name buffer)
- (format "api/v1/trends/%s" type)
- nil)
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n"
- (upcase (format " TRENDING %s\n" type))
- " " mastodon-tl--horiz-bar "\n\n")
- 'success))
- (funcall print-fun data)
- (unless (equal type "statuses")
- (goto-char (point-min)))))))
+ (with-mastodon-buffer buffer #'mastodon-mode nil
+ (mastodon-tl--set-buffer-spec (buffer-name buffer)
+ (format "api/v1/trends/%s" type)
+ nil)
+ (insert (mastodon-tl--set-face
+ (concat "\n " mastodon-tl--horiz-bar "\n"
+ (upcase (format " TRENDING %s\n" type))
+ " " mastodon-tl--horiz-bar "\n\n")
+ 'success))
+ (funcall print-fun data)
+ (unless (equal type "statuses")
+ (goto-char (point-min))))))
;; functions for mastodon search
@@ -153,36 +151,32 @@ PRINT-FUN is the function used to print the data from the response."
tags))
(toots-list-json
(mastodon-search--get-full-statuses-data statuses)))
- (with-current-buffer (get-buffer-create buffer)
- (switch-to-buffer buffer)
- (mastodon-mode)
- (let ((inhibit-read-only t))
- (erase-buffer)
- (mastodon-tl--set-buffer-spec buffer
- "api/v2/search"
- nil)
- ;; user results:
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n"
- " USERS\n"
- " " mastodon-tl--horiz-bar "\n\n")
- 'success))
- (mastodon-search--insert-users-propertized accts :note)
- ;; hashtag results:
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n"
- " HASHTAGS\n"
- " " mastodon-tl--horiz-bar "\n\n")
- 'success))
- (mastodon-search--print-tags-list tags-list)
- ;; status results:
- (insert (mastodon-tl--set-face
- (concat "\n " mastodon-tl--horiz-bar "\n"
- " STATUSES\n"
- " " mastodon-tl--horiz-bar "\n")
- 'success))
- (mapc #'mastodon-tl--toot toots-list-json)
- (goto-char (point-min))))))
+ (with-mastodon-buffer buffer #'mastodon-mode nil
+ (mastodon-tl--set-buffer-spec buffer
+ "api/v2/search"
+ nil)
+ ;; user results:
+ (insert (mastodon-tl--set-face
+ (concat "\n " mastodon-tl--horiz-bar "\n"
+ " USERS\n"
+ " " mastodon-tl--horiz-bar "\n\n")
+ 'success))
+ (mastodon-search--insert-users-propertized accts :note)
+ ;; hashtag results:
+ (insert (mastodon-tl--set-face
+ (concat "\n " mastodon-tl--horiz-bar "\n"
+ " HASHTAGS\n"
+ " " mastodon-tl--horiz-bar "\n\n")
+ 'success))
+ (mastodon-search--print-tags-list tags-list)
+ ;; status results:
+ (insert (mastodon-tl--set-face
+ (concat "\n " mastodon-tl--horiz-bar "\n"
+ " STATUSES\n"
+ " " mastodon-tl--horiz-bar "\n")
+ 'success))
+ (mapc #'mastodon-tl--toot toots-list-json)
+ (goto-char (point-min)))))
(defun mastodon-search--insert-users-propertized (json &optional note)
"Insert users list into the buffer.