From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/54926 Path: main.gmane.org!not-for-mail From: Kevin Ryde Newsgroups: gmane.emacs.gnus.general Subject: emacs 20 copy-part uncompress Date: Tue, 25 Nov 2003 09:00:32 +1000 Organization: Bah Humbug Sender: ding-owner@lists.math.uh.edu Message-ID: <873ccdfk33.fsf@zip.com.au> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1069714896 21727 80.91.224.253 (24 Nov 2003 23:01:36 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 24 Nov 2003 23:01:36 +0000 (UTC) Original-X-From: ding-owner+M3466@lists.math.uh.edu Tue Nov 25 00:01:33 2003 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1AOPi1-0006dQ-00 for ; Tue, 25 Nov 2003 00:01:33 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1AOPhh-00054S-00; Mon, 24 Nov 2003 17:01:13 -0600 Original-Received: from justine.libertine.org ([66.139.78.221] ident=postfix) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1AOPhZ-00054M-00 for ding@lists.math.uh.edu; Mon, 24 Nov 2003 17:01:05 -0600 Original-Received: from snoopy.pacific.net.au (snoopy.pacific.net.au [61.8.0.36]) by justine.libertine.org (Postfix) with ESMTP id 46AD73A0042 for ; Mon, 24 Nov 2003 17:01:03 -0600 (CST) Original-Received: from mongrel.pacific.net.au (mongrel.pacific.net.au [61.8.0.107]) by snoopy.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAON0xi0023372 for ; Tue, 25 Nov 2003 10:00:59 +1100 Original-Received: from localhost (ppp47.dyn228.pacific.net.au [203.143.228.47]) by mongrel.pacific.net.au (8.12.3/8.12.3/Debian-6.6) with ESMTP id hAOMx2MX025889 for ; Tue, 25 Nov 2003 09:59:03 +1100 Original-Received: from gg by localhost with local (Exim 3.35 #1 (Debian)) id 1AOPh3-00019G-00; Tue, 25 Nov 2003 09:00:33 +1000 Original-To: ding@gnus.org User-Agent: Gnus/5.1003 (Gnus v5.10.3) Emacs/20.7 (gnu/linux) Precedence: bulk Xref: main.gmane.org gmane.emacs.gnus.general:54926 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:54926 --=-=-= The change I'd made a while ago to gnus-mime-copy-part for jka-compr auto-decompression never actually worked with emacs 20, it bombs prompting for a coding system and then sending the wrong bytes out to gzip. Eg. press "c" on the foo.txt.gz below to see it happen. I think the part contents have to be sent out from a unibyte buffer to avoid conversions, * gnus-art.el (gnus-mime-jka-compr-maybe-uncompress): Take contents parameter, use a unibyte buffer for that data to get the right bytes out of call-process-region under emacs 20. (gnus-mime-copy-part): Pass contents parameter. --=-=-= Content-Disposition: attachment; filename=gnus-art.el.jka-e20.diff --- gnus-art.el.~6.378.~ 1970-01-01 10:00:01.000000000 +1000 +++ gnus-art.el 2003-11-23 08:46:48.000000000 +1000 @@ -4140,9 +4140,14 @@ (eval-when-compile ;; 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. -The uncompress method used is derived from `buffer-file-name'." +;; The temporary unibyte buffer used is necessary to get the right bytes out +;; of call-process-region in Emacs 20. In Emacs 21 unibyte data can be +;; successfully sent via a multibyte buffer, but not in Emacs 20. +;; +(defun gnus-mime-jka-compr-maybe-uncompress (contents) + "Uncompress CONTENTS if `auto-compression-mode' is enabled. +The uncompress method used is derived from `buffer-file-name'. +CONTENTS should be a unibyte string." (when (and (fboundp 'jka-compr-installed-p) (jka-compr-installed-p)) (let ((info (jka-compr-get-compression-info buffer-file-name))) @@ -4151,18 +4156,22 @@ (defun gnus-mime-jka-compr-maybe-uncompr (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))) + (err-file (jka-compr-make-temp-name)) + (out-buf (current-buffer))) + (erase-buffer) + (mm-with-unibyte-buffer + (insert contents) (if message (message "%s %s..." message basename)) (unwind-protect (unless (memq (apply 'call-process-region (point-min) (point-max) prog - t (list t err-file) nil + nil (list out-buf err-file) nil 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. @@ -4187,7 +4196,7 @@ (defun gnus-mime-copy-part (&optional ha (unwind-protect (progn (setq buffer-file-name (expand-file-name base)) - (gnus-mime-jka-compr-maybe-uncompress) + (gnus-mime-jka-compr-maybe-uncompress contents) (normal-mode)) (setq buffer-file-name nil)) (goto-char (point-min))))) --=-=-= Content-Type: application/octet-stream Content-Disposition: attachment; filename=foo.txt.gz Content-Transfer-Encoding: base64 H4sICKNsvD8CA2Zvby50eHQAbVRNj9MwEL37V4y4cKnKD+gRwWolBHtYhLjh OpPGYHuKPzYKv543TtptEack9njexzyHiB4+f6UP0bpCvtCbMTNTkbHONvOb A9UJq5FtKni1lfiF8yKJtbjXVjGt4LOSTcNliTIPvtTsj632PUnkOFfr8ZQ0 +Oollf09uElSCQV1Yjq3Y/COBok4ctAOwHNyXrI/TZWHDobCzASegFMw17sa YPla6EoAizvCU+vLfW0/PHDxp4Se4H3mHH01XSWkp9Oq2tJJZAABQYGtuu6g 4Q8nmqWFgWabqp4fBKK+6ZFNjw1BZvQGfWzXvHSUDAAcEFWgPkqksWX9ojLZ rP1tWggsCmgaGW+M6oRQulBUL+jEde2wSAP4s7qX2XlIfbVahZpRGlzbHNaG D5wgJ9DT6vYn7zjhWEdwErnQ7Ou04arjNhQx9nxmq7RFta0eQV7h7uneGCL6 goTMtotVfrbPju50+E14AZAGigOg50lostise/NdGiWGd93H8guAmaTldUhF nVktR4sdYa9yCN23S7sD/Wylmo6NjkSPo7oEhBfkxjku61Rgx2OqnBPXXS9w NnXeuhNsRWLMbZwug7kXdFwALmmJ0gp9fH46wBLuLUYf2Pzg6t5h+e1lAuup u76qMAoy6RNeo301VM2IMFQngAg79i98gz1PiKIyP7alux3PuHkZkt9vryba 1EbrasuaOQ3+5bLeXFVY5TF2WRkWG1EAt9fU6eRDn+n1L6Aur6Erl8rMv5vP XXjs81emSq070UIwBUOE9zuodKENmqAZ7bUpucmmE5ct4BDcZxXtwLv1zl/v aG/5z5/mEuzVlM2mYc1Z54MLABAta6XZYFbKGGM/+d/roLFJ61XFZc8DePc/ VJZTtpGiJuy4manzU17XcWiIPEKlEdYsvpZpj9uR7M1fDCcVCIwFAAA= --=-=-=--