all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
Cc: 70987@debbugs.gnu.org
Subject: bug#70987: 29.2; Zip nested in tar, members do not open
Date: Sun, 19 May 2024 16:22:37 +0300	[thread overview]
Message-ID: <867cfqaqci.fsf@gnu.org> (raw)
In-Reply-To: <87bk55hges.fsf@turtle-trading.net> (message from Benjamin Riefenstahl on Thu, 16 May 2024 18:26:19 +0200)

> From: Benjamin Riefenstahl <b.riefenstahl@turtle-trading.net>
> Date: Thu, 16 May 2024 18:26:19 +0200
> 
> Create a zip file wrapped in a tar file.  E.g. in a shell do:
> 
>   $ zip -j zipped /etc/passwd
>   $ tar cvzf tarred.tar.gz zipped.zip
> 
> In Emacs
> 
>   * C-x C-f tarred.tar.gz RET
>   * RET on zipped.zip
>   * RET on passwd
>   * Error: unzip:  cannot find or open tarred.tar.gz!./zipped.zip, ...

Does the patch below give good results?

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index 9a8dd66..bf9def6 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -563,6 +563,8 @@ archive-file-name-coding-system
 (defvar-local archive-files nil
   "Vector of `archive--file-desc' objects.")
 
+(defvar tar-archive-from-tar nil)
+
 ;; -------------------------------------------------------------------------
 ;;; Section: Support functions.
 
@@ -754,7 +756,8 @@ archive-mode
 	;; on local filesystem.  Treat such archives as remote.
 	(or archive-remote
 	    (setq archive-remote
-		  (or (string-match archive-remote-regexp (buffer-file-name))
+		  (or tar-archive-from-tar ; was included in a tar archive
+                      (string-match archive-remote-regexp (buffer-file-name))
 		      (string-match file-name-invalid-regexp
 				    (buffer-file-name)))))
 
@@ -920,6 +923,9 @@ archive-unique-fname
 If FNAME is something our underlying filesystem can't grok, or if another
 file by that name already exists in DIR, a unique new name is generated
 using `make-temp-file', and the generated name is returned."
+  (if (file-name-absolute-p fname)
+      ;; We need a file name relative to the filesystem root.
+      (setq fname (substring fname (1+ (string-search "/" fname)))))
   (let ((fullname (expand-file-name fname dir))
 	(alien (string-match file-name-invalid-regexp fname))
 	(tmpfile
@@ -1179,6 +1185,9 @@ archive-extract
          (buffer (get-buffer bufname))
          (just-created nil)
 	 (file-name-coding archive-file-name-coding-system))
+      (or archive-remote
+          (and (local-variable-p 'tar-archive-from-tar)
+               (setq archive-remote tar-archive-from-tar)))
       (if (and buffer
 	       (string= (buffer-file-name buffer) arcfilename))
           nil
diff --git a/lisp/tar-mode.el b/lisp/tar-mode.el
index 375191a..7278bee 100644
--- a/lisp/tar-mode.el
+++ b/lisp/tar-mode.el
@@ -135,6 +135,10 @@ tar-file-name-coding-system
 (put 'tar-superior-buffer 'permanent-local t)
 (put 'tar-superior-descriptor 'permanent-local t)
 
+(defvar tar-archive-from-tar nil
+  "Non-nil if an arc-mode archive file is a member of a tar archive.")
+(put tar-archive-from-tar 'permanent-local t)
+
 ;; The Tar data is made up of bytes and better manipulated as bytes
 ;; and can be very large, so insert/delete can be costly.  The summary we
 ;; want to display may contain non-ascii chars, of course, so we'd like it
@@ -1124,6 +1128,8 @@ tar-extract
                 default-directory))
         (set-buffer-modified-p nil)
         (normal-mode)                   ; pick a mode.
+        (when (derived-mode-p 'archive-mode)
+          (setq-local tar-archive-from-tar t))
         (setq-local tar-superior-buffer tar-buffer)
         (setq-local tar-superior-descriptor descriptor)
         (setq buffer-read-only read-only-p)





  parent reply	other threads:[~2024-05-19 13:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-16 16:26 bug#70987: 29.2; Zip nested in tar, members do not open Benjamin Riefenstahl
2024-05-18 18:23 ` Andrea Corallo
2024-05-19 13:22 ` Eli Zaretskii [this message]
2024-05-20  6:22   ` Juri Linkov
2024-05-20 11:52     ` Eli Zaretskii
2024-05-20  9:50   ` Benjamin Riefenstahl
2024-05-20 12:30     ` Eli Zaretskii

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=867cfqaqci.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=70987@debbugs.gnu.org \
    --cc=b.riefenstahl@turtle-trading.net \
    /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.