comparison lisp/mail/rmailmm.el @ 102403:b7059e95eba9

(rmail-mime-media-type-handlers-alist) (rmail-mime-attachment-dirs-alist): Doc fixes. Fix custom-type. Add version. (rmail-mime-total-number-of-bulk-attachments): Doc fix. (rmail-mime): Doc fix. Use rmail-apply-in-message. Disable undo in the mime buffer, mark unmodified.
author Glenn Morris <rgm@gnu.org>
date Thu, 05 Mar 2009 03:42:22 +0000
parents 562b3a7e1016
children 62a954f574fa
comparison
equal deleted inserted replaced
102402:53f455933f5f 102403:b7059e95eba9
31 ;;; Code: 31 ;;; Code:
32 32
33 (require 'rmail) 33 (require 'rmail)
34 (require 'mail-parse) 34 (require 'mail-parse)
35 35
36 ;;; Variables 36 ;;; User options.
37 37
38 ;; FIXME should these be in an rmail group?
39 ;; FIXME we ought to be able to display images in Emacs.
38 (defcustom rmail-mime-media-type-handlers-alist 40 (defcustom rmail-mime-media-type-handlers-alist
39 '(("multipart/.*" rmail-mime-multipart-handler) 41 '(("multipart/.*" rmail-mime-multipart-handler)
40 ("text/.*" rmail-mime-text-handler) 42 ("text/.*" rmail-mime-text-handler)
41 ("text/\\(x-\\)?patch" rmail-mime-bulk-handler) 43 ("text/\\(x-\\)?patch" rmail-mime-bulk-handler)
42 ("application/pgp-signature" rmail-mime-application/pgp-signature-handler) 44 ;; FIXME this handler not defined anywhere?
45 ;;; ("application/pgp-signature" rmail-mime-application/pgp-signature-handler)
43 ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler)) 46 ("\\(image\\|audio\\|video\\|application\\)/.*" rmail-mime-bulk-handler))
44 "Alist of media type handlers, also known as agents. 47 "Functions to handle various content types.
45 Every handler is a list of type (string symbol) where STRING is a 48 This is an alist with elements of the form (REGEXP FUNCTION).
46 regular expression to match the media type with and SYMBOL is a 49 REGEXP is a regular expression matching a content-type, and
47 function to run. Handlers should return a non-nil value if the 50 FUNCTION is a handler function to run. It should return non-nil
48 job is done." 51 if the job is done."
49 :type 'list 52 :type '(alist :key-type regexp :value-type (group function))
53 :version "23.1"
50 :group 'mime) 54 :group 'mime)
51 55
52 (defcustom rmail-mime-attachment-dirs-alist 56 (defcustom rmail-mime-attachment-dirs-alist
53 `(("text/.*" "~/Documents") 57 `(("text/.*" "~/Documents")
54 ("image/.*" "~/Pictures") 58 ("image/.*" "~/Pictures")
55 (".*" "~/Desktop" "~" ,temporary-file-directory)) 59 (".*" "~/Desktop" "~" ,temporary-file-directory))
56 "Default directories to save attachments into. 60 "Default directories to save attachments of various types into.
57 Each media type may have it's own list of directories in order of 61 This is an alist with elements of the form (REGEXP DIR ...).
58 preference. The first existing directory in the list will be 62 The first item is a regular expression matching a content-type.
59 used." 63 The remaining elements are directories, in order of decreasing preference.
60 :type 'list 64 The first directory that exists is used."
65 :type '(alist :key-type regexp :value-type (repeat directory))
66 :version "23.1"
61 :group 'mime) 67 :group 'mime)
62 68
69 ;;; End of user options.
70
71
63 (defvar rmail-mime-total-number-of-bulk-attachments 0 72 (defvar rmail-mime-total-number-of-bulk-attachments 0
64 "A total number of attached bulk bodyparts in the message. If more than 3, 73 "The total number of bulk attachments in the message.
65 offer a way to save all attachments at once.") 74 If more than 3, offer a way to save all attachments at once.")
66 (put 'rmail-mime-total-number-of-bulk-attachments 'permanent-local t) 75 (put 'rmail-mime-total-number-of-bulk-attachments 'permanent-local t)
67 76
68 ;;; Buttons 77 ;;; Buttons
69 78
70 (defun rmail-mime-save (button) 79 (defun rmail-mime-save (button)
104 (coding-system (when charset 113 (coding-system (when charset
105 (intern (downcase charset))))) 114 (intern (downcase charset)))))
106 (when (coding-system-p coding-system) 115 (when (coding-system-p coding-system)
107 (decode-coding-region (point-min) (point-max) coding-system)))) 116 (decode-coding-region (point-min) (point-max) coding-system))))
108 117
118 ;; FIXME move to the test/ directory?
109 (defun test-rmail-mime-handler () 119 (defun test-rmail-mime-handler ()
110 "Test of a mail using no MIME parts at all." 120 "Test of a mail using no MIME parts at all."
111 (let ((mail "To: alex@gnu.org 121 (let ((mail "To: alex@gnu.org
112 Content-Type: text/plain; charset=koi8-r 122 Content-Type: text/plain; charset=koi8-r
113 Content-Transfer-Encoding: 8bit 123 Content-Transfer-Encoding: 8bit
369 (rmail-mime-handle content-type content-disposition 379 (rmail-mime-handle content-type content-disposition
370 content-transfer-encoding)))) 380 content-transfer-encoding))))
371 381
372 ;;;###autoload 382 ;;;###autoload
373 (defun rmail-mime () 383 (defun rmail-mime ()
374 "Copy buffer contents to a temporary buffer and handle MIME. 384 "Process the current Rmail message as a MIME message.
375 This calls `rmail-mime-show' to do the real job." 385 This creates a temporary \"*RMAIL*\" buffer holding a decoded
386 copy of the message. Content-types are handled according to
387 `rmail-mime-media-type-handlers-alist'. By default, this
388 displays text and multipart messages, and offers to download
389 attachments as specfied by `rmail-mime-attachment-dirs-alist'."
376 (interactive) 390 (interactive)
377 (rmail-swap-buffers-maybe) 391 (let ((data (rmail-apply-in-message rmail-current-message 'buffer-string))
378 (let ((data (with-current-buffer rmail-buffer
379 (save-restriction
380 (widen)
381 (buffer-substring
382 (rmail-msgbeg rmail-current-message)
383 (rmail-msgend rmail-current-message)))))
384 (buf (get-buffer-create "*RMAIL*"))) 392 (buf (get-buffer-create "*RMAIL*")))
385 (set-buffer buf) 393 (set-buffer buf)
394 (setq buffer-undo-list t)
386 (let ((inhibit-read-only t)) 395 (let ((inhibit-read-only t))
387 (erase-buffer) 396 (erase-buffer)
388 (insert data) 397 (insert data)
389 (rmail-mime-show t)) 398 (rmail-mime-show t)
399 (set-buffer-modified-p nil))
390 (view-buffer buf))) 400 (view-buffer buf)))
391 401
392 (defun rmail-mm-get-boundary-error-message (message type disposition encoding) 402 (defun rmail-mm-get-boundary-error-message (message type disposition encoding)
393 "Return MESSAGE with more information on the main mime components." 403 "Return MESSAGE with more information on the main mime components."
394 (error "%s; type: %s; disposition: %s; encoding: %s" 404 (error "%s; type: %s; disposition: %s; encoding: %s"