diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-20 12:18:44 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-20 12:30:02 -0400 |
commit | fa9b989e536e384ad51cdac7682c9d60b2e535af (patch) | |
tree | e371892bbddb922f6198008d8fc40e59b3ce76f6 /lisp/mastodon-toot.el | |
parent | df6320f5174e610f1eb281ff619fd88a5fb1ba6a (diff) |
Cleanup mastodon-toot feature
- Delete unused functions
- Refactor --action function to use mastodon-http--triage
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 13e23b7..0346f46 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -37,19 +37,6 @@ (defvar mastodon-toot--reply-to-id nil) -(defun mastodon-toot--send-triage (status) - "Callback function to triage toot POST. - -STATUS is passed by `url-retrieve'." - (mastodon--http-response-triage status - (lambda () (switch-to-buffer (current-buffer))))) ;; FIXME - -(defun mastodon-toot--cancel () - "Kill new-toot buffer/window. Does not POST content to Mastodon." - (interactive) - (setq mastodon-toot--reply-to-id nil) - (kill-buffer-and-window)) - (defun mastodon-toot--action-success (marker) "Insert MARKER with 'success face in byline." (let ((inhibit-read-only t)) @@ -57,25 +44,21 @@ STATUS is passed by `url-retrieve'." (propertize marker 'face 'success))) (mastodon-tl--goto-prev-toot))) -(defun mastodon-toot--action-triage (response callback) - "Parse response code from RESPONSE buffer. - -Execute CALLBACK function if response was OK." - (let ((status (with-current-buffer response - (mastodon--response-code)))) - (if (string-prefix-p "2" status) - (funcall callback) - (switch-to-buffer response)))) - (defun mastodon-toot--action (action callback) - "Take action on toot at point." + "Take ACTION on toot at point, then execute CALLBACK." (let* ((id (mastodon-tl--property 'toot-id)) (url (mastodon--api-for (concat "statuses/" (number-to-string id) "/" action)))) (let ((response (mastodon-http--post url nil nil))) - (mastodon-toot--action-triage response callback)))) + (mastodon-http--triage response callback)))) + +(defun mastodon-toot--cancel () + "Kill new-toot buffer/window. Does not POST content to Mastodon." + (interactive) + (setq mastodon-toot--reply-to-id nil) + (kill-buffer-and-window)) (defun mastodon-toot--send () "Kill new-toot buffer/window and POST contents to the Mastodon instance." |