annotate lisp/gnus/gnus-html.el @ 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.
author Katsumi Yamaoka <yamaoka@jpl.org>
date Tue, 07 Sep 2010 00:08:33 +0000
parents 91bdd0141c6e
children 97a40b7935bd
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
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
75 ;;;###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
76 (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
77 (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
78 (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
79 (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
80 (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
81 (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
82 (save-excursion
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
83 (mm-with-part handle
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
84 (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
85 (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
86 (default-process-coding-system
110086
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
87 (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
88 (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
89 'charset)))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
90 (when (and charset
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
91 (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
92 (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
93 (insert (prog1
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
94 (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
95 (erase-buffer)
19ce95f8bbbb gnus-article-html: Make work buffer multibyte for decoded contents.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110112
diff changeset
96 (mm-enable-multibyte))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
97 (call-process-region (point-min) (point-max)
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
98 "w3m"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
99 nil article-buffer nil
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
100 "-halfdump"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
101 "-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
102 "-I" "UTF-8"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
103 "-O" "UTF-8"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
104 "-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
105 "-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
106 "-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
107 "-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
108 "-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
109 "-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
110 (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
111
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
112 (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
113
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
114 (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
115 (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
116 (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
117 (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
118 (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
119 (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
120 (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
121 (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
122 (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
123 (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
124 (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
125 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
126 start (match-beginning 0))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
127 (when (plusp (length parameters))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
128 (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
129 (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
130 (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
131 (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
132 (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
133 (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
134 ;; 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
135 ((equal tag "img_alt")
110093
cb103d02d7f5 gnus-html.el: Add extra logging.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110092
diff changeset
136 (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
137 (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
138 (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
139 (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
140 ;; 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
141 ;; 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
142 ;; 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
143 (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
144 (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
145 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
146 (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
147 (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
148 (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
149 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
150 (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
151 (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
152 (delete-region 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
153 (gnus-put-image image (gnus-string-or string "*")))))
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
154 ;; 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
155 (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
156 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
157 (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
158 (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
159 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
160 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
161 (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
162 (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
163 '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
164 :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
165 :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
166 :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
167 :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
168 (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
169 (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
170 (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
171 (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
172 (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
173 (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
174 (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
175 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 '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
177 (let ((file (gnus-html-image-id 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
178 width 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
179 (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
180 (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
181 (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
182 (setq width (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
183 ;; 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
184 ;; 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
185 (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
186 (> 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
187 (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
188 (> 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
189 (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
190 ;; 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
191 (let ((string (buffer-substring start end)))
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
192 ;; Delete the ALT text.
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 (delete-region start end)
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 (gnus-html-put-image file (point) string))
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 ;; 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
196 ;; 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
197 (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
198 (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
199 (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
200 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
201 ;; 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
202 ((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
203 (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
204 (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
205 (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
206 (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
207 (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
208 '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
209 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
210 (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
211 (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
212 (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
213 (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
214 (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
215 (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
216 ;; 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
217 ;; should be deleted.
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
218 ((equal tag "IMG_ALT")
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
219 (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
220 ;; 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
221 (t
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
222 ))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
223 (goto-char start))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
224 (goto-char (point-min))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
225 ;; 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
226 ;; 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
227 (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
228 (replace-match "" t t))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
229 (when images
110172
f400055a098b Fix previous merge from Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110170
diff changeset
230 (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
231 (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
232
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
233 (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
234 "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
235 (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
236 (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
237 (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
238
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
239 (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
240 (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
241 buffer images)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
242 (let* ((url (caar images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
243 (process (start-process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
244 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
245 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
246 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
247 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
248 "-o" (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
249 url)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
250 (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
251 (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
252 (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
253 'buffer buffer))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
254
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
255 (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
256 (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
257
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
258 (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
259 (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
260 (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
261 (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
262 (spec (pop images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
263 (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
264 (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
265 ;; 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
266 ;; 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
267 ;; 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
268 ;; 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
269 (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
270 (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
271 (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
272 (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
273 (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
274 (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
275 (when images
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
276 (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
277
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
278 (defun gnus-html-put-image (file point string)
110158
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
279 (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
280 (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
281 (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
282 (size (and image
110158
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
283 (if (featurep 'xemacs)
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
284 (cons (glyph-width image) (glyph-height image))
64b3982570b5 Make gnus-html work for XEmacs.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110156
diff changeset
285 (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
286 (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
287 (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
288 (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
289 ;; 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
290 ;; 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
291 (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
292 (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
293 (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
294 (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
295 (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
296 (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
297 (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
298 (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
299 (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
300 '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
301 (= (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
302 (= (cdr size) 30))))
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
303 (progn
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
304 (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
305 (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
306 (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
307 'external)
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
308 (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
309 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
310 (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
311 (when (fboundp 'find-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
312 (gnus-put-image (find-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
313 '((:type xpm :file "lock-broken.xpm")))
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
314 (gnus-string-or 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
315 nil)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
316
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
317 (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
318 (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
319 (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
320 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
321 (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
322 (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
323 (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
324 (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
325 (- (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
326 (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
327 (- (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
328 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
329 (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
330 (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
331 :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
332 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
333 (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
334 (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
335 (setq image (or
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
336 (create-image file 'imagemagick nil
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
337 :width window-width)
3b368edf4df1 gnus-html-rescale-image: Fix up typo in rescaling.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110144
diff changeset
338 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
339 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
340
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
341 (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
342 (let ((total-size 0)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
343 files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
344 (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
345 (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
346 (unless (nth 0 attributes)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
347 (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
348 (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
349 (nth 7 attributes) file)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
350 files))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
351 (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
352 (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
353 (< (car f1) (car f2)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
354 (dolist (file files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
355 (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
356 (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
357 (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
358
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
359 (defun gnus-html-image-url-blocked-p (url blocked-images)
110105
a2011a3c7791 gnus-html.el: Doc fix for gnus-html-image-url-blocked-p.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110104
diff changeset
360 "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
361 (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
362 (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
363 (if ret
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
364 (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
365 url blocked-images)
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
366 (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
367 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
368 ret))
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
369
110169
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
370 (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
371 "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
372 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
373 (interactive)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
374 (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
375 (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
376 overlay images)
49b2e6d8b396 gnus-html.el: Add the new command gnus-html-show-images.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110168
diff changeset
377 (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
378 (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
379 (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
380 (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
381 (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
382 (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
383
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
384 ;;;###autoload
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
385 (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
386 (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
387 (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
388 (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
389 (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
390 (save-match-data
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
391 (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
392 (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
393 (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
394 (unless (file-exists-p (gnus-html-image-id url))
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
395 (push url urls)
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
396 (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
397 (push "-o" urls)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
398 (let ((process
110111
5b9f64b04a04 Delete all trailing white space.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110110
diff changeset
399 (apply 'start-process
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
400 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
401 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
402 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
403 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
404 urls)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
405 (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
406
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
407 (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
408
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
409 ;;; gnus-html.el ends here