diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-08-09 18:08:20 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-08-12 14:55:20 +0200 |
commit | ca4ac2e568690b7c1c0a2a1b3ebf11be2a963aa8 (patch) | |
tree | 4fe4dc79172abbb8554eb31cb18e33720d67a16f | |
parent | 806253ee26d3fd5741c1495265c8fb8d54010859 (diff) |
fix read-poll option check
-rw-r--r-- | lisp/mastodon-tl.el | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 948ee37..6c6307d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1358,19 +1358,18 @@ OPTIONS is an alist." (defun mastodon-tl--read-poll-option () "Read a poll option to vote on a poll." (let* ((toot (mastodon-tl--property 'item-json)) - (poll (mastodon-tl--field 'poll toot)) - (options (mastodon-tl--field 'options poll)) - (titles (mastodon-tl--map-alist 'title options)) - (number-seq (number-sequence 1 (length options))) - (numbers (mapcar #'number-to-string number-seq)) - (options-alist (cl-mapcar #'cons numbers titles)) - - (candidates (mastodon-tl--format-read-poll-option options-alist)) - (choice (completing-read "Poll option to vote for: " - candidates nil :match))) + (poll (mastodon-tl--field 'poll toot))) (if (null poll) (user-error "No poll here") - (list (cdr (assoc choice candidates)))))) + (let* ((options (mastodon-tl--field 'options poll)) + (titles (mastodon-tl--map-alist 'title options)) + (number-seq (number-sequence 1 (length options))) + (numbers (mapcar #'number-to-string number-seq)) + (options-alist (cl-mapcar #'cons numbers titles)) + (candidates (mastodon-tl--format-read-poll-option options-alist)) + (choice (completing-read "Poll option to vote for: " + candidates nil :match))) + (list (cdr (assoc choice candidates))))))) (defun mastodon-tl--poll-vote (option) "If there is a poll at point, prompt user for OPTION to vote on it." |