[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon babb3a1adf 28/50: fold-toot - respect CW state
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon babb3a1adf 28/50: fold-toot - respect CW state |
Date: |
Sat, 2 Nov 2024 13:00:54 -0400 (EDT) |
branch: elpa/mastodon
commit babb3a1adf7dbc2c458c65d841e758aafaabd298
Author: marty hiatt <martianhiatus@disroot.org>
Commit: marty hiatt <martianhiatus@disroot.org>
fold-toot - respect CW state
---
lisp/mastodon-tl.el | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index 5178a25721..b655bec41f 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1772,15 +1772,18 @@ title, and context."
(mastodon-tl--filter-by-context context filters-no-context)))
(defun mastodon-tl--toot (toot &optional detailed-p thread domain
- unfolded no-byline)
+ unfolded no-byline no-cw)
"Format TOOT and insert it into the buffer.
DETAILED-P means display more detailed info. For now
this just means displaying toot client.
THREAD means the status will be displayed in a thread view.
When DOMAIN, force inclusion of user's domain in their handle.
UNFOLDED is a boolean meaning whether to unfold or fold item if foldable.
-NO-BYLINE means just insert toot body, used for folding."
- (let* ((filtered (mastodon-tl--field 'filtered toot))
+NO-BYLINE means just insert toot body, used for folding.
+NO-CW means treat content warnings as unfolded."
+ (let* ((mastodon-tl--expand-content-warnings
+ (or no-cw mastodon-tl--expand-content-warnings))
+ (filtered (mastodon-tl--field 'filtered toot))
(filters (when filtered
(mastodon-tl--current-filters filtered)))
(spoiler-or-content (if-let ((match (assoc "warn" filters)))
@@ -1826,9 +1829,14 @@ When DOMAIN, force inclusion of user's domain in their
handle."
(defun mastodon-tl--fold-body (body)
"Fold toot BODY if it is very long.
Folding decided by `mastodon-tl--fold-toots-at-length'."
- (let* ((heading (mastodon-search--format-heading
- (mastodon-tl--make-link "READ MORE" 'read-more)
- nil :no-newline))
+ (let* ((invis (get-text-property (1- (length body)) 'invisible body))
+ (spoiler (get-text-property (1- (length body))
+ 'mastodon-content-warning-body body))
+ (heading (propertize (mastodon-search--format-heading
+ (mastodon-tl--make-link "READ MORE" 'read-more)
+ nil :no-newline)
+ 'mastodon-content-warning-body spoiler
+ 'invisible invis))
(display (concat (substring body 0
mastodon-tl--fold-toots-at-length)
heading)))
@@ -1848,6 +1856,10 @@ FOLD means to fold it instead."
(let* ((inhibit-read-only t)
(body-range (mastodon-tl--find-property-range 'toot-body
(point) :backward))
+ (cw-range (mastodon-tl--find-property-range
+ 'mastodon-content-warning-body
+ (point) :backward))
+ (cw-invis (get-text-property (car cw-range) 'invisible))
(toot (mastodon-tl--property 'item-json :no-move))
;; `replace-region-contents' is much too slow, our hack from
;; fedi.el is much simpler and much faster:
@@ -1863,7 +1875,8 @@ FOLD means to fold it instead."
(delete-region beg end)
(delete-char 1) ;; prevent newlines accumulating
;; insert toot body:
- (mastodon-tl--toot toot nil nil nil (not fold) :no-byline)
+ (mastodon-tl--toot toot nil nil nil (not fold) :no-byline
+ (unless cw-invis :no-cw)) ;; respect CW state
;; set toot-folded prop on entire toot (not just body):
(let ((toot-range ;; post fold action range:
(mastodon-tl--find-property-range 'item-json
- [nongnu] elpa/mastodon 411e9f22e0 14/50: grouped notifs: top byline create with account data, not toot. #612 half fixed., (continued)
- [nongnu] elpa/mastodon 411e9f22e0 14/50: grouped notifs: top byline create with account data, not toot. #612 half fixed., ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 380c6be86f 22/50: keep cleaning up notifs insert note, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon c7a3ed75ab 26/50: fold-toot - respect CW state, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 8a8b13dc0a 21/50: --byline: pull fave/boost/edit/visibility from base toot if present, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 1bf73f2528 33/50: remove elsa from Cask, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon ee25cb9b02 41/50: update point after widget. FIX #615, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon c09935b100 37/50: tl: remove stale args to insert status, inc. action-byline arg, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon b47390993b 46/50: Merge branch 'poll-var' into develop, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 94ea642a1a 38/50: notifs: improve byline docstrings for new byline logic, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 071c33eed2 32/50: Merge branch 'develop' into non-group-notifs, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon babb3a1adf 28/50: fold-toot - respect CW state,
ELPA Syncer <=
- [nongnu] elpa/mastodon 1606b34c5d 45/50: Merge branch 'read-less' into develop, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 7623478121 48/50: bump, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 7af46336f2 42/50: add read less button to unfolded long posts (read more). FIX #614, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon bf82092dde 44/50: autoload ht-get, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 639745a885 04/50: move notifs customizes into mastodon.el, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 0e75fc74ee 01/50: group-notifs custom (for servers without). #608. WIP., ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon bfb17cdf91 10/50: docstrings tl.el, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon f3602493da 03/50: fix notifs custom group, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon 8446f239bb 02/50: working v1 notifications custom. #608, ELPA Syncer, 2024/11/02
- [nongnu] elpa/mastodon b529690f96 06/50: notifs: refactor some v1/v2 calling code, mastodon-notifiations--body-arg, ELPA Syncer, 2024/11/02