diff options
author | martianh <martianh@noreply.codeberg.org> | 2023-01-19 15:31:41 +0000 |
---|---|---|
committer | martianh <martianh@noreply.codeberg.org> | 2023-01-19 15:31:41 +0000 |
commit | ff9c066034bf94ff03c1a0f1183c0f20dfbc693a (patch) | |
tree | eae27cefab9c7ba2dc6ee6fe2f20cecfb050ed30 /lisp/mastodon-tl.el | |
parent | bf7a1b445003f7e15d1e2b38f7635de142df19d1 (diff) | |
parent | 035c07af4ad93ad1ed3e30d1dc8bb293f375837a (diff) |
Merge pull request 'Add option to hide replies' (#365) from boynux/mastodon.el:hide-replies into develop
Reviewed-on: https://codeberg.org/martianh/mastodon.el/pulls/365
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 931fa0b..ae39887 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -162,6 +162,11 @@ Valid values are: Must be an integer between 20 and 40 inclusive." :type '(string)) +(defcustom mastodon-tl--hide-replies nil + "Whether to hide replies from the timelines." + :group 'mastodon-tl + :type '(boolean :tag "Whether to hide replies from the timelines.")) + (defvar-local mastodon-tl--update-point nil "When updating a mastodon buffer this is where new toots will be inserted. If nil `(point-min)' is used instead.") @@ -1339,8 +1344,13 @@ in which case play first video or gif from current toot." (message "no moving image here?")) (message "no moving image here?")))) +(defun mastodon-tl--is-reply (toot) + "Check if the TOOT is a reply to another one (and not boosted)." + (and (null (mastodon-tl--field 'in_reply_to_id toot)) + (not (mastodon-tl--field 'rebloged toot)))) + (defun mastodon-tl--toot (toot &optional detailed-p) - "Formats TOOT and insertes it into the buffer. + "Formats TOOT and inserts it into the buffer. DETAILED-P means display more detailed info. For now this just means displaying toot client." (mastodon-tl--insert-status @@ -1356,8 +1366,12 @@ this just means displaying toot client." detailed-p)) (defun mastodon-tl--timeline (toots) - "Display each toot in TOOTS." - (mapc 'mastodon-tl--toot toots) + "Display each toot in TOOTS. + + This function removes replies if user required." + (mapc 'mastodon-tl--toot (if (mastodon-tl--hide-replies-p current-prefix-arg) + (cl-remove-if-not #'mastodon-tl--is-reply toots) + toots)) (goto-char (point-min))) (defun mastodon-tl--get-update-function (&optional buffer) @@ -1503,6 +1517,20 @@ buffers that aren't strictly mastodon timelines." (let ((timeline-buffers '(home federated local tag-timeline list-timeline profile-statuses))) (member (mastodon-tl--get-buffer-type) timeline-buffers))) +(defun mastodon-tl--hide-replies-p (&optional prefix) + "Return non-nil if replies should be hidden in the timeline. +We hide replies if user explictly set the +`mastodon-tl--hide-replies' or used PREFIX combination to open a +timeline." + (and + ;; Only hide replies if we are in a proper timeline + (mastodon-tl--timeline-proper-p) + (or + ;; User configured to hide replies + mastodon-tl--hide-replies + ;; Timeline called with C-u prefix + (equal '(4) prefix)))) + (defun mastodon-tl--more-json (endpoint id) "Return JSON for timeline ENDPOINT before ID." (let* ((args `(("max_id" . ,(mastodon-tl--as-string id)))) |