From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#34251: 27.0.50; Use pretty ugly hack for tar-extract Date: Tue, 29 Jan 2019 22:54:43 +0200 Organization: LINKOV.NET Message-ID: <87womnnrv0.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="119727"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (x86_64-pc-linux-gnu) To: 34251@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jan 29 22:17:16 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goakt-000V1F-8k for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Jan 2019 22:17:15 +0100 Original-Received: from localhost ([127.0.0.1]:55707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goaks-0005hB-7A for geb-bug-gnu-emacs@m.gmane.org; Tue, 29 Jan 2019 16:17:14 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51676) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goaki-0005gu-CZ for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:17:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goakh-0002LM-FB for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:17:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:51603) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goakg-0002L9-SS for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:17:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1goakg-0007Rk-Ef for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:17:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 29 Jan 2019 21:17:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 34251 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.154879656828512 (code B ref -1); Tue, 29 Jan 2019 21:17:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Jan 2019 21:16:08 +0000 Original-Received: from localhost ([127.0.0.1]:50882 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goajm-0007Pn-5F for submit@debbugs.gnu.org; Tue, 29 Jan 2019 16:16:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1goajk-0007Oj-I0 for submit@debbugs.gnu.org; Tue, 29 Jan 2019 16:16:04 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:57238) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goaje-0001kI-NU for submit@debbugs.gnu.org; Tue, 29 Jan 2019 16:15:59 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:51269) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goajd-00056g-PA for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:15:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goajb-0001ip-Dn for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:15:57 -0500 Original-Received: from common.maple.relay.mailchannels.net ([23.83.214.38]:32989) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1goajZ-0001gA-0q for bug-gnu-emacs@gnu.org; Tue, 29 Jan 2019 16:15:53 -0500 X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 6CD345C49DD for ; Tue, 29 Jan 2019 21:15:48 +0000 (UTC) Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (unknown [100.96.19.74]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id E694B5C23E9 for ; Tue, 29 Jan 2019 21:15:47 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|jurta@jurta.org Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.16.2); Tue, 29 Jan 2019 21:15:48 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|jurta@jurta.org X-MailChannels-Auth-Id: dreamhost X-Print-Relation: 1642a8db0dbb1d32_1548796548230_2215458282 X-MC-Loop-Signature: 1548796548230:3210444564 X-MC-Ingress-Time: 1548796548230 Original-Received: from pdx1-sub0-mail-a62.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTP id 8FD9F80120 for ; Tue, 29 Jan 2019 13:15:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=linkov.net; h=from:to :subject:date:message-id:mime-version:content-type; s= linkov.net; bh=1JLKQhiBWdOubnZpS50byl5f+DQ=; b=2ScOIXhysCTNVyIFe va1s7Lhd+63yeqUmPnOBCNWwQYtH2uqgX5elu1d/28oYEK5GXVnWnWMCciaqOmqK VE5PV6jZMEtg9eB0ccljAXXP1X8O0IeLrf9FVp46rhbgDHTlbrdtQOKvwAulZwMV grWESvxHJLG6TPM6OHgb+57nyU= Original-Received: from mail.jurta.org (m91-129-110-202.cust.tele2.ee [91.129.110.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: jurta@jurta.org) by pdx1-sub0-mail-a62.g.dreamhost.com (Postfix) with ESMTPSA id BE90480124 for ; Tue, 29 Jan 2019 13:15:46 -0800 (PST) X-DH-BACKEND: pdx1-sub0-mail-a62 X-VR-OUT-STATUS: OK X-VR-OUT-SCORE: 0 X-VR-OUT-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtledrjedvgddugeelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuggftfghnshhusghstghrihgsvgdpffftgfetoffjqffuvfenuceurghilhhouhhtmecufedttdenucenucfjughrpefhvffuohffkfgfgggtsehmtderredtredtnecuhfhrohhmpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqnecukfhppeeluddruddvledruddutddrvddtvdenucfrrghrrghmpehmohguvgepshhmthhppdhhvghlohepmhgrihhlrdhjuhhrthgrrdhorhhgpdhinhgvthepledurdduvdelrdduuddtrddvtddvpdhrvghtuhhrnhdqphgrthhhpefluhhrihcunfhinhhkohhvuceojhhurhhisehlihhnkhhovhdrnhgvtheqpdhmrghilhhfrhhomhepjhhurhhisehlihhnkhhovhdrnhgvthdpnhhrtghpthhtohepsghughdqghhnuhdqvghmrggtshesghhnuhdrohhrghenucevlhhushhtvghrufhiiigvpedt X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:154871 Archived-At: --=-=-= Content-Type: text/plain Tags: patch 0. cd /tmp 1. echo "test" | gzip > test.gz 2. zip test.zip test.gz 3. C-x C-f test.zip RET 4. RET ('archive-extract' to visit the first file) -- file content is nicely displayed ungzipped from zip archive. 1. echo "test" | gzip > test.gz 2. tar zcvf test.tar.gz test.gz 3. C-x C-f test.tar.gz RET 4. RET ('tar-extract' to visit the first file) -- garbage is displayed instead of ungzipped file content. The reason why gzipped files can be visited from arc-mode archives is because of this line in arc-mode.el in 'archive-extract' with this comment: (defun archive-extract (&optional other-window-p event) ... (archive-try-jka-compr) ;Pretty ugly hack :-( ... To support gzipped files in tar archives as well, this patch copies the same pretty ugly hack from arc-mode.el to tar-mode.el: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=tar-extract-try-jka-compr.patch diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el index 5b83d173b4..6f537df8e8 100644 --- a/lisp/tar-mode.el +++ b/lisp/tar-mode.el @@ -852,6 +852,26 @@ tar-mouse-extract (goto-char (posn-point (event-end event))) (tar-extract)) +(defun tar--try-jka-compr () + (when (and auto-compression-mode + (jka-compr-get-compression-info buffer-file-name)) + (let* ((basename (file-name-nondirectory buffer-file-name)) + (tmpname (if (string-match ":\\([^:]+\\)\\'" basename) + (match-string 1 basename) basename)) + (tmpfile (make-temp-file (file-name-sans-extension tmpname) + nil + (file-name-extension tmpname 'period)))) + (unwind-protect + (progn + (let ((coding-system-for-write 'no-conversion) + ;; Don't re-compress this data just before decompressing it. + (jka-compr-inhibit t)) + (write-region (point-min) (point-max) tmpfile nil 'quiet)) + (erase-buffer) + (let ((coding-system-for-read 'no-conversion)) + (insert-file-contents tmpfile))) + (delete-file tmpfile))))) + (defun tar-file-name-handler (op &rest args) "Helper function for `tar-extract'." (or (eq op 'file-exists-p) @@ -931,6 +951,7 @@ tar-extract (setq buffer-file-name new-buffer-file-name) (setq buffer-file-truename (abbreviate-file-name buffer-file-name)) + (tar--try-jka-compr) ;Pretty ugly hack :-( ;; Force buffer-file-coding-system to what ;; decode-coding-region actually used. (set-buffer-file-coding-system last-coding-system-used t) --=-=-=--