annotate lisp/mail/pmailmm.el @ 98055:04b7a6119a88

(diff-find-source-location): Declare. (find-change-log): If called from a diff buffer, try to switch to the source buffer (e.g. to respect change-log-default-name there).
author Glenn Morris <rgm@gnu.org>
date Sat, 06 Sep 2008 19:38:35 +0000
parents 72564311fb7b
children 20326e3d1912
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
1 ;;; pmailmm.el --- MIME decoding and display stuff for PMAIL
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
2
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
4
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
5 ;; Maintainer: FSF
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
6 ;; Keywords: mail
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
7
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
9
98012
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
98012
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
13 ;; (at your option) any later version.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
14
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
19
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
98012
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
22
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
23 ;;; Commentary:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
24
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
25 ;; Essentially based on the design of Alexander Pohoyda's MIME
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
26 ;; extensions (mime-display.el and mime.el). To use, copy a complete
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
27 ;; message into a new buffer and call (mime-show t).
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
28
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
29 ;; To use:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
30
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
31 ;; (autoload 'pmail-mime "pmailmm"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
32 ;; "Show MIME message." t)
98012
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
33 ;; (add-hook 'pmail-mode-hook
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
34 ;; (lambda ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
35 ;; (define-key pmail-mode-map (kbd "v")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
36 ;; 'pmail-mime)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
37
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
38 ;;; Code:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
39
97808
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
40 ;; For ...
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
41 (require 'pmail)
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
42
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
43 ;;; Variables
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
44
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
45 (defcustom pmail-mime-media-type-handlers-alist
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
46 '(("multipart/.*" pmail-mime-multipart-handler)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
47 ("text/.*" pmail-mime-text-handler)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
48 ("text/\\(x-\\)?patch" pmail-mime-bulk-handler)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
49 ("application/pgp-signature" pmail-mime-application/pgp-signature-handler)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
50 ("\\(image\\|audio\\|video\\|application\\)/.*" pmail-mime-bulk-handler))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
51 "Alist of media type handlers, also known as agents.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
52 Every handler is a list of type (string symbol) where STRING is a
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
53 regular expression to match the media type with and SYMBOL is a
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
54 function to run. Handlers should return a non-nil value if the
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
55 job is done."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
56 :type 'list
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
57 :group 'mime)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
58
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
59 (defcustom pmail-mime-attachment-dirs-alist
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
60 '(("text/.*" "~/Documents")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
61 ("image/.*" "~/Pictures")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
62 (".*" "~/Desktop" "~" "/tmp"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
63 "Default directories to save attachments into.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
64 Each media type may have it's own list of directories in order of
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
65 preference. The first existing directory in the list will be
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
66 used."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
67 :type 'list
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
68 :group 'mime)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
69
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
70 (defvar pmail-mime-total-number-of-bulk-attachments 0
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
71 "A total number of attached bulk bodyparts in the message. If more than 3,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
72 offer a way to save all attachments at once.")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
73 (put 'pmail-mime-total-number-of-bulk-attachments 'permanent-local t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
74
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
75 ;;; Buttons
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
76
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
77 (defun pmail-mime-save (button)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
78 "Save the attachment using info in the BUTTON."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
79 (let* ((filename (button-get button 'filename))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
80 (directory (button-get button 'directory))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
81 (data (button-get button 'data)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
82 (while (file-exists-p (expand-file-name filename directory))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
83 (let* ((f (file-name-sans-extension filename))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
84 (i 1))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
85 (when (string-match "-\\([0-9]+\\)$" f)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
86 (setq i (1+ (string-to-number (match-string 1 f)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
87 f (substring f 0 (match-beginning 0))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
88 (setq filename (concat f "-" (number-to-string i) "."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
89 (file-name-extension filename)))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
90 (setq filename (expand-file-name
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
91 (read-file-name (format "Save as (default: %s): " filename)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
92 directory
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
93 (expand-file-name filename directory))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
94 directory))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
95 (when (file-regular-p filename)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
96 (error (message "File `%s' already exists" filename)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
97 (with-temp-file filename
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
98 (set-buffer-file-coding-system 'no-conversion)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
99 (insert data))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
100
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
101 (define-button-type 'pmail-mime-save
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
102 'action 'pmail-mime-save)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
103
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
104 ;;; Handlers
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
105
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
106 (defun pmail-mime-text-handler (content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
107 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
108 content-transfer-encoding)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
109 "Handle the current buffer as a plain text MIME part."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
110 (let* ((charset (cdr (assq 'charset (cdr content-type))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
111 (coding-system (when charset
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
112 (intern (downcase charset)))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
113 (when (coding-system-p coding-system)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
114 (decode-coding-region (point-min) (point-max) coding-system))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
115
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
116 (defun test-pmail-mime-handler ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
117 "Test of a mail using no MIME parts at all."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
118 (let ((mail "To: alex@gnu.org
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
119 Content-Type: text/plain; charset=koi8-r
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
120 Content-Transfer-Encoding: 8bit
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
121 MIME-Version: 1.0
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
122
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
123 \372\304\322\301\327\323\324\327\325\312\324\305\41"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
124 (switch-to-buffer (get-buffer-create "*test*"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
125 (erase-buffer)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
126 (set-buffer-multibyte nil)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
127 (insert mail)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
128 (pmail-mime-show t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
129 (set-buffer-multibyte t)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
130
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
131 (defun pmail-mime-bulk-handler (content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
132 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
133 content-transfer-encoding)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
134 "Handle the current buffer as an attachment to download."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
135 (setq pmail-mime-total-number-of-bulk-attachments
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
136 (1+ pmail-mime-total-number-of-bulk-attachments))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
137 ;; Find the default directory for this media type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
138 (let* ((directory (catch 'directory
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
139 (dolist (entry pmail-mime-attachment-dirs-alist)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
140 (when (string-match (car entry) (car content-type))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
141 (dolist (dir (cdr entry))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
142 (when (file-directory-p dir)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
143 (throw 'directory dir)))))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
144 (filename (or (cdr (assq 'name (cdr content-type)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
145 (cdr (assq 'filename (cdr content-disposition)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
146 "noname"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
147 (label (format "\nAttached %s file: " (car content-type)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
148 (data (buffer-string)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
149 (delete-region (point-min) (point-max))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
150 (insert label)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
151 (insert-button filename
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
152 :type 'pmail-mime-save
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
153 'filename filename
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
154 'directory directory
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
155 'data data)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
156
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
157 (defun test-pmail-mime-bulk-handler ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
158 "Test of a mail used as an example in RFC 2183."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
159 (let ((mail "Content-Type: image/jpeg
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
160 Content-Disposition: attachment; filename=genome.jpeg;
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
161 modification-date=\"Wed, 12 Feb 1997 16:29:51 -0500\";
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
162 Content-Description: a complete map of the human genome
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
163 Content-Transfer-Encoding: base64
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
164
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
165 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAABGdBTUEAALGPC/xhBQAAAAZQ
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
166 TFRF////AAAAVcLTfgAAAPZJREFUeNq9ldsOwzAIQ+3//+l1WlvA5ZLsoUiTto4TB+ISoAjy
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
167 +ITfRBfcAmgRFFeAm+J6uhdKdFhFWUgDkFsK0oUp/9G2//Kj7Jx+5tSKOdBscgUYiKHRS/me
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
168 WATQdRUvAK0Bnmshmtn79PpaLBbbOZkjKvRnjRZoRswOkG1wFchKew2g9wXVJVZL/m4+B+vv
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
169 9AxQQR2Q33SgAYJzzVACdAWjAfRYzYFO9n6SLnydtQHSMxYDMAKqZ/8FS/lTK+zuq3CtK64L
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
170 UDwbgUEAUmk2Zyg101d6PhCDySgAvTvDgKiuOrc4dLxUb7UMnhGIexyI+d6U+ABuNAP4Simx
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
171 lgAAAABJRU5ErkJggg==
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
172 "))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
173 (switch-to-buffer (get-buffer-create "*test*"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
174 (erase-buffer)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
175 (insert mail)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
176 (pmail-mime-show)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
177
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
178 (defun pmail-mime-multipart-handler (content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
179 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
180 content-transfer-encoding)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
181 "Handle the current buffer as a multipart MIME body.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
182 The current buffer should be narrowed to the body. CONTENT-TYPE,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
183 CONTENT-DISPOSITION, and CONTENT-TRANSFER-ENCODING are the values
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
184 of the respective parsed headers. See `pmail-mime-handle' for their
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
185 format."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
186 ;; Some MUAs start boundaries with "--", while it should start
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
187 ;; with "CRLF--", as defined by RFC 2046:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
188 ;; The boundary delimiter MUST occur at the beginning of a line,
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
189 ;; i.e., following a CRLF, and the initial CRLF is considered to
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
190 ;; be attached to the boundary delimiter line rather than part
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
191 ;; of the preceding part.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
192 ;; We currently don't handle that.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
193 (let ((boundary (cdr (assq 'boundary content-type)))
97808
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
194 beg end next)
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
195 (unless boundary
97808
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
196 (pmail-mm-get-boundary-error-message
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
197 "No boundary defined" content-type content-disposition
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
198 content-transfer-encoding))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
199 (setq boundary (concat "\n--" boundary))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
200 ;; Hide the body before the first bodypart
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
201 (goto-char (point-min))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
202 (when (and (search-forward boundary nil t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
203 (looking-at "[ \t]*\n"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
204 (delete-region (point-min) (match-end 0)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
205 ;; Reset the counter
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
206 (setq pmail-mime-total-number-of-bulk-attachments 0)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
207 ;; Loop over all body parts, where beg points at the beginning of
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
208 ;; the part and end points at the end of the part. next points at
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
209 ;; the beginning of the next part.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
210 (setq beg (point-min))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
211 (while (search-forward boundary nil t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
212 (setq end (match-beginning 0))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
213 ;; If this is the last boundary according to RFC 2046, hide the
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
214 ;; epilogue, else hide the boundary only. Use a marker for
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
215 ;; `next' because `pmail-mime-show' may change the buffer.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
216 (cond ((looking-at "--[ \t]*\n")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
217 (setq next (point-max-marker)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
218 ((looking-at "[ \t]*\n")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
219 (setq next (copy-marker (match-end 0))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
220 (t
97808
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
221 (pmail-mm-get-boundary-error-message
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
222 "Malformed boundary" content-type content-disposition
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
223 content-transfer-encoding)))
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
224 (delete-region end next)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
225 ;; Handle the part.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
226 (save-match-data
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
227 (save-excursion
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
228 (save-restriction
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
229 (narrow-to-region beg end)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
230 (pmail-mime-show))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
231 (setq beg next)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
232 (goto-char beg))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
233
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
234 (defun test-pmail-mime-multipart-handler ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
235 "Test of a mail used as an example in RFC 2046."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
236 (let ((mail "From: Nathaniel Borenstein <nsb@bellcore.com>
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
237 To: Ned Freed <ned@innosoft.com>
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
238 Date: Sun, 21 Mar 1993 23:56:48 -0800 (PST)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
239 Subject: Sample message
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
240 MIME-Version: 1.0
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
241 Content-type: multipart/mixed; boundary=\"simple boundary\"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
242
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
243 This is the preamble. It is to be ignored, though it
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
244 is a handy place for composition agents to include an
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
245 explanatory note to non-MIME conformant readers.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
246
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
247 --simple boundary
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
248
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
249 This is implicitly typed plain US-ASCII text.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
250 It does NOT end with a linebreak.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
251 --simple boundary
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
252 Content-type: text/plain; charset=us-ascii
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
253
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
254 This is explicitly typed plain US-ASCII text.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
255 It DOES end with a linebreak.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
256
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
257 --simple boundary--
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
258
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
259 This is the epilogue. It is also to be ignored."))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
260 (switch-to-buffer (get-buffer-create "*test*"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
261 (erase-buffer)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
262 (insert mail)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
263 (pmail-mime-show t)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
264
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
265 ;;; Main code
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
266
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
267 (defun pmail-mime-handle (content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
268 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
269 content-transfer-encoding)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
270 "Handle the current buffer as a MIME part.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
271 The current buffer should be narrowed to the respective body, and
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
272 point should be at the beginning of the body.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
273
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
274 CONTENT-TYPE, CONTENT-DISPOSITION, and CONTENT-TRANSFER-ENCODING
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
275 are the values of the respective parsed headers. The parsed
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
276 headers for CONTENT-TYPE and CONTENT-DISPOSITION have the form
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
277
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
278 \(VALUE . ALIST)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
279
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
280 In other words:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
281
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
282 \(VALUE (ATTRIBUTE . VALUE) (ATTRIBUTE . VALUE) ...)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
283
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
284 VALUE is a string and ATTRIBUTE is a symbol.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
285
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
286 Consider the following header, for example:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
287
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
288 Content-Type: multipart/mixed;
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
289 boundary=\"----=_NextPart_000_0104_01C617E4.BDEC4C40\"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
290
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
291 The parsed header value:
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
292
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
293 \(\"multipart/mixed\"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
294 \(\"boundary\" . \"----=_NextPart_000_0104_01C617E4.BDEC4C40\"))"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
295 ;; Handle the content transfer encodings we know. Unknown transfer
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
296 ;; encodings will be passed on to the various handlers.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
297 (cond ((string= content-transfer-encoding "base64")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
298 (when (ignore-errors
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
299 (base64-decode-region (point) (point-max)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
300 (setq content-transfer-encoding nil)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
301 ((string= content-transfer-encoding "quoted-printable")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
302 (quoted-printable-decode-region (point) (point-max))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
303 (setq content-transfer-encoding nil))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
304 ((string= content-transfer-encoding "8bit")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
305 ;; FIXME: Is this the correct way?
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
306 (set-buffer-multibyte nil)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
307 ;; Inline stuff requires work. Attachments are handled by the bulk
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
308 ;; handler.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
309 (if (string= "inline" (car content-disposition))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
310 (let ((stop nil))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
311 (dolist (entry pmail-mime-media-type-handlers-alist)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
312 (when (and (string-match (car entry) (car content-type)) (not stop))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
313 (progn
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
314 (setq stop (funcall (cadr entry) content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
315 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
316 content-transfer-encoding))))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
317 ;; Everything else is an attachment.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
318 (pmail-mime-bulk-handler content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
319 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
320 content-transfer-encoding)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
321
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
322 (defun pmail-mime-show (&optional show-headers)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
323 "Handle the current buffer as a MIME message.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
324 If SHOW-HEADERS is non-nil, then the headers of the current part
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
325 will shown as usual for a MIME message. The headers are also
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
326 shown for the content type message/rfc822. This function will be
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
327 called recursively if multiple parts are available.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
328
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
329 The current buffer must contain a single message. It will be
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
330 modified."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
331 (let ((end (point-min))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
332 content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
333 content-transfer-encoding
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
334 content-disposition)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
335 ;; `point-min' returns the beginning and `end' points at the end
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
336 ;; of the headers. We're not using `pmail-header-get-header'
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
337 ;; because we must be able to handle the case of no headers
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
338 ;; existing in a part. In this case end is at point-min.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
339 (goto-char (point-min))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
340 ;; If we're showing a part without headers, then it will start
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
341 ;; with a newline.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
342 (if (eq (char-after) ?\n)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
343 (setq end (1+ (point)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
344 (when (search-forward "\n\n" nil t)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
345 (setq end (match-end 0))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
346 (save-restriction
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
347 (narrow-to-region (point-min) end)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
348 ;; FIXME: Default disposition of the multipart entities should
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
349 ;; be inherited.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
350 (setq content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
351 (mail-fetch-field "Content-Type")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
352 content-transfer-encoding
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
353 (mail-fetch-field "Content-Transfer-Encoding")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
354 content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
355 (mail-fetch-field "Content-Disposition")))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
356 (if content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
357 (setq content-type (mail-header-parse-content-type
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
358 content-type))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
359 ;; FIXME: Default "message/rfc822" in a "multipart/digest"
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
360 ;; according to RFC 2046.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
361 (setq content-type '("text/plain")))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
362 (setq content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
363 (if content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
364 (mail-header-parse-content-disposition content-disposition)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
365 ;; If none specified, we are free to choose what we deem
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
366 ;; suitable according to RFC 2183. We like inline.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
367 '("inline")))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
368 ;; Unrecognized disposition types are to be treated like
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
369 ;; attachment according to RFC 2183.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
370 (unless (member (car content-disposition) '("inline" "attachment"))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
371 (setq content-disposition '("attachment")))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
372 ;; Hide headers and handle the part.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
373 (save-restriction
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
374 (cond ((string= (car content-type) "message/rfc822")
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
375 (pmail-header-hide-headers)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
376 (narrow-to-region end (point-max)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
377 (show-headers
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
378 (pmail-header-hide-headers))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
379 (t
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
380 (delete-region (point-min) end)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
381 (pmail-mime-handle content-type content-disposition
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
382 content-transfer-encoding))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
383
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
384 (defun pmail-mime ()
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
385 "Copy buffer contents to a temporary buffer and handle MIME.
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
386 This calls `pmail-mime-show' to do the real job."
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
387 (interactive)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
388 (let ((data (with-current-buffer pmail-buffer
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
389 (save-restriction
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
390 (widen)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
391 (buffer-substring
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
392 (pmail-desc-get-start pmail-current-message)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
393 (pmail-desc-get-end pmail-current-message)))))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
394 (buf (get-buffer-create "*PMAIL*")))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
395 (set-buffer buf)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
396 (let ((inhibit-read-only t))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
397 (erase-buffer)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
398 (insert data)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
399 (pmail-mime-show t))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
400 (view-buffer buf)))
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
401
97808
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
402 (defun pmail-mm-get-boundary-error-message (message type disposition encoding)
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
403 "Return MESSAGE with more information on the main mime components."
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
404 (error "%s; type: %s; disposition: %s; encoding: %s"
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
405 message type disposition encoding))
1aab9bdd9355 Resolve all byte compiler warnings and enable IMAP/movemail support.
Paul Reilly <pmr@pajato.com>
parents: 97529
diff changeset
406
97528
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
407 (provide 'pmailmm)
184bb2071e3f mail/: Add new (temporary) libaries for which to test Rmail/mbox such
Paul Reilly <pmr@pajato.com>
parents:
diff changeset
408
98019
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 98012
diff changeset
409 ;; Local Variables:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 98012
diff changeset
410 ;; change-log-default-name: "ChangeLog.pmail"
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 98012
diff changeset
411 ;; End:
72564311fb7b Add local variable setting for change-log-default-name.
Glenn Morris <rgm@gnu.org>
parents: 98012
diff changeset
412
97529
1b1837ac37e2 Add arch tagline
Miles Bader <miles@gnu.org>
parents: 97528
diff changeset
413 ;; arch-tag: 3f2c5e5d-1aef-4512-bc20-fd737c9d5dd9
98012
f4a921de2099 Fix copyright years and license notices.
Glenn Morris <rgm@gnu.org>
parents: 97808
diff changeset
414 ;;; pmailmm.el ends here