[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mastodon c8565612b9 22/63: fold long posts, unfolding cmd.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mastodon c8565612b9 22/63: fold long posts, unfolding cmd. FIX #572. |
Date: |
Sun, 4 Aug 2024 04:00:31 -0400 (EDT) |
branch: elpa/mastodon
commit c8565612b95ce09c1d55470943a52c25798c27a1
Author: marty hiatt <martianhiatus@riseup.net>
Commit: marty hiatt <martianhiatus@riseup.net>
fold long posts, unfolding cmd. FIX #572.
---
lisp/mastodon-tl.el | 51 +++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 47 insertions(+), 4 deletions(-)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index ac3000539a..d87a469cc2 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -979,6 +979,8 @@ the toot)."
LINK-TYPE is the type of link to produce."
(let ((help-text (cond ((eq link-type 'content-warning)
"Toggle hidden text")
+ ((eq link-type 'read-more)
+ "Toggle full post")
(t
(error "Unknown link type %s" link-type)))))
(propertize string
@@ -1020,6 +1022,8 @@ Used for hitting RET on a given link."
"Search for account returned nothing. Perform URL
lookup?")
(mastodon-url-lookup (get-text-property position
'shr-url))
(message "Unable to find account."))))))))
+ ((eq link-type 'read-more)
+ (mastodon-tl--unfold-post))
(t
(error "Unknown link type %s" link-type)))))
@@ -1526,12 +1530,13 @@ When DOMAIN, force inclusion of user's domain in their
handle."
(concat (mastodon-tl--symbol 'replied)
"\n")
"")
- (if (and after-reply-status-p thread)
- (let ((bar (mastodon-tl--symbol 'reply-bar)))
+ (let ((bar (mastodon-tl--symbol 'reply-bar))
+ (body (mastodon-tl--fold-body-maybe body)))
+ (if (and after-reply-status-p thread)
(propertize body
'line-prefix bar
- 'wrap-prefix bar))
- body)
+ 'wrap-prefix bar)
+ body))
" \n"
;; byline:
(mastodon-tl--byline toot author-byline action-byline detailed-p
domain))
@@ -1551,6 +1556,44 @@ When DOMAIN, force inclusion of user's domain in their
handle."
(when mastodon-tl--display-media-p
(mastodon-media--inline-images start-pos (point)))))
+(defun mastodon-tl--fold-body-maybe (body)
+ "Fold toot BODY if it is very long."
+ (if (length> body 500)
+ (let* ((heading (mastodon-search--format-heading
+ (mastodon-tl--make-link
+ "READ MORE"
+ 'read-more)))
+ (display (concat (substring body 0 500)
+ heading)))
+ (propertize display
+ 'read-more body))
+ body))
+
+(defun mastodon-tl--unfold-post ()
+ "Unfold the toot at point if it is folded (read-more)."
+ (interactive)
+ ;; if at byline, must search backwards:
+ (let* ((byline (mastodon-tl--property 'byline :no-move))
+ (range (mastodon-tl--find-property-range
+ 'read-more (point) byline)))
+ (if (not range)
+ (user-error "No folded item at point?")
+ (let* ((inhibit-read-only t)
+ (body (save-excursion
+ (goto-char (car range))
+ (mastodon-tl--property 'read-more))))
+ ;; `replace-region-contents' is much to slow, our hack from fedi.el is
+ ;; much simpler and much faster
+ (let ((beg (car range))
+ (end (cdr range)))
+ (save-excursion
+ (goto-char beg)
+ (delete-region beg end)
+ (insert body))
+ ;; move point to line where text formerly ended:
+ (goto-char end)
+ (beginning-of-line))))))
+
;; from mastodon-alt.el:
(defun mastodon-tl--toot-for-stats (&optional toot)
"Return the TOOT on which we want to extract stats.
- [nongnu] elpa/mastodon 028ab8ea22 43/63: fix newlines accumulating on (un)folding toots, (continued)
- [nongnu] elpa/mastodon 028ab8ea22 43/63: fix newlines accumulating on (un)folding toots, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 134ec9413a 45/63: small adjustments to point placement with (un)folding, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon cf72fb5af0 47/63: bind fold toggle, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon d0a5bae331 50/63: refactor toot--toggle-boost-or-favourite, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon c75c4b7753 60/63: Revert "readme: multisession", ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 1887a2d414 11/63: readme: multisession, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon a9c6c04ac6 09/63: comments on mastodon-tl--goto-item-pos, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 4d335d45f4 16/63: index, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon a7fec25557 17/63: Merge branch 'multisession' into develop, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon f19f3bc273 08/63: replace persist with multisession, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon c8565612b9 22/63: fold long posts, unfolding cmd. FIX #572.,
ELPA Syncer <=
- [nongnu] elpa/mastodon d60d1d4c31 34/63: read CW when setting, not when sending, also display it. FIX #569., ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon d7816ab59f 35/63: add item-json prop to fave/boost strings, so (un)folding works, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon f16fcb15a8 27/63: use mastodon-use-emojify in toot.el, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 945de24d3e 57/63: Merge branch 'develop' into insert-status-for-fold, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 6b0a0eb1fa 49/63: readme, index, info, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 46b66e332a 58/63: commentary, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 7b4d77b86b 10/63: tl: no-refresh for next-item in --single-toot, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon b8e8328a35 04/63: use with-toot-item and clean up functions that use it, ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 6721f40cfd 30/63: unfold toot: replace whole item on unfolding (so we have props!), ELPA Syncer, 2024/08/04
- [nongnu] elpa/mastodon 41404473ea 05/63: toot.el: user-error not message when needed, ELPA Syncer, 2024/08/04