diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-16 07:35:33 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-16 07:38:02 -0400 |
commit | 43c1e81cd4945d6a96760718647d65a9a349fa4a (patch) | |
tree | 6f4d0b1f3209adad720639267061ab37bdd28e0f | |
parent | fc90522bf239c3fab749ca774621abdf6e60ae62 (diff) |
Add function to update current timeline
-rw-r--r-- | lisp/mastodon-tl.el | 23 | ||||
-rw-r--r-- | lisp/mastodon.el | 23 |
2 files changed, 31 insertions, 15 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) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 3bddf55..336ffd4 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -102,7 +102,8 @@ (define-key map (kbd "n") #'mastodon-toot) (define-key map (kbd "q") #'kill-this-buffer) (define-key map (kbd "Q") #'kill-buffer-and-window) - (define-key map (kbd "T") #'mastodon-tl--get-tag-timeline))) + (define-key map (kbd "T") #'mastodon-tl--get-tag-timeline) + (define-key map (kbd "u") #'mastodon-tl--update))) (with-eval-after-load 'mastodon (when (require 'discover nil :noerror) @@ -113,16 +114,16 @@ :context-menu '(mastodon (description "Mastodon feed viewer") (actions - ("Navigation" - ("j" "Go to next toot" mastodon-tl--goto-next-toot) - ("k" "Go to previous toot" mastodon-tl--goto-prev-toot)) - ("Feed switch" - ("F" "Open federated timeline" mastodon-tl--get-federated-timeline) - ("H" "Open home timeline" mastodon-tl--get-home-timeline) - ("L" "Open local timeline" mastodon-tl--get-local-timeline) - ("T" "Prompt for tag and open its timeline" mastodon-tl--get-tag-timeline)) - ("Toot" - ("n" "Switch to 'mastodon-toot' buffer" mastodon-toot)) + ("Toots" + ("j" "Next" mastodon-tl--goto-next-toot) + ("k" "Prev" mastodon-tl--goto-prev-toot) + ("n" "Send" mastodon-toot) + ("u" "Update" mastodon-tl--update)) + ("Timelines" + ("F" "Federated" mastodon-tl--get-federated-timeline) + ("H" "Home" mastodon-tl--get-home-timeline) + ("L" "Local" mastodon-tl--get-local-timeline) + ("T" "Tag" mastodon-tl--get-tag-timeline)) ("Quit" ("q" "Quit mastodon buffer. Leave window open." kill-this-buffer) ("Q" "Quit mastodon buffer and kill window." kill-buffer-and-window))))))) |