From 470c7931c6604d280d0e0070408d5a797c5f94a0 Mon Sep 17 00:00:00 2001 From: Katsumi Yamaoka Date: Wed, 12 Apr 2006 02:00:49 +0000 Subject: [PATCH] * gnus-art.el (gnus-mime-copy-part): Find name parameter in Content-Type header instead of Content-Disposition header. (gnus-mime-inline-part): Ditto. (gnus-mime-view-part-as-charset): Ignore charset that the part specifies. * mm-decode.el (mm-display-part): Work with external parts and usual parts similarly. * mm-extern.el (mm-inline-external-body): Use mm-display-part instead of gnus-display-mime. * mm-util.el (mm-decompress-buffer): Use mm-with-unibyte-buffer instead of with-temp-buffer. * gnus-uu.el (gnus-uu-save-article): Put mml tags instead of part tag to summarized topics part in order to encode non-ASCII text. ;; From Kenichi Handa. * rfc2231.el (rfc2231-decode-encoded-string): Work on unibyte buffer and then decode the buffer text if necessary. (rfc2231-encode-string): Be sure to work on multibyte buffer at first, and after mm-encode-body, change the buffer to unibyte. --- lisp/ChangeLog | 27 +++++++++++++++++++++++++++ lisp/gnus-art.el | 34 ++++++++++++++++++++++------------ lisp/gnus-uu.el | 4 +++- lisp/mm-decode.el | 15 +++++++++++---- lisp/mm-extern.el | 24 +++++------------------- lisp/mm-util.el | 2 +- lisp/rfc2231.el | 11 ++++++----- 7 files changed, 75 insertions(+), 42 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7f0c13f41..85eddca70 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,30 @@ +2006-04-12 Katsumi Yamaoka + + * gnus-art.el (gnus-mime-copy-part): Find name parameter in + Content-Type header instead of Content-Disposition header. + (gnus-mime-inline-part): Ditto. + (gnus-mime-view-part-as-charset): Ignore charset that the part + specifies. + + * mm-decode.el (mm-display-part): Work with external parts and + usual parts similarly. + + * mm-extern.el (mm-inline-external-body): Use mm-display-part + instead of gnus-display-mime. + + * mm-util.el (mm-decompress-buffer): Use mm-with-unibyte-buffer + instead of with-temp-buffer. + + * gnus-uu.el (gnus-uu-save-article): Put mml tags instead of part + tag to summarized topics part in order to encode non-ASCII text. + +2006-04-12 Kenichi Handa + + * rfc2231.el (rfc2231-decode-encoded-string): Work on unibyte + buffer and then decode the buffer text if necessary. + (rfc2231-encode-string): Be sure to work on multibyte buffer at + first, and after mm-encode-body, change the buffer to unibyte. + 2006-04-11 Reiner Steib * smiley.el (smiley-style): New variable. diff --git a/lisp/gnus-art.el b/lisp/gnus-art.el index b48b482da..053c8a761 100644 --- a/lisp/gnus-art.el +++ b/lisp/gnus-art.el @@ -4508,7 +4508,7 @@ are decompressed." (unless handle (setq handle (get-text-property (point) 'gnus-data))) (when handle - (let ((filename (or (mail-content-type-get (mm-handle-disposition handle) + (let ((filename (or (mail-content-type-get (mm-handle-type handle) 'name) (mail-content-type-get (mm-handle-disposition handle) 'filename))) @@ -4602,7 +4602,7 @@ Compressed files like .gz and .bz2 are decompressed." (mm-insert-part handle) (setq contents (or (mm-decompress-buffer - (or (mail-content-type-get (mm-handle-disposition handle) + (or (mail-content-type-get (mm-handle-type handle) 'name) (mail-content-type-get (mm-handle-disposition handle) 'filename)) @@ -4644,19 +4644,29 @@ Compressed files like .gz and .bz2 are decompressed." specified charset." (interactive (list nil current-prefix-arg)) (gnus-article-check-buffer) - (let* ((handle (or handle (get-text-property (point) 'gnus-data))) - contents charset - (b (point)) - (inhibit-read-only t)) + (let ((handle (or handle (get-text-property (point) 'gnus-data))) + (fun (get-text-property (point) 'gnus-callback)) + (gnus-newsgroup-ignored-charsets 'gnus-all) + gnus-newsgroup-charset type charset) (when handle (if (mm-handle-undisplayer handle) (mm-remove-part handle)) - (let ((gnus-newsgroup-charset - (or (cdr (assq arg - gnus-summary-show-article-charset-alist)) - (mm-read-coding-system "Charset: "))) - (gnus-newsgroup-ignored-charsets 'gnus-all)) - (gnus-article-press-button))))) + (when fun + (setq gnus-newsgroup-charset + (or (cdr (assq arg gnus-summary-show-article-charset-alist)) + (mm-read-coding-system "Charset: "))) + ;; Strip the charset parameter from `handle'. + (setq type (mm-handle-type + (if (equal (mm-handle-media-type handle) + "message/external-body") + (progn + (unless (mm-handle-cache handle) + (mm-extern-cache-contents handle)) + (mm-handle-cache handle)) + handle)) + charset (assq 'charset (cdr type))) + (delq charset type) + (funcall fun handle))))) (defun gnus-mime-view-part-externally (&optional handle) "View the MIME part under point with an external viewer." diff --git a/lisp/gnus-uu.el b/lisp/gnus-uu.el index 7c381cec2..aaf6472f7 100644 --- a/lisp/gnus-uu.el +++ b/lisp/gnus-uu.el @@ -853,7 +853,9 @@ When called interactively, prompt for REGEXP." "Date: %s\nFrom: %s\nSubject: %s Digest\n\n" (message-make-date) name name)) (when (and message-forward-as-mime gnus-uu-digest-buffer) - (insert "<#part type=message/rfc822>\nSubject: Topics\n\n")) + (insert + "<#mml type=message/rfc822>\nSubject: Topics\n\n<#/mml>\n") + (forward-line -1)) (insert "Topics:\n"))) (when (not (eq in-state 'end)) (setq state (list 'middle)))) diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index 99076ccda..cb356174e 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -666,7 +666,14 @@ external if displayed external." (mailcap-parse-mailcaps) (if (mm-handle-displayed-p handle) (mm-remove-part handle) - (let* ((type (mm-handle-media-type handle)) + (let* ((ehandle (if (equal (mm-handle-media-type handle) + "message/external-body") + (progn + (unless (mm-handle-cache handle) + (mm-extern-cache-contents handle)) + (mm-handle-cache handle)) + handle)) + (type (mm-handle-media-type ehandle)) (method (mailcap-mime-info type)) (filename (or (mail-content-type-get (mm-handle-disposition handle) 'filename) @@ -674,8 +681,8 @@ external if displayed external." (mm-handle-type handle) 'name) "")) (external mm-enable-external)) - (if (and (mm-inlinable-p handle) - (mm-inlined-p handle)) + (if (and (mm-inlinable-p ehandle) + (mm-inlined-p ehandle)) (progn (forward-line 1) (mm-display-inline handle) @@ -683,7 +690,7 @@ external if displayed external." (when (or method (not no-default)) (if (and (not method) - (equal "text" (car (split-string type)))) + (equal "text" (car (split-string type "/")))) (progn (forward-line 1) (mm-insert-inline handle (mm-get-part handle)) diff --git a/lisp/mm-extern.el b/lisp/mm-extern.el index b736374f0..c574bd615 100644 --- a/lisp/mm-extern.el +++ b/lisp/mm-extern.el @@ -157,25 +157,11 @@ If NO-DISPLAY is nil, display it. Otherwise, do nothing after replacing." (save-excursion (save-restriction (narrow-to-region (point) (point)) - (let* ((type (regexp-quote - (mm-handle-media-type (mm-handle-cache handle)))) - ;; Force the part to be displayed (but if there is no - ;; method to display, a user will be prompted to save). - ;; See `gnus-mime-display-single'. - (mm-inline-override-types nil) - (mm-attachment-override-types - (cons type mm-attachment-override-types)) - (mm-automatic-display (cons type mm-automatic-display)) - (mm-automatic-external-display - (cons type mm-automatic-external-display)) - ;; Suppress adding of button to the cached part. - (gnus-inhibit-mime-unbuttonizing nil)) - (gnus-display-mime (mm-handle-cache handle))) - ;; Move undisplayer added to the cached handle to the parent. - (mm-handle-set-undisplayer - handle - (mm-handle-undisplayer (mm-handle-cache handle))) - (mm-handle-set-undisplayer (mm-handle-cache handle) nil))))) + (mm-display-part (mm-handle-cache handle)))) + ;; Move undisplayer added to the cached handle to the parent. + (mm-handle-set-undisplayer + handle (mm-handle-undisplayer (mm-handle-cache handle))) + (mm-handle-set-undisplayer (mm-handle-cache handle) nil))) (provide 'mm-extern) diff --git a/lisp/mm-util.el b/lisp/mm-util.el index 802ad8688..1f6028d0e 100644 --- a/lisp/mm-util.el +++ b/lisp/mm-util.el @@ -1210,7 +1210,7 @@ decompressed data. The buffer's multibyteness must be turned off." (coding-system-for-write mm-binary-coding-system) retval err-msg) (message "%s" msg) - (with-temp-buffer + (mm-with-unibyte-buffer (insert-buffer-substring cur) (condition-case err (progn diff --git a/lisp/rfc2231.el b/lisp/rfc2231.el index 3728b780c..d066591cd 100644 --- a/lisp/rfc2231.el +++ b/lisp/rfc2231.el @@ -227,7 +227,7 @@ These look like: (let ((coding-system (mm-charset-to-coding-system (match-string 1 string))) ;;(language (match-string 2 string)) (value (match-string 3 string))) - (mm-with-multibyte-buffer + (mm-with-unibyte-buffer (insert value) (goto-char (point-min)) (while (search-forward "%" nil t) @@ -236,9 +236,9 @@ These look like: (string-to-number (buffer-substring (point) (+ (point) 2)) 16) (delete-region (1- (point)) (+ (point) 2))))) ;; Decode using the charset, if any. - (unless (memq coding-system '(nil ascii)) - (mm-decode-coding-region (point-min) (point-max) coding-system)) - (buffer-string)))) + (if (memq coding-system '(nil ascii)) + (buffer-string) + (mm-decode-coding-string (buffer-string) coding-system))))) (defun rfc2231-encode-string (param value) "Return and PARAM=VALUE string encoded according to RFC2231. @@ -252,7 +252,7 @@ the result of this function." ;; Don't make lines exceeding 76 column. (limit (- 74 (length param))) spacep encodep charsetp charset broken) - (with-temp-buffer + (mm-with-multibyte-buffer (insert value) (goto-char (point-min)) (while (not (eobp)) @@ -268,6 +268,7 @@ the result of this function." (forward-char 1)) (when charsetp (setq charset (mm-encode-body))) + (mm-disable-multibyte) (cond ((or encodep charsetp (progn -- 2.34.1