annotate lisp/gnus/mm-view.el @ 112318:deae5bb3f0f6

Give a name FLOAT_TO_STRING_BUFSIZE to the constant 350. * lisp.h (FLOAT_TO_STRING_BUFSIZE): New macro. * data.c (Fnumber_to_string): Use it. * print.c (float_to_string, print_object): Likewise.
author Paul Eggert <eggert@cs.ucla.edu>
date Sun, 09 Jan 2011 00:21:21 -0800
parents 52100bac91db
children 1b25cd6a6e36
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38413
a26d9b55abb6 Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents: 33329
diff changeset
1 ;;; mm-view.el --- functions for viewing MIME objects
64754
fafd692d1e40 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
2
95820
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
3 ;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
4 ;; 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92774
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92774
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92774
diff changeset
12 ;; (at your option) any later version.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92774
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; GNU General Public License for more details.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
94662
f42ef85caf91 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 92774
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;;; Commentary:
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;;; Code:
110918
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110747
diff changeset
25
236342431786 nnimap.el (gnutls-negotiate): Silence the byte compiler.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110747
diff changeset
26 ;; For Emacs <22.2 and XEmacs.
87192
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
27 (eval-and-compile
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
28 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 (eval-when-compile (require 'cl))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 (require 'mail-parse)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 (require 'mailcap)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 (require 'mm-bodies)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 (require 'mm-decode)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
34 (require 'smime)
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
35 (require 'mml-smime)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36
110661
2b8ece636433 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110102
diff changeset
37 (autoload 'gnus-completing-read "gnus-util")
110747
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
38 (autoload 'gnus-window-inside-pixel-edges "gnus-ems")
95820
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
39 (autoload 'gnus-article-prepare-display "gnus-art")
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
40 (autoload 'vcard-parse-string "vcard")
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
41 (autoload 'vcard-format-string "vcard")
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
42 (autoload 'fill-flowed "flow-fill")
645fb33380d6 Remove unnecessary eval-and-compile of autoloads.
Glenn Morris <rgm@gnu.org>
parents: 94662
diff changeset
43 (autoload 'html2text "html2text" nil t)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
65278
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
45 (defvar gnus-article-mime-handles)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
46 (defvar gnus-newsgroup-charset)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
47 (defvar smime-keys)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
48 (defvar w3m-cid-retrieve-function-alist)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
49 (defvar w3m-current-buffer)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
50 (defvar w3m-display-inline-images)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
51 (defvar w3m-minor-mode-map)
1c443c9ad5cf (gnus-article-mime-handles, gnus-newsgroup-charset, smime-keys,
Juanma Barranquero <lekktu@gmail.com>
parents: 64754
diff changeset
52
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
53 (defvar mm-text-html-renderer-alist
111067
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
54 '((shr . mm-shr)
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
55 (w3 . mm-inline-text-html-render-with-w3)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
56 (w3m . mm-inline-text-html-render-with-w3m)
68207
fbd379b34f0a Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-698
Miles Bader <miles@gnu.org>
parents: 67418
diff changeset
57 (w3m-standalone . mm-inline-text-html-render-with-w3m-standalone)
111067
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
58 (gnus-w3m . gnus-article-html)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
59 (links mm-inline-render-with-file
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
60 mm-links-remove-leading-blank
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
61 "links" "-dump" file)
111067
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
62 (lynx mm-inline-render-with-stdin nil
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
63 "lynx" "-dump" "-force_html" "-stdin" "-nolist")
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
64 (html2text mm-inline-render-with-function html2text))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
65 "The attributes of renderer types for text/html.")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
66
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
67 (defcustom mm-fill-flowed t
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
68 "If non-nil a format=flowed article will be displayed flowed."
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
69 :type 'boolean
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
70 :version "22.1"
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
71 :group 'mime-display)
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
72
110747
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
73 (defcustom mm-inline-large-images-proportion 0.9
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
74 "Maximum proportion of large image resized when
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
75 `mm-inline-large-images' is set to resize."
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
76 :type 'float
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
77 :version "24.1"
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
78 :group 'mime-display)
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
79
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
80 ;;; Internal variables.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
81
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;;;
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;;; Functions for displaying various formats inline
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;;;
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
85
111280
3e377e8bbed5 Silence mm-view.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111067
diff changeset
86 (autoload 'gnus-rescale-image "gnus-util")
3e377e8bbed5 Silence mm-view.el compilation.
Glenn Morris <rgm@gnu.org>
parents: 111067
diff changeset
87
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (defun mm-inline-image-emacs (handle)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (let ((b (point-marker))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
90 (inhibit-read-only t))
110747
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
91 (put-image
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
92 (let ((image (mm-get-image handle)))
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
93 (if (eq mm-inline-large-images 'resize)
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
94 (gnus-rescale-image image
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
95 (let ((edges (gnus-window-inside-pixel-edges
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
96 (get-buffer-window (current-buffer)))))
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
97 (cons (truncate (* mm-inline-large-images-proportion
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
98 (- (nth 2 edges) (nth 0 edges))))
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
99 (truncate (* mm-inline-large-images-proportion
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
100 (- (nth 3 edges) (nth 1 edges)))))))
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
101 image))
0defef1647a5 Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110661
diff changeset
102 b)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
103 (insert "\n\n")
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (mm-handle-set-undisplayer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 handle
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
106 `(lambda ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
107 (let ((b ,b)
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
108 (inhibit-read-only t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
109 (remove-images b b)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
110 (delete-region b (+ b 2)))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (defun mm-inline-image-xemacs (handle)
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
113 (when (featurep 'xemacs)
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
114 (insert "\n\n")
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
115 (forward-char -2)
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
116 (let ((annot (make-annotation (mm-get-image handle) nil 'text))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
117 (inhibit-read-only t))
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
118 (mm-handle-set-undisplayer
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
119 handle
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
120 `(lambda ()
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
121 (let ((b ,(point-marker))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
122 (inhibit-read-only t))
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
123 (delete-annotation ,annot)
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
124 (delete-region (- b 2) b))))
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
125 (set-extent-property annot 'mm t)
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
126 (set-extent-property annot 'duplicable t))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (eval-and-compile
33329
71ce9ad48432 Use featurep for XEmacs test.
Dave Love <fx@gnu.org>
parents: 31764
diff changeset
129 (if (featurep 'xemacs)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (defalias 'mm-inline-image 'mm-inline-image-xemacs)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (defalias 'mm-inline-image 'mm-inline-image-emacs)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132
87192
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
133 ;; External.
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
134 (declare-function w3-do-setup "ext:w3" ())
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
135 (declare-function w3-region "ext:w3-display" (st nd))
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
136 (declare-function w3-prepare-buffer "ext:w3-display" (&rest args))
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
137
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (defvar mm-w3-setup nil)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (defun mm-setup-w3 ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (unless mm-w3-setup
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (require 'w3)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (w3-do-setup)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (require 'url)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (require 'w3-vars)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (require 'url-vars)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 (setq mm-w3-setup t)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
148 (defun mm-inline-text-html-render-with-w3 (handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
149 (mm-setup-w3)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
150 (let ((text (mm-get-part handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
151 (b (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
152 (url-standalone-mode t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
153 (url-gateway-unplugged t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
154 (w3-honor-stylesheets nil)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
155 (url-current-object
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
156 (url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
157 (width (window-width))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
158 (charset (mail-content-type-get
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
159 (mm-handle-type handle) 'charset)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
160 (save-excursion
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
161 (insert (if charset (mm-decode-string text charset) text))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
162 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
163 (narrow-to-region b (point))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
164 (unless charset
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
165 (goto-char (point-min))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
166 (when (or (and (boundp 'w3-meta-content-type-charset-regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
167 (re-search-forward
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
168 w3-meta-content-type-charset-regexp nil t))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
169 (and (boundp 'w3-meta-charset-content-type-regexp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
170 (re-search-forward
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
171 w3-meta-charset-content-type-regexp nil t)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
172 (setq charset
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
173 (let ((bsubstr (buffer-substring-no-properties
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
174 (match-beginning 2)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
175 (match-end 2))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
176 (if (fboundp 'w3-coding-system-for-mime-charset)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
177 (w3-coding-system-for-mime-charset bsubstr)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
178 (mm-charset-to-coding-system bsubstr))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
179 (delete-region (point-min) (point-max))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
180 (insert (mm-decode-string text charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
181 (save-window-excursion
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 (save-restriction
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
183 (let ((w3-strict-width width)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
184 ;; Don't let w3 set the global version of
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
185 ;; this variable.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
186 (fill-column fill-column))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
187 (if (or debug-on-error debug-on-quit)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
188 (w3-region (point-min) (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
189 (condition-case ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
190 (w3-region (point-min) (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
191 (error
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
192 (delete-region (point-min) (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
193 (let ((b (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
194 (charset (mail-content-type-get
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
195 (mm-handle-type handle) 'charset)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
196 (if (or (eq charset 'gnus-decoded)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
197 (eq mail-parse-charset 'gnus-decoded))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
198 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
199 (narrow-to-region (point) (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
200 (mm-insert-part handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
201 (goto-char (point-max)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
202 (insert (mm-decode-string (mm-get-part handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
203 charset))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
204 (message
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
205 "Error while rendering html; showing as text/plain")))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
206 (mm-handle-set-undisplayer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
207 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
208 `(lambda ()
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
209 (let ((inhibit-read-only t))
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
210 ,@(if (functionp 'remove-specifier)
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
211 '((dolist (prop '(background background-pixmap foreground))
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
212 (remove-specifier
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
213 (face-property 'default prop)
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
214 (current-buffer)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
215 (delete-region ,(point-min-marker)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
216 ,(point-max-marker)))))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
217
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
218 (defvar mm-w3m-setup nil
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
219 "Whether gnus-article-mode has been setup to use emacs-w3m.")
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
220
87192
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
221 ;; External.
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
222 (declare-function w3m-detect-meta-charset "ext:w3m" ())
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
223 (declare-function w3m-region "ext:w3m" (start end &optional url charset))
4b72ecd263bd (declare-function): Add compatibility declaration.
Glenn Morris <rgm@gnu.org>
parents: 86154
diff changeset
224
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
225 (defun mm-setup-w3m ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
226 "Setup gnus-article-mode to use emacs-w3m."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
227 (unless mm-w3m-setup
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
228 (require 'w3m)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
229 (unless (assq 'gnus-article-mode w3m-cid-retrieve-function-alist)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
230 (push (cons 'gnus-article-mode 'mm-w3m-cid-retrieve)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
231 w3m-cid-retrieve-function-alist))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
232 (setq mm-w3m-setup t))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
233 (setq w3m-display-inline-images mm-inline-text-html-with-images))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
234
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
235 (defun mm-w3m-cid-retrieve-1 (url handle)
57617
7fdc1df35f39 Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-628
Miles Bader <miles@gnu.org>
parents: 56927
diff changeset
236 (dolist (elem handle)
69304
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
237 (when (consp elem)
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
238 (when (equal url (mm-handle-id elem))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
239 (mm-insert-part elem)
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
240 (throw 'found-handle (mm-handle-media-type elem)))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
241 (when (and (stringp (car elem))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
242 (equal "multipart" (mm-handle-media-supertype elem)))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
243 (mm-w3m-cid-retrieve-1 url elem)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
244
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
245 (defun mm-w3m-cid-retrieve (url &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
246 "Insert a content pointed by URL if it has the cid: scheme."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
247 (when (string-match "\\`cid:" url)
69304
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
248 (or (catch 'found-handle
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
249 (mm-w3m-cid-retrieve-1
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
250 (setq url (concat "<" (substring url (match-end 0)) ">"))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
251 (with-current-buffer w3m-current-buffer
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
252 gnus-article-mime-handles)))
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
253 (prog1
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
254 nil
55d8c694b9cf Revision: emacs@sv.gnu.org/emacs--devo--0--patch-139
Miles Bader <miles@gnu.org>
parents: 69135
diff changeset
255 (message "Failed to find \"Content-ID: %s\"" url)))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
256
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
257 (defun mm-inline-text-html-render-with-w3m (handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
258 "Render a text/html part using emacs-w3m."
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
259 (mm-setup-w3m)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
260 (let ((text (mm-get-part handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
261 (b (point))
77309
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
262 (charset (or (mail-content-type-get (mm-handle-type handle) 'charset)
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
263 mail-parse-charset)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
264 (save-excursion
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
265 (insert (if charset (mm-decode-string text charset) text))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
266 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
267 (narrow-to-region b (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
268 (unless charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
269 (goto-char (point-min))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
270 (when (setq charset (w3m-detect-meta-charset))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 (delete-region (point-min) (point-max))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
272 (insert (mm-decode-string text charset))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
273 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
274 w3m-force-redisplay)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
275 (w3m-region (point-min) (point-max) nil charset))
100208
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
276 ;; Put the mark meaning this part was rendered by emacs-w3m.
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
277 (put-text-property (point-min) (point-max)
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
278 'mm-inline-text-html-with-w3m t)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
279 (when (and mm-inline-text-html-with-w3m-keymap
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
280 (boundp 'w3m-minor-mode-map)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
281 w3m-minor-mode-map)
100198
c20a057aefda * mm-view.el (mm-inline-text-html-render-with-w3m): Put special keymap on links.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98344
diff changeset
282 (if (and (boundp 'w3m-link-map)
c20a057aefda * mm-view.el (mm-inline-text-html-render-with-w3m): Put special keymap on links.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98344
diff changeset
283 w3m-link-map)
100208
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
284 (let* ((start (point-min))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
285 (end (point-max))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
286 (on (get-text-property start 'w3m-href-anchor))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
287 (map (copy-keymap w3m-link-map))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
288 next)
100198
c20a057aefda * mm-view.el (mm-inline-text-html-render-with-w3m): Put special keymap on links.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 98344
diff changeset
289 (set-keymap-parent map w3m-minor-mode-map)
100208
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
290 (while (< start end)
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
291 (if on
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
292 (progn
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
293 (setq next (or (text-property-any start end
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
294 'w3m-href-anchor nil)
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
295 end))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
296 (put-text-property start next 'keymap map))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
297 (setq next (or (text-property-not-all start end
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
298 'w3m-href-anchor nil)
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
299 end))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
300 (put-text-property start next 'keymap w3m-minor-mode-map))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
301 (setq start next
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
302 on (not on))))
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
303 (put-text-property (point-min) (point-max)
c5f2603d7595 * mm-view.el (mm-inline-text-html-render-with-w3m): Make it simple and fast.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 100198
diff changeset
304 'keymap w3m-minor-mode-map)))
67418
28264c86d408 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 65719
diff changeset
305 (mm-handle-set-undisplayer
28264c86d408 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 65719
diff changeset
306 handle
28264c86d408 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 65719
diff changeset
307 `(lambda ()
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
308 (let ((inhibit-read-only t))
67418
28264c86d408 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 65719
diff changeset
309 (delete-region ,(point-min-marker)
28264c86d408 Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-668
Miles Bader <miles@gnu.org>
parents: 65719
diff changeset
310 ,(point-max-marker)))))))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
311
68380
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
312 (defvar mm-w3m-standalone-supports-m17n-p (if (featurep 'mule) 'undecided)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
313 "*T means the w3m command supports the m17n feature.")
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
314
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
315 (defun mm-w3m-standalone-supports-m17n-p ()
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
316 "Say whether the w3m command supports the m17n feature."
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
317 (cond ((eq mm-w3m-standalone-supports-m17n-p t) t)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
318 ((eq mm-w3m-standalone-supports-m17n-p nil) nil)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
319 ((not (featurep 'mule)) (setq mm-w3m-standalone-supports-m17n-p nil))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
320 ((condition-case nil
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
321 (let ((coding-system-for-write 'iso-2022-jp)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
322 (coding-system-for-read 'iso-2022-jp)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
323 (str (mm-decode-coding-string "\
92694
d3767aa9ae49 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 87649
diff changeset
324 \e$B#D#o#e#s!!#w#3#m!!#s#u#p#p#o#r#t!!#m#1#7#n!)\e(B" 'iso-2022-jp)))
68380
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
325 (mm-with-multibyte-buffer
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
326 (insert str)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
327 (call-process-region
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
328 (point-min) (point-max) "w3m" t t nil "-dump"
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
329 "-T" "text/html" "-I" "iso-2022-jp" "-O" "iso-2022-jp")
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
330 (goto-char (point-min))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
331 (search-forward str nil t)))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
332 (error nil))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
333 (setq mm-w3m-standalone-supports-m17n-p t))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
334 (t
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
335 ;;(message "You had better upgrade your w3m command")
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
336 (setq mm-w3m-standalone-supports-m17n-p nil))))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
337
68207
fbd379b34f0a Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-698
Miles Bader <miles@gnu.org>
parents: 67418
diff changeset
338 (defun mm-inline-text-html-render-with-w3m-standalone (handle)
fbd379b34f0a Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-698
Miles Bader <miles@gnu.org>
parents: 67418
diff changeset
339 "Render a text/html part using w3m."
68380
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
340 (if (mm-w3m-standalone-supports-m17n-p)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
341 (let ((source (mm-get-part handle))
77309
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
342 (charset (or (mail-content-type-get (mm-handle-type handle)
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
343 'charset)
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
344 (symbol-name mail-parse-charset)))
68380
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
345 cs)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
346 (unless (and charset
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
347 (setq cs (mm-charset-to-coding-system charset))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
348 (not (eq cs 'ascii)))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
349 ;; The default.
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
350 (setq charset "iso-8859-1"
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
351 cs 'iso-8859-1))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
352 (mm-insert-inline
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
353 handle
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
354 (mm-with-unibyte-buffer
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
355 (insert source)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
356 (mm-enable-multibyte)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
357 (let ((coding-system-for-write 'binary)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
358 (coding-system-for-read cs))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
359 (call-process-region
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
360 (point-min) (point-max)
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
361 "w3m" t t nil "-dump" "-T" "text/html"
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
362 "-I" charset "-O" charset))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
363 (buffer-string))))
e1843613ecb8 Revision: emacs@sv.gnu.org/emacs--devo--0--patch-14
Miles Bader <miles@gnu.org>
parents: 68230
diff changeset
364 (mm-inline-render-with-stdin handle nil "w3m" "-dump" "-T" "text/html")))
68207
fbd379b34f0a Revision: miles@gnu.org--gnu-2005/emacs--cvs-trunk--0--patch-698
Miles Bader <miles@gnu.org>
parents: 67418
diff changeset
365
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
366 (defun mm-links-remove-leading-blank ()
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
367 ;; Delete the annoying three spaces preceding each line of links
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
368 ;; output.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
369 (goto-char (point-min))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
370 (while (re-search-forward "^ " nil t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
371 (delete-region (match-beginning 0) (match-end 0))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
372
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
373 (defun mm-inline-wash-with-file (post-func cmd &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
374 (let ((file (mm-make-temp-file
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
375 (expand-file-name "mm" mm-tmp-directory))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
376 (let ((coding-system-for-write 'binary))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
377 (write-region (point-min) (point-max) file nil 'silent))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
378 (delete-region (point-min) (point-max))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
379 (unwind-protect
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
380 (apply 'call-process cmd nil t nil (mapcar 'eval args))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
381 (delete-file file))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
382 (and post-func (funcall post-func))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
383
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
384 (defun mm-inline-wash-with-stdin (post-func cmd &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
385 (let ((coding-system-for-write 'binary))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
386 (apply 'call-process-region (point-min) (point-max)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
387 cmd t t nil args))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
388 (and post-func (funcall post-func)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
389
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
390 (defun mm-inline-render-with-file (handle post-func cmd &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
391 (let ((source (mm-get-part handle)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
392 (mm-insert-inline
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
393 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
394 (mm-with-unibyte-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
395 (insert source)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
396 (apply 'mm-inline-wash-with-file post-func cmd args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
397 (buffer-string)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
398
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
399 (defun mm-inline-render-with-stdin (handle post-func cmd &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
400 (let ((source (mm-get-part handle)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
401 (mm-insert-inline
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
402 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
403 (mm-with-unibyte-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
404 (insert source)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
405 (apply 'mm-inline-wash-with-stdin post-func cmd args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
406 (buffer-string)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
407
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
408 (defun mm-inline-render-with-function (handle func &rest args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
409 (let ((source (mm-get-part handle))
77309
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
410 (charset (or (mail-content-type-get (mm-handle-type handle) 'charset)
56cc03f5f68c Merge from gnus--rel--5.10
Miles Bader <miles@gnu.org>
parents: 75347
diff changeset
411 mail-parse-charset)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
412 (mm-insert-inline
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
413 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
414 (mm-with-multibyte-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
415 (insert (if charset
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
416 (mm-decode-string source charset)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
417 source))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
418 (apply func args)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
419 (buffer-string)))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
420
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
421 (defun mm-inline-text-html (handle)
111067
e36c65ac23bf Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 110918
diff changeset
422 (let* ((func mm-text-html-renderer)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
423 (entry (assq func mm-text-html-renderer-alist))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
424 (inhibit-read-only t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
425 (if entry
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
426 (setq func (cdr entry)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
427 (cond
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
428 ((functionp func)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
429 (funcall func handle))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 (t
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
431 (apply (car func) handle (cdr func))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
432
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
433 (defun mm-inline-text-vcard (handle)
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
434 (let ((inhibit-read-only t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
435 (mm-insert-inline
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
436 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
437 (concat "\n-- \n"
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
438 (ignore-errors
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
439 (if (fboundp 'vcard-pretty-print)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
440 (vcard-pretty-print (mm-get-part handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
441 (vcard-format-string
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
442 (vcard-parse-string (mm-get-part handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
443 'vcard-standard-filter))))))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
444
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
445 (defun mm-inline-text (handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
446 (let ((b (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
447 (type (mm-handle-media-subtype handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
448 (charset (mail-content-type-get
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
449 (mm-handle-type handle) 'charset))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
450 (inhibit-read-only t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
451 (if (or (eq charset 'gnus-decoded)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
452 ;; This is probably not entirely correct, but
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
453 ;; makes rfc822 parts with embedded multiparts work.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
454 (eq mail-parse-charset 'gnus-decoded))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (save-restriction
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
456 (narrow-to-region (point) (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
457 (mm-insert-part handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
458 (goto-char (point-max)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
459 (insert (mm-decode-string (mm-get-part handle) charset)))
69135
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
460 (when (and mm-fill-flowed
12d289b6e5de Revision: emacs@sv.gnu.org/emacs--devo--0--patch-118
Miles Bader <miles@gnu.org>
parents: 68762
diff changeset
461 (equal type "plain")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
462 (equal (cdr (assoc 'format (mm-handle-type handle)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
463 "flowed"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
464 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
465 (narrow-to-region b (point))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
466 (goto-char b)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
467 (fill-flowed nil (equal (cdr (assoc 'delsp (mm-handle-type handle)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
468 "yes"))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
469 (goto-char (point-max))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
470 (save-restriction
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
471 (narrow-to-region b (point))
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
472 (when (member type '("enriched" "richtext"))
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
473 (set-text-properties (point-min) (point-max) nil)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
474 (ignore-errors
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
475 (enriched-decode (point-min) (point-max))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
476 (mm-handle-set-undisplayer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
477 handle
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
478 `(lambda ()
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
479 (let ((inhibit-read-only t))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
480 (delete-region ,(point-min-marker)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
481 ,(point-max-marker))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 (defun mm-insert-inline (handle text)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 "Insert TEXT inline from HANDLE."
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
485 (let ((b (point)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (insert text)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
487 (unless (bolp)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
488 (insert "\n"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 (mm-handle-set-undisplayer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 handle
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 `(lambda ()
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
492 (let ((inhibit-read-only t))
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
493 (delete-region ,(copy-marker b)
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
494 ,(copy-marker (point))))))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (defun mm-inline-audio (handle)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (message "Not implemented"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 (defun mm-view-sound-file ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (message "Not implemented"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 (defun mm-w3-prepare-buffer ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (require 'w3)
43166
aa31e3865857 * gnus-art.el (article-wash-html): Bind url-gateway-unplugged.
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 41829
diff changeset
504 (let ((url-standalone-mode t)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
505 (url-gateway-unplugged t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
506 (w3-honor-stylesheets nil))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (w3-prepare-buffer)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (defun mm-view-message ()
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (mm-enable-multibyte)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (let (handles)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (let (gnus-article-mime-handles)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 ;; Double decode problem may happen. See mm-inline-message.
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (run-hooks 'gnus-article-decode-hook)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (gnus-article-prepare-display)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (setq handles gnus-article-mime-handles))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (when handles
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 (setq gnus-article-mime-handles
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
519 (mm-merge-handles gnus-article-mime-handles handles))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520 (fundamental-mode)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (goto-char (point-min)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (defun mm-inline-message (handle)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (let ((b (point))
41829
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
525 (bolp (bolp))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (charset (mail-content-type-get
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (mm-handle-type handle) 'charset))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 gnus-displaying-mime handles)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 (when (and charset
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (stringp charset))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (setq charset (intern (downcase charset)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (when (eq charset 'us-ascii)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (setq charset nil)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (save-excursion
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (save-restriction
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (narrow-to-region b b)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (mm-insert-part handle)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (let (gnus-article-mime-handles
41829
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
539 ;; disable prepare hook
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
540 gnus-article-prepare-hook
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 (gnus-newsgroup-charset
68762
970bf6e6463b Revision: emacs@sv.gnu.org/emacs--devo--0--patch-62
Miles Bader <miles@gnu.org>
parents: 68380
diff changeset
542 (unless (eq charset 'gnus-decoded) ;; mm-uu might set it.
970bf6e6463b Revision: emacs@sv.gnu.org/emacs--devo--0--patch-62
Miles Bader <miles@gnu.org>
parents: 68380
diff changeset
543 (or charset gnus-newsgroup-charset))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
544 (let ((gnus-original-article-buffer (mm-handle-buffer handle)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
545 (run-hooks 'gnus-article-decode-hook))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (gnus-article-prepare-display)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 (setq handles gnus-article-mime-handles))
41829
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
548 (goto-char (point-min))
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
549 (unless bolp
b4833df45a4c 2001-12-05 ShengHuo ZHU <zsh@cs.rochester.edu>
ShengHuo ZHU <zsh@cs.rochester.edu>
parents: 38635
diff changeset
550 (insert "\n"))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (goto-char (point-max))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (unless (bolp)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (insert "\n"))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (insert "----------\n\n")
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 (when handles
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 (setq gnus-article-mime-handles
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
557 (mm-merge-handles gnus-article-mime-handles handles)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (mm-handle-set-undisplayer
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 handle
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 `(lambda ()
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
561 (let ((inhibit-read-only t))
33329
71ce9ad48432 Use featurep for XEmacs test.
Dave Love <fx@gnu.org>
parents: 31764
diff changeset
562 (if (fboundp 'remove-specifier)
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 ;; This is only valid on XEmacs.
92774
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
564 (dolist (prop '(background background-pixmap foreground))
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
565 (remove-specifier
3035f32851cf Use inhibit-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92694
diff changeset
566 (face-property 'default prop) (current-buffer))))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 (delete-region ,(point-min-marker) ,(point-max-marker)))))))))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
569 (defun mm-display-inline-fontify (handle mode)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
570 (let ((charset (mail-content-type-get (mm-handle-type handle) 'charset))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
571 text coding-system)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
572 (unless (eq charset 'gnus-decoded)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
573 (mm-with-unibyte-buffer
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
574 (mm-insert-part handle)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
575 (mm-decompress-buffer
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
576 (or (mail-content-type-get (mm-handle-disposition handle) 'name)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
577 (mail-content-type-get (mm-handle-disposition handle) 'filename))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
578 t t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
579 (unless charset
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
580 (setq coding-system (mm-find-buffer-file-coding-system)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
581 (setq text (buffer-string))))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
582 ;; XEmacs @#$@ version of font-lock refuses to fully turn itself
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
583 ;; on for buffers whose name begins with " ". That's why we use
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
584 ;; `with-current-buffer'/`generate-new-buffer' rather than
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
585 ;; `with-temp-buffer'.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
586 (with-current-buffer (generate-new-buffer "*fontification*")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
587 (buffer-disable-undo)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
588 (mm-enable-multibyte)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
589 (insert (cond ((eq charset 'gnus-decoded)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
590 (with-current-buffer (mm-handle-buffer handle)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
591 (buffer-string)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
592 (coding-system
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
593 (mm-decode-coding-string text coding-system))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
594 (charset
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
595 (mm-decode-string text charset))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
596 (t
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
597 text)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
598 (require 'font-lock)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
599 (let ((font-lock-maximum-size nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
600 ;; Disable support modes, e.g., jit-lock, lazy-lock, etc.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
601 (font-lock-mode-hook nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
602 (font-lock-support-mode nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
603 ;; I find font-lock a bit too verbose.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
604 (font-lock-verbose nil))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
605 (funcall mode)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
606 ;; The mode function might have already turned on font-lock.
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
607 (unless (symbol-value 'font-lock-mode)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
608 (font-lock-fontify-buffer)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
609 ;; By default, XEmacs font-lock uses non-duplicable text
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
610 ;; properties. This code forces all the text properties
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
611 ;; to be copied along with the text.
86154
1cdfc94602cb * smime.el (from):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 85712
diff changeset
612 (when (featurep 'xemacs)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
613 (map-extents (lambda (ext ignored)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
614 (set-extent-property ext 'duplicable t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
615 nil)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
616 nil nil nil nil nil 'text-prop))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
617 (setq text (buffer-string))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
618 (kill-buffer (current-buffer)))
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 (mm-insert-inline handle text)))
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
621 ;; Shouldn't these functions check whether the user even wants to use
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
622 ;; font-lock? At least under XEmacs, this fontification is pretty
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
623 ;; much unconditional. Also, it would be nice to change for the size
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
624 ;; of the fontified region.
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
625
31764
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
626 (defun mm-display-patch-inline (handle)
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
627 (mm-display-inline-fontify handle 'diff-mode))
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
628
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
629 (defun mm-display-elisp-inline (handle)
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
630 (mm-display-inline-fontify handle 'emacs-lisp-mode))
54ae1def18cf Merge from Gnus trunk.
Dave Love <fx@gnu.org>
parents: 31717
diff changeset
631
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
632 (defun mm-display-dns-inline (handle)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
633 (mm-display-inline-fontify handle 'dns-mode))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
634
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
635 ;; id-signedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
636 ;; us(840) rsadsi(113549) pkcs(1) pkcs7(7) 2 }
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
637 (defvar mm-pkcs7-signed-magic
98344
7fa3e064d230 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95820
diff changeset
638 "\x30\x5c\x28\x80\x5c\x7c\x81\x2e\x5c\x7c\x82\x2e\x2e\x5c\x7c\x83\x2e\x2e\
7fa3e064d230 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95820
diff changeset
639 \x2e\x5c\x29\x06\x09\x5c\x2a\x86\x48\x86\xf7\x0d\x01\x07\x02")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
640
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
641 ;; id-envelopedData OBJECT IDENTIFIER ::= { iso(1) member-body(2)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
642 ;; us(840) rsadsi(113549) pkcs(1) pkcs7(7) 3 }
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
643 (defvar mm-pkcs7-enveloped-magic
98344
7fa3e064d230 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95820
diff changeset
644 "\x30\x5c\x28\x80\x5c\x7c\x81\x2e\x5c\x7c\x82\x2e\x2e\x5c\x7c\x83\x2e\x2e\
7fa3e064d230 Merge from gnus--devo--0
Miles Bader <miles@gnu.org>
parents: 95820
diff changeset
645 \x2e\x5c\x29\x06\x09\x5c\x2a\x86\x48\x86\xf7\x0d\x01\x07\x03")
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
646
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
647 (defun mm-view-pkcs7-get-type (handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
648 (mm-with-unibyte-buffer
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
649 (mm-insert-part handle)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
650 (cond ((looking-at mm-pkcs7-enveloped-magic)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
651 'enveloped)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
652 ((looking-at mm-pkcs7-signed-magic)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
653 'signed)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
654 (t
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
655 (error "Could not identify PKCS#7 type")))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
656
111501
5b30cfe2d392 Make mm-dissect-buffer pass sender's mail address to smime-decrypt-region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111280
diff changeset
657 (defun mm-view-pkcs7 (handle &optional from)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
658 (case (mm-view-pkcs7-get-type handle)
111501
5b30cfe2d392 Make mm-dissect-buffer pass sender's mail address to smime-decrypt-region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111280
diff changeset
659 (enveloped (mm-view-pkcs7-decrypt handle from))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
660 (signed (mm-view-pkcs7-verify handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
661 (otherwise (error "Unknown or unimplemented PKCS#7 type"))))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
662
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
663 (defun mm-view-pkcs7-verify (handle)
85712
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
664 (let ((verified nil))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
665 (with-temp-buffer
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
666 (insert "MIME-Version: 1.0\n")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
667 (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
668 (insert-buffer-substring (mm-handle-buffer handle))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
669 (setq verified (smime-verify-region (point-min) (point-max))))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
670 (goto-char (point-min))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
671 (mm-insert-part handle)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
672 (if (search-forward "Content-Type: " nil t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
673 (delete-region (point-min) (match-beginning 0)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
674 (goto-char (point-max))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
675 (if (re-search-backward "--\r?\n?" nil t)
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
676 (delete-region (match-end 0) (point-max)))
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
677 (unless verified
a3c27999decb Update Gnus to No Gnus 0.7 from the Gnus CVS trunk
Miles Bader <miles@gnu.org>
parents: 78224
diff changeset
678 (insert-buffer-substring smime-details-buffer)))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
679 (goto-char (point-min))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
680 (while (search-forward "\r\n" nil t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
681 (replace-match "\n"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
682 t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
683
111501
5b30cfe2d392 Make mm-dissect-buffer pass sender's mail address to smime-decrypt-region.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111280
diff changeset
684 (defun mm-view-pkcs7-decrypt (handle &optional from)
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
685 (insert-buffer-substring (mm-handle-buffer handle))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
686 (goto-char (point-min))
112045
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
687 (if (eq mml-smime-use 'epg)
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
688 ;; Use EPG/gpgsm
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
689 (let ((part (base64-decode-string (buffer-string))))
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
690 (erase-buffer)
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
691 (insert (epg-decrypt-string (epg-make-context 'CMS) part)))
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
692 ;; Use openssl
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
693 (insert "MIME-Version: 1.0\n")
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
694 (mm-insert-headers "application/pkcs7-mime" "base64" "smime.p7m")
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
695 (smime-decrypt-region
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
696 (point-min) (point-max)
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
697 (if (= (length smime-keys) 1)
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
698 (cadar smime-keys)
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
699 (smime-get-key-by-email
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
700 (gnus-completing-read
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
701 "Decipher using key"
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
702 smime-keys nil nil nil (car-safe (car-safe smime-keys)))))
52100bac91db Merge changes made in Gnus trunk.
Katsumi Yamaoka <yamaoka@jpl.org>
parents: 111501
diff changeset
703 from))
56927
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
704 (goto-char (point-min))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
705 (while (search-forward "\r\n" nil t)
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
706 (replace-match "\n"))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
707 (goto-char (point-min)))
55fd4f77387a Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-523
Miles Bader <miles@gnu.org>
parents: 55680
diff changeset
708
31717
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
709 (provide 'mm-view)
6b20b7e85e3c *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
710
38413
a26d9b55abb6 Some fixes to follow coding conventions in files from Gnus.
Pavel Janík <Pavel@Janik.cz>
parents: 33329
diff changeset
711 ;;; mm-view.el ends here