diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-06-04 12:08:46 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-06-04 12:08:46 +0200 |
commit | 7d27e4d5ff7f2e5c330f23ec119b6aeca30031e3 (patch) | |
tree | 51625293142a01773349ee766fee870881f2d794 /lisp/mastodon-tl.el | |
parent | 5964ad1703bf04010d46497b27b388e1b0057883 (diff) |
move toggle sensitive image to tl and give it a binding
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 573c2fa..cf5d316 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -292,6 +292,7 @@ types of mastodon links and not just shr.el-generated ones.") ;; keep new my-profile binding; shr 'O' doesn't work here anyway (define-key map (kbd "O") #'mastodon-profile--my-profile) (define-key map (kbd "C") #'mastodon-tl--copy-image-caption) + (define-key map (kbd "C-c C-c") #'mastodon-tl--toggle-sensitive-image) (define-key map (kbd "<C-return>") #'mastodon-tl--mpv-play-video-at-point) (define-key map (kbd "<mouse-2>") #'mastodon-tl--click-image-or-video) map) @@ -1215,6 +1216,28 @@ SENSITIVE is a flag from the item's JSON data." (url-retrieve url #'mastodon-media--process-full-sized-image-response `(,url))))))) +(defvar mastodon-media--generic-broken-image-data) + +(defun mastodon-tl--toggle-sensitive-image () + "Toggle dislay of sensitive image at point." + (interactive) + (let ((data (mastodon-tl--property 'image-data :no-move)) + (inhibit-read-only t) + (end (next-single-property-change (point) 'sensitive-state))) + (if (equal 'hidden (mastodon-tl--property 'sensitive-state :no-move)) + ;; display sensitive image: + (add-text-properties (point) end + `(display ,data + sensitive-state showing)) + ;; hide sensitive image: + (add-text-properties (point) end + `( sensitive-state hidden + display + ;; TODO: use an image placeholder + ,(create-image mastodon-media--generic-broken-image-data nil t) + ;; ,(mastodon-search--format-heading " SENSITIVE") + ))))) + ;; POLLS |