From: Kevin Ryde <user42@zip.com.au>
Subject: emacs 20 copy-part uncompress
Date: Tue, 25 Nov 2003 09:00:32 +1000 [thread overview]
Message-ID: <873ccdfk33.fsf@zip.com.au> (raw)
[-- Attachment #1: Type: text/plain, Size: 592 bytes --]
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.
[-- Attachment #2: gnus-art.el.jka-e20.diff --]
[-- Type: text/plain, Size: 2680 bytes --]
--- 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)))))
[-- Attachment #3: foo.txt.gz --]
[-- Type: application/octet-stream, Size: 716 bytes --]
next reply other threads:[~2003-11-24 23:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-24 23:00 Kevin Ryde [this message]
2003-11-25 23:30 ` Kevin Ryde
2004-01-02 21:23 ` Lars Magne Ingebrigtsen
2004-01-03 14:40 ` What XEmacs support in No Gnus? (Was: emacs 20 copy-part uncompress) Steinar Bang
2004-01-03 15:46 ` What XEmacs support in No Gnus? Reiner Steib
2004-01-03 18:04 ` Lars Magne Ingebrigtsen
2004-01-04 12:14 ` Steinar Bang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873ccdfk33.fsf@zip.com.au \
--to=user42@zip.com.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).