From: Juri Linkov <juri@linkov.net>
To: 34251@debbugs.gnu.org
Subject: bug#34251: 27.0.50; Use pretty ugly hack for tar-extract
Date: Tue, 29 Jan 2019 22:54:43 +0200 [thread overview]
Message-ID: <87womnnrv0.fsf@mail.linkov.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 817 bytes --]
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:
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: tar-extract-try-jka-compr.patch --]
[-- Type: text/x-diff, Size: 1741 bytes --]
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)
next reply other threads:[~2019-01-29 20:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-29 20:54 Juri Linkov [this message]
2019-02-03 21:01 ` bug#34251: 27.0.50; Use pretty ugly hack for tar-extract Juri Linkov
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=87womnnrv0.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=34251@debbugs.gnu.org \
/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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.