Commit 075843d3 authored by Lars Magne Ingebrigtsen's avatar Lars Magne Ingebrigtsen Committed by Katsumi Yamaoka
Browse files

gnus.el, gnus-html.el: Use the deleted text as the image alt text.

parent 59d09f15
2010-09-01 Lars Magne Ingebrigtsen <larsi@gnus.org>
* gnus-html.el (gnus-html-put-image): Use the deleted text as the image
alt text.
* gnus.el (gnus-string-or): Fix the syntax to not use eval or
overshadow variable bindings.
2010-09-01 Teodor Zlatanov <tzz@lifelogs.com> 2010-09-01 Teodor Zlatanov <tzz@lifelogs.com>
* gnus-html.el (gnus-html-wash-tags) * gnus-html.el (gnus-html-wash-tags)
......
...@@ -132,17 +132,19 @@ fit these criteria." ...@@ -132,17 +132,19 @@ fit these criteria."
(setq image (gnus-create-image (buffer-string) (setq image (gnus-create-image (buffer-string)
nil t)))) nil t))))
(when image (when image
(delete-region start end) (let ((string (buffer-substring start end)))
(gnus-put-image image))) (delete-region start end)
(gnus-put-image image (gnus-string-or string "*")))))
;; Normal, external URL. ;; Normal, external URL.
(when (or (null gnus-blocked-images) (when (or (null gnus-blocked-images)
(not (string-match gnus-blocked-images url))) (not (string-match gnus-blocked-images url)))
(let ((file (gnus-html-image-id url))) (let ((file (gnus-html-image-id url)))
(if (file-exists-p file) (if (file-exists-p file)
;; It's already cached, so just insert it. ;; It's already cached, so just insert it.
(when (gnus-html-put-image file (point)) (let ((string (buffer-substring start end)))
;; Delete the ALT text. ;; Delete the ALT text.
(delete-region start end)) (delete-region start end)
(gnus-html-put-image file (point) string))
;; We don't have it, so schedule it for fetching ;; We don't have it, so schedule it for fetching
;; asynchronously. ;; asynchronously.
(push (list url (push (list url
...@@ -209,13 +211,14 @@ fit these criteria." ...@@ -209,13 +211,14 @@ fit these criteria."
;; article before the image arrived. ;; article before the image arrived.
(not (= (marker-position (cadr spec)) (point-min)))) (not (= (marker-position (cadr spec)) (point-min))))
(with-current-buffer buffer (with-current-buffer buffer
(let ((inhibit-read-only t)) (let ((inhibit-read-only t)
(when (gnus-html-put-image file (cadr spec)) (string (buffer-substring (cadr spec) (caddr spec))))
(delete-region (1+ (cadr spec)) (caddr spec)))))) (delete-region (cadr spec) (caddr spec))
(gnus-html-put-image file (cadr spec) string))))
(when images (when images
(gnus-html-schedule-image-fetching buffer images))))) (gnus-html-schedule-image-fetching buffer images)))))
(defun gnus-html-put-image (file point) (defun gnus-html-put-image (file point string)
(when (display-graphic-p) (when (display-graphic-p)
(let ((image (ignore-errors (let ((image (ignore-errors
(gnus-create-image file)))) (gnus-create-image file))))
...@@ -229,11 +232,14 @@ fit these criteria." ...@@ -229,11 +232,14 @@ fit these criteria."
(= (car (image-size image t)) 30) (= (car (image-size image t)) 30)
(= (cdr (image-size image t)) 30)))) (= (cdr (image-size image t)) 30))))
(progn (progn
(gnus-put-image (gnus-html-rescale-image image)) (gnus-put-image (gnus-html-rescale-image image)
(gnus-string-or string "*"))
t) t)
(insert string)
(when (fboundp 'find-image) (when (fboundp 'find-image)
(gnus-put-image (find-image (gnus-put-image (find-image
'((:type xpm :file "lock-broken.xpm"))))) '((:type xpm :file "lock-broken.xpm")))
(gnus-string-or string "*")))
nil))))) nil)))))
(defun gnus-html-rescale-image (image) (defun gnus-html-rescale-image (image)
......
...@@ -3289,12 +3289,12 @@ with a `subscribed' parameter." ...@@ -3289,12 +3289,12 @@ with a `subscribed' parameter."
(defmacro gnus-string-or (&rest strings) (defmacro gnus-string-or (&rest strings)
"Return the first element of STRINGS that is a non-blank string. "Return the first element of STRINGS that is a non-blank string.
STRINGS will be evaluated in normal `or' order." STRINGS will be evaluated in normal `or' order."
`(gnus-string-or-1 ',strings)) `(gnus-string-or-1 (list ,@strings)))
(defun gnus-string-or-1 (strings) (defun gnus-string-or-1 (strings)
(let (string) (let (string)
(while strings (while strings
(setq string (eval (pop strings))) (setq string (pop strings))
(if (string-match "^[ \t]*$" string) (if (string-match "^[ \t]*$" string)
(setq string nil) (setq string nil)
(setq strings nil))) (setq strings nil)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment