diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-06-02 19:10:01 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-06-02 19:10:01 +0200 |
commit | f4b9c70d18aabd8f53bd09645cc8f29de599edec (patch) | |
tree | 55648361f78dd6bb7bf82d51ca277fb9ad304b7b /lisp | |
parent | d68cf7104b59e0c98743359bc566d7faf4a07776 (diff) |
simply format-poll length formatting
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-tl.el | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 89d70a5..1d9795d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1218,14 +1218,14 @@ SENSITIVE is a flag from the item's JSON data." ;; POLLS -(defun mastodon-tl--format-poll-option (option option-counter longest-option) +(defun mastodon-tl--format-poll-option (option option-counter length) "Format poll OPTION. OPTION-COUNTER is just a counter. LONGEST-OPTION is the option whose length determines the formatting." (format "%s: %s%s%s\n" option-counter (propertize (alist-get 'title option) 'face 'success) - (make-string (1+ (- (length longest-option) + (make-string (1+ (- length (length (alist-get 'title option)))) ?\ ) ;; TODO: disambiguate no votes from hidden votes @@ -1236,16 +1236,13 @@ LONGEST-OPTION is the option whose length determines the formatting." "If TOOT includes a poll, return it as a formatted string." (let-alist poll (let* ((option-titles (mastodon-tl--map-alist 'title .options)) - (longest-option (car (sort option-titles - (lambda (x y) - (> (length x) - (length y)))))) + (longest (car (sort (mapcar #'length option-titles) #'>))) (option-counter 0)) (concat "\nPoll: \n\n" (mapconcat (lambda (option) (setq option-counter (1+ option-counter)) (mastodon-tl--format-poll-option - option option-counter longest-option)) + option option-counter longest)) .options "\n") "\n" |