annotate lisp/gnus/gnus-html.el @ 110295:f70d39f7b8fd

gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Fri, 10 Sep 2010 00:07:33 +0000
parents 8c1028027f1b
children fb6801a4089a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110166
514c8efbfdbb gnus-html: Comment fix.; gnus-art.el: Provide an `u' command on urls and the like that copies the string over to the kill ring; Also have the `u' command work for HTML links.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110159
diff changeset
1 ;;; gnus-html.el --- Render HTML in a buffer.
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
2
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
3 ;; Copyright (C) 2010 Free Software Foundation, Inc.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
4
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
6 ;; Keywords: html, web
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
7
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
9
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
13 ;; (at your option) any later version.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
14
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
19
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
22
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
23 ;;; Commentary:
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
24
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
25 ;; The idea is to provide a simple, fast and pretty minimal way to
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
26 ;; render HTML (including links and images) in a buffer, based on an
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
27 ;; external HTML renderer (i.e., w3m).
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
28
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
29 ;;; Code:
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
30
110072
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
31 (eval-when-compile (require 'cl))
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
32 (eval-when-compile (require 'mm-decode))
110055
140a469a3964 gnus-html.el: require mm-url; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110054
diff changeset
33 (require 'mm-url)
140a469a3964 gnus-html.el: require mm-url; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110054
diff changeset
34
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
35 (defcustom gnus-html-cache-directory (nnheader-concat gnus-directory "html-cache/")
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
36 "Where Gnus will cache images it downloads from the web."
110084
320a820be8d8 gnus-html.el, message.el: Add custom version to new variables; gnus-sum.el: Bump custom version of gnus-auto-expirable-marks.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110083
diff changeset
37 :version "24.1"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
38 :group 'gnus-art
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
39 :type 'directory)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
40
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
41 (defcustom gnus-html-cache-size 500000000
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
42 "The size of the Gnus image cache."
110084
320a820be8d8 gnus-html.el, message.el: Add custom version to new variables; gnus-sum.el: Bump custom version of gnus-auto-expirable-marks.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110083
diff changeset
43 :version "24.1"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
44 :group 'gnus-art
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
45 :type 'integer)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
46
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
47 (defcustom gnus-html-frame-width 70
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
48 "What width to use when rendering HTML."
110084
320a820be8d8 gnus-html.el, message.el: Add custom version to new variables; gnus-sum.el: Bump custom version of gnus-auto-expirable-marks.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110083
diff changeset
49 :version "24.1"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
50 :group 'gnus-art
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
51 :type 'integer)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
52
110075
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
53 (defcustom gnus-blocked-images "."
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
54 "Images that have URLs matching this regexp will be blocked."
110084
320a820be8d8 gnus-html.el, message.el: Add custom version to new variables; gnus-sum.el: Bump custom version of gnus-auto-expirable-marks.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110083
diff changeset
55 :version "24.1"
110075
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
56 :group 'gnus-art
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
57 :type 'regexp)
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
58
110094
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
59 (defcustom gnus-max-image-proportion 0.7
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
60 "How big pictures displayed are in relation to the window they're in.
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
61 A value of 0.7 means that they are allowed to take up 70% of the
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
62 width and height of the window. If they are larger than this,
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
63 and Emacs supports it, then the images will be rescaled down to
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
64 fit these criteria."
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
65 :version "24.1"
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
66 :group 'gnus-art
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
67 :type 'float)
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
68
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
69 (defvar gnus-html-image-map
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
70 (let ((map (make-sparse-keymap)))
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
71 (define-key map "u" 'gnus-article-copy-string)
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
72 (define-key map "i" 'gnus-html-insert-image)
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
73 map))
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
74
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
75 (defvar gnus-html-displayed-image-map
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
76 (let ((map (make-sparse-keymap)))
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
77 (define-key map "a" 'gnus-html-show-alt-text)
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
78 (define-key map "i" 'gnus-html-browse-image)
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
79 (define-key map "\r" 'gnus-html-browse-url)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
80 (define-key map "u" 'gnus-article-copy-string)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
81 (define-key map [tab] 'widget-forward)
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
82 map))
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
83
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
84 ;;;###autoload
110221
f0d95837f863 gnus-html.el (gnus-article-html): Allow calling without specifying the handle. In that case, dissect the buffer first.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110179
diff changeset
85 (defun gnus-article-html (&optional handle)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
86 (let ((article-buffer (current-buffer)))
110221
f0d95837f863 gnus-html.el (gnus-article-html): Allow calling without specifying the handle. In that case, dissect the buffer first.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110179
diff changeset
87 (unless handle
f0d95837f863 gnus-html.el (gnus-article-html): Allow calling without specifying the handle. In that case, dissect the buffer first.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110179
diff changeset
88 (setq handle (mm-dissect-buffer t)))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
89 (save-restriction
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
90 (narrow-to-region (point) (point))
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
91 (save-excursion
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
92 (mm-with-part handle
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
93 (let* ((coding-system-for-read 'utf-8)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
94 (coding-system-for-write 'utf-8)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
95 (default-process-coding-system
110086
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
96 (cons coding-system-for-read coding-system-for-write))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
97 (charset (mail-content-type-get (mm-handle-type handle)
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
98 'charset)))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
99 (when (and charset
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
100 (setq charset (mm-charset-to-coding-system charset))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
101 (not (eq charset 'ascii)))
110143
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
102 (insert (prog1
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
103 (mm-decode-coding-string (buffer-string) charset)
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
104 (erase-buffer)
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
105 (mm-enable-multibyte))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
106 (call-process-region (point-min) (point-max)
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
107 "w3m"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
108 nil article-buffer nil
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
109 "-halfdump"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
110 "-no-cookie"
110049
00d3a187d587 Tell w3m that the input is UTF-8; This seems to fix problems with some German web feeds; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110045
diff changeset
111 "-I" "UTF-8"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
112 "-O" "UTF-8"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
113 "-o" "ext_halfdump=1"
110049
00d3a187d587 Tell w3m that the input is UTF-8; This seems to fix problems with some German web feeds; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110045
diff changeset
114 "-o" "pre_conv=1"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
115 "-t" (format "%s" tab-width)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
116 "-cols" (format "%s" gnus-html-frame-width)
110109
8c2040cb14d7 gnus-html.el (gnus-html-wash-tags): Don't show images that are really small. They're probably tracking images; nntp.el (nntp-request-set-mark): Refuse to do marks if nntp-marks-file-name is nil.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110108
diff changeset
117 "-o" "display_image=on"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
118 "-T" "text/html"))))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
119 (gnus-html-wash-tags))))
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
120
110072
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
121 (defvar gnus-article-mouse-face)
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
122
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
123 (defun gnus-html-pre-wash ()
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
124 (goto-char (point-min))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
125 (while (re-search-forward " *<pre_int> *</pre_int> *\n" nil t)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
126 (replace-match "" t t))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
127 (goto-char (point-min))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
128 (while (re-search-forward "<a name[^\n>]+>" nil t)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
129 (replace-match "" t t)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
130
110295
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
131 (defun gnus-html-wash-images ()
110068
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
132 (let (tag parameters string start end images url)
110110
91cc7bab2ca4 gnus-html.el (gnus-html-wash-tags): Remove all <pre_int> place holders.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110109
diff changeset
133 (goto-char (point-min))
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
134 ;; Search for all the images first.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
135 (while (re-search-forward "<img_alt \\([^>]*\\)>" nil t)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
136 (setq parameters (match-string 1)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
137 start (match-beginning 0))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
138 (delete-region start (point))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
139 (when (search-forward "</img_alt>" (line-end-position) t)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
140 (delete-region (match-beginning 0) (match-end 0)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
141 (setq end (point))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
142 (when (string-match "src=\"\\([^\"]+\\)" parameters)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
143 (setq url (match-string 1 parameters))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
144 (gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
145 (if (string-match "^cid:\\(.*\\)" url)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
146 ;; URLs with cid: have their content stashed in other
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
147 ;; parts of the MIME structure, so just insert them
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
148 ;; immediately.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
149 (let ((handle (mm-get-content-id
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
150 (setq url (match-string 1 url))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
151 image)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
152 (when handle
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
153 (mm-with-part handle
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
154 (setq image (gnus-create-image (buffer-string)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
155 nil t))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
156 (when image
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
157 (let ((string (buffer-substring start end)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
158 (delete-region start end)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
159 (gnus-put-image image (gnus-string-or string "*") 'cid)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
160 (gnus-add-image 'cid image))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
161 ;; Normal, external URL.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
162 (if (gnus-html-image-url-blocked-p
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
163 url
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
164 (if (buffer-live-p gnus-summary-buffer)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
165 (with-current-buffer gnus-summary-buffer
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
166 gnus-blocked-images)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
167 gnus-blocked-images))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
168 (progn
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
169 (widget-convert-button
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
170 'link start end
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
171 :action 'gnus-html-insert-image
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
172 :help-echo url
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
173 :keymap gnus-html-image-map
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
174 :button-keymap gnus-html-image-map)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
175 (let ((overlay (gnus-make-overlay start end))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
176 (spec (list url
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
177 (set-marker (make-marker) start)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
178 (set-marker (make-marker) end))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
179 (gnus-overlay-put overlay 'local-map gnus-html-image-map)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
180 (gnus-overlay-put overlay 'gnus-image spec)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
181 (gnus-put-text-property
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
182 start end
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
183 'gnus-image spec)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
184 (let ((file (gnus-html-image-id url))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
185 width height alt-text)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
186 (when (string-match "height=\"?\\([0-9]+\\)" parameters)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
187 (setq height (string-to-number (match-string 1 parameters))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
188 (when (string-match "width=\"?\\([0-9]+\\)" parameters)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
189 (setq width (string-to-number (match-string 1 parameters))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
190 (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)"
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
191 parameters)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
192 (setq alt-text (match-string 2 parameters)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
193 ;; Don't fetch images that are really small. They're
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
194 ;; probably tracking pictures.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
195 (when (and (or (null height)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
196 (> height 4))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
197 (or (null width)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
198 (> width 4)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
199 (if (file-exists-p file)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
200 ;; It's already cached, so just insert it.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
201 (let ((string (buffer-substring start end)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
202 ;; Delete the IMG text.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
203 (delete-region start end)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
204 (gnus-html-put-image file (point) string url alt-text))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
205 ;; We don't have it, so schedule it for fetching
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
206 ;; asynchronously.
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
207 (push (list url
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
208 (set-marker (make-marker) start)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
209 (point-marker))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
210 images))))))))
110295
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
211 (when images
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
212 (gnus-html-schedule-image-fetching (current-buffer) (nreverse images)))))
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
213
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
214 (defun gnus-html-wash-tags ()
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
215 (let (tag parameters string start end images url)
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
216 (gnus-html-pre-wash)
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
217 (gnus-html-wash-images)
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
218
110255
91bdd0141c6e gnus-html.el (gnus-html-wash-tags): Remove <a name...> tags, which confuses the rest of the function.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110221
diff changeset
219 (goto-char (point-min))
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
220 ;; Then do the other tags.
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
221 (while (re-search-forward "<\\([^ />]+\\)\\([^>]*\\)>" nil t)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
222 (setq tag (match-string 1)
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
223 parameters (match-string 2)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
224 start (match-beginning 0))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
225 (when (plusp (length parameters))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
226 (set-text-properties 0 (1- (length parameters)) nil parameters))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
227 (delete-region start (point))
110295
f70d39f7b8fd gnus-html.el (gnus-html-wash-tags): Refactor out the image bit, and don't restrict end-tag searches to the end of the line.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110278
diff changeset
228 (when (search-forward (concat "</" tag ">") nil t)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
229 (delete-region (match-beginning 0) (match-end 0)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
230 (setq end (point))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
231 (cond
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
232 ;; Fetch and insert a picture.
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
233 ((equal tag "img_alt"))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
234 ;; Add a link.
110103
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
235 ((or (equal tag "a")
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
236 (equal tag "A"))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
237 (when (string-match "href=\"\\([^\"]+\\)" parameters)
110068
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
238 (setq url (match-string 1 parameters))
110107
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
239 (gnus-message 8 "gnus-html-wash-tags: fetching link URL %s" url)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
240 (gnus-article-add-button start end
110068
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
241 'browse-url url
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
242 url)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
243 (let ((overlay (gnus-make-overlay start end)))
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
244 (gnus-overlay-put overlay 'evaporate t)
110068
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
245 (gnus-overlay-put overlay 'gnus-button-url url)
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
246 (gnus-put-text-property start end 'gnus-string url)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
247 (when gnus-article-mouse-face
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
248 (gnus-overlay-put overlay 'mouse-face gnus-article-mouse-face)))))
110092
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
249 ;; The upper-case IMG_ALT is apparently just an artifact that
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
250 ;; should be deleted.
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
251 ((equal tag "IMG_ALT")
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
252 (delete-region start end))
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
253 ;; Whatever. Just ignore the tag.
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
254 (t
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
255 ))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
256 (goto-char start))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
257 (goto-char (point-min))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
258 ;; The output from -halfdump isn't totally regular, so strip
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
259 ;; off any </pre_int>s that were left over.
110259
b350cc580a0f gnus-html.el (gnus-html-wash-tags): Limit end-tag matching to the current line to work around bugs in the output from w3m.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110255
diff changeset
260 (while (re-search-forward "</pre_int>\\|</internal>" nil t)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
261 (replace-match "" t t))
110172
f400055a098b Fix previous merge from Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110170
diff changeset
262 (mm-url-decode-entities)))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
263
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
264 (defun gnus-html-insert-image ()
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
265 "Fetch and insert the image under point."
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
266 (interactive)
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
267 (gnus-html-schedule-image-fetching
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
268 (current-buffer) (list (get-text-property (point) 'gnus-image))))
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
269
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
270 (defun gnus-html-show-alt-text ()
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
271 "Show the ALT text of the image under point."
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
272 (interactive)
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
273 (message "%s" (get-text-property (point) 'gnus-alt-text)))
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
274
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
275 (defun gnus-html-browse-image ()
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
276 "Browse the image under point."
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
277 (interactive)
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
278 (browse-url (get-text-property (point) 'gnus-image)))
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
279
110278
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
280 (defun gnus-html-browse-url ()
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
281 "Browse the image under point."
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
282 (interactive)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
283 (let ((url (get-text-property (point) 'gnus-string)))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
284 (if (not url)
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
285 (message "No URL at point")
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
286 (browse-url url))))
8c1028027f1b gnus-html (gnus-html-wash-tags): Search for images first, so that <a><img> works better; (gnus-html-displayed-image-map): Bind RET and TAB on images for better UX.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110277
diff changeset
287
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
288 (defun gnus-html-schedule-image-fetching (buffer images)
110107
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
289 (gnus-message 8 "gnus-html-schedule-image-fetching: buffer %s, images %s"
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
290 buffer images)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
291 (let* ((url (caar images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
292 (process (start-process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
293 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
294 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
295 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
296 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
297 "-o" (gnus-html-image-id url)
110276
07962d48d848 gnus-html.el (gnus-html-schedule-image-fetching): Decode entities before feeding URLs to curl.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110262
diff changeset
298 (mm-url-decode-entities-string url))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
299 (process-kill-without-query process)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
300 (set-process-sentinel process 'gnus-html-curl-sentinel)
110073
38805092633e gnus-ems.el: Provide compatibility functions for gnus-set-process-plist by Katsumi Yamaoka <yamaoka@jpl.org>; gnus-html.el: Use gnus-process-plist and friends for compatibility; gnus-cite.el: New function to guess whether a long line is natural text or not; message.el: Implement message-prune-recipient-rules; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110072
diff changeset
301 (gnus-set-process-plist process (list 'images images
38805092633e gnus-ems.el: Provide compatibility functions for gnus-set-process-plist by Katsumi Yamaoka <yamaoka@jpl.org>; gnus-html.el: Use gnus-process-plist and friends for compatibility; gnus-cite.el: New function to guess whether a long line is natural text or not; message.el: Implement message-prune-recipient-rules; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110072
diff changeset
302 'buffer buffer))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
303
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
304 (defun gnus-html-image-id (url)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
305 (expand-file-name (sha1 url) gnus-html-cache-directory))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
306
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
307 (defun gnus-html-curl-sentinel (process event)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
308 (when (string-match "finished" event)
110083
9921d33b9ce3 gnus-html-curl-sentinel: Replace process-get with gnus-process-get.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110081
diff changeset
309 (let* ((images (gnus-process-get process 'images))
9921d33b9ce3 gnus-html-curl-sentinel: Replace process-get with gnus-process-get.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110081
diff changeset
310 (buffer (gnus-process-get process 'buffer))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
311 (spec (pop images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
312 (file (gnus-html-image-id (car spec))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
313 (when (and (buffer-live-p buffer)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
314 ;; If the position of the marker is 1, then that
110072
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
315 ;; means that the text it was in has been deleted;
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
316 ;; i.e., that the user has selected a different
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
317 ;; article before the image arrived.
110072
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
318 (not (= (marker-position (cadr spec)) (point-min))))
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
319 (with-current-buffer buffer
110096
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
320 (let ((inhibit-read-only t)
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
321 (string (buffer-substring (cadr spec) (caddr spec))))
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
322 (delete-region (cadr spec) (caddr spec))
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
323 (gnus-html-put-image file (cadr spec) string))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
324 (when images
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
325 (gnus-html-schedule-image-fetching buffer images)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
326
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
327 (defun gnus-html-put-image (file point string &optional url alt-text)
110158
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
328 (when (gnus-graphic-display-p)
110156
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
329 (let* ((image (ignore-errors
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
330 (gnus-create-image file)))
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
331 (size (and image
110158
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
332 (if (featurep 'xemacs)
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
333 (cons (glyph-width image) (glyph-height image))
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
334 (image-size image t)))))
110045
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
335 (save-excursion
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
336 (goto-char point)
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
337 (if (and image
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
338 ;; Kludge to avoid displaying 30x30 gif images, which
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
339 ;; seems to be a signal of a broken image.
110159
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
340 (not (and (if (featurep 'xemacs)
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
341 (glyphp image)
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
342 (listp image))
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
343 (eq (if (featurep 'xemacs)
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
344 (let ((data (cdadar (specifier-spec-list
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
345 (glyph-image image)))))
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
346 (and (vectorp data)
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
347 (aref data 0)))
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
348 (plist-get (cdr image) :type))
2fe16dc7896c gnus-html.el (gnus-html-put-image): make avoidance of displaying small images work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110158
diff changeset
349 'gif)
110156
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
350 (= (car size) 30)
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
351 (= (cdr size) 30))))
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
352 (let ((start (point)))
110168
1feebeccf097 gnus-html.el: Fix up the logic that marks resized images for buffer deletion; Have the image insertion work even if the missing image is in an <a>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110167
diff changeset
353 (setq image (gnus-html-rescale-image image file size))
1feebeccf097 gnus-html.el: Fix up the logic that marks resized images for buffer deletion; Have the image insertion work even if the missing image is in an <a>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110167
diff changeset
354 (gnus-put-image image
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
355 (gnus-string-or string "*")
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
356 'external)
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
357 (let ((overlay (gnus-make-overlay start (point))))
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
358 (gnus-overlay-put overlay 'local-map
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
359 gnus-html-displayed-image-map)
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
360 (gnus-put-text-property start (point) 'gnus-alt-text alt-text)
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
361 (when url
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
362 (gnus-put-text-property start (point) 'gnus-image url)))
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.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110166
diff changeset
363 (gnus-add-image 'external image)
110045
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
364 t)
110096
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
365 (insert string)
110045
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
366 (when (fboundp 'find-image)
110262
97a40b7935bd gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110259
diff changeset
367 (setq image (find-image '((:type xpm :file "lock-broken.xpm"))))
97a40b7935bd gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110259
diff changeset
368 (gnus-put-image image
97a40b7935bd gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110259
diff changeset
369 (gnus-string-or string "*")
97a40b7935bd gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110259
diff changeset
370 'internal)
97a40b7935bd gnus-html.el (gnus-html-wash-tags, gnus-html-put-image): Mark cid and internal images as deletable by `W D D'.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110259
diff changeset
371 (gnus-add-image 'internal image))
110045
2758282288b9 Use gnus-create-image to be XEmacs-compatible; Don't do images on non-graphic displays; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110041
diff changeset
372 nil)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
373
110156
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
374 (defun gnus-html-rescale-image (image file size)
110098
3e3e1965a2c2 gnus-html.el: We can't rescale if we don't have the article buffer in a window.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110097
diff changeset
375 (if (or (not (fboundp 'imagemagick-types))
3e3e1965a2c2 gnus-html.el: We can't rescale if we don't have the article buffer in a window.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110097
diff changeset
376 (not (get-buffer-window (current-buffer))))
110094
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
377 image
110156
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
378 (let* ((width (car size))
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
379 (height (cdr size))
110098
3e3e1965a2c2 gnus-html.el: We can't rescale if we don't have the article buffer in a window.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110097
diff changeset
380 (edges (window-pixel-edges (get-buffer-window (current-buffer))))
110094
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
381 (window-width (truncate (* gnus-max-image-proportion
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
382 (- (nth 2 edges) (nth 0 edges)))))
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
383 (window-height (truncate (* gnus-max-image-proportion
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
384 (- (nth 3 edges) (nth 1 edges)))))
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
385 scaled-image)
110112
8eb5f382b2e6 gnus-html.el (gnus-html-rescale-image): Yet another try at getting the image sizing right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
386 (when (> height window-height)
8eb5f382b2e6 gnus-html.el (gnus-html-rescale-image): Yet another try at getting the image sizing right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
387 (setq image (or (create-image file 'imagemagick nil
8eb5f382b2e6 gnus-html.el (gnus-html-rescale-image): Yet another try at getting the image sizing right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
388 :height window-height)
110156
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
389 image))
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
390 (setq size (image-size image t)))
a2439ed30c52 message.el (message-generate-hashcash): Change default to 'opportunistic if hashcash is installed; gnus-html.el (gnus-html-put-image): Only call image-size once, since it's somewhat time-consuming on remote X servers.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110152
diff changeset
391 (when (> (car size) window-width)
110152
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
392 (setq image (or
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
393 (create-image file 'imagemagick nil
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
394 :width window-width)
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
395 image)))
110112
8eb5f382b2e6 gnus-html.el (gnus-html-rescale-image): Yet another try at getting the image sizing right.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110111
diff changeset
396 image)))
110094
b9d6d7f1d89f gnus-html.el: Rescale images in article buffers for Emacs versions that support this. This is currently only Emacs 24 compiled with imagemagick support.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110093
diff changeset
397
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
398 (defun gnus-html-prune-cache ()
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
399 (let ((total-size 0)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
400 files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
401 (dolist (file (directory-files gnus-html-cache-directory t nil t))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
402 (let ((attributes (file-attributes file)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
403 (unless (nth 0 attributes)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
404 (incf total-size (nth 7 attributes))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
405 (push (list (time-to-seconds (nth 5 attributes))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
406 (nth 7 attributes) file)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
407 files))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
408 (when (> total-size gnus-html-cache-size)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
409 (setq files (sort files (lambda (f1 f2)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
410 (< (car f1) (car f2)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
411 (dolist (file files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
412 (when (> total-size gnus-html-cache-size)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
413 (decf total-size (cadr file))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
414 (delete-file (nth 2 file)))))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
415
110103
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
416 (defun gnus-html-image-url-blocked-p (url blocked-images)
110277
a46aad43ce5a gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110276
diff changeset
417 "Find out if URL is blocked by BLOCKED-IMAGES."
110103
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
418 (let ((ret (and blocked-images
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
419 (string-match blocked-images url))))
110107
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
420 (if ret
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
421 (gnus-message 8 "gnus-html-image-url-blocked-p: %s blocked by regex %s"
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
422 url blocked-images)
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
423 (gnus-message 9 "gnus-html-image-url-blocked-p: %s passes regex %s"
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
424 url blocked-images))
110099
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
425 ret))
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
426
110169
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
427 (defun gnus-html-show-images ()
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
428 "Show any images that are in the HTML-rendered article buffer.
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
429 This only works if the article in question is HTML."
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
430 (interactive)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
431 (gnus-with-article-buffer
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
432 (let ((overlays (overlays-in (point-min) (point-max)))
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
433 overlay images)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
434 (while (setq overlay (pop overlays))
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
435 (when (overlay-get overlay 'gnus-image)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
436 (push (overlay-get overlay 'gnus-image) images)))
110179
b801b7109176 (gnus-html-show-images): If there are no images to show, then say so instead of bugging out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110178
diff changeset
437 (if (not images)
b801b7109176 (gnus-html-show-images): If there are no images to show, then say so instead of bugging out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110178
diff changeset
438 (message "No images to show")
b801b7109176 (gnus-html-show-images): If there are no images to show, then say so instead of bugging out.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110178
diff changeset
439 (gnus-html-schedule-image-fetching (current-buffer) images)))))
110169
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
440
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
441 ;;;###autoload
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
442 (defun gnus-html-prefetch-images (summary)
110075
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
443 (let (blocked-images urls)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
444 (when (buffer-live-p summary)
110072
1a236d9dcc23 * lisp/gnus/gnus-html.el: Require pkgs that define macros used in this file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 110068
diff changeset
445 (with-current-buffer summary
110075
9ef61fac0063 gnus-html.el: Introduce a new variable, gnus-blocked-images, and use that instead of the w3m variable; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110073
diff changeset
446 (setq blocked-images gnus-blocked-images))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
447 (save-match-data
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
448 (while (re-search-forward "<img.*src=[\"']\\([^\"']+\\)" nil t)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
449 (let ((url (match-string 1)))
110103
7181bb530921 gnus-html.el (gnus-html-wash-tags): "A" is also used for links, just like "a", it seems like; (gnus-html-image-url-blocked-p): Take a parameter for blocked-images since it needs to be picked from the correct buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110099
diff changeset
450 (unless (gnus-html-image-url-blocked-p url blocked-images)
110099
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
451 (unless (file-exists-p (gnus-html-image-id url))
110276
07962d48d848 gnus-html.el (gnus-html-schedule-image-fetching): Decode entities before feeding URLs to curl.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110262
diff changeset
452 (push (mm-url-decode-entities-string url) urls)
110099
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
453 (push (gnus-html-image-id url) urls)
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
454 (push "-o" urls)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
455 (let ((process
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
456 (apply 'start-process
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
457 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
458 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
459 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
460 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
461 urls)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
462 (process-kill-without-query process))))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
463
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
464 (provide 'gnus-html)
110024
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
465
5428546bbb98 Add a new super-simple HTML renderer based on w3m -halfdump by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents:
diff changeset
466 ;;; gnus-html.el ends here