From b2f927617e0e6394cfe55bb603668ee689480103 Mon Sep 17 00:00:00 2001 From: Johnson Denen Date: Tue, 18 Apr 2017 13:55:16 -0400 Subject: Add and use mastodon-tl--field function Retrieves FIELD from TOOT, prioritizing FIELD from boosted toot before TOOT itself. --- lisp/mastodon-tl.el | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 6358c72..e1487bd 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -106,14 +106,17 @@ " " (mastodon-tl--byline-author reblog))))) +(defun mastodon-tl--field (field toot) + "Return FIELD from TOOT. + +Return value from boosted content if available." + (or (cdr (assoc field (cdr (assoc 'reblog toot)))) + (cdr (assoc field toot)))) + (defun mastodon-tl--byline (toot) (let ((id (cdr (assoc 'id toot))) - (faved (or (cdr (assoc 'favourited toot)) - (cdr (assoc 'favourited - (cdr (assoc 'reblog toot)))))) - (boosted (or (cdr (assoc 'reblogged toot)) - (cdr (assoc 'reblogged - (cdr (assoc 'reblog toot))))))) + (faved (mastodon-tl--field 'favourited toot)) + (boosted (mastodon-tl--field 'reblogged toot))) (propertize (concat (propertize "\n | " 'face 'default) (when boosted @@ -123,13 +126,12 @@ (mastodon-tl--byline-author toot) (mastodon-tl--byline-boosted toot) (propertize "\n ------------" 'face 'default)) - 'toot-id id))) + 'toot-id id + 'toot-json toot))) (defun mastodon-tl--content (toot) - (let* ((reblog (cdr (assoc 'reblog toot))) - (content (if reblog - (cdr (assoc 'content reblog)) - (cdr (assoc 'content toot))))) + "Retrieve text content from TOOT." + (let ((content (mastodon-tl--field 'content toot))) (propertize (mastodon-tl--remove-html content) 'face 'default))) -- cgit v1.2.3