diff options
author | mousebot <mousebot@riseup.net> | 2021-05-08 12:03:43 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-05-08 12:03:43 +0200 |
commit | 77941ed350b83ab36459e0bb1346699e1db992c2 (patch) | |
tree | 6c2d0b11f97b81a523735f8f69c8cb5d3f3ea02d | |
parent | 5e1751c2c9ec8096c5b2d03c6aca699fc102cf60 (diff) |
unfollow user fun
-rw-r--r-- | lisp/mastodon-tl.el | 27 | ||||
-rw-r--r-- | lisp/mastodon.el | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 14623e6..10284d2 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -45,6 +45,7 @@ ;; try an autoload for new follow fun (autoload 'mastodon-profile--toot-json "mastodon-profile.el") (autoload 'mastodon-profile--account-field "mastodon-profile.el") +(autoload 'mastodon-profile--extract-users-handles "mastodon-profile.el") (defvar mastodon-instance-url) (defvar mastodon-toot-timestamp-format) (defvar shr-use-fonts) ;; need to declare it since Emacs24 didn't have this @@ -799,7 +800,7 @@ webapp" (message "Toot deleted! There may be a delay before it disappears from your profile.")))))) (defun mastodon-tl--follow-user (user-handle) - "Query user for user id from current status and follow that user." + "Query for user id from current status and follow that user." (interactive (list (let ((user-handles (mastodon-profile--extract-users-handles @@ -820,6 +821,30 @@ webapp" (message "User %s (@%s) followed!" name user-handle)))) (message "Cannot find a user with handle %S" user-handle)))) +(defun mastodon-tl--unfollow-user (user-handle) + "Query for user id from current status and unfollow that user." + (interactive + (list + (let ((user-handles (mastodon-profile--extract-users-handles + (mastodon-profile--toot-json)))) + (completing-read "User handle: " + user-handles + nil ; predicate + 'confirm)))) + (let* ((account (mastodon-profile--lookup-account-in-status + user-handle (mastodon-profile--toot-json))) + (user-id (mastodon-profile--account-field account 'id)) + (name (mastodon-profile--account-field account 'display_name)) + (url (mastodon-http--api (format "accounts/%s/unfollow" user-id)))) + (if account + (when (y-or-n-p (format "Unfollow user %s? " name)) + (let ((response (mastodon-http--post url nil nil))) + (mastodon-http--triage response + (lambda () + (message "User %s (@%s) unfollowed!" name user-handle)))) + (message "Cannot find a user with handle %S" user-handle))))) + + (defun mastodon-tl--more () "Append older toots to timeline." (interactive) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index a6609ac..22c7c1c 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -108,6 +108,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "g") #'undefined) (define-key map (kbd "D") #'mastodon-tl--delete-toot) (define-key map (kbd "W") #'mastodon-tl--follow-user) + (define-key map (kbd "C-S-W") #'mastodon-tl--unfollow-user) map) "Keymap for `mastodon-mode'.") |