diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-08-30 09:17:49 +0200 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2023-08-30 09:17:49 +0200 |
commit | 28b12f4eb895fe1775cac1ec217733f5fa2ea810 (patch) | |
tree | 4c9b05fb5cd03b98691fdccde67d8fbc6734ad9a /lisp/mastodon-media.el | |
parent | afb3ac38e0e9738d73a5cd1cb5d5b63f059b781a (diff) | |
parent | 756096757d13f13f7262ad616e4206ded538566d (diff) |
Merge branch 'scratch/mastodon' into develop
Diffstat (limited to 'lisp/mastodon-media.el')
-rw-r--r-- | lisp/mastodon-media.el | 61 |
1 files changed, 30 insertions, 31 deletions
diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el index 5cd233a..04cf0c2 100644 --- a/lisp/mastodon-media.el +++ b/lisp/mastodon-media.el @@ -148,40 +148,39 @@ with the image." (when (marker-buffer marker) ; if buffer hasn't been killed (let ((url-buffer (current-buffer)) (is-error-response-p (eq :error (car status-plist)))) - (unwind-protect - (let* ((data (unless is-error-response-p - (goto-char (point-min)) - (search-forward "\n\n") - (buffer-substring (point) (point-max)))) - (image (when data - (apply #'create-image data - (if (version< emacs-version "27.1") - (when image-options 'imagemagick) - nil) ; inbuilt scaling in 27.1 - t image-options)))) - (when mastodon-media--enable-image-caching - (unless (url-is-cached url) ; cache if not already cached - (url-store-in-cache url-buffer))) - (with-current-buffer (marker-buffer marker) - ;; Save narrowing in our buffer - (let ((inhibit-read-only t)) - (save-restriction - (widen) - (put-text-property marker - (+ marker region-length) 'media-state 'loaded) - (when image - ;; We only set the image to display if we could load - ;; it; we already have set a default image when we - ;; added the tag. - (put-text-property marker (+ marker region-length) - 'display image)) - ;; We are done with the marker; release it: - (set-marker marker nil))) - (kill-buffer url-buffer))))))) + (let* ((data (unless is-error-response-p + (goto-char (point-min)) + (search-forward "\n\n") + (buffer-substring (point) (point-max)))) + (image (when data + (apply #'create-image data + (if (version< emacs-version "27.1") + (when image-options 'imagemagick) + nil) ; inbuilt scaling in 27.1 + t image-options)))) + (when mastodon-media--enable-image-caching + (unless (url-is-cached url) ; cache if not already cached + (url-store-in-cache url-buffer))) + (with-current-buffer (marker-buffer marker) + ;; Save narrowing in our buffer + (let ((inhibit-read-only t)) + (save-restriction + (widen) + (put-text-property marker + (+ marker region-length) 'media-state 'loaded) + (when image + ;; We only set the image to display if we could load + ;; it; we already have set a default image when we + ;; added the tag. + (put-text-property marker (+ marker region-length) + 'display image)) + ;; We are done with the marker; release it: + (set-marker marker nil))) + (kill-buffer url-buffer)))))) (defun mastodon-media--load-image-from-url (url media-type start region-length) "Take a URL and MEDIA-TYPE and load the image asynchronously. -MEDIA-TYPE is a symbol and either `avatar' or `media-link.' +MEDIA-TYPE is a symbol and either `avatar' or `media-link'. START is the position where we start loading the image. REGION-LENGTH is the range from start to propertize." (let ((image-options (when (or (image-type-available-p 'imagemagick) |