aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-tl.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r--lisp/mastodon-tl.el76
1 files changed, 57 insertions, 19 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index b2b7d27..ac15f7b 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -140,7 +140,9 @@ nil."
(locked . ("🔒" . "[locked]"))
(private . ("🔒" . "[followers]"))
(direct . ("✉" . "[direct]"))
- (edited . ("✍" . "[edited]")))
+ (edited . ("✍" . "[edited]"))
+ (replied . ("⬇" . "↓"))
+ (reply-bar . ("┃" . "|")))
"A set of symbols (and fallback strings) to be used in timeline.
If a symbol does not look right (tofu), it means your
font settings do not support it."
@@ -749,7 +751,7 @@ links in the text. If TOOT is nil no parsing occurs."
(insert string)
(let ((shr-use-fonts mastodon-tl--enable-proportional-fonts)
(shr-width (when mastodon-tl--enable-proportional-fonts
- (- (window-width) 1))))
+ (- (window-width) 3))))
(shr-render-region (point-min) (point-max)))
;; Make all links a tab stop recognized by our own logic, make things point
;; to our own logic (e.g. hashtags), and update keymaps where needed:
@@ -1264,8 +1266,21 @@ Runs `mastodon-tl--render-text' and fetches poll or media."
(mastodon-tl--get-poll toot))
(mastodon-tl--media toot))))
+(defun mastodon-tl--prev-toot-id ()
+ "Return the id of the last toot inserted into the buffer."
+ (let ((prev-pos (1- (save-excursion
+ (previous-single-property-change
+ (point)
+ 'base-toot-id)))))
+ (get-text-property prev-pos 'base-toot-id)))
+
+(defun mastodon-tl--after-reply-status (reply-to-id)
+ "T if REPLY-TO-ID is equal to that of the last toot inserted in the bufer."
+ (let ((prev-id (mastodon-tl--prev-toot-id)))
+ (string= reply-to-id prev-id)))
+
(defun mastodon-tl--insert-status (toot body author-byline action-byline
- &optional id base-toot detailed-p)
+ &optional id base-toot detailed-p thread)
"Display the content and byline of timeline element TOOT.
BODY will form the section of the toot above the byline.
AUTHOR-BYLINE is an optional function for adding the author
@@ -1280,14 +1295,30 @@ attached as a `toot-id' property if provided. If the
status is a favourite or boost notification, BASE-TOOT is the
JSON of the toot responded to.
DETAILED-P means display more detailed info. For now
-this just means displaying toot client."
- (let ((start-pos (point)))
+this just means displaying toot client.
+THREAD means the status will be displayed in a thread view."
+ (let* ((start-pos (point))
+ (reply-to-id (alist-get 'in_reply_to_id toot))
+ (after-reply-status-p
+ (when (and thread reply-to-id)
+ (mastodon-tl--after-reply-status reply-to-id))))
(insert
(propertize
- (concat "\n"
- body
- " \n"
- (mastodon-tl--byline toot author-byline action-byline detailed-p))
+ (concat
+ "\n"
+ (if (and after-reply-status-p thread)
+ (concat (mastodon-tl--symbol 'replied)
+ "\n")
+ "")
+ (if (and after-reply-status-p thread)
+ (let ((bar (mastodon-tl--symbol 'reply-bar)))
+ (propertize body
+ 'line-prefix bar
+ 'wrap-prefix bar))
+ body)
+ ;; body
+ " \n"
+ (mastodon-tl--byline toot author-byline action-byline detailed-p))
'toot-id (or id ; notification's own id
(alist-get 'id toot)) ; toot id
'base-toot-id (mastodon-tl--toot-id
@@ -1363,10 +1394,11 @@ To disable showing the stats, customize
(and (null (mastodon-tl--field 'in_reply_to_id toot))
(not (mastodon-tl--field 'rebloged toot))))
-(defun mastodon-tl--toot (toot &optional detailed-p)
+(defun mastodon-tl--toot (toot &optional detailed-p thread)
"Format TOOT and insert it into the buffer.
DETAILED-P means display more detailed info. For now
-this just means displaying toot client."
+this just means displaying toot client.
+THREAD means the status will be displayed in a thread view."
(mastodon-tl--insert-status
toot
(mastodon-tl--clean-tabs-and-nl
@@ -1377,12 +1409,15 @@ this just means displaying toot client."
'mastodon-tl--byline-boosted
nil
nil
- detailed-p))
+ detailed-p
+ thread))
-(defun mastodon-tl--timeline (toots)
+(defun mastodon-tl--timeline (toots &optional thread)
"Display each toot in TOOTS.
-This function removes replies if user required."
- (mapc #'mastodon-tl--toot
+This function removes replies if user required.
+THREAD means the status will be displayed in a thread view."
+ (mapc (lambda (toot)
+ (mastodon-tl--toot toot nil thread))
;; hack to *not* filter replies on profiles:
(if (eq (mastodon-tl--get-buffer-type) 'profile-statuses)
toots
@@ -1739,12 +1774,14 @@ view all branches of a thread."
(mastodon-tl--set-buffer-spec buffer
endpoint
#'mastodon-tl--thread)
- (mastodon-tl--timeline (alist-get 'ancestors context))
+ (mastodon-tl--timeline (alist-get 'ancestors context)
+ :thread)
(goto-char (point-max))
(move-marker marker (point))
;; print re-fetched toot:
- (mastodon-tl--toot toot :detailed-p)
- (mastodon-tl--timeline (alist-get 'descendants context))
+ (mastodon-tl--toot toot :detailed-p :thread)
+ (mastodon-tl--timeline (alist-get 'descendants context)
+ :thread)
;; put point at the toot:
(goto-char (marker-position marker))
(mastodon-tl--goto-next-toot))))
@@ -2098,7 +2135,8 @@ PREFIX is sent to `mastodon-tl--show-tag-timeline', which see."
(defun mastodon-tl--some-followed-tags-timeline (&optional prefix)
"Prompt for some tags, and open a timeline for them.
-The suggestions are from followed tags, but any other tags are also allowed."
+The suggestions are from followed tags, but any other tags are also allowed.
+PREFIX us sent to `mastodon-tl--show-tag-timeline', which see."
(interactive "p")
(let* ((followed-tags-json (mastodon-tl--followed-tags))
(tags (mastodon-tl--map-alist 'name followed-tags-json))