From 7654913413a1fb8b8a215408f62276483d1f21b6 Mon Sep 17 00:00:00 2001 From: Lars Magne Ingebrigtsen Date: Fri, 3 Sep 2010 20:26:30 +0200 Subject: [PATCH] Add a new `i' command to insert images. --- lisp/ChangeLog | 4 ++++ lisp/gnus-html.el | 40 +++++++++++++++++++++++++++++++++------- 2 files changed, 37 insertions(+), 7 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 5cb2a3e7f..a6f05e1a3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,9 @@ 2010-09-03 Lars Magne Ingebrigtsen + * gnus-html.el (gnus-html-put-image): Allow images to be removed. + (gnus-html-wash-tags): Add a new `i' command to insert images. + (gnus-html-insert-image): New command and keystroke. + * gnus-agent.el (gnus-agent-auto-agentize-methods): Change the default so that nnimap methods aren't agentized by default. There's apparently many problems related to agent/imap behaviour. diff --git a/lisp/gnus-html.el b/lisp/gnus-html.el index 9f530fbfe..4c0d4c066 100644 --- a/lisp/gnus-html.el +++ b/lisp/gnus-html.el @@ -66,6 +66,12 @@ fit these criteria." :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 @@ fit these criteria." (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) @@ -203,6 +221,12 @@ fit these criteria." (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) @@ -269,7 +293,9 @@ fit these criteria." (= (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) -- 2.34.1