aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-media.el
diff options
context:
space:
mode:
authorH Durer <h.duerer@gmail.com>2018-03-02 07:00:19 +0000
committerGitHub <noreply@github.com>2018-03-02 07:00:19 +0000
commit114c611f88e1a0188cb6541e9a185dbdc03ebf3a (patch)
treeebc64bee24db9c04a9c255815a75ab38f2edd620 /lisp/mastodon-media.el
parentdb1ae6f94e13475b9fae16bbe290d280f12feeb1 (diff)
parent3eae90ac03aea4c609f2cf2660b85338a33d9f89 (diff)
Merge pull request #160 from alexjgriffith/fix-buffer-switching
Fixes buffer switching issue and closes issue #158
Diffstat (limited to 'lisp/mastodon-media.el')
-rw-r--r--lisp/mastodon-media.el30
1 files changed, 15 insertions, 15 deletions
diff --git a/lisp/mastodon-media.el b/lisp/mastodon-media.el
index 94c6e9f..f010fee 100644
--- a/lisp/mastodon-media.el
+++ b/lisp/mastodon-media.el
@@ -144,21 +144,21 @@ REGION-LENGTH is the length of the region that should be replaced with the image
(image (when data
(apply #'create-image data (when image-options 'imagemagick)
t image-options))))
- (switch-to-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))))))
+ (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)
"Takes a URL and MEDIA-TYPE and load the image asynchronously.