annotate lisp/gnus/gnus-html.el @ 110277:a46aad43ce5a

gnus-html.el: Allow showing the ALT text of images and to browse the images themselves.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Wed, 08 Sep 2010 23:59:52 +0000
parents 07962d48d848
children 8c1028027f1b
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)
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
79 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
80
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
81 ;;;###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
82 (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
83 (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
84 (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
85 (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
86 (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
87 (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
88 (save-excursion
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
89 (mm-with-part handle
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
90 (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
91 (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
92 (default-process-coding-system
110086
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
93 (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
94 (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
95 'charset)))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
96 (when (and charset
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
97 (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
98 (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
99 (insert (prog1
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
100 (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
101 (erase-buffer)
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
102 (mm-enable-multibyte))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
103 (call-process-region (point-min) (point-max)
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
104 "w3m"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
105 nil article-buffer nil
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
106 "-halfdump"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
107 "-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
108 "-I" "UTF-8"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
109 "-O" "UTF-8"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
110 "-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
111 "-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
112 "-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
113 "-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
114 "-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
115 "-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
116 (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
117
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
118 (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
119
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
120 (defun gnus-html-wash-tags ()
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
121 (let (tag parameters string start end images 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
122 (goto-char (point-min))
110178
0d6f1624cdf7 (gnus-article-copy-string): Say what data we copied; (gnus-html-wash-tags): Remove even more white space around <pre_int>; (gnus-agent-load-alist): Check whether the agentview files exist before trying to read them.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110172
diff changeset
123 (while (re-search-forward " *<pre_int> *</pre_int> *\n" nil t)
110110
91cc7bab2ca4 gnus-html.el (gnus-html-wash-tags): Remove all <pre_int> place holders.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110109
diff changeset
124 (replace-match "" t t))
91cc7bab2ca4 gnus-html.el (gnus-html-wash-tags): Remove all <pre_int> place holders.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110109
diff changeset
125 (goto-char (point-min))
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
126 (while (re-search-forward "<a name[^\n>]+>" nil t)
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
127 (replace-match "" t t))
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
128 (goto-char (point-min))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
129 (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
130 (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
131 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
132 start (match-beginning 0))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
133 (when (plusp (length parameters))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
134 (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
135 (delete-region start (point))
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
136 (when (search-forward (concat "</" tag ">") (line-end-position) t)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
137 (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
138 (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
139 (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
140 ;; Fetch and insert a picture.
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
141 ((equal tag "img_alt")
110093
cb103d02d7f5 gnus-html.el: Add extra logging.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110092
diff changeset
142 (when (string-match "src=\"\\([^\"]+\\)" 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
143 (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
144 (gnus-message 8 "gnus-html-wash-tags: fetching image URL %s" url)
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
145 (if (string-match "^cid:\\(.*\\)" url)
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
146 ;; URLs with cid: have their content stashed in other
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
147 ;; parts of the MIME structure, so just insert them
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
148 ;; immediately.
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
149 (let ((handle (mm-get-content-id
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
150 (setq url (match-string 1 url))))
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
151 image)
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
152 (when handle
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
153 (mm-with-part handle
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
154 (setq image (gnus-create-image (buffer-string)
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
155 nil t))))
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
156 (when image
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
157 (let ((string (buffer-substring start end)))
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
158 (delete-region start end)
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
159 (gnus-put-image image (gnus-string-or string "*") 'cid)
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
160 (gnus-add-image 'cid image))))
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
161 ;; Normal, external 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
162 (if (gnus-html-image-url-blocked-p
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
163 url
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
164 (if (buffer-live-p gnus-summary-buffer)
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
165 (with-current-buffer gnus-summary-buffer
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
166 gnus-blocked-images)
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
167 gnus-blocked-images))
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
168 (progn
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
169 (widget-convert-button
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
170 'link start end
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
171 :action '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
172 :help-echo url
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
173 :keymap 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
174 :button-keymap gnus-html-image-map)
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
175 (let ((overlay (gnus-make-overlay start end))
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
176 (spec (list url
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
177 (set-marker (make-marker) start)
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
178 (set-marker (make-marker) end))))
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
179 (gnus-overlay-put overlay 'local-map gnus-html-image-map)
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
180 (gnus-overlay-put overlay 'gnus-image spec)
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
181 (gnus-put-text-property
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
182 start end
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
183 'gnus-image spec)))
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
184 (let ((file (gnus-html-image-id url))
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
185 width height alt-text)
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
186 (when (string-match "height=\"?\\([0-9]+\\)" parameters)
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
187 (setq height (string-to-number (match-string 1 parameters))))
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
188 (when (string-match "width=\"?\\([0-9]+\\)" parameters)
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
189 (setq width (string-to-number (match-string 1 parameters))))
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
190 (when (string-match "\\(alt\\|title\\)=\"\\([^\"]+\\)"
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
191 parameters)
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
192 (setq alt-text (match-string 2 parameters)))
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
193 ;; Don't fetch images that are really small. They're
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
194 ;; probably tracking pictures.
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
195 (when (and (or (null height)
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
196 (> height 4))
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
197 (or (null width)
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
198 (> width 4)))
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
199 (if (file-exists-p file)
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
200 ;; It's already cached, so just insert it.
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
201 (let ((string (buffer-substring start end)))
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
202 ;; Delete the IMG text.
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
203 (delete-region start end)
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
204 (gnus-html-put-image file (point) string url alt-text))
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
205 ;; We don't have it, so schedule it for fetching
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
206 ;; asynchronously.
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
207 (push (list url
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
208 (set-marker (make-marker) start)
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
209 (point-marker))
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
210 images))))))))
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
211 ;; 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
212 ((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
213 (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
214 (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
215 (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
216 (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
217 (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
218 '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
219 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
220 (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
221 (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
222 (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
223 (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
224 (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
225 (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
226 ;; 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
227 ;; should be deleted.
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
228 ((equal tag "IMG_ALT")
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
229 (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
230 ;; 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
231 (t
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
232 ))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
233 (goto-char start))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
234 (goto-char (point-min))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
235 ;; 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
236 ;; 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
237 (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
238 (replace-match "" t t))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
239 (when images
110172
f400055a098b Fix previous merge from Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110170
diff changeset
240 (gnus-html-schedule-image-fetching (current-buffer) (nreverse images)))
f400055a098b Fix previous merge from Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110170
diff changeset
241 (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
242
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
243 (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
244 "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
245 (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
246 (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
247 (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
248
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
249 (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
250 "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
251 (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
252 (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
253
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
254 (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
255 "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
256 (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
257 (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
258
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
259 (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
260 (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
261 buffer images)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
262 (let* ((url (caar images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
263 (process (start-process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
264 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
265 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
266 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
267 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
268 "-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
269 (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
270 (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
271 (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
272 (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
273 'buffer buffer))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
274
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
275 (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
276 (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
277
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
278 (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
279 (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
280 (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
281 (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
282 (spec (pop images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
283 (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
284 (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
285 ;; 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
286 ;; 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
287 ;; 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
288 ;; 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
289 (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
290 (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
291 (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
292 (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
293 (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
294 (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
295 (when images
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
296 (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
297
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
298 (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
299 (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
300 (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
301 (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
302 (size (and image
110158
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
303 (if (featurep 'xemacs)
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
304 (cons (glyph-width image) (glyph-height image))
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
305 (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
306 (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
307 (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
308 (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
309 ;; 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
310 ;; 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
311 (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
312 (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
313 (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
314 (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
315 (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
316 (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
317 (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
318 (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
319 (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
320 '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
321 (= (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
322 (= (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
323 (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
324 (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
325 (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
326 (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
327 '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
328 (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
329 (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
330 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
331 (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
332 (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
333 (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
334 (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
335 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
336 (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
337 (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
338 (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
339 (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
340 (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
341 '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
342 (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
343 nil)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
344
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
345 (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
346 (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
347 (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
348 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
349 (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
350 (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
351 (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
352 (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
353 (- (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
354 (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
355 (- (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
356 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
357 (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
358 (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
359 :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
360 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
361 (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
362 (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
363 (setq image (or
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
364 (create-image file 'imagemagick nil
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
365 :width window-width)
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
366 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
367 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
368
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
369 (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
370 (let ((total-size 0)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
371 files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
372 (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
373 (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
374 (unless (nth 0 attributes)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
375 (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
376 (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
377 (nth 7 attributes) file)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
378 files))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
379 (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
380 (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
381 (< (car f1) (car f2)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
382 (dolist (file files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
383 (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
384 (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
385 (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
386
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
387 (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
388 "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
389 (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
390 (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
391 (if ret
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
392 (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
393 url blocked-images)
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
394 (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
395 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
396 ret))
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
397
110169
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
398 (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
399 "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
400 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
401 (interactive)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
402 (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
403 (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
404 overlay images)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
405 (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
406 (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
407 (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
408 (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
409 (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
410 (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
411
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
412 ;;;###autoload
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
413 (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
414 (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
415 (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
416 (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
417 (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
418 (save-match-data
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
419 (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
420 (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
421 (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
422 (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
423 (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
424 (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
425 (push "-o" urls)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
426 (let ((process
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
427 (apply 'start-process
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
428 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
429 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
430 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
431 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
432 urls)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
433 (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
434
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
435 (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
436
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
437 ;;; gnus-html.el ends here