aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-16 07:35:33 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-16 07:38:02 -0400
commit43c1e81cd4945d6a96760718647d65a9a349fa4a (patch)
tree6f4d0b1f3209adad720639267061ab37bdd28e0f /lisp/mastodon-tl.el
parentfc90522bf239c3fab749ca774621abdf6e60ae62 (diff)
Add function to update current timeline
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el23
1 files changed, 19 insertions, 4 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 10a7ed7..e7100e8 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -119,16 +119,31 @@
'toot-url url))))
(defun mastodon-tl--render-timeline (buffer json)
- (with-output-to-temp-buffer buffer
- (switch-to-buffer buffer)
- (mapcar 'mastodon-tl--render-toot json))
+ (switch-to-buffer buffer)
+ (mapcar 'mastodon-tl--render-toot json)
(html2text))
+(defun mastodon-tl--timeline-name ()
+ (replace-regexp-in-string "\*" ""
+ (replace-regexp-in-string "mastodon-" "" (buffer-name))))
+
+(defun mastodon-tl--update ()
+ (interactive)
+ (let* ((tl (mastodon-tl--timeline-name))
+ (id (get-text-property (point-min) 'toot-id))
+ (url (mastodon--api-for (concat "timelines/" tl "?since_id=" id))))
+ (with-current-buffer (current-buffer)
+ (let ((inhibit-read-only t)
+ (json (mastodon-http--get-json url)))
+ (goto-char (point-min))
+ (mastodon-tl--render-timeline (current-buffer) json)))))
+
(defun mastodon-tl--get (timeline)
(let* ((url (mastodon--api-for (concat "timelines/" timeline)))
(tl-buff (concat "*mastodon-" timeline "*"))
(tl-json (mastodon-http--get-json url)))
- (mastodon-tl--render-timeline tl-buff tl-json)
+ (with-output-to-temp-buffer tl-buff
+ (mastodon-tl--render-timeline tl-buff tl-json))
(mastodon-mode)))
(provide 'mastodon-tl)