annotate lisp/gnus/gnus-html.el @ 110107:ffa0ce354f9d

gnus-html.el: prefix log messages with function name
author Katsumi Yamaoka <yamaoka@jpl.org>
date Thu, 02 Sep 2010 01:18:45 +0000
parents 8e1063b66037
children 5412f2e311ef
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
1 ;;; gnus-html.el --- Quoted-Printable functions
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
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
69 ;;;###autoload
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
70 (defun gnus-article-html (handle)
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
71 (let ((article-buffer (current-buffer)))
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
72 (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
73 (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
74 (save-excursion
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
75 (mm-with-part handle
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
76 (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
77 (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
78 (default-process-coding-system
110086
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
79 (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
80 (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
81 'charset)))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
82 (when (and charset
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
83 (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
84 (not (eq charset 'ascii)))
f661002e9a6d gnus-article-html: Decode contents by charset.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110084
diff changeset
85 (mm-decode-coding-region (point-min) (point-max) charset))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
86 (call-process-region (point-min) (point-max)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
87 "w3m"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
88 nil article-buffer nil
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
89 "-halfdump"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
90 "-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
91 "-I" "UTF-8"
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
92 "-O" "UTF-8"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
93 "-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
94 "-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
95 "-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
96 "-cols" (format "%s" gnus-html-frame-width)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
97 "-o" "display_image=off"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
98 "-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
99 (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
100
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
101 (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
102
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
103 (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
104 (let (tag parameters string start end images url)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
105 (mm-url-decode-entities)
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
106 (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
107 (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
108 (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
109 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
110 start (match-beginning 0))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
111 (when (plusp (length parameters))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
112 (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
113 (delete-region start (point))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
114 (when (search-forward (concat "</" tag ">") nil t)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
115 (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
116 (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
117 (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
118 ;; 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
119 ((equal tag "img_alt")
110093
cb103d02d7f5 gnus-html.el: Add extra logging.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110092
diff changeset
120 (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
121 (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
122 (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
123 (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
124 ;; 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
125 ;; 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
126 ;; 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
127 (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
128 (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
129 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
130 (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
131 (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
132 (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
133 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
134 (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
135 (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
136 (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
137 (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
138 ;; Normal, external URL.
110106
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
139 (unless (gnus-html-image-url-blocked-p
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
140 url
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
141 (if (buffer-live-p gnus-summary-buffer)
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
142 (with-current-buffer gnus-summary-buffer
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
143 gnus-blocked-images)
8e1063b66037 gnus-html.el (gnus-html-wash-tags): Check the value ofgnus-blocked-images in the summary buffer.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110105
diff changeset
144 gnus-blocked-images))
110068
2af503eb57ef Clarify the code a bit by renaming the variable with the url to `url'; Support cid: URLs/images; by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110055
diff changeset
145 (let ((file (gnus-html-image-id 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
146 (if (file-exists-p file)
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
147 ;; It's already cached, so just insert it.
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
148 (let ((string (buffer-substring 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
149 ;; Delete the ALT text.
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
150 (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
151 (gnus-html-put-image file (point) string))
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
152 ;; We don't have it, so schedule it for fetching
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
153 ;; asynchronously.
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
154 (push (list 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
155 (set-marker (make-marker) start)
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
156 (point-marker))
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
157 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
158 ;; 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
159 ((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
160 (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
161 (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
162 (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
163 (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
164 (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
165 '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
166 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
167 (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
168 (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
169 (gnus-overlay-put overlay 'gnus-button-url 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
170 (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
171 (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
172 ;; 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
173 ;; should be deleted.
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
174 ((equal tag "IMG_ALT")
1e526716f8fc gnus-html.el: Delete the IMG_ALT region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110086
diff changeset
175 (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
176 ;; 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
177 (t
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
178 ))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
179 (goto-char start))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
180 (goto-char (point-min))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
181 ;; 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
182 ;; off any </pre_int>s that were left over.
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
183 (while (re-search-forward "</pre_int>" nil t)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
184 (replace-match "" t t))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
185 (when images
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
186 (gnus-html-schedule-image-fetching (current-buffer) (nreverse images)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
187
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
188 (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
189 (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
190 buffer images)
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
191 (let* ((url (caar images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
192 (process (start-process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
193 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
194 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
195 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
196 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
197 "-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
198 url)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
199 (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
200 (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
201 (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
202 'buffer buffer))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
203
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
204 (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
205 (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
206
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
207 (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
208 (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
209 (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
210 (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
211 (spec (pop images))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
212 (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
213 (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
214 ;; 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
215 ;; 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
216 ;; 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
217 ;; 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
218 (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
219 (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
220 (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
221 (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
222 (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
223 (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
224 (when images
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
225 (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
226
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
227 (defun gnus-html-put-image (file point 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
228 (when (display-graphic-p)
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
229 (let ((image (ignore-errors
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
230 (gnus-create-image file))))
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
231 (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
232 (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
233 (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
234 ;; 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
235 ;; seems to be a signal of a broken image.
110054
fe1595694e7e Fix previous merge from Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110049
diff changeset
236 (not (and (listp image)
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
237 (eq (plist-get (cdr image) :type) 'gif)
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
238 (= (car (image-size image t)) 30)
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
239 (= (cdr (image-size image t)) 30))))
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
240 (progn
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
241 (gnus-put-image (gnus-html-rescale-image image)
018dd09f6b31 gnus.el, gnus-html.el: Use the deleted text as the image alt text.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110094
diff changeset
242 (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
243 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
244 (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
245 (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
246 (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
247 '((: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
248 (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
249 nil)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
250
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
251 (defun gnus-html-rescale-image (image)
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
252 (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
253 (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
254 image
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
255 (let* ((width (car (image-size image t)))
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
256 (height (cdr (image-size image t)))
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
257 (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
258 (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
259 (- (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
260 (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
261 (- (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
262 scaled-image)
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
263 (when (> width window-width)
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
264 (setq window-height (truncate (* window-height
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
265 (/ (* 1.0 window-width) width)))))
110097
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
266 (or
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
267 (cond ((> height window-height)
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
268 (create-image file 'imagemagick nil
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
269 :height window-height))
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
270 ((> width window-width)
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
271 (create-image file 'imagemagick nil
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
272 :width window-width)))
19dfa5177fdd gnus-html.el: Try to get the rescaling logic right for images that are just wide and not tall.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110096
diff changeset
273 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
274
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
275 (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
276 (let ((total-size 0)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
277 files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
278 (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
279 (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
280 (unless (nth 0 attributes)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
281 (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
282 (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
283 (nth 7 attributes) file)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
284 files))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
285 (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
286 (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
287 (< (car f1) (car f2)))))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
288 (dolist (file files)
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
289 (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
290 (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
291 (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
292
110099
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
293
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
294 (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
295 "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
296 (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
297 (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
298 (if ret
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
299 (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
300 url blocked-images)
ffa0ce354f9d gnus-html.el: prefix log messages with function name
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110106
diff changeset
301 (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
302 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
303 ret))
7a6012e13748 gnus-html.el: add and use gnus-html-image-url-blocked-p
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110098
diff changeset
304
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
305 ;;;###autoload
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
306 (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
307 (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
308 (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
309 (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
310 (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
311 (save-match-data
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
312 (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
313 (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
314 (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
315 (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
316 (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
317 (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
318 (push "-o" urls)))))
110025
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
319 (let ((process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
320 (apply 'start-process
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
321 "images" nil "curl"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
322 "-s" "--create-dirs"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
323 "--location"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
324 "--max-time" "60"
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
325 urls)))
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
326 (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
327
5f352fd4346a Misc Gnus fixes by Lars Magne Ingebrigtsen <larsi@gnus.org>.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110024
diff changeset
328 (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
329
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
330 ;;; gnus-html.el ends here