summaryrefslogtreecommitdiff
path: root/lisp/gnus/mm-decode.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2006-03-19 19:39:53 +0000
committerMiles Bader <miles@gnu.org>2006-03-19 19:39:53 +0000
commit531bedc37c5e0b060c51565ba3a17ef471c2b510 (patch)
tree56be81522417c7122267c086e4ba5deb8cdba21f /lisp/gnus/mm-decode.el
parent3dcef10bbc435cc2d2b89670366500603fd6f31b (diff)
downloademacs-531bedc37c5e0b060c51565ba3a17ef471c2b510.tar.gz
Revision: emacs@sv.gnu.org/emacs--devo--0--patch-163
Merge from gnus--rel--5.10 Patches applied: * gnus--rel--5.10 (patch 58-61) - Update from CVS
Diffstat (limited to 'lisp/gnus/mm-decode.el')
-rw-r--r--lisp/gnus/mm-decode.el52
1 files changed, 36 insertions, 16 deletions
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index 01557659fd6..f0f1ee430ff 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -36,6 +36,7 @@
(autoload 'executable-find "executable")
(autoload 'mm-inline-partial "mm-partial")
(autoload 'mm-inline-external-body "mm-extern")
+ (autoload 'mm-extern-cache-contents "mm-extern")
(autoload 'mm-insert-inline "mm-view"))
(defvar gnus-current-window-configuration)
@@ -1082,17 +1083,35 @@ external if displayed external."
;;; Functions for outputting parts
;;;
+(defmacro mm-with-part (handle &rest forms)
+ "Run FORMS in the temp buffer containing the contents of HANDLE."
+ `(let* ((handle ,handle)
+ ;; The multibyteness of the temp buffer should be turned on
+ ;; if inserting a multibyte string. Contrarily, the buffer's
+ ;; multibyteness should be off if inserting a unibyte string,
+ ;; especially if a string contains 8bit data.
+ (default-enable-multibyte-characters
+ (with-current-buffer (mm-handle-buffer handle)
+ (mm-multibyte-p))))
+ (with-temp-buffer
+ (insert-buffer-substring (mm-handle-buffer handle))
+ (mm-disable-multibyte)
+ (mm-decode-content-transfer-encoding
+ (mm-handle-encoding handle)
+ (mm-handle-media-type handle))
+ ,@forms)))
+(put 'mm-with-part 'lisp-indent-function 1)
+(put 'mm-with-part 'edebug-form-spec '(body))
+
(defun mm-get-part (handle)
"Return the contents of HANDLE as a string."
- (let ((default-enable-multibyte-characters
- (with-current-buffer (mm-handle-buffer handle)
- (mm-multibyte-p))))
- (with-temp-buffer
- (insert-buffer-substring (mm-handle-buffer handle))
- (mm-disable-multibyte)
- (mm-decode-content-transfer-encoding
- (mm-handle-encoding handle)
- (mm-handle-media-type handle))
+ (if (equal (mm-handle-media-type handle) "message/external-body")
+ (progn
+ (unless (mm-handle-cache handle)
+ (mm-extern-cache-contents handle))
+ (with-current-buffer (mm-handle-buffer (mm-handle-cache handle))
+ (buffer-string)))
+ (mm-with-part handle
(buffer-string))))
(defun mm-insert-part (handle)
@@ -1148,18 +1167,19 @@ string if you do not like underscores."
(defun mm-save-part (handle)
"Write HANDLE to a file."
- (let* ((name (mail-content-type-get (mm-handle-type handle) 'name))
- (filename (mail-content-type-get
- (mm-handle-disposition handle) 'filename))
- file)
+ (let ((filename (or (mail-content-type-get
+ (mm-handle-disposition handle) 'filename)
+ (mail-content-type-get
+ (mm-handle-type handle) 'name)))
+ file)
(when filename
(setq filename (gnus-map-function mm-file-name-rewrite-functions
(file-name-nondirectory filename))))
(setq file
(mm-with-multibyte
- (read-file-name "Save MIME part to: "
- (or mm-default-directory default-directory)
- nil nil (or filename name ""))))
+ (read-file-name "Save MIME part to: "
+ (or mm-default-directory default-directory)
+ nil nil (or filename ""))))
(setq mm-default-directory (file-name-directory file))
(and (or (not (file-exists-p file))
(yes-or-no-p (format "File %s already exists; overwrite? "