diff options
author | marty hiatt <martianhiatus@riseup.net> | 2024-06-04 18:44:41 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2024-06-04 18:44:41 +0200 |
commit | b8999c84719f1076616efb73ab8906dd71480c3a (patch) | |
tree | a6e0b227bb8547acf95b2be55158190042ed5bcd /lisp/mastodon-tl.el | |
parent | bd2f44911044f64c3303d080649ca2571b876ce1 (diff) | |
parent | 638045a2b2e76d506eab61f7aca23b5439299c39 (diff) |
Merge branch 'nsfw-hide' into develop
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 00e3ce3..166a0a4 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 "S") #'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) @@ -1216,6 +1217,26 @@ 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 + ,(create-image + mastodon-media--sensitive-image-data nil t)))))) + ;; POLLS |