diff lisp/gnus/gnus-html.el @ 110167:b8559a372ac8

gnus-agent.el: Change the default so that nnimap methods aren't agentized by default. There's apparently many problems related to agent/imap behaviour; gnus-art.el: Don't reuse the 'gnus-data text property, but use a new property. This avoids stomping over other functions that use this for other things; gnus-html.el: Add a new `i' command to insert images.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Sat, 04 Sep 2010 00:21:34 +0000
parents 514c8efbfdbb
children 1feebeccf097
line wrap: on
line diff
--- a/lisp/gnus/gnus-html.el	Sat Sep 04 00:12:44 2010 +0000
+++ b/lisp/gnus/gnus-html.el	Sat Sep 04 00:21:34 2010 +0000
@@ -66,6 +66,12 @@
   :group 'gnus-art
   :type 'float)
 
+(defvar gnus-html-image-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "u" 'gnus-article-copy-string)
+    (define-key map "i" 'gnus-html-insert-image)
+    map))
+
 ;;;###autoload
 (defun gnus-article-html (handle)
   (let ((article-buffer (current-buffer)))
@@ -142,12 +148,24 @@
 		    (delete-region start end)
 		    (gnus-put-image image (gnus-string-or string "*")))))
 	    ;; Normal, external URL.
-	    (unless (gnus-html-image-url-blocked-p
-		     url
-		     (if (buffer-live-p gnus-summary-buffer)
-			 (with-current-buffer gnus-summary-buffer
-			   gnus-blocked-images)
-		       gnus-blocked-images))
+	    (if (gnus-html-image-url-blocked-p
+		 url
+		 (if (buffer-live-p gnus-summary-buffer)
+		     (with-current-buffer gnus-summary-buffer
+		       gnus-blocked-images)
+		   gnus-blocked-images))
+		(progn
+		  (widget-convert-button
+		   'link start end
+		   :action 'gnus-html-insert-image
+		   :help-echo url
+		   :keymap gnus-html-image-map
+		   :button-keymap gnus-html-image-map)
+		  (gnus-put-text-property
+		   start end
+		   'gnus-image (list url
+				     (set-marker (make-marker) start)
+				     (set-marker (make-marker) end))))
 	      (let ((file (gnus-html-image-id url))
 		    width height)
 		(when (string-match "height=\"?\\([0-9]+\\)" parameters)
@@ -184,6 +202,7 @@
 	  (let ((overlay (gnus-make-overlay start end)))
 	    (gnus-overlay-put overlay 'evaporate t)
 	    (gnus-overlay-put overlay 'gnus-button-url url)
+	    (gnus-put-text-property start end 'gnus-string url)
 	    (when gnus-article-mouse-face
 	      (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
        ;; The upper-case IMG_ALT is apparently just an artifact that
@@ -202,6 +221,12 @@
     (when images
       (gnus-html-schedule-image-fetching (current-buffer) (nreverse images)))))
 
+(defun gnus-html-insert-image ()
+  "Fetch and insert the image under point."
+  (interactive)
+  (gnus-html-schedule-image-fetching
+   (current-buffer) (list (get-text-property (point) 'gnus-image))))
+
 (defun gnus-html-schedule-image-fetching (buffer images)
   (gnus-message 8 "gnus-html-schedule-image-fetching: buffer %s, images %s"
                 buffer images)
@@ -268,7 +293,9 @@
 			   (= (cdr size) 30))))
 	    (progn
 	      (gnus-put-image (gnus-html-rescale-image image file size)
-			      (gnus-string-or string "*"))
+			      (gnus-string-or string "*")
+			      'external)
+	      (gnus-add-image 'external image)
 	      t)
 	  (insert string)
 	  (when (fboundp 'find-image)