--- gnus-art.el.~7.72.~ 2005-02-08 09:32:44.000000000 +1100 +++ gnus-art.el 2005-02-08 09:33:00.000000000 +1100 @@ -4235,20 +4235,18 @@ ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days ;; emacs can do that itself. ;; -(defun gnus-mime-jka-compr-maybe-uncompress () - "Uncompress the current buffer if `auto-compression-mode' is enabled. +(defun gnus-mime-copy-part-jka-insert (contents) + "Uncompress CONTENTS into the current buffer using jka-compr. The uncompress method used is derived from `buffer-file-name'." - (when (and (fboundp 'jka-compr-installed-p) - (jka-compr-installed-p)) - (let ((info (jka-compr-get-compression-info buffer-file-name))) - (when info - (let ((basename (file-name-nondirectory buffer-file-name)) + (let* ((info (jka-compr-get-compression-info buffer-file-name)) + (basename (file-name-nondirectory buffer-file-name)) (args (jka-compr-info-uncompress-args info)) (prog (jka-compr-info-uncompress-program info)) (message (jka-compr-info-uncompress-message info)) (err-file (jka-compr-make-temp-name))) (if message (message "%s %s..." message basename)) + (insert contents) (unwind-protect (unless (memq (apply 'call-process-region (point-min) (point-max) @@ -4257,7 +4255,7 @@ args) jka-compr-acceptable-retval-list) (jka-compr-error prog args basename message err-file)) - (jka-compr-delete-temp-file err-file))))))) + (jka-compr-delete-temp-file err-file)))) (defun gnus-mime-copy-part (&optional handle) "Put the MIME part under point into a new buffer. @@ -4267,6 +4265,10 @@ (gnus-article-check-buffer) (let* ((handle (or handle (get-text-property (point) 'gnus-data))) (contents (and handle (mm-get-part handle))) + (charset (and handle (or (mail-content-type-get + (mm-handle-type handle) 'charset) + gnus-newsgroup-charset))) + (coding-system (mm-charset-to-coding-system charset)) (base (and handle (file-name-nondirectory (or @@ -4277,13 +4279,20 @@ (buffer (and base (generate-new-buffer base)))) (when contents (switch-to-buffer buffer) - (insert contents) - ;; We do it this way to make `normal-mode' set the appropriate mode. + (setq buffer-file-name (expand-file-name base)) + (cond ((and (fboundp 'jka-compr-installed-p) + (jka-compr-installed-p) + (jka-compr-get-compression-info buffer-file-name)) + (gnus-mime-copy-part-jka-insert contents)) + (coding-system + (insert (mm-decode-coding-string contents coding-system)) + (setq buffer-file-coding-system coding-system)) + (t + (insert contents))) + ;; Run normal-mode with buffer-file-name set from the part, but then + ;; zap that variable so the user will be prompted in `save-buffer'. (unwind-protect - (progn - (setq buffer-file-name (expand-file-name base)) - (gnus-mime-jka-compr-maybe-uncompress) - (normal-mode)) + (normal-mode) (setq buffer-file-name nil)) (goto-char (point-min)))))