aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-async.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-async.el')
-rw-r--r--lisp/mastodon-async.el40
1 files changed, 19 insertions, 21 deletions
diff --git a/lisp/mastodon-async.el b/lisp/mastodon-async.el
index 56dc230..524e13d 100644
--- a/lisp/mastodon-async.el
+++ b/lisp/mastodon-async.el
@@ -55,17 +55,14 @@
(defvar mastodon-tl--display-media-p)
(defvar mastodon-tl--buffer-spec)
-(make-variable-buffer-local
- (defvar mastodon-async--queue "" ;;"*mastodon-async-queue*"
- "The intermediate queue buffer name."))
+(defvar-local mastodon-async--queue "" ;;"*mastodon-async-queue*"
+ "The intermediate queue buffer name.")
-(make-variable-buffer-local
- (defvar mastodon-async--buffer "" ;;"*mastodon-async-buffer*"
- "User facing output buffer name."))
+(defvar-local mastodon-async--buffer "" ;;"*mastodon-async-buffer*"
+ "User facing output buffer name.")
-(make-variable-buffer-local
- (defvar mastodon-async--http-buffer "" ;;""
- "Buffer variable bound to http output."))
+(defvar-local mastodon-async--http-buffer "" ;;""
+ "Buffer variable bound to http output.")
(defun mastodon-async--display-http ()
"Display the async HTTP input buffer."
@@ -180,16 +177,16 @@ is not known when `mastodon-async--setup-buffer' is called."
NAME is used to generate the display buffer and the queue."
(let ((queue-name (concat " *mastodon-async-queue-" name "-"
- mastodon-instance-url "*"))
+ mastodon-instance-url "*"))
(buffer-name (concat "*mastodon-async-display-" name "-"
- mastodon-instance-url "*")))
+ mastodon-instance-url "*")))
(mastodon-async--set-local-variables http-buffer http-buffer
buffer-name queue-name)))
(defun mastodon-async--setup-queue (http-buffer name)
"Sets up the buffer for the async queue."
(let ((queue-name (concat " *mastodon-async-queue-" name "-"
- mastodon-instance-url "*"))
+ mastodon-instance-url "*"))
(buffer-name(concat "*mastodon-async-display-" name "-"
mastodon-instance-url "*")))
(mastodon-async--set-local-variables queue-name http-buffer
@@ -206,11 +203,12 @@ ENPOINT is the endpoint for the stream and timeline."
mastodon-instance-url "*"))
(buffer-name (concat "*mastodon-async-display-" name "-"
mastodon-instance-url "*"))
- ;; if user stream, we need "timelines/home" not "timelines/user"
- ;; if notifs, we need "notifications" not "timelines/notifications"
- (endpoint (if (equal name "notifications") "notifications"
- (if (equal name "home") "timelines/home"
- (format "timelines/%s" endpoint)))))
+ ;; if user stream, we need "timelines/home" not "timelines/user"
+ ;; if notifs, we need "notifications" not "timelines/notifications"
+ (endpoint (cond
+ ((equal name "notifications") "notifications")
+ ((equal name "home") "timelines/home")
+ (t (format "timelines/%s" endpoint)))))
(mastodon-async--set-local-variables buffer-name http-buffer
buffer-name queue-name)
;; Similar to timeline init.
@@ -288,8 +286,8 @@ Filter the toots using FILTER."
;; NB notification events in streams include follow requests
(let* ((split-strings (split-string string "\n" t))
(event-type (replace-regexp-in-string
- "^event: " ""
- (car split-strings)))
+ "^event: " ""
+ (car split-strings)))
(data (replace-regexp-in-string
"^data: " "" (cadr split-strings))))
(when (equal "notification" event-type)
@@ -307,8 +305,8 @@ Filter the toots using FILTER."
(defun mastodon-async--account-local-p (json)
"Test JSON to see if account is local."
(not (string-match-p
- "@"
- (cdr (assoc 'acct (cdr (assoc 'account json)))))))
+ "@"
+ (alist-get 'acct (alist-get 'account json)))))
(defun mastodon-async--output-toot (toot)
"Process TOOT and prepend it to the async user-facing buffer."