aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authorAlexander Griffith <griffitaj@gmail.com>2017-04-24 20:49:41 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-28 19:57:23 -0400
commit721859b2ed5cb2fbc687c6be1c0b9845c03f1fae (patch)
tree5683d6fb6554191e868f22781ec3652e245f1406 /lisp/mastodon-toot.el
parente44cda1eafa8e21d5ec5c2191bab1dad0c3055de (diff)
Fixed #70, added mastodon-toot--unfavorite
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el24
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)