aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-12 15:04:42 +0200
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-05-13 09:12:47 +0200
commite34cc6acb20f9f32b42d0d51ce127a5c8a6778ae (patch)
tree182227d5cba710119ea0694e79505982ee274461
parent156ee6ea522f3c6eb23ae8a78e210d0da88d3f7a (diff)
FIX #467. follow tag: prompt for tags in post, default tag at point.
-rw-r--r--lisp/mastodon-tl.el22
1 files changed, 17 insertions, 5 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index bcbb7e3..f682c50 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -2016,15 +2016,27 @@ ARGS is an alist of any parameters to send with the request."
;; FOLLOW TAGS
+(defun mastodon-tl--get-tags-list ()
+ "Return the list of tags of the toot at point."
+ (let* ((toot (or (mastodon-tl--property 'base-toot :no-move) ; fave/boost notifs
+ (mastodon-tl--property 'toot-json :no-move)))
+ (tags (mastodon-tl--field 'tags toot)))
+ (mapcar (lambda (x)
+ (alist-get 'name x))
+ tags)))
+
(defun mastodon-tl--follow-tag (&optional tag)
"Prompt for a tag and follow it.
If TAG provided, follow it."
(interactive)
- (let* ((tag-at-point
- (when (eq 'hashtag (get-text-property (point) 'mastodon-tab-stop))
- (get-text-property (point) 'mastodon-tag)))
- (tag (or tag (read-string (format "Tag to follow [%s]: " tag-at-point)
- nil nil tag-at-point)))
+ (let* ((tags (unless tag (mastodon-tl--get-tags-list)))
+ (tag-at-point
+ (unless tag
+ (when (eq 'hashtag (get-text-property (point) 'mastodon-tab-stop))
+ (get-text-property (point) 'mastodon-tag))))
+ (tag (or tag (completing-read
+ (format "Tag to follow [%s]: " tag-at-point)
+ tags nil nil nil nil tag-at-point)))
(url (mastodon-http--api (format "tags/%s/follow" tag)))
(response (mastodon-http--post url)))
(mastodon-http--triage response