diff options
author | Alexander Griffith <griffitaj@gmail.com> | 2017-04-24 20:49:41 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-27 16:04:28 -0400 |
commit | 075fc0eb2c4f4fb356339ed27370ea477a7b47e4 (patch) | |
tree | 5683d6fb6554191e868f22781ec3652e245f1406 | |
parent | e44cda1eafa8e21d5ec5c2191bab1dad0c3055de (diff) |
Fixed #70, added mastodon-toot--unfavorite
-rw-r--r-- | lisp/mastodon-toot.el | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 166f95b..7d5a362 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -41,9 +41,21 @@ (defun mastodon-toot--action-success (marker) "Insert MARKER with 'success face in byline." (let ((inhibit-read-only t)) + (move-beginning-of-line '()) + (mastodon-tl--goto-next-toot) (insert (format "(%s) " - (propertize marker 'face 'success))) - (mastodon-tl--goto-prev-toot))) + (propertize marker 'face 'success))))) + +(defun mastodon-toot--action-success-undo (marker) + "Remove MARKER from byline." + (let ((inhibit-read-only t) + (start (progn (move-beginning-of-line '()) + (point))) + (end (progn (move-end-of-line '()) + (point)))) + (replace-regexp (format "(%s) " marker) "" '() start end) + (move-beginning-of-line '()) + (mastodon-tl--goto-next-toot))) (defun mastodon-toot--action (action callback) "Take ACTION on toot at point, then execute CALLBACK." @@ -103,6 +115,14 @@ Set `mastodon-toot--content-warning' to nil." (mastodon-toot--action "favourite" callback) (message (format "Favourited #%s" id)))) +(defun mastodon-toot--unfavourite () + "Favourite toot at `point'." + (interactive) + (let ((callback (lambda () ( mastodon-toot--action-success-undo "F"))) + (id (mastodon-tl--property 'toot-id))) + (mastodon-toot--action "unfavourite" callback) + (message (format "unfavourited #%s" id)))) + (defun mastodon-toot--reply () "Reply to toot at `point'." (interactive) |