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