From 43c1e81cd4945d6a96760718647d65a9a349fa4a Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Sun, 16 Apr 2017 07:35:33 -0400 Subject: Add function to update current timeline --- lisp/mastodon-tl.el | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'lisp/mastodon-tl.el') 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) -- cgit v1.2.3