From 0e2cebe57e75c570c7fcac25890ce995fbc7c598 Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sat, 18 Feb 2012 22:28:00 +0000 Subject: [PATCH] shr.el (shr-image-fetched): Be more defensive about killing the correct buffer --- lisp/gnus/ChangeLog | 5 +++++ lisp/gnus/shr.el | 29 +++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 61f6ff9a3d..d2f2b1b466 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,8 @@ +2012-02-18 Lars Ingebrigtsen + + * shr.el (shr-image-fetched): Make sure we really kill the right + buffer. + 2012-02-16 Leo Liu * gnus-start.el (gnus-1): Avoid duplicate entries. diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index f3d7503292..dd0f1599c3 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el @@ -524,20 +524,21 @@ the URL of the image to the kill buffer instead." directory))))) (defun shr-image-fetched (status buffer start end) - (when (and (buffer-name buffer) - (not (plist-get status :error))) - (url-store-in-cache (current-buffer)) - (when (or (search-forward "\n\n" nil t) - (search-forward "\r\n\r\n" nil t)) - (let ((data (buffer-substring (point) (point-max)))) - (with-current-buffer buffer - (save-excursion - (let ((alt (buffer-substring start end)) - (inhibit-read-only t)) - (delete-region start end) - (goto-char start) - (funcall shr-put-image-function data alt))))))) - (kill-buffer (current-buffer))) + (let ((image-buffer (current-buffer))) + (when (and (buffer-name buffer) + (not (plist-get status :error))) + (url-store-in-cache image-buffer) + (when (or (search-forward "\n\n" nil t) + (search-forward "\r\n\r\n" nil t)) + (let ((data (buffer-substring (point) (point-max)))) + (with-current-buffer buffer + (save-excursion + (let ((alt (buffer-substring start end)) + (inhibit-read-only t)) + (delete-region start end) + (goto-char start) + (funcall shr-put-image-function data alt))))))) + (kill-buffer image-buffer))) (defun shr-put-image (data alt) "Put image DATA with a string ALT. Return image." -- 2.20.1