From 075fc0eb2c4f4fb356339ed27370ea477a7b47e4 Mon Sep 17 00:00:00 2001 From: Alexander Griffith Date: Mon, 24 Apr 2017 20:49:41 -0400 Subject: Fixed #70, added mastodon-toot--unfavorite --- lisp/mastodon-toot.el | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'lisp') 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) -- cgit v1.2.3