diff options
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/mastodon-tl.el | 34 | ||||
-rw-r--r-- | lisp/mastodon.el | 2 |
2 files changed, 29 insertions, 7 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 4865b4f..ee7c48d 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -337,8 +337,7 @@ the byline that takes one variable. ACTION-BYLINE is a function for adding an action, such as boosting favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'" - (let ((id (cdr (assoc 'id toot))) - (parsed-time (date-to-time (mastodon-tl--field 'created_at toot))) + (let ((parsed-time (date-to-time (mastodon-tl--field 'created_at toot))) (faved (equal 't (mastodon-tl--field 'favourited toot))) (boosted (equal 't (mastodon-tl--field 'reblogged toot)))) (concat @@ -363,9 +362,7 @@ it is `mastodon-tl--byline-boosted'" parsed-time)) (propertize "\n ------------" 'face 'default)) 'favourited-p faved - 'boosted-p boosted - 'toot-id id - 'toot-json toot)))) + 'boosted-p boosted)))) (defun mastodon-tl--render-text (string toot) "Returns a propertized text giving the rendering of the given HTML string STRING. @@ -454,6 +451,26 @@ the toot)." (list 'invisible (not (get-text-property (car spoiler-text-region) 'invisible))))))) + +(defun mastodon-tl--toggle-spoiler-text-in-toot () + "Toggle the visibility of the spoiler text in the current toot." + (interactive) + (let* ((toot-range (or (mastodon-tl--find-property-range + 'toot-json (point)) + (mastodon-tl--find-property-range + 'toot-json (point) t))) + (spoiler-range (when toot-range + (mastodon-tl--find-property-range + 'mastodon-content-warning-body + (car toot-range))))) + (cond ((null toot-range) + (message "No toot here")) + ((or (null spoiler-range) + (> (car spoiler-range) (cdr toot-range))) + (message "No content warning text here")) + (t + (mastodon-tl--toggle-spoiler-text (car spoiler-range)))))) + (defun mastodon-tl--make-link (string link-type) "Return a propertized version of STRING that will act like link. @@ -551,8 +568,11 @@ ACTION-BYLINE is also an optional function for adding an action, such as boostin favouriting and following to the byline. It also takes a single function. By default it is `mastodon-tl--byline-boosted'" (insert - body - (mastodon-tl--byline toot author-byline action-byline) + (propertize + (concat body + (mastodon-tl--byline toot author-byline action-byline)) + 'toot-id (cdr (assoc 'id toot)) + 'toot-json toot) "\n\n")) (defun mastodon-tl--toot(toot) diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 7f02295..c362513 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -41,6 +41,7 @@ (autoload 'mastodon-tl--next-tab-item "mastodon-tl") (autoload 'mastodon-tl--previous-tab-item "mastodon-tl") (autoload 'mastodon-tl--thread "mastodon-tl") +(autoload 'mastodon-tl--toggle-spoiler-text-in-toot "mastodon-tl") (autoload 'mastodon-tl--update "mastodon-tl") (autoload 'mastodon-toot--compose-buffer "mastodon-toot") (autoload 'mastodon-toot--reply "mastodon-toot") @@ -120,6 +121,7 @@ If REPLY-TO-ID is non-nil, attach new toot to a conversation." "Major mode for Mastodon, the federated microblogging network." :group 'mastodon (let ((map mastodon-mode-map)) + (define-key map (kbd "c") #'mastodon-tl--toggle-spoiler-text-in-toot) (define-key map (kbd "b") #'mastodon-toot--toggle-boost) (define-key map (kbd "f") #'mastodon-toot--toggle-favourite) (define-key map (kbd "F") #'mastodon-tl--get-federated-timeline) |