From 13e1ebff3b73ba3e6ad522d91103f432ce96ff92 Mon Sep 17 00:00:00 2001 From: mousebot Date: Sat, 19 Feb 2022 13:43:24 +0100 Subject: add checks to profile--show-user for when its called on nothing - also make profile--extract-ysers-handles work on user listings as well as toots --- lisp/mastodon-profile.el | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'lisp/mastodon-profile.el') diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index 57fa080..9c1cd88 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -400,19 +400,23 @@ If toot is a boost, opens the profile of the booster." "Query for USER-HANDLE from current status and show that user's profile." (interactive (list - (let ((user-handles (mastodon-profile--extract-users-handles - (mastodon-profile--toot-json)))) - (completing-read "View profile of user [choose or enter any handle]: " - user-handles - nil ; predicate - 'confirm)))) - (let ((account (mastodon-profile--lookup-account-in-status - user-handle (mastodon-profile--toot-json)))) - (if account - (progn - (message "Loading profile of user %s..." user-handle) - (mastodon-profile--make-author-buffer account)) - (message "Cannot find a user with handle %S" user-handle)))) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (let ((user-handles (mastodon-profile--extract-users-handles + (mastodon-profile--toot-json)))) + (completing-read "View profile of user [choose or enter any handle]: " + user-handles + nil ; predicate + 'confirm))))) + (if (not (get-text-property (point) 'toot-json)) + (message "Looks like there's no toot or user at point?") + (let ((account (mastodon-profile--lookup-account-in-status + user-handle (mastodon-profile--toot-json)))) + (if account + (progn + (message "Loading profile of user %s..." user-handle) + (mastodon-profile--make-author-buffer account)) + (message "Cannot find a user with handle %S" user-handle))))) (defun mastodon-profile--my-profile () "Show the profile of the currently signed in user." @@ -474,9 +478,11 @@ If the handle does not match a search return then retun NIL." These include the author, author of reblogged entries and any user mentioned." (when status - (let ((this-account (alist-get 'account status)) - (mentions (alist-get 'mentions status)) - (reblog (alist-get 'reblog status))) + (let ((this-account + (or (alist-get 'account status) ; status is a toot + status)) ; status is a user listing + (mentions (alist-get 'mentions status)) + (reblog (alist-get 'reblog status))) (seq-filter 'stringp (seq-uniq -- cgit v1.2.3