diff options
author | mousebot <mousebot@riseup.net> | 2021-05-25 17:22:13 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-05-25 17:22:13 +0200 |
commit | 16db675587e2e33ac512e2ea43171c2f4fffed9f (patch) | |
tree | f75d4e2470c82858c8faeecf1465d8bfa9637286 /lisp | |
parent | d8121e7447bf30767cd91523e12429a7a934a2c9 (diff) |
Support basic displaying of polls.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-tl.el | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 5bc07e0..298964d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -47,6 +47,7 @@ (autoload 'mastodon-profile--account-field "mastodon-profile.el") (autoload 'mastodon-profile--extract-users-handles "mastodon-profile.el") (autoload 'mastodon-profile--my-profile "mastodon-profile.el") +(autoload 'mastodon-toot--delete-toot "mastodon-toot") (defvar mastodon-instance-url) (defvar mastodon-toot-timestamp-format) @@ -640,8 +641,11 @@ message is a link which unhides/hides the main body." (defun mastodon-tl--content (toot) "Retrieve text content from TOOT." - (let ((content (mastodon-tl--field 'content toot))) + (let ((content (mastodon-tl--field 'content toot)) + (poll-p (cdr (assoc 'poll toot)))) (concat + (when poll-p + (mastodon-tl--get-poll toot)) (mastodon-tl--render-text content toot) (mastodon-tl--media toot)))) @@ -668,6 +672,18 @@ it is `mastodon-tl--byline-boosted'" (when mastodon-tl--display-media-p (mastodon-media--inline-images start-pos (point))))) +(defun mastodon-tl--get-poll (toot) + "If post TOOT is a poll, return a formatted string of poll." + (let* ((poll (mastodon-tl--field 'poll toot)) + (options (mastodon-tl--field 'options poll))) + (concat "Poll: \n\n" + (mapconcat (lambda (option) + (format "Option: %s, %s votes.\n" + (cdr (assoc 'title option)) + (cdr (assoc 'votes_count option)))) + options + "\n") "\n"))) + (defun mastodon-tl--toot (toot) "Formats TOOT and insertes it into the buffer." (mastodon-tl--insert-status |