From c35e0a33be088bdb27031855886e5dd9cbed4f32 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Sep 2022 13:23:51 +0200 Subject: work on url-lookup --- lisp/mastodon.el | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 3162e91..8f49538 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -274,15 +274,15 @@ URL can be arg QUERY-URL, or URL at point, or provided by the user. If a status or account is found, load it in `mastodon.el', if not, just browse the URL in the normal fashion." (interactive) - (message "Performing lookup...") (let* ((query (or query-url (url-get-url-at-point) - (read-string "Lookup URL: "))) - (url (format "%s/api/v2/search" mastodon-instance-url)) - (param (concat "resolve=t")) ; webfinger - (response (mastodon-http--get-search-json url query param :silent))) - (if (equal response '((accounts . #1=[]) (statuses . #1#) (hashtags . #1#))) - (shr-browse-url query-url) + (mastodon-tl--property 'shr-url) + (read-string "Lookup URL: ")))) + ;; TODO: test for a likely masto link and just browse-url if not + (message "Performing lookup...") + (let* ((url (format "%s/api/v2/search" mastodon-instance-url)) + (param (concat "resolve=t")) ; webfinger + (response (mastodon-http--get-search-json url query param :silent))) (cond ((not (seq-empty-p (alist-get 'statuses response))) (let* ((statuses (assoc 'statuses response)) @@ -293,8 +293,10 @@ not, just browse the URL in the normal fashion." (alist-get 'accounts response))) (let* ((accounts (assoc 'accounts response)) (account (seq-first (cdr accounts))) - (account-id (alist-get 'id account))) - (mastodon-profile--account-from-id account-id))))))) + (account-acct (alist-get 'acct account))) + (mastodon-profile--show-user account-acct))) + (t + (browse-url query)))))) ;;;###autoload (add-hook 'mastodon-mode-hook (lambda () -- cgit v1.2.3