Mercurial > emacs
annotate lisp/mail/rmailmm.el @ 111824:88e55e239ecc
* lisp/replace.el: Add "collect" feature to occur.
(occur-collect-regexp-history): New var.
(occur-read-primary-args): Return a replace string for nlines, if needed.
(occur): Extend the meaning of nlines.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Fri, 03 Dec 2010 20:58:06 -0500 |
parents | 141d3f14d8c3 |
children | c00190a8c8ef |
rev | line source |
---|---|
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
1 ;;; rmailmm.el --- MIME decoding and display stuff for RMAIL |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
2 |
106815 | 3 ;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
4 |
101380
50eed64d8f54
Comment (add Author: header).
Glenn Morris <rgm@gnu.org>
parents:
101370
diff
changeset
|
5 ;; Author: Alexander Pohoyda |
50eed64d8f54
Comment (add Author: header).
Glenn Morris <rgm@gnu.org>
parents:
101370
diff
changeset
|
6 ;; Alex Schroeder |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
7 ;; Maintainer: FSF |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
8 ;; Keywords: mail |
110015
280c8ae2476d
Add "Package:" file headers to denote built-in packages.
Chong Yidong <cyd@stupidchicken.com>
parents:
109330
diff
changeset
|
9 ;; Package: rmail |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
10 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
12 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
13 ;; GNU Emacs is free software: you can redistribute it and/or modify |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
15 ;; the Free Software Foundation, either version 3 of the License, or |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
16 ;; (at your option) any later version. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
17 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
22 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
25 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
27 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
28 ;; Essentially based on the design of Alexander Pohoyda's MIME |
102317 | 29 ;; extensions (mime-display.el and mime.el). |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
30 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
31 ;; This file provides two operation modes for viewing a MIME message. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
32 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
33 ;; (1) When rmail-enable-mime is non-nil (now it is the default), the |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
34 ;; function `rmail-show-mime' is automatically called. That function |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
35 ;; shows a MIME message directly in RMAIL's view buffer. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
36 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
37 ;; (2) When rmail-enable-mime is nil, the command 'v' (or M-x |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
38 ;; rmail-mime) shows a MIME message in a new buffer "*RMAIL*". |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
39 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
40 ;; Both operations share the intermediate functions rmail-mime-process |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
41 ;; and rmail-mime-process-multipart as below. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
42 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
43 ;; rmail-show-mime |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
44 ;; +- rmail-mime-parse |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
45 ;; | +- rmail-mime-process <--+------------+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
46 ;; | | +---------+ | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
47 ;; | + rmail-mime-process-multipart --+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
48 ;; | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
49 ;; + rmail-mime-insert <----------------+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
50 ;; +- rmail-mime-insert-text | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
51 ;; +- rmail-mime-insert-bulk | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
52 ;; +- rmail-mime-insert-multipart --+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
53 ;; |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
54 ;; rmail-mime |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
55 ;; +- rmail-mime-show <----------------------------------+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
56 ;; +- rmail-mime-process | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
57 ;; +- rmail-mime-handle | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
58 ;; +- rmail-mime-text-handler | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
59 ;; +- rmail-mime-bulk-handler | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
60 ;; | + rmail-mime-insert-bulk |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
61 ;; +- rmail-mime-multipart-handler | |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
62 ;; +- rmail-mime-process-multipart --+ |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
63 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
64 ;; In addition, for the case of rmail-enable-mime being non-nil, this |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
65 ;; file provides two functions rmail-insert-mime-forwarded-message and |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
66 ;; rmail-insert-mime-resent-message for composing forwarded and resent |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
67 ;; messages respectively. |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
68 |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
69 ;; Todo: |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
70 |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
71 ;; Make rmail-mime-media-type-handlers-alist usable in the first |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
72 ;; operation mode. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
73 ;; Handle multipart/alternative in the second operation mode. |
105211
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
74 ;; Offer the option to call external/internal viewers (doc-view, xpdf, etc). |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
75 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
76 ;;; Code: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
77 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
78 (require 'rmail) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
79 (require 'mail-parse) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
80 (require 'message) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
81 |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
82 ;;; User options. |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
83 |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
84 (defgroup rmail-mime nil |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
85 "Rmail MIME handling options." |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
86 :prefix "rmail-mime-" |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
87 :group 'rmail) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
88 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
89 (defcustom rmail-mime-media-type-handlers-alist |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
90 '(("multipart/.*" rmail-mime-multipart-handler) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
91 ("text/.*" rmail-mime-text-handler) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
92 ("text/\\(x-\\)?patch" rmail-mime-bulk-handler) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
93 ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler)) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
94 "Functions to handle various content types. |
102421
62a954f574fa
(rmail-mime-media-type-handlers-alist): Fix doc and custom type.
Glenn Morris <rgm@gnu.org>
parents:
102403
diff
changeset
|
95 This is an alist with elements of the form (REGEXP FUNCTION ...). |
62a954f574fa
(rmail-mime-media-type-handlers-alist): Fix doc and custom type.
Glenn Morris <rgm@gnu.org>
parents:
102403
diff
changeset
|
96 The first item is a regular expression matching a content-type. |
62a954f574fa
(rmail-mime-media-type-handlers-alist): Fix doc and custom type.
Glenn Morris <rgm@gnu.org>
parents:
102403
diff
changeset
|
97 The remaining elements are handler functions to run, in order of |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
98 decreasing preference. These are called until one returns non-nil. |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
99 Note that this only applies to items with an inline Content-Disposition, |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
100 all others are handled by `rmail-mime-bulk-handler'." |
102421
62a954f574fa
(rmail-mime-media-type-handlers-alist): Fix doc and custom type.
Glenn Morris <rgm@gnu.org>
parents:
102403
diff
changeset
|
101 :type '(alist :key-type regexp :value-type (repeat function)) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
102 :version "23.1" |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
103 :group 'rmail-mime) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
104 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
105 (defcustom rmail-mime-attachment-dirs-alist |
101890
4f858364bb26
(rmail-mime-attachment-dirs-alist): Use temporary-file-directory.
Chong Yidong <cyd@stupidchicken.com>
parents:
101380
diff
changeset
|
106 `(("text/.*" "~/Documents") |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
107 ("image/.*" "~/Pictures") |
101890
4f858364bb26
(rmail-mime-attachment-dirs-alist): Use temporary-file-directory.
Chong Yidong <cyd@stupidchicken.com>
parents:
101380
diff
changeset
|
108 (".*" "~/Desktop" "~" ,temporary-file-directory)) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
109 "Default directories to save attachments of various types into. |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
110 This is an alist with elements of the form (REGEXP DIR ...). |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
111 The first item is a regular expression matching a content-type. |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
112 The remaining elements are directories, in order of decreasing preference. |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
113 The first directory that exists is used." |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
114 :type '(alist :key-type regexp :value-type (repeat directory)) |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
115 :version "23.1" |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
116 :group 'rmail-mime) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
117 |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
118 (defcustom rmail-mime-show-images 'button |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
119 "What to do with image attachments that Emacs is capable of displaying. |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
120 If nil, do nothing special. If `button', add an extra button |
105211
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
121 that when pushed displays the image in the buffer. If a number, |
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
122 automatically show images if they are smaller than that size (in |
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
123 bytes), otherwise add a display button. Anything else means to |
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
124 automatically display the image in the buffer." |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
125 :type '(choice (const :tag "Add button to view image" button) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
126 (const :tag "No special treatment" nil) |
105211
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
127 (number :tag "Show if smaller than certain size") |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
128 (other :tag "Always show" show)) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
129 :version "23.2" |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
130 :group 'rmail-mime) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
131 |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
132 ;;; End of user options. |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
133 |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
134 ;;; MIME-entity object |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
135 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
136 (defun rmail-mime-entity (type disposition transfer-encoding |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
137 header body children) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
138 "Retrun a newly created MIME-entity object. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
139 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
140 A MIME-entity is a vector of 6 elements: |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
141 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
142 [ TYPE DISPOSITION TRANSFER-ENCODING HEADER BODY CHILDREN ] |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
143 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
144 TYPE and DISPOSITION correspond to MIME headers Content-Type: and |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
145 Cotent-Disposition: respectively, and has this format: |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
146 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
147 \(VALUE (ATTRIBUTE . VALUE) (ATTRIBUTE . VALUE) ...) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
148 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
149 VALUE is a string and ATTRIBUTE is a symbol. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
150 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
151 Consider the following header, for example: |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
152 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
153 Content-Type: multipart/mixed; |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
154 boundary=\"----=_NextPart_000_0104_01C617E4.BDEC4C40\" |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
155 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
156 The corresponding TYPE argument must be: |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
157 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
158 \(\"multipart/mixed\" |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
159 \(\"boundary\" . \"----=_NextPart_000_0104_01C617E4.BDEC4C40\")) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
160 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
161 TRANSFER-ENCODING corresponds to MIME header |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
162 Content-Transfer-Encoding, and is a lowercased string. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
163 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
164 HEADER and BODY are a cons (BEG . END), where BEG and END specify |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
165 the region of the corresponding part in RMAIL's data (mbox) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
166 buffer. BODY may be nil. In that case, the current buffer is |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
167 narrowed to the body part. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
168 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
169 CHILDREN is a list of MIME-entities for a \"multipart\" entity, and |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
170 nil for the other types." |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
171 (vector type disposition transfer-encoding header body children)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
172 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
173 ;; Accessors for a MIME-entity object. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
174 (defsubst rmail-mime-entity-type (entity) (aref entity 0)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
175 (defsubst rmail-mime-entity-disposition (entity) (aref entity 1)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
176 (defsubst rmail-mime-entity-transfer-encoding (entity) (aref entity 2)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
177 (defsubst rmail-mime-entity-header (entity) (aref entity 3)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
178 (defsubst rmail-mime-entity-body (entity) (aref entity 4)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
179 (defsubst rmail-mime-entity-children (entity) (aref entity 5)) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
180 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
181 ;;; Buttons |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
182 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
183 (defun rmail-mime-save (button) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
184 "Save the attachment using info in the BUTTON." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
185 (let* ((filename (button-get button 'filename)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
186 (directory (button-get button 'directory)) |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
187 (data (button-get button 'data)) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
188 (mbox-buf rmail-view-buffer) |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
189 (ofilename filename)) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
190 (setq filename (expand-file-name |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
191 (read-file-name (format "Save as (default: %s): " filename) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
192 directory |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
193 (expand-file-name filename directory)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
194 directory)) |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
195 ;; If arg is just a directory, use the default file name, but in |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
196 ;; that directory (copied from write-file). |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
197 (if (file-directory-p filename) |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
198 (setq filename (expand-file-name |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
199 (file-name-nondirectory ofilename) |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
200 (file-name-as-directory filename)))) |
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
201 (with-temp-buffer |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
202 (set-buffer-file-coding-system 'no-conversion) |
109330
d03ee75f7be2
mail/rmailmm.el (rmail-mime-save): Make the temp buffer unibyte,
Eli Zaretskii <eliz@gnu.org>
parents:
106953
diff
changeset
|
203 ;; Needed e.g. by jka-compr, so if the attachment is a compressed |
d03ee75f7be2
mail/rmailmm.el (rmail-mime-save): Make the temp buffer unibyte,
Eli Zaretskii <eliz@gnu.org>
parents:
106953
diff
changeset
|
204 ;; file, the magic signature compares equal with the unibyte |
d03ee75f7be2
mail/rmailmm.el (rmail-mime-save): Make the temp buffer unibyte,
Eli Zaretskii <eliz@gnu.org>
parents:
106953
diff
changeset
|
205 ;; signature string recorded in jka-compr-compression-info-list. |
d03ee75f7be2
mail/rmailmm.el (rmail-mime-save): Make the temp buffer unibyte,
Eli Zaretskii <eliz@gnu.org>
parents:
106953
diff
changeset
|
206 (set-buffer-multibyte nil) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
207 (setq buffer-undo-list t) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
208 (if (stringp data) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
209 (insert data) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
210 ;; DATA is a MIME-entity object. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
211 (let ((transfer-encoding (rmail-mime-entity-transfer-encoding data)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
212 (body (rmail-mime-entity-body data))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
213 (insert-buffer-substring mbox-buf (car body) (cdr body)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
214 (cond ((string= transfer-encoding "base64") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
215 (ignore-errors (base64-decode-region (point-min) (point-max)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
216 ((string= transfer-encoding "quoted-printable") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
217 (quoted-printable-decode-region (point-min) (point-max)))))) |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
218 (write-region nil nil filename nil nil nil t)))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
219 |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
220 (define-button-type 'rmail-mime-save 'action 'rmail-mime-save) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
221 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
222 ;;; Handlers |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
223 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
224 (defun rmail-mime-text-handler (content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
225 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
226 content-transfer-encoding) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
227 "Handle the current buffer as a plain text MIME part." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
228 (let* ((charset (cdr (assq 'charset (cdr content-type)))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
229 (coding-system (when charset |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
230 (intern (downcase charset))))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
231 (when (coding-system-p coding-system) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
232 (decode-coding-region (point-min) (point-max) coding-system)))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
233 |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
234 (defun rmail-mime-insert-text (entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
235 "Insert MIME-entity ENTITY as a plain text MIME part in the current buffer." |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
236 (let* ((content-type (rmail-mime-entity-type entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
237 (charset (cdr (assq 'charset (cdr content-type)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
238 (coding-system (if charset (intern (downcase charset)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
239 (transfer-encoding (rmail-mime-entity-transfer-encoding entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
240 (body (rmail-mime-entity-body entity))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
241 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
242 (narrow-to-region (point) (point)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
243 (insert-buffer-substring rmail-buffer (car body) (cdr body)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
244 (cond ((string= transfer-encoding "base64") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
245 (ignore-errors (base64-decode-region (point-min) (point-max)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
246 ((string= transfer-encoding "quoted-printable") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
247 (quoted-printable-decode-region (point-min) (point-max)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
248 (if (coding-system-p coding-system) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
249 (decode-coding-region (point-min) (point-max) coding-system))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
250 |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
251 ;; FIXME move to the test/ directory? |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
252 (defun test-rmail-mime-handler () |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
253 "Test of a mail using no MIME parts at all." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
254 (let ((mail "To: alex@gnu.org |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
255 Content-Type: text/plain; charset=koi8-r |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
256 Content-Transfer-Encoding: 8bit |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
257 MIME-Version: 1.0 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
258 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
259 \372\304\322\301\327\323\324\327\325\312\324\305\41")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
260 (switch-to-buffer (get-buffer-create "*test*")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
261 (erase-buffer) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
262 (set-buffer-multibyte nil) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
263 (insert mail) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
264 (rmail-mime-show t) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
265 (set-buffer-multibyte t))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
266 |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
267 |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
268 (defun rmail-mime-insert-image (type data) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
269 "Insert an image of type TYPE, where DATA is the image data. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
270 If DATA is not a string, it is a MIME-entity object." |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
271 (end-of-line) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
272 (let ((modified (buffer-modified-p))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
273 (insert ?\n) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
274 (unless (stringp data) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
275 ;; DATA is a MIME-entity. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
276 (let ((transfer-encoding (rmail-mime-entity-transfer-encoding data)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
277 (body (rmail-mime-entity-body data)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
278 (mbox-buffer rmail-view-buffer)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
279 (with-temp-buffer |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
280 (set-buffer-multibyte nil) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
281 (setq buffer-undo-list t) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
282 (insert-buffer-substring mbox-buffer (car body) (cdr body)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
283 (cond ((string= transfer-encoding "base64") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
284 (ignore-errors (base64-decode-region (point-min) (point-max)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
285 ((string= transfer-encoding "quoted-printable") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
286 (quoted-printable-decode-region (point-min) (point-max)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
287 (setq data |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
288 (buffer-substring-no-properties (point-min) (point-max)))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
289 (insert-image (create-image data type t)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
290 (set-buffer-modified-p modified))) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
291 |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
292 (defun rmail-mime-image (button) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
293 "Display the image associated with BUTTON." |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
294 (let ((inhibit-read-only t)) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
295 (rmail-mime-insert-image (button-get button 'image-type) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
296 (button-get button 'image-data)))) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
297 |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
298 (define-button-type 'rmail-mime-image 'action 'rmail-mime-image) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
299 |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
300 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
301 (defun rmail-mime-bulk-handler (content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
302 content-disposition |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
303 content-transfer-encoding) |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
304 "Handle the current buffer as an attachment to download. |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
305 For images that Emacs is capable of displaying, the behavior |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
306 depends upon the value of `rmail-mime-show-images'." |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
307 (rmail-mime-insert-bulk |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
308 (rmail-mime-entity content-type content-disposition content-transfer-encoding |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
309 nil nil nil))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
310 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
311 (defun rmail-mime-insert-bulk (entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
312 "Inesrt a MIME-entity ENTITY as an attachment. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
313 The optional second arg DATA, if non-nil, is a string containing |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
314 the attachment data that is already decoded." |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
315 ;; Find the default directory for this media type. |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
316 (let* ((content-type (rmail-mime-entity-type entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
317 (content-disposition (rmail-mime-entity-disposition entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
318 (body (rmail-mime-entity-body entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
319 (directory (catch 'directory |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
320 (dolist (entry rmail-mime-attachment-dirs-alist) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
321 (when (string-match (car entry) (car content-type)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
322 (dolist (dir (cdr entry)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
323 (when (file-directory-p dir) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
324 (throw 'directory dir))))))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
325 (filename (or (cdr (assq 'name (cdr content-type))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
326 (cdr (assq 'filename (cdr content-disposition))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
327 "noname")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
328 (label (format "\nAttached %s file: " (car content-type))) |
105198
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
329 (units '(B kB MB GB)) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
330 data udata size osize type) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
331 (if body |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
332 (setq data entity |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
333 udata entity |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
334 size (- (cdr body) (car body))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
335 (setq data (buffer-string) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
336 udata (string-as-unibyte data) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
337 size (length udata)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
338 (delete-region (point-min) (point-max))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
339 (setq osize size) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
340 (while (and (> size 1024.0) ; cribbed from gnus-agent-expire-done-message |
105198
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
341 (cdr units)) |
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
342 (setq size (/ size 1024.0) |
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
343 units (cdr units))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
344 (insert label) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
345 (insert-button filename |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
346 :type 'rmail-mime-save |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
347 'help-echo "mouse-2, RET: Save attachment" |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
348 'filename filename |
105019
a4b91a313ddf
(rmail-mime-save): If file exists, don't try to be clever and add a
Glenn Morris <rgm@gnu.org>
parents:
104907
diff
changeset
|
349 'directory (file-name-as-directory directory) |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
350 'data data) |
105198
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
351 (insert (format " (%.0f%s)" size (car units))) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
352 (when (and rmail-mime-show-images |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
353 (string-match "image/\\(.*\\)" (setq type (car content-type))) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
354 (setq type (concat "." (match-string 1 type)) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
355 type (image-type-from-file-name type)) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
356 (memq type image-types) |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
357 (image-type-available-p type)) |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
358 (insert " ") |
105211
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
359 (cond ((or (eq rmail-mime-show-images 'button) |
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
360 (and (numberp rmail-mime-show-images) |
7c61dadc38f9
(rmail-mime-show-images, rmail-mime-bulk-handler):
Glenn Morris <rgm@gnu.org>
parents:
105198
diff
changeset
|
361 (>= osize rmail-mime-show-images))) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
362 (insert-button "Display" |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
363 :type 'rmail-mime-image |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
364 'help-echo "mouse-2, RET: Show image" |
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
365 'image-type type |
105198
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
366 'image-data udata)) |
105193
d05b41e0a7ef
(rmail-mime): New custom group.
Glenn Morris <rgm@gnu.org>
parents:
105176
diff
changeset
|
367 (t |
105198
550b90cc7226
(rmail-mime-bulk-handler): Print the size of attachments.
Glenn Morris <rgm@gnu.org>
parents:
105193
diff
changeset
|
368 (rmail-mime-insert-image type udata)))))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
369 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
370 (defun test-rmail-mime-bulk-handler () |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
371 "Test of a mail used as an example in RFC 2183." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
372 (let ((mail "Content-Type: image/jpeg |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
373 Content-Disposition: attachment; filename=genome.jpeg; |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
374 modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\"; |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
375 Content-Description: a complete map of the human genome |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
376 Content-Transfer-Encoding: base64 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
377 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
378 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAZQ |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
379 TFRF////AAAAVcLTfgAAAPZJREFUeNq9ldsOwzAIQ+3//+l1WlvA5ZLsoUiTto4TB+ISoAjy |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
380 +ITfRBfcAmgRFFeAm+J6uhdKdFhFWUgDkFsK0oUp/9G2//Kj7Jx+5tSKOdBscgUYiKHRS/me |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
381 WATQdRUvAK0Bnmshmtn79PpaLBbbOZkjKvRnjRZoRswOkG1wFchKew2g9wXVJVZL/m4+B+vv |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
382 9AxQQR2Q33SgAYJzzVACdAWjAfRYzYFO9n6SLnydtQHSMxYDMAKqZ/8FS/lTK+zuq3CtK64L |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
383 UDwbgUEAUmk2Zyg101d6PhCDySgAvTvDgKiuOrc4dLxUb7UMnhGIexyI+d6U+ABuNAP4Simx |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
384 lgAAAABJRU5ErkJggg== |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
385 ")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
386 (switch-to-buffer (get-buffer-create "*test*")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
387 (erase-buffer) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
388 (insert mail) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
389 (rmail-mime-show))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
390 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
391 (defun rmail-mime-multipart-handler (content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
392 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
393 content-transfer-encoding) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
394 "Handle the current buffer as a multipart MIME body. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
395 The current buffer should be narrowed to the body. CONTENT-TYPE, |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
396 CONTENT-DISPOSITION, and CONTENT-TRANSFER-ENCODING are the values |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
397 of the respective parsed headers. See `rmail-mime-handle' for their |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
398 format." |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
399 (rmail-mime-process-multipart |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
400 content-type content-disposition content-transfer-encoding nil)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
401 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
402 (defun rmail-mime-process-multipart (content-type |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
403 content-disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
404 content-transfer-encoding |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
405 parse-only) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
406 "Process the current buffer as a multipart MIME body. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
407 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
408 If PARSE-ONLY is nil, modify the current buffer directly for showing |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
409 the MIME body and return nil. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
410 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
411 Otherwise, just parse the current buffer and return a list of |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
412 MIME-entity objects. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
413 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
414 The other arguments are the same as `rmail-mime-multipart-handler'." |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
415 ;; Some MUAs start boundaries with "--", while it should start |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
416 ;; with "CRLF--", as defined by RFC 2046: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
417 ;; The boundary delimiter MUST occur at the beginning of a line, |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
418 ;; i.e., following a CRLF, and the initial CRLF is considered to |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
419 ;; be attached to the boundary delimiter line rather than part |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
420 ;; of the preceding part. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
421 ;; We currently don't handle that. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
422 (let ((boundary (cdr (assq 'boundary content-type))) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
423 beg end next entities) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
424 (unless boundary |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
425 (rmail-mm-get-boundary-error-message |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
426 "No boundary defined" content-type content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
427 content-transfer-encoding)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
428 (setq boundary (concat "\n--" boundary)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
429 ;; Hide the body before the first bodypart |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
430 (goto-char (point-min)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
431 (when (and (search-forward boundary nil t) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
432 (looking-at "[ \t]*\n")) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
433 (if parse-only |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
434 (narrow-to-region (match-end 0) (point-max)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
435 (delete-region (point-min) (match-end 0)))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
436 ;; Loop over all body parts, where beg points at the beginning of |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
437 ;; the part and end points at the end of the part. next points at |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
438 ;; the beginning of the next part. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
439 (setq beg (point-min)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
440 (while (search-forward boundary nil t) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
441 (setq end (match-beginning 0)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
442 ;; If this is the last boundary according to RFC 2046, hide the |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
443 ;; epilogue, else hide the boundary only. Use a marker for |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
444 ;; `next' because `rmail-mime-show' may change the buffer. |
105175
721db724bb12
(rmail-mime-multipart-handler): Accept the case where
Glenn Morris <rgm@gnu.org>
parents:
105019
diff
changeset
|
445 (cond ((looking-at "--[ \t]*$") |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
446 (setq next (point-max-marker))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
447 ((looking-at "[ \t]*\n") |
105175
721db724bb12
(rmail-mime-multipart-handler): Accept the case where
Glenn Morris <rgm@gnu.org>
parents:
105019
diff
changeset
|
448 (setq next (copy-marker (match-end 0) t))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
449 (t |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
450 (rmail-mm-get-boundary-error-message |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
451 "Malformed boundary" content-type content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
452 content-transfer-encoding))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
453 ;; Handle the part. |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
454 (if parse-only |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
455 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
456 (narrow-to-region beg end) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
457 (setq entities (cons (rmail-mime-process nil t) entities))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
458 (delete-region end next) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
459 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
460 (narrow-to-region beg end) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
461 (rmail-mime-show))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
462 (goto-char (setq beg next))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
463 (nreverse entities))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
464 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
465 (defun test-rmail-mime-multipart-handler () |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
466 "Test of a mail used as an example in RFC 2046." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
467 (let ((mail "From: Nathaniel Borenstein <nsb@bellcore.com> |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
468 To: Ned Freed <ned@innosoft.com> |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
469 Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
470 Subject: Sample message |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
471 MIME-Version: 1.0 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
472 Content-type: multipart/mixed; boundary=\"simple boundary\" |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
473 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
474 This is the preamble. It is to be ignored, though it |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
475 is a handy place for composition agents to include an |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
476 explanatory note to non-MIME conformant readers. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
477 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
478 --simple boundary |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
479 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
480 This is implicitly typed plain US-ASCII text. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
481 It does NOT end with a linebreak. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
482 --simple boundary |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
483 Content-type: text/plain; charset=us-ascii |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
484 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
485 This is explicitly typed plain US-ASCII text. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
486 It DOES end with a linebreak. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
487 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
488 --simple boundary-- |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
489 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
490 This is the epilogue. It is also to be ignored.")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
491 (switch-to-buffer (get-buffer-create "*test*")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
492 (erase-buffer) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
493 (insert mail) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
494 (rmail-mime-show t))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
495 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
496 ;;; Main code |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
497 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
498 (defun rmail-mime-handle (content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
499 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
500 content-transfer-encoding) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
501 "Handle the current buffer as a MIME part. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
502 The current buffer should be narrowed to the respective body, and |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
503 point should be at the beginning of the body. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
504 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
505 CONTENT-TYPE, CONTENT-DISPOSITION, and CONTENT-TRANSFER-ENCODING |
106339
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
506 are the values of the respective parsed headers. The latter should |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
507 be downcased. The parsed headers for CONTENT-TYPE and CONTENT-DISPOSITION |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
508 have the form |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
509 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
510 \(VALUE . ALIST) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
511 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
512 In other words: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
513 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
514 \(VALUE (ATTRIBUTE . VALUE) (ATTRIBUTE . VALUE) ...) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
515 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
516 VALUE is a string and ATTRIBUTE is a symbol. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
517 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
518 Consider the following header, for example: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
519 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
520 Content-Type: multipart/mixed; |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
521 boundary=\"----=_NextPart_000_0104_01C617E4.BDEC4C40\" |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
522 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
523 The parsed header value: |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
524 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
525 \(\"multipart/mixed\" |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
526 \(\"boundary\" . \"----=_NextPart_000_0104_01C617E4.BDEC4C40\"))" |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
527 ;; Handle the content transfer encodings we know. Unknown transfer |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
528 ;; encodings will be passed on to the various handlers. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
529 (cond ((string= content-transfer-encoding "base64") |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
530 (when (ignore-errors |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
531 (base64-decode-region (point) (point-max))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
532 (setq content-transfer-encoding nil))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
533 ((string= content-transfer-encoding "quoted-printable") |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
534 (quoted-printable-decode-region (point) (point-max)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
535 (setq content-transfer-encoding nil)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
536 ((string= content-transfer-encoding "8bit") |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
537 ;; FIXME: Is this the correct way? |
106953
a1e356d208cd
* mail/rmailmm.el (rmail-mime-handle): Don't set the buffer to unibyte
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
538 ;; No, of course not, it just means there's no decoding to do. |
a1e356d208cd
* mail/rmailmm.el (rmail-mime-handle): Don't set the buffer to unibyte
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
539 ;; (set-buffer-multibyte nil) |
a1e356d208cd
* mail/rmailmm.el (rmail-mime-handle): Don't set the buffer to unibyte
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
540 (setq content-transfer-encoding nil) |
a1e356d208cd
* mail/rmailmm.el (rmail-mime-handle): Don't set the buffer to unibyte
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
106815
diff
changeset
|
541 )) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
542 ;; Inline stuff requires work. Attachments are handled by the bulk |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
543 ;; handler. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
544 (if (string= "inline" (car content-disposition)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
545 (let ((stop nil)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
546 (dolist (entry rmail-mime-media-type-handlers-alist) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
547 (when (and (string-match (car entry) (car content-type)) (not stop)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
548 (progn |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
549 (setq stop (funcall (cadr entry) content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
550 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
551 content-transfer-encoding)))))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
552 ;; Everything else is an attachment. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
553 (rmail-mime-bulk-handler content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
554 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
555 content-transfer-encoding))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
556 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
557 (defun rmail-mime-show (&optional show-headers) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
558 "Handle the current buffer as a MIME message. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
559 If SHOW-HEADERS is non-nil, then the headers of the current part |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
560 will shown as usual for a MIME message. The headers are also |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
561 shown for the content type message/rfc822. This function will be |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
562 called recursively if multiple parts are available. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
563 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
564 The current buffer must contain a single message. It will be |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
565 modified." |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
566 (rmail-mime-process show-headers nil)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
567 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
568 (defun rmail-mime-process (show-headers parse-only) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
569 (let ((end (point-min)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
570 content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
571 content-transfer-encoding |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
572 content-disposition) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
573 ;; `point-min' returns the beginning and `end' points at the end |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
574 ;; of the headers. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
575 (goto-char (point-min)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
576 ;; If we're showing a part without headers, then it will start |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
577 ;; with a newline. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
578 (if (eq (char-after) ?\n) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
579 (setq end (1+ (point))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
580 (when (search-forward "\n\n" nil t) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
581 (setq end (match-end 0)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
582 (save-restriction |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
583 (narrow-to-region (point-min) end) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
584 ;; FIXME: Default disposition of the multipart entities should |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
585 ;; be inherited. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
586 (setq content-type |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
587 (mail-fetch-field "Content-Type") |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
588 content-transfer-encoding |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
589 (mail-fetch-field "Content-Transfer-Encoding") |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
590 content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
591 (mail-fetch-field "Content-Disposition"))))) |
106339
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
592 ;; Per RFC 2045, C-T-E is case insensitive (bug#5070), but the others |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
593 ;; are not completely so. Hopefully mail-header-parse-* DTRT. |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
594 (if content-transfer-encoding |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
595 (setq content-transfer-encoding (downcase content-transfer-encoding))) |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
596 (setq content-type |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
597 (if content-type |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
598 (mail-header-parse-content-type content-type) |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
599 ;; FIXME: Default "message/rfc822" in a "multipart/digest" |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
600 ;; according to RFC 2046. |
656eabdc03be
(rmail-mime-handle): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
106178
diff
changeset
|
601 '("text/plain"))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
602 (setq content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
603 (if content-disposition |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
604 (mail-header-parse-content-disposition content-disposition) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
605 ;; If none specified, we are free to choose what we deem |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
606 ;; suitable according to RFC 2183. We like inline. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
607 '("inline"))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
608 ;; Unrecognized disposition types are to be treated like |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
609 ;; attachment according to RFC 2183. |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
610 (unless (member (car content-disposition) '("inline" "attachment")) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
611 (setq content-disposition '("attachment"))) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
612 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
613 (if parse-only |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
614 (cond ((string-match "multipart/.*" (car content-type)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
615 (setq end (1- end)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
616 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
617 (let ((header (if show-headers (cons (point-min) end)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
618 (narrow-to-region end (point-max)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
619 (rmail-mime-entity content-type |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
620 content-disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
621 content-transfer-encoding |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
622 header nil |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
623 (rmail-mime-process-multipart |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
624 content-type content-disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
625 content-transfer-encoding t))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
626 ((string-match "message/rfc822" (car content-type)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
627 (or show-headers |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
628 (narrow-to-region end (point-max))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
629 (rmail-mime-process t t)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
630 (t |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
631 (rmail-mime-entity content-type |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
632 content-disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
633 content-transfer-encoding |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
634 nil |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
635 (cons end (point-max)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
636 nil))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
637 ;; Hide headers and handle the part. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
638 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
639 (cond ((string= (car content-type) "message/rfc822") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
640 (narrow-to-region end (point-max))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
641 ((not show-headers) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
642 (delete-region (point-min) end))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
643 (rmail-mime-handle content-type content-disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
644 content-transfer-encoding))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
645 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
646 (defun rmail-mime-insert-multipart (entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
647 "Insert MIME-entity ENTITY of multipart type in the current buffer." |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
648 (let ((subtype (cadr (split-string (car (rmail-mime-entity-type entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
649 "/"))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
650 (disposition (rmail-mime-entity-disposition entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
651 (header (rmail-mime-entity-header entity)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
652 (children (rmail-mime-entity-children entity))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
653 (if header |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
654 (let ((pos (point))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
655 (or (bolp) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
656 (insert "\n")) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
657 (insert-buffer-substring rmail-buffer (car header) (cdr header)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
658 (rfc2047-decode-region pos (point)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
659 (insert "\n"))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
660 (cond |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
661 ((string= subtype "mixed") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
662 (dolist (child children) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
663 (rmail-mime-insert child '("text/plain") disposition))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
664 ((string= subtype "digest") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
665 (dolist (child children) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
666 (rmail-mime-insert child '("message/rfc822") disposition))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
667 ((string= subtype "alternative") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
668 (let (best-plain-text best-text) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
669 (dolist (child children) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
670 (if (string= (or (car (rmail-mime-entity-disposition child)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
671 (car disposition)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
672 "inline") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
673 (if (string-match "text/plain" |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
674 (car (rmail-mime-entity-type child))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
675 (setq best-plain-text child) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
676 (if (string-match "text/.*" |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
677 (car (rmail-mime-entity-type child))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
678 (setq best-text child))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
679 (if (or best-plain-text best-text) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
680 (rmail-mime-insert (or best-plain-text best-text)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
681 ;; No child could be handled. Insert all. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
682 (dolist (child children) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
683 (rmail-mime-insert child nil disposition))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
684 (t |
111773
7db1ebaea814
mail/rmailmm.el (rmail-mime-insert-multipart): For unsupported multipart subtypes, insert all as usual.
Kenichi Handa <handa@m17n.org>
parents:
111769
diff
changeset
|
685 ;; Unsupported subtype. Insert all of them. |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
686 (dolist (child children) |
111773
7db1ebaea814
mail/rmailmm.el (rmail-mime-insert-multipart): For unsupported multipart subtypes, insert all as usual.
Kenichi Handa <handa@m17n.org>
parents:
111769
diff
changeset
|
687 (rmail-mime-insert child)))))) |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
688 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
689 (defun rmail-mime-parse () |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
690 "Parse the current Rmail message as a MIME message. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
691 The value is a MIME-entiy object (see `rmail-mime-enty-new')." |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
692 (save-excursion |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
693 (goto-char (point-min)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
694 (rmail-mime-process nil t))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
695 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
696 (defun rmail-mime-insert (entity &optional content-type disposition) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
697 "Insert a MIME-entity ENTITY in the current buffer. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
698 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
699 This function will be called recursively if multiple parts are |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
700 available." |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
701 (if (rmail-mime-entity-children entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
702 (rmail-mime-insert-multipart entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
703 (setq content-type |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
704 (or (rmail-mime-entity-type entity) content-type)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
705 (setq disposition |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
706 (or (rmail-mime-entity-disposition entity) disposition)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
707 (if (and (string= (car disposition) "inline") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
708 (string-match "text/.*" (car content-type))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
709 (rmail-mime-insert-text entity) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
710 (rmail-mime-insert-bulk entity)))) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
711 |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
712 (define-derived-mode rmail-mime-mode fundamental-mode "RMIME" |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
713 "Major mode used in `rmail-mime' buffers." |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
714 (setq font-lock-defaults '(rmail-font-lock-keywords t t nil nil))) |
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
715 |
102317 | 716 ;;;###autoload |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
717 (defun rmail-mime () |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
718 "Process the current Rmail message as a MIME message. |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
719 This creates a temporary \"*RMAIL*\" buffer holding a decoded |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
720 copy of the message. Inline content-types are handled according to |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
721 `rmail-mime-media-type-handlers-alist'. By default, this |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
722 displays text and multipart messages, and offers to download |
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
723 attachments as specfied by `rmail-mime-attachment-dirs-alist'." |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
724 (interactive) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
725 (let ((data (rmail-apply-in-message rmail-current-message 'buffer-string)) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
726 (buf (get-buffer-create "*RMAIL*"))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
727 (set-buffer buf) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
728 (setq buffer-undo-list t) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
729 (let ((inhibit-read-only t)) |
106178
3f65383da746
(rmail-mime): Decode in fundamental-mode. (Bug#4993)
Glenn Morris <rgm@gnu.org>
parents:
105211
diff
changeset
|
730 ;; Decoding the message in fundamental mode for speed, only |
3f65383da746
(rmail-mime): Decode in fundamental-mode. (Bug#4993)
Glenn Morris <rgm@gnu.org>
parents:
105211
diff
changeset
|
731 ;; switching to rmail-mime-mode at the end for display. Eg |
3f65383da746
(rmail-mime): Decode in fundamental-mode. (Bug#4993)
Glenn Morris <rgm@gnu.org>
parents:
105211
diff
changeset
|
732 ;; quoted-printable-decode-region gets very slow otherwise (Bug#4993). |
3f65383da746
(rmail-mime): Decode in fundamental-mode. (Bug#4993)
Glenn Morris <rgm@gnu.org>
parents:
105211
diff
changeset
|
733 (fundamental-mode) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
734 (erase-buffer) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
735 (insert data) |
106178
3f65383da746
(rmail-mime): Decode in fundamental-mode. (Bug#4993)
Glenn Morris <rgm@gnu.org>
parents:
105211
diff
changeset
|
736 (rmail-mime-show t) |
105176
debabf496159
(rmail-mime-media-type-handlers-alist): Doc fix. Add image handler.
Glenn Morris <rgm@gnu.org>
parents:
105175
diff
changeset
|
737 (rmail-mime-mode) |
102403
b7059e95eba9
(rmail-mime-media-type-handlers-alist)
Glenn Morris <rgm@gnu.org>
parents:
102317
diff
changeset
|
738 (set-buffer-modified-p nil)) |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
739 (view-buffer buf))) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
740 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
741 (defun rmail-mm-get-boundary-error-message (message type disposition encoding) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
742 "Return MESSAGE with more information on the main mime components." |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
743 (error "%s; type: %s; disposition: %s; encoding: %s" |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
744 message type disposition encoding)) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
745 |
111769
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
746 (defun rmail-show-mime () |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
747 (let ((mbox-buf rmail-buffer)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
748 (condition-case nil |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
749 (let ((entity (rmail-mime-parse))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
750 (with-current-buffer rmail-view-buffer |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
751 (let ((inhibit-read-only t) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
752 (rmail-buffer mbox-buf)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
753 (erase-buffer) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
754 (rmail-mime-insert entity)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
755 (error |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
756 ;; Decoding failed. Insert the original message body as is. |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
757 (let ((region (with-current-buffer mbox-buf |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
758 (goto-char (point-min)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
759 (re-search-forward "^$" nil t) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
760 (forward-line 1) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
761 (cons (point) (point-max))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
762 (with-current-buffer rmail-view-buffer |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
763 (let ((inhibit-read-only t)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
764 (erase-buffer) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
765 (insert-buffer-substring mbox-buf (car region) (cdr region)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
766 (message "MIME decoding failed")))))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
767 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
768 (setq rmail-show-mime-function 'rmail-show-mime) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
769 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
770 (defun rmail-insert-mime-forwarded-message (forward-buffer) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
771 (let ((mbox-buf (with-current-buffer forward-buffer rmail-view-buffer))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
772 (save-restriction |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
773 (narrow-to-region (point) (point)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
774 (message-forward-make-body-mime mbox-buf)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
775 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
776 (setq rmail-insert-mime-forwarded-message-function |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
777 'rmail-insert-mime-forwarded-message) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
778 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
779 (defun rmail-insert-mime-resent-message (forward-buffer) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
780 (insert-buffer-substring |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
781 (with-current-buffer forward-buffer rmail-view-buffer)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
782 (goto-char (point-min)) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
783 (when (looking-at "From ") |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
784 (forward-line 1) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
785 (delete-region (point-min) (point)))) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
786 |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
787 (setq rmail-insert-mime-resent-message-function |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
788 'rmail-insert-mime-resent-message) |
0e19494fd75d
Improve rmail's MIME handling.
Kenichi Handa <handa@m17n.org>
parents:
109330
diff
changeset
|
789 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
790 (provide 'rmailmm) |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
791 |
104907
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
102421
diff
changeset
|
792 ;; Local Variables: |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
102421
diff
changeset
|
793 ;; generated-autoload-file: "rmail.el" |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
102421
diff
changeset
|
794 ;; End: |
6a35503cf20b
Put autoloads in rmail.el rather than loaddefs.el.
Glenn Morris <rgm@gnu.org>
parents:
102421
diff
changeset
|
795 |
101360
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
796 ;; arch-tag: 3f2c5e5d-1aef-4512-bc20-fd737c9d5dd9 |
b10df8502c4a
Renamed all pmail* files to rmail*.
Bastien Guerry <bzg@altern.org>
parents:
diff
changeset
|
797 ;;; rmailmm.el ends here |