aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-12-17 21:47:01 +0100
committermousebot <mousebot@riseup.net>2021-12-17 21:47:01 +0100
commit03bf9741f77b2c1292ab72148a4d60bb6fcfe3cc (patch)
treeaf3e2c720c3ef8e8676f00857c2fc5a0ed210ba6 /lisp
parent9a44a97b751855529647ead629bc300bc7e045ce (diff)
improve faves count help-echo propertizing
- add `mastodon-tl--format-faves-count function - handle notifications formatting (get 'status field of toot) - apply to author-byline formatting - apply to the (F) and (B) formatting for faves/boosts - ensures where point lands after `mastodon-tl--goto-next-toot is always propertized
Diffstat (limited to 'lisp')
-rw-r--r--lisp/mastodon-tl.el40
1 files changed, 30 insertions, 10 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index fe8f7c8..c2cfdb2 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -287,14 +287,11 @@ Optionally start from POS."
(propertize name
'face 'mastodon-display-name-face
'help-echo
+ (mastodon-tl--format-faves-count toot))
+ ;; 'help-echo
;; echo faves count when point on post author name:
;; which is where --goto-next-toot puts point.
- ;; prefer the reblog toot if present:
- (let ((toot-to-use (or (alist-get 'reblog toot) toot)))
- (format "%s faves | %s boosts | %s replies"
- (alist-get 'favourites_count toot-to-use)
- (alist-get 'reblogs_count toot-to-use)
- (alist-get 'replies_count toot-to-use))))
+ ;; (mastodon-tl--format-faves-count toot))
" ("
(propertize (concat "@" handle)
'face 'mastodon-handle-face
@@ -308,6 +305,21 @@ Optionally start from POS."
'help-echo (concat "Browse user profile of @" handle))
")")))
+(defun mastodon-tl--format-faves-count (toot)
+ "Format a favorites, boosts, replies count for a TOOT.
+Used to help-echo when point is at the start of a byline,
+i.e. where `mastodon-tl--goto-next-toot' leaves point."
+ (let ((toot-to-count
+ (or
+ ;; simply praying this order works
+ (alist-get 'status toot) ; notifications timeline
+ (alist-get 'reblog toot) ; boosts
+ toot))) ; everything else
+ (format "%s faves | %s boosts | %s replies"
+ (alist-get 'favourites_count toot-to-count)
+ (alist-get 'reblogs_count toot-to-count)
+ (alist-get 'replies_count toot-to-count))))
+
(defun mastodon-tl--byline-boosted (toot)
"Add byline for boosted data from TOOT."
(let ((reblog (alist-get 'reblog toot)))
@@ -406,11 +418,19 @@ By default it is `mastodon-tl--byline-boosted'"
;; (propertize "\n | " 'face 'default)
(propertize
(concat (when boosted
- (format "(%s) "
- (propertize "B" 'face 'mastodon-boost-fave-face)))
+ (format
+ (propertize "(%s) "
+ 'help-echo
+ (mastodon-tl--format-faves-count toot))
+ (propertize "B" 'face 'mastodon-boost-fave-face)))
(when faved
- (format "(%s) "
- (propertize "F" 'face 'mastodon-boost-fave-face)))
+ (format
+ (propertize "(%s) "
+ 'help-echo
+ (mastodon-tl--format-faves-count toot))
+ (propertize "F" 'face 'mastodon-boost-fave-face)))
+ ;; we propertize help-echo format faves for author name
+ ;; in `mastodon-tl--byline-author'
(funcall author-byline toot)
(cond ((equal visibility "direct")
(if (fontp (char-displayable-p #10r128274))