Mercurial > emacs
comparison lisp/gnus/mm-decode.el @ 69572:b4faac2800dd
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
author | Miles Bader <miles@gnu.org> |
---|---|
date | Sun, 19 Mar 2006 19:39:53 +0000 |
parents | 6580c61aced7 |
children | ab0b847baba4 e3bacb89536a |
comparison
equal
deleted
inserted
replaced
69571:4f6b547120ec | 69572:b4faac2800dd |
---|---|
34 | 34 |
35 (eval-and-compile | 35 (eval-and-compile |
36 (autoload 'executable-find "executable") | 36 (autoload 'executable-find "executable") |
37 (autoload 'mm-inline-partial "mm-partial") | 37 (autoload 'mm-inline-partial "mm-partial") |
38 (autoload 'mm-inline-external-body "mm-extern") | 38 (autoload 'mm-inline-external-body "mm-extern") |
39 (autoload 'mm-extern-cache-contents "mm-extern") | |
39 (autoload 'mm-insert-inline "mm-view")) | 40 (autoload 'mm-insert-inline "mm-view")) |
40 | 41 |
41 (defvar gnus-current-window-configuration) | 42 (defvar gnus-current-window-configuration) |
42 | 43 |
43 (add-hook 'gnus-exit-gnus-hook 'mm-destroy-postponed-undisplay-list) | 44 (add-hook 'gnus-exit-gnus-hook 'mm-destroy-postponed-undisplay-list) |
1080 | 1081 |
1081 ;;; | 1082 ;;; |
1082 ;;; Functions for outputting parts | 1083 ;;; Functions for outputting parts |
1083 ;;; | 1084 ;;; |
1084 | 1085 |
1086 (defmacro mm-with-part (handle &rest forms) | |
1087 "Run FORMS in the temp buffer containing the contents of HANDLE." | |
1088 `(let* ((handle ,handle) | |
1089 ;; The multibyteness of the temp buffer should be turned on | |
1090 ;; if inserting a multibyte string. Contrarily, the buffer's | |
1091 ;; multibyteness should be off if inserting a unibyte string, | |
1092 ;; especially if a string contains 8bit data. | |
1093 (default-enable-multibyte-characters | |
1094 (with-current-buffer (mm-handle-buffer handle) | |
1095 (mm-multibyte-p)))) | |
1096 (with-temp-buffer | |
1097 (insert-buffer-substring (mm-handle-buffer handle)) | |
1098 (mm-disable-multibyte) | |
1099 (mm-decode-content-transfer-encoding | |
1100 (mm-handle-encoding handle) | |
1101 (mm-handle-media-type handle)) | |
1102 ,@forms))) | |
1103 (put 'mm-with-part 'lisp-indent-function 1) | |
1104 (put 'mm-with-part 'edebug-form-spec '(body)) | |
1105 | |
1085 (defun mm-get-part (handle) | 1106 (defun mm-get-part (handle) |
1086 "Return the contents of HANDLE as a string." | 1107 "Return the contents of HANDLE as a string." |
1087 (let ((default-enable-multibyte-characters | 1108 (if (equal (mm-handle-media-type handle) "message/external-body") |
1088 (with-current-buffer (mm-handle-buffer handle) | 1109 (progn |
1089 (mm-multibyte-p)))) | 1110 (unless (mm-handle-cache handle) |
1090 (with-temp-buffer | 1111 (mm-extern-cache-contents handle)) |
1091 (insert-buffer-substring (mm-handle-buffer handle)) | 1112 (with-current-buffer (mm-handle-buffer (mm-handle-cache handle)) |
1092 (mm-disable-multibyte) | 1113 (buffer-string))) |
1093 (mm-decode-content-transfer-encoding | 1114 (mm-with-part handle |
1094 (mm-handle-encoding handle) | |
1095 (mm-handle-media-type handle)) | |
1096 (buffer-string)))) | 1115 (buffer-string)))) |
1097 | 1116 |
1098 (defun mm-insert-part (handle) | 1117 (defun mm-insert-part (handle) |
1099 "Insert the contents of HANDLE in the current buffer." | 1118 "Insert the contents of HANDLE in the current buffer." |
1100 (save-excursion | 1119 (save-excursion |
1146 (setq filename (gnus-replace-in-string filename "[<>|]" "")) | 1165 (setq filename (gnus-replace-in-string filename "[<>|]" "")) |
1147 (gnus-replace-in-string filename "^[.-]+" "")) | 1166 (gnus-replace-in-string filename "^[.-]+" "")) |
1148 | 1167 |
1149 (defun mm-save-part (handle) | 1168 (defun mm-save-part (handle) |
1150 "Write HANDLE to a file." | 1169 "Write HANDLE to a file." |
1151 (let* ((name (mail-content-type-get (mm-handle-type handle) 'name)) | 1170 (let ((filename (or (mail-content-type-get |
1152 (filename (mail-content-type-get | 1171 (mm-handle-disposition handle) 'filename) |
1153 (mm-handle-disposition handle) 'filename)) | 1172 (mail-content-type-get |
1154 file) | 1173 (mm-handle-type handle) 'name))) |
1174 file) | |
1155 (when filename | 1175 (when filename |
1156 (setq filename (gnus-map-function mm-file-name-rewrite-functions | 1176 (setq filename (gnus-map-function mm-file-name-rewrite-functions |
1157 (file-name-nondirectory filename)))) | 1177 (file-name-nondirectory filename)))) |
1158 (setq file | 1178 (setq file |
1159 (mm-with-multibyte | 1179 (mm-with-multibyte |
1160 (read-file-name "Save MIME part to: " | 1180 (read-file-name "Save MIME part to: " |
1161 (or mm-default-directory default-directory) | 1181 (or mm-default-directory default-directory) |
1162 nil nil (or filename name "")))) | 1182 nil nil (or filename "")))) |
1163 (setq mm-default-directory (file-name-directory file)) | 1183 (setq mm-default-directory (file-name-directory file)) |
1164 (and (or (not (file-exists-p file)) | 1184 (and (or (not (file-exists-p file)) |
1165 (yes-or-no-p (format "File %s already exists; overwrite? " | 1185 (yes-or-no-p (format "File %s already exists; overwrite? " |
1166 file))) | 1186 file))) |
1167 (progn | 1187 (progn |