diff options
| -rw-r--r-- | lisp/gnus/ChangeLog | 14 | ||||
| -rw-r--r-- | lisp/gnus/gnus-art.el | 11 | ||||
| -rw-r--r-- | lisp/gnus/gnus-html.el | 24 | ||||
| -rw-r--r-- | lisp/gnus/gnus-sum.el | 2 | ||||
| -rw-r--r-- | lisp/gnus/gnus-util.el | 15 | ||||
| -rw-r--r-- | lisp/gnus/gnus.el | 1 | ||||
| -rw-r--r-- | lisp/gnus/shr.el | 11 |
7 files changed, 56 insertions, 22 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 74f218aa4bd..e1265e7cc43 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog | |||
| @@ -1,5 +1,19 @@ | |||
| 1 | 2010-11-15 Lars Magne Ingebrigtsen <larsi@gnus.org> | 1 | 2010-11-15 Lars Magne Ingebrigtsen <larsi@gnus.org> |
| 2 | 2 | ||
| 3 | * shr.el (shr-tag-img): Put a displayer in the text property. | ||
| 4 | |||
| 5 | * gnus-util.el (gnus-find-text-property-region): New utility function. | ||
| 6 | |||
| 7 | * gnus-html.el (gnus-html-display-image): Make the alt optional. | ||
| 8 | (gnus-html-show-images): Remove. | ||
| 9 | |||
| 10 | * gnus-art.el (gnus-article-show-images): New, more general function. | ||
| 11 | |||
| 12 | * gnus-html.el: Use image-url instead of gnus-image-url to unify the | ||
| 13 | image url text properties. | ||
| 14 | |||
| 15 | * shr.el: Ditto. | ||
| 16 | |||
| 3 | * gnus-agent.el (gnus-agentize): Only do the auto-agentizing if | 17 | * gnus-agent.el (gnus-agentize): Only do the auto-agentizing if |
| 4 | gnus-agent-auto-agentize-methods is set. Which it isn't. | 18 | gnus-agent-auto-agentize-methods is set. Which it isn't. |
| 5 | 19 | ||
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index a5d9a279ddb..e2be314f8d1 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el | |||
| @@ -2271,6 +2271,17 @@ unfolded." | |||
| 2271 | (dolist (elem gnus-article-image-alist) | 2271 | (dolist (elem gnus-article-image-alist) |
| 2272 | (gnus-delete-images (car elem))))) | 2272 | (gnus-delete-images (car elem))))) |
| 2273 | 2273 | ||
| 2274 | (defun gnus-article-show-images () | ||
| 2275 | "Show any images that are in the HTML-rendered article buffer. | ||
| 2276 | This only works if the article in question is HTML." | ||
| 2277 | (interactive) | ||
| 2278 | (gnus-with-article-buffer | ||
| 2279 | (dolist (region (gnus-find-text-property-region (point-min) (point-max) | ||
| 2280 | 'image-displayer)) | ||
| 2281 | (destructuring-bind (start end function) region | ||
| 2282 | (funcall function (get-text-property start 'image-url) | ||
| 2283 | start end))))) | ||
| 2284 | |||
| 2274 | (defun gnus-article-treat-fold-newsgroups () | 2285 | (defun gnus-article-treat-fold-newsgroups () |
| 2275 | "Unfold folded message headers. | 2286 | "Unfold folded message headers. |
| 2276 | Only the headers that fit into the current window width will be | 2287 | Only the headers that fit into the current window width will be |
diff --git a/lisp/gnus/gnus-html.el b/lisp/gnus/gnus-html.el index 46e5881d9fb..8274e20c8c1 100644 --- a/lisp/gnus/gnus-html.el +++ b/lisp/gnus/gnus-html.el | |||
| @@ -201,7 +201,7 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")." | |||
| 201 | (let ((alt-text (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)" | 201 | (let ((alt-text (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)" |
| 202 | parameters) | 202 | parameters) |
| 203 | (xml-substitute-special (match-string 2 parameters))))) | 203 | (xml-substitute-special (match-string 2 parameters))))) |
| 204 | (gnus-put-text-property start end 'gnus-image-url url) | 204 | (gnus-put-text-property start end 'image-url url) |
| 205 | (if (gnus-html-image-url-blocked-p | 205 | (if (gnus-html-image-url-blocked-p |
| 206 | url | 206 | url |
| 207 | (if (buffer-live-p gnus-summary-buffer) | 207 | (if (buffer-live-p gnus-summary-buffer) |
| @@ -237,7 +237,7 @@ CHARS is a regexp-like character alternative (e.g., \"[)$]\")." | |||
| 237 | (> width 4))) | 237 | (> width 4))) |
| 238 | (gnus-html-display-image url start end alt-text)))))))))) | 238 | (gnus-html-display-image url start end alt-text)))))))))) |
| 239 | 239 | ||
| 240 | (defun gnus-html-display-image (url start end alt-text) | 240 | (defun gnus-html-display-image (url start end &optional alt-text) |
| 241 | "Display image at URL on text from START to END. | 241 | "Display image at URL on text from START to END. |
| 242 | Use ALT-TEXT for the image string." | 242 | Use ALT-TEXT for the image string." |
| 243 | (if (gnus-html-cache-expired url gnus-html-image-cache-ttl) | 243 | (if (gnus-html-cache-expired url gnus-html-image-cache-ttl) |
| @@ -247,7 +247,7 @@ Use ALT-TEXT for the image string." | |||
| 247 | (current-buffer) | 247 | (current-buffer) |
| 248 | (list url alt-text)) | 248 | (list url alt-text)) |
| 249 | ;; It's already cached, so just insert it. | 249 | ;; It's already cached, so just insert it. |
| 250 | (gnus-html-put-image (gnus-html-get-image-data url) url alt-text))) | 250 | (gnus-html-put-image (gnus-html-get-image-data url) url (or alt-text "*")))) |
| 251 | 251 | ||
| 252 | (defun gnus-html-wash-tags () | 252 | (defun gnus-html-wash-tags () |
| 253 | (let (tag parameters string start end images url) | 253 | (let (tag parameters string start end images url) |
| @@ -344,7 +344,7 @@ Use ALT-TEXT for the image string." | |||
| 344 | (defun gnus-html-browse-image () | 344 | (defun gnus-html-browse-image () |
| 345 | "Browse the image under point." | 345 | "Browse the image under point." |
| 346 | (interactive) | 346 | (interactive) |
| 347 | (browse-url (get-text-property (point) 'gnus-image-url))) | 347 | (browse-url (get-text-property (point) 'image-url))) |
| 348 | 348 | ||
| 349 | (defun gnus-html-browse-url () | 349 | (defun gnus-html-browse-url () |
| 350 | "Browse the image under point." | 350 | "Browse the image under point." |
| @@ -415,9 +415,9 @@ Return a string with image data." | |||
| 415 | "Put an image with DATA from URL and optional ALT-TEXT." | 415 | "Put an image with DATA from URL and optional ALT-TEXT." |
| 416 | (when (gnus-graphic-display-p) | 416 | (when (gnus-graphic-display-p) |
| 417 | (let* ((start (text-property-any (point-min) (point-max) | 417 | (let* ((start (text-property-any (point-min) (point-max) |
| 418 | 'gnus-image-url url)) | 418 | 'image-url url)) |
| 419 | (end (when start | 419 | (end (when start |
| 420 | (next-single-property-change start 'gnus-image-url)))) | 420 | (next-single-property-change start 'image-url)))) |
| 421 | ;; Image found? | 421 | ;; Image found? |
| 422 | (when start | 422 | (when start |
| 423 | (let* ((image | 423 | (let* ((image |
| @@ -459,7 +459,7 @@ Return a string with image data." | |||
| 459 | 'gnus-alt-text alt-text) | 459 | 'gnus-alt-text alt-text) |
| 460 | (when url | 460 | (when url |
| 461 | (gnus-put-text-property start (point) | 461 | (gnus-put-text-property start (point) |
| 462 | 'gnus-image-url url)) | 462 | 'image-url url)) |
| 463 | (gnus-add-image 'external image) | 463 | (gnus-add-image 'external image) |
| 464 | t) | 464 | t) |
| 465 | ;; Bad image, try to show something else | 465 | ;; Bad image, try to show something else |
| @@ -482,16 +482,6 @@ Return a string with image data." | |||
| 482 | url blocked-images)) | 482 | url blocked-images)) |
| 483 | ret)) | 483 | ret)) |
| 484 | 484 | ||
| 485 | (defun gnus-html-show-images () | ||
| 486 | "Show any images that are in the HTML-rendered article buffer. | ||
| 487 | This only works if the article in question is HTML." | ||
| 488 | (interactive) | ||
| 489 | (gnus-with-article-buffer | ||
| 490 | (dolist (overlay (overlays-in (point-min) (point-max))) | ||
| 491 | (let ((o (overlay-get overlay 'gnus-image))) | ||
| 492 | (when o | ||
| 493 | (apply 'gnus-html-display-image o)))))) | ||
| 494 | |||
| 495 | ;;;###autoload | 485 | ;;;###autoload |
| 496 | (defun gnus-html-prefetch-images (summary) | 486 | (defun gnus-html-prefetch-images (summary) |
| 497 | (when (buffer-live-p summary) | 487 | (when (buffer-live-p summary) |
diff --git a/lisp/gnus/gnus-sum.el b/lisp/gnus/gnus-sum.el index f936127f0de..ff85d45d7b0 100644 --- a/lisp/gnus/gnus-sum.el +++ b/lisp/gnus/gnus-sum.el | |||
| @@ -2136,7 +2136,7 @@ increase the score of each group you read." | |||
| 2136 | "d" gnus-article-display-face | 2136 | "d" gnus-article-display-face |
| 2137 | "s" gnus-treat-smiley | 2137 | "s" gnus-treat-smiley |
| 2138 | "D" gnus-article-remove-images | 2138 | "D" gnus-article-remove-images |
| 2139 | "W" gnus-html-show-images | 2139 | "W" gnus-article-show-images |
| 2140 | "f" gnus-treat-from-picon | 2140 | "f" gnus-treat-from-picon |
| 2141 | "m" gnus-treat-mail-picon | 2141 | "m" gnus-treat-mail-picon |
| 2142 | "n" gnus-treat-newsgroups-picon | 2142 | "n" gnus-treat-newsgroups-picon |
diff --git a/lisp/gnus/gnus-util.el b/lisp/gnus/gnus-util.el index cacca018fd5..4e4aab43ba2 100644 --- a/lisp/gnus/gnus-util.el +++ b/lisp/gnus/gnus-util.el | |||
| @@ -277,6 +277,21 @@ Uses `gnus-extract-address-components'." | |||
| 277 | (setq start (when end | 277 | (setq start (when end |
| 278 | (next-single-property-change start prop)))))) | 278 | (next-single-property-change start prop)))))) |
| 279 | 279 | ||
| 280 | (defun gnus-find-text-property-region (start end prop) | ||
| 281 | "Return a list of text property regions that has property PROP." | ||
| 282 | (let (regions value) | ||
| 283 | (unless (get-text-property start prop) | ||
| 284 | (setq start (next-single-property-change start prop))) | ||
| 285 | (while start | ||
| 286 | (setq value (get-text-property start prop) | ||
| 287 | end (text-property-not-all start (point-max) prop value)) | ||
| 288 | (if (not end) | ||
| 289 | (setq start nil) | ||
| 290 | (when value | ||
| 291 | (push (list start end value) regions)) | ||
| 292 | (setq start (next-single-property-change start prop)))) | ||
| 293 | (nreverse regions))) | ||
| 294 | |||
| 280 | (defun gnus-newsgroup-directory-form (newsgroup) | 295 | (defun gnus-newsgroup-directory-form (newsgroup) |
| 281 | "Make hierarchical directory name from NEWSGROUP name." | 296 | "Make hierarchical directory name from NEWSGROUP name." |
| 282 | (let* ((newsgroup (gnus-newsgroup-savable-name newsgroup)) | 297 | (let* ((newsgroup (gnus-newsgroup-savable-name newsgroup)) |
diff --git a/lisp/gnus/gnus.el b/lisp/gnus/gnus.el index 82cfd672be7..20ce72d8855 100644 --- a/lisp/gnus/gnus.el +++ b/lisp/gnus/gnus.el | |||
| @@ -2876,7 +2876,6 @@ gnus-registry.el will populate this if it's loaded.") | |||
| 2876 | gnus-start-date-timer gnus-stop-date-timer | 2876 | gnus-start-date-timer gnus-stop-date-timer |
| 2877 | gnus-mime-view-all-parts) | 2877 | gnus-mime-view-all-parts) |
| 2878 | ("gnus-int" gnus-request-type) | 2878 | ("gnus-int" gnus-request-type) |
| 2879 | ("gnus-html" gnus-html-show-images) | ||
| 2880 | ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1 | 2879 | ("gnus-start" gnus-newsrc-parse-options gnus-1 gnus-no-server-1 |
| 2881 | gnus-dribble-enter gnus-read-init-file gnus-dribble-touch | 2880 | gnus-dribble-enter gnus-read-init-file gnus-dribble-touch |
| 2882 | gnus-check-reasonable-setup) | 2881 | gnus-check-reasonable-setup) |
diff --git a/lisp/gnus/shr.el b/lisp/gnus/shr.el index d1788c334bc..4f3b20531f5 100644 --- a/lisp/gnus/shr.el +++ b/lisp/gnus/shr.el | |||
| @@ -154,7 +154,7 @@ redirects somewhere else." | |||
| 154 | (defun shr-browse-image () | 154 | (defun shr-browse-image () |
| 155 | "Browse the image under point." | 155 | "Browse the image under point." |
| 156 | (interactive) | 156 | (interactive) |
| 157 | (let ((url (get-text-property (point) 'shr-image))) | 157 | (let ((url (get-text-property (point) 'image-url))) |
| 158 | (if (not url) | 158 | (if (not url) |
| 159 | (message "No image under point") | 159 | (message "No image under point") |
| 160 | (message "Browsing %s..." url) | 160 | (message "Browsing %s..." url) |
| @@ -163,7 +163,7 @@ redirects somewhere else." | |||
| 163 | (defun shr-insert-image () | 163 | (defun shr-insert-image () |
| 164 | "Insert the image under point into the buffer." | 164 | "Insert the image under point into the buffer." |
| 165 | (interactive) | 165 | (interactive) |
| 166 | (let ((url (get-text-property (point) 'shr-image))) | 166 | (let ((url (get-text-property (point) 'image-url))) |
| 167 | (if (not url) | 167 | (if (not url) |
| 168 | (message "No image under point") | 168 | (message "No image under point") |
| 169 | (message "Inserting %s..." url) | 169 | (message "Inserting %s..." url) |
| @@ -572,7 +572,12 @@ Return a string with image data." | |||
| 572 | t)))) | 572 | t)))) |
| 573 | (put-text-property start (point) 'keymap shr-map) | 573 | (put-text-property start (point) 'keymap shr-map) |
| 574 | (put-text-property start (point) 'shr-alt alt) | 574 | (put-text-property start (point) 'shr-alt alt) |
| 575 | (put-text-property start (point) 'shr-image url) | 575 | (put-text-property start (point) 'image-url url) |
| 576 | (put-text-property start (point) 'image-displayer | ||
| 577 | (lambda (url start end) | ||
| 578 | (url-retrieve url 'shr-image-fetched | ||
| 579 | (list (current-buffer) start end) | ||
| 580 | t))) | ||
| 576 | (put-text-property start (point) 'help-echo alt) | 581 | (put-text-property start (point) 'help-echo alt) |
| 577 | (setq shr-state 'image))))) | 582 | (setq shr-state 'image))))) |
| 578 | 583 | ||