unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#1702: feature request: correctly display single file zip archive
@ 2008-12-25 18:30           ` xah lee
  2014-11-18 13:22             ` bug#1702: [PATCH]: " Rasmus
  0 siblings, 1 reply; 19+ messages in thread
From: xah lee @ 2008-12-25 18:30 UTC (permalink / raw)
  To: bug-gnu-emacs

this might be considered as a feature request or a bug.

Problem:
When opening a zip archive that is just a single file, emacs displays  
gibberish, as opposed to decompressed file content.

(Note: when the zip archive is a directory of files, Emacs behaves  
correctly by showing its file index)

Thanks.

GNU Emacs 22.2.1 (powerpc-apple-darwin8.11.0, Carbon Version 1.6.0)  
of 2008-04-05 on g5.tokyo.stp.isas.jaxa.jp

   Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: feature request: correctly display single file zip archive
@ 2008-12-28  2:47 Chong Yidong
  2009-01-16 20:09 ` xah lee
  0 siblings, 1 reply; 19+ messages in thread
From: Chong Yidong @ 2008-12-28  2:47 UTC (permalink / raw)
  To: xah lee; +Cc: 1702

> When opening a zip archive that is just a single file, emacs displays
> gibberish, as opposed to decompressed file content.

I can't reproduce this.  Do you have an example of a zip file that shows
this problem?






^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: feature request: correctly display single file zip archive
  2008-12-28  2:47 bug#1702: feature request: correctly display single file zip archive Chong Yidong
@ 2009-01-16 20:09 ` xah lee
  2014-11-13 18:39   ` bug#1702: [PATCH]: " Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: xah lee @ 2009-01-16 20:09 UTC (permalink / raw)
  To: Chong Yidong; +Cc: 1702


On Dec 27, 2008, at 6:47 PM, Chong Yidong wrote:

> When opening a zip archive that is just a single file, emacs displays
> gibberish, as opposed to decompressed file content.

I can't reproduce this.  Do you have an example of a zip file that shows
this problem?

---------------------

Sorry, i can't reproduced what i wrote. I think rather that i wrote  
wrong. Here's a correct report:

When opening a zip archive of a single file, emacs displays the zip  
archive's index (which is just a single file), as opposed to the  
decompressed file content.

I think when the zip file is a single file, it is more useful to  
display file content and allow transparent editing.

For what's worth,

Thanks.

   Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2009-01-16 20:09 ` xah lee
@ 2014-11-13 18:39   ` Matthew Leach
  2014-11-13 18:50     ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-13 18:39 UTC (permalink / raw)
  To: xah lee; +Cc: 1702, Chong Yidong

[-- Attachment #1: Type: text/plain, Size: 611 bytes --]

Hi all,

xah lee <xah@xahlee.org> writes:

> When opening a zip archive of a single file, emacs displays the zip
> archive's index (which is just a single file), as opposed to the
> decompressed file content.
>
> I think when the zip file is a single file, it is more useful to
> display file content and allow transparent editing.

Please see the attached patch to implement this.

Any comments welcome!

Thanks,
-- 
Matt

ChangeLog entry:

2014-11-13  Matthew Leach  <matthew@mattleach.net>

	* arc-mode.el (singular-file-archive-action): New.
	(archive-mode): Visit file if archive contains a single file.



[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-show-summary-for-single-file-archives.patch --]
[-- Type: text/x-diff, Size: 1687 bytes --]

From 1c84ec04f024f9de44b0bb57d60d009b9738c899 Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@mattleach.net>
Date: Thu, 13 Nov 2014 18:30:24 +0000
Subject: [PATCH] Don't show summary for single-file archives.

* arc-mode.el (singular-file-archive-action): New.
(archive-mode): Visit file if archive contains a single file.
---
 lisp/arc-mode.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index ef155ee..279b9a1 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -147,6 +147,13 @@ A local copy of the archive will be used when updating."
   "Hook run when an archive member has been extracted."
   :type 'hook
   :group 'archive)
+
+(defcustom singular-file-archive-action 'visit-file
+  "When opening an archive that contains a single file choose
+whether to open the file or display the archive summary."
+  :type '(choice (const :tag "Show archive summary" show-summary)
+                 (const :tag "Visit the single file" visit-file))
+  :group 'archive)
 ;; ------------------------------
 ;; Arc archive configuration
 
@@ -742,7 +749,12 @@ archive.
       (if (default-value 'enable-multibyte-characters)
 	  (set-buffer-multibyte 'to))
       (archive-summarize nil)
-      (setq buffer-read-only t))))
+      (setq buffer-read-only t)
+      (when (and (= (length archive-files) 1)
+                 (eq singular-file-archive-action 'visit-file))
+        (let ((archive-buffer (current-buffer)))
+          (archive-extract)
+          (kill-buffer archive-buffer))))))
 
 ;; Archive mode is suitable only for specially formatted data.
 (put 'archive-mode 'mode-class 'special)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 18:39   ` bug#1702: [PATCH]: " Matthew Leach
@ 2014-11-13 18:50     ` Eli Zaretskii
  2014-11-13 19:26       ` Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-13 18:50 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702, cyd

> From: Matthew Leach <matthew@mattleach.net>
> Date: Thu, 13 Nov 2014 18:39:43 +0000
> Cc: 1702@debbugs.gnu.org, Chong Yidong <cyd@stupidchicken.com>
> 
> xah lee <xah@xahlee.org> writes:
> 
> > When opening a zip archive of a single file, emacs displays the zip
> > archive's index (which is just a single file), as opposed to the
> > decompressed file content.
> >
> > I think when the zip file is a single file, it is more useful to
> > display file content and allow transparent editing.
> 
> Please see the attached patch to implement this.

Thanks.

> Any comments welcome!

A comment: if the default is indeed going to be to automatically visit
such a compressed file (and I personally am not convinced it should),
then this is a user-visible change in behavior, so it should be
mentioned in NEWS, and the entry should describe how to get the old
behavior back.

> +(defcustom singular-file-archive-action 'visit-file
> +  "When opening an archive that contains a single file choose
> +whether to open the file or display the archive summary."

We use a certain style in doc strings of options: the first line
should be a complete sentence.  In addition, option names should begin
with the name of the package.

Also, this is just a boolean yes/no option, so no need to use a symbol
as its value.  Therefor, I suggest:

  (defcustom archive-visit-single-files t
    "If non-nil, opening an archive with a single file visits that file.

  If this option's value is nil, visiting such archives will display
  the archive summary."

(and the corresponding change in the code).





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 18:50     ` Eli Zaretskii
@ 2014-11-13 19:26       ` Matthew Leach
  2014-11-13 19:39         ` Eli Zaretskii
  2014-11-13 19:51         ` Lars Magne Ingebrigtsen
  0 siblings, 2 replies; 19+ messages in thread
From: Matthew Leach @ 2014-11-13 19:26 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: xah, 1702, cyd

Hi Eli,

Eli Zaretskii <eliz@gnu.org> writes:

[...]

> A comment: if the default is indeed going to be to automatically visit
> such a compressed file (and I personally am not convinced it should),
> then this is a user-visible change in behavior, so it should be
> mentioned in NEWS, and the entry should describe how to get the old
> behavior back.

I think the advantage gained here is transparent editing of compressed
files, like how Emacs can read .el.gz files without having to manually
decompress them first.  Of course, if you think the user-visible change
is too substantial without much benefit, I shall make the current
behaviour default.  Thoughts?
-- 
Matt





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 19:26       ` Matthew Leach
@ 2014-11-13 19:39         ` Eli Zaretskii
  2014-11-13 20:03           ` Matthew Leach
  2014-11-13 19:51         ` Lars Magne Ingebrigtsen
  1 sibling, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-13 19:39 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702, cyd

> From: Matthew Leach <matthew@mattleach.net>
> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> Date: Thu, 13 Nov 2014 19:26:13 +0000
> 
> I think the advantage gained here is transparent editing of compressed
> files, like how Emacs can read .el.gz files without having to manually
> decompress them first.

This won't work without a suitable change to jka-compr.el.

> Of course, if you think the user-visible change is too substantial
> without much benefit, I shall make the current behaviour default.
> Thoughts?

I already expressed my doubts, so let's wait for others to chime in,
if they care.





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 19:26       ` Matthew Leach
  2014-11-13 19:39         ` Eli Zaretskii
@ 2014-11-13 19:51         ` Lars Magne Ingebrigtsen
  2008-12-25 18:30           ` bug#1702: " xah lee
  2014-11-13 19:58           ` Eli Zaretskii
  1 sibling, 2 replies; 19+ messages in thread
From: Lars Magne Ingebrigtsen @ 2014-11-13 19:51 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702, cyd

Matthew Leach <matthew@mattleach.net> writes:

> I think the advantage gained here is transparent editing of compressed
> files, like how Emacs can read .el.gz files without having to manually
> decompress them first.

If it were possible to edit files inside archives, that would be great.
But that's a pretty major undertaking, I think.

> Of course, if you think the user-visible change is too substantial
> without much benefit, I shall make the current behaviour default.
> Thoughts?

I think it would be nice to go directly to the single file in these
archives, but, on the other hand, it might be kinda surprising.  If
you're visiting an archive, you expect to see the list of files in the
archive.  For one type of archives (ones with a single file in them) to
work differently may be too inconsistent.

So I dunno...  others who want to chime in?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 19:51         ` Lars Magne Ingebrigtsen
  2008-12-25 18:30           ` bug#1702: " xah lee
@ 2014-11-13 19:58           ` Eli Zaretskii
  1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-13 19:58 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: xah, matthew, cyd, 1702

> From: Lars Magne Ingebrigtsen <larsi@gnus.org>
> Cc: Eli Zaretskii <eliz@gnu.org>,  xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> Date: Thu, 13 Nov 2014 20:51:36 +0100
> 
> Matthew Leach <matthew@mattleach.net> writes:
> 
> > I think the advantage gained here is transparent editing of compressed
> > files, like how Emacs can read .el.gz files without having to manually
> > decompress them first.
> 
> If it were possible to edit files inside archives, that would be great.
> But that's a pretty major undertaking, I think.

Maybe so, but that undertaking was already made many years ago:
arc-mode.el does support editing files in archives.





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 19:39         ` Eli Zaretskii
@ 2014-11-13 20:03           ` Matthew Leach
  2014-11-13 20:25             ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-13 20:03 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: xah, 1702, cyd

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Matthew Leach <matthew@mattleach.net>
>> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
>> Date: Thu, 13 Nov 2014 19:26:13 +0000
>> 
>> I think the advantage gained here is transparent editing of compressed
>> files, like how Emacs can read .el.gz files without having to manually
>> decompress them first.
>
> This won't work without a suitable change to jka-compr.el.

Could you please elaborate on what kind of change would be needed?  From
the small amount of testing I've done so far, it seems to `just work (TM)'.
-- 
Matt





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 20:03           ` Matthew Leach
@ 2014-11-13 20:25             ` Eli Zaretskii
  2014-11-13 20:50               ` Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-13 20:25 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702, cyd

> From: Matthew Leach <matthew@mattleach.net>
> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> Date: Thu, 13 Nov 2014 20:03:32 +0000
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> From: Matthew Leach <matthew@mattleach.net>
> >> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> >> Date: Thu, 13 Nov 2014 19:26:13 +0000
> >> 
> >> I think the advantage gained here is transparent editing of compressed
> >> files, like how Emacs can read .el.gz files without having to manually
> >> decompress them first.
> >
> > This won't work without a suitable change to jka-compr.el.
> 
> Could you please elaborate on what kind of change would be needed?

Do we want to disable decompression when auto-compression-mode is off,
for example?  (I was mistaken: the change to do that needs to be done
in arc-mode.el itself, because it bypasses jka-compr.)





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 20:25             ` Eli Zaretskii
@ 2014-11-13 20:50               ` Matthew Leach
  2014-11-14  5:27                 ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-13 20:50 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: xah, 1702, cyd

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Matthew Leach <matthew@mattleach.net>
>> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
>> Date: Thu, 13 Nov 2014 20:03:32 +0000
>> 
>> Eli Zaretskii <eliz@gnu.org> writes:
>> 
>> >> From: Matthew Leach <matthew@mattleach.net>
>> >> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
>> >> Date: Thu, 13 Nov 2014 19:26:13 +0000
>> >> 
>> >> I think the advantage gained here is transparent editing of compressed
>> >> files, like how Emacs can read .el.gz files without having to manually
>> >> decompress them first.
>> >
>> > This won't work without a suitable change to jka-compr.el.
>> 
>> Could you please elaborate on what kind of change would be needed?
>
> Do we want to disable decompression when auto-compression-mode is off,
> for example?

I think in the case that the user has auto-compression-mode off, the
archive summary should be shown instead.
-- 
Matt





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-13 20:50               ` Matthew Leach
@ 2014-11-14  5:27                 ` Eli Zaretskii
  2014-11-14 11:06                   ` Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-14  5:27 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702, cyd

> From: Matthew Leach <matthew@mattleach.net>
> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> Date: Thu, 13 Nov 2014 20:50:21 +0000
> 
> > Do we want to disable decompression when auto-compression-mode is off,
> > for example?
> 
> I think in the case that the user has auto-compression-mode off, the
> archive summary should be shown instead.

I agree.  So this needs to be part of the patch, if the rationale is
what you proposed.





^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-14  5:27                 ` Eli Zaretskii
@ 2014-11-14 11:06                   ` Matthew Leach
  2014-11-14 11:31                     ` Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-14 11:06 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: xah, 1702, cyd

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

Hi Eli,

Eli Zaretskii <eliz@gnu.org> writes:

>> From: Matthew Leach <matthew@mattleach.net>
>> Cc: xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
>> Date: Thu, 13 Nov 2014 20:50:21 +0000
>> 
>> > Do we want to disable decompression when auto-compression-mode is off,
>> > for example?
>> 
>> I think in the case that the user has auto-compression-mode off, the
>> archive summary should be shown instead.
>
> I agree.  So this needs to be part of the patch, if the rationale is
> what you proposed.

Thank you for the review.  The attached patch should take care of
everything mentioned.
-- 
Matt

lisp/ChangeLog:

2014-11-14  Matthew Leach  <matthew@mattleach.net>

	* arc-mode.el (archive-visit-single-files): New.
	(archive-mode): Visit file if archive contains a single file.

etc/ChangeLog:

2014-11-14  Matthew Leach  <matthew@mattleach.net>

	* NEWS: Mention archive will now visit the file in singular-file
	archives.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-show-summary-for-single-file-archives.patch --]
[-- Type: text/x-diff, Size: 2354 bytes --]

From fb5402f8fe3e5bdd7e6994cc7fc744d75b0da1da Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@mattleach.net>
Date: Thu, 13 Nov 2014 18:30:24 +0000
Subject: [PATCH] Don't show summary for single-file archives.

* arc-mode.el (archive-visit-single-files): New.
(archive-mode): Visit file if archive contains a single file.
* etc/NEWS: Mention archive will now visit the file in singular-file
archives.
---
 etc/NEWS         |  6 ++++++
 lisp/arc-mode.el | 17 ++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 05210df..2083127 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -184,6 +184,12 @@ appending FUN to `minibuffer-setup-hook'.
 ** cl-lib
 *** New functions cl-fresh-line, cl-digit-char-p and cl-parse-integer.
 
+** Archive
+*** When visiting an archive that contains a single file automatically
+visit that file, rather than displaying the archive summary.  To
+revert to the original behaviour, set `archive-visit-single-files' to
+nil.
+
 ** Calendar and diary
 
 +++
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index ef155ee..80f6564 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -147,6 +147,15 @@ A local copy of the archive will be used when updating."
   "Hook run when an archive member has been extracted."
   :type 'hook
   :group 'archive)
+
+(defcustom archive-visit-single-files t
+  "If non-nil, opening an archive with a single file visits that file.
+
+  If this option's value is nil, visiting such archives will
+  display the archive summary."
+  :type '(choice (const :tag "Visit the single file" t)
+                 (const :tag "Show the archive summary" nil))
+  :group 'archive)
 ;; ------------------------------
 ;; Arc archive configuration
 
@@ -742,7 +751,13 @@ archive.
       (if (default-value 'enable-multibyte-characters)
 	  (set-buffer-multibyte 'to))
       (archive-summarize nil)
-      (setq buffer-read-only t))))
+      (setq buffer-read-only t)
+      (when (and archive-visit-single-files
+                 auto-compression-mode
+                 (= (length archive-files) 1))
+        (let ((archive-buffer (current-buffer)))
+          (rename-buffer (concat " " (buffer-name)))
+          (archive-extract))))))
 
 ;; Archive mode is suitable only for specially formatted data.
 (put 'archive-mode 'mode-class 'special)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-14 11:06                   ` Matthew Leach
@ 2014-11-14 11:31                     ` Matthew Leach
  2014-11-18 13:04                       ` Daniel Colascione
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-14 11:31 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: xah, 1702, cyd

[-- Attachment #1: Type: text/plain, Size: 546 bytes --]

Matthew Leach <matthew@mattleach.net> writes:

[...]

> @@ -742,7 +751,13 @@ archive.
>        (if (default-value 'enable-multibyte-characters)
>  	  (set-buffer-multibyte 'to))
>        (archive-summarize nil)
> -      (setq buffer-read-only t))))
> +      (setq buffer-read-only t)
> +      (when (and archive-visit-single-files
> +                 auto-compression-mode
> +                 (= (length archive-files) 1))
> +        (let ((archive-buffer (current-buffer)))

Oops, the `let' isn't needed anymore.

Sorry for the noise.
-- 
Matt


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Don-t-show-summary-for-single-file-archives.patch --]
[-- Type: text/x-diff, Size: 2298 bytes --]

From a6ec5479a42c130c36d7d628fa976630b19d741c Mon Sep 17 00:00:00 2001
From: Matthew Leach <matthew@mattleach.net>
Date: Thu, 13 Nov 2014 18:30:24 +0000
Subject: [PATCH] Don't show summary for single-file archives.

* arc-mode.el (archive-visit-single-files): New.
(archive-mode): Visit file if archive contains a single file.
* etc/NEWS: Mention archive will now visit the file in singular-file
archives.
---
 etc/NEWS         |  6 ++++++
 lisp/arc-mode.el | 16 +++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/etc/NEWS b/etc/NEWS
index 05210df..2083127 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -184,6 +184,12 @@ appending FUN to `minibuffer-setup-hook'.
 ** cl-lib
 *** New functions cl-fresh-line, cl-digit-char-p and cl-parse-integer.
 
+** Archive
+*** When visiting an archive that contains a single file automatically
+visit that file, rather than displaying the archive summary.  To
+revert to the original behaviour, set `archive-visit-single-files' to
+nil.
+
 ** Calendar and diary
 
 +++
diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index ef155ee..3026a6a 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -147,6 +147,15 @@ A local copy of the archive will be used when updating."
   "Hook run when an archive member has been extracted."
   :type 'hook
   :group 'archive)
+
+(defcustom archive-visit-single-files t
+  "If non-nil, opening an archive with a single file visits that file.
+
+  If this option's value is nil, visiting such archives will
+  display the archive summary."
+  :type '(choice (const :tag "Visit the single file" t)
+                 (const :tag "Show the archive summary" nil))
+  :group 'archive)
 ;; ------------------------------
 ;; Arc archive configuration
 
@@ -742,7 +751,12 @@ archive.
       (if (default-value 'enable-multibyte-characters)
 	  (set-buffer-multibyte 'to))
       (archive-summarize nil)
-      (setq buffer-read-only t))))
+      (setq buffer-read-only t)
+      (when (and archive-visit-single-files
+                 auto-compression-mode
+                 (= (length archive-files) 1))
+        (rename-buffer (concat " " (buffer-name)))
+        (archive-extract)))))
 
 ;; Archive mode is suitable only for specially formatted data.
 (put 'archive-mode 'mode-class 'special)
-- 
2.1.3


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-14 11:31                     ` Matthew Leach
@ 2014-11-18 13:04                       ` Daniel Colascione
  2014-11-18 20:12                         ` Matthew Leach
  0 siblings, 1 reply; 19+ messages in thread
From: Daniel Colascione @ 2014-11-18 13:04 UTC (permalink / raw)
  To: Matthew Leach, Eli Zaretskii; +Cc: xah, 1702, cyd

[-- Attachment #1: Type: text/plain, Size: 348 bytes --]

On 11/14/2014 03:31 AM, Matthew Leach wrote:
> Matthew Leach <matthew@mattleach.net> writes:
> 

I don't think the new behavior should be the default. I'd prefer to avoid making a special case for singleton zip files and let users opt into the special case when it's convenient for their workflow. Special cases make programs hard to learn.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2008-12-25 18:30           ` bug#1702: " xah lee
@ 2014-11-18 13:22             ` Rasmus
  0 siblings, 0 replies; 19+ messages in thread
From: Rasmus @ 2014-11-18 13:22 UTC (permalink / raw)
  To: 1702

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> I think it would be nice to go directly to the single file in these
> archives, but, on the other hand, it might be kinda surprising.  If
> you're visiting an archive, you expect to see the list of files in the
> archive.  For one type of archives (ones with a single file in them) to
> work differently may be too inconsistent.
>
> So I dunno...  others who want to chime in?

If I get the zip from somewhere I probably don't know it's a single-file
zip beforehand. . .  So maybe displaying it in tar-mode (or whatever
it's called) and requiring one more RET is better.

How about a zip file that contains only one folder and one file, like
    folder/
    folder/txt

I don't necessarily agree that the proposed behavior is the logically
correct thing to do in the case of an archive that is not "obviously"(?)
a file (like foo.el.gz).

—Rasmus

-- 
However beautiful the theory, you should occasionally look at the evidence






^ permalink raw reply	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-18 13:04                       ` Daniel Colascione
@ 2014-11-18 20:12                         ` Matthew Leach
  2014-11-21 10:10                           ` Eli Zaretskii
  0 siblings, 1 reply; 19+ messages in thread
From: Matthew Leach @ 2014-11-18 20:12 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: xah, 1702, cyd

[-- Attachment #1: Type: text/plain, Size: 523 bytes --]

Daniel Colascione <dancol@dancol.org> writes:

> On 11/14/2014 03:31 AM, Matthew Leach wrote:
>> Matthew Leach <matthew@mattleach.net> writes:
>> 
>
> I don't think the new behavior should be the default. 

It seems as though that is the consensus.  Revised patch included that
turns off the feature by default.

Thanks,
Matt

lisp/ChangeLog:
2014-11-13  Matthew Leach  <matthew@mattleach.net>

        * arc-mode.el (archive-visit-single-files): New.
        (archive-mode): Visit file if archive contains a single file.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: arc-single-file-mode.patch --]
[-- Type: text/x-diff, Size: 1258 bytes --]

diff --git a/lisp/arc-mode.el b/lisp/arc-mode.el
index ef155ee..9833c90 100644
--- a/lisp/arc-mode.el
+++ b/lisp/arc-mode.el
@@ -147,6 +147,15 @@ A local copy of the archive will be used when updating."
   "Hook run when an archive member has been extracted."
   :type 'hook
   :group 'archive)
+
+(defcustom archive-visit-single-files nil
+  "If non-nil, opening an archive with a single file visits that file.
+
+  If this option's value is nil, visiting such archives will
+  display the archive summary."
+  :type '(choice (const :tag "Visit the single file" t)
+                 (const :tag "Show the archive summary" nil))
+  :group 'archive)
 ;; ------------------------------
 ;; Arc archive configuration
 
@@ -742,7 +751,12 @@ archive.
       (if (default-value 'enable-multibyte-characters)
 	  (set-buffer-multibyte 'to))
       (archive-summarize nil)
-      (setq buffer-read-only t))))
+      (setq buffer-read-only t)
+      (when (and archive-visit-single-files
+                 auto-compression-mode
+                 (= (length archive-files) 1))
+        (rename-buffer (concat " " (buffer-name)))
+        (archive-extract)))))
 
 ;; Archive mode is suitable only for specially formatted data.
 (put 'archive-mode 'mode-class 'special)

^ permalink raw reply related	[flat|nested] 19+ messages in thread

* bug#1702: [PATCH]: feature request: correctly display single file zip archive
  2014-11-18 20:12                         ` Matthew Leach
@ 2014-11-21 10:10                           ` Eli Zaretskii
  0 siblings, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2014-11-21 10:10 UTC (permalink / raw)
  To: Matthew Leach; +Cc: xah, 1702-done, cyd

> From: Matthew Leach <matthew@mattleach.net>
> Cc: Eli Zaretskii <eliz@gnu.org>,  xah@xahlee.org,  1702@debbugs.gnu.org,  cyd@stupidchicken.com
> Date: Tue, 18 Nov 2014 20:12:25 +0000
> 
> Daniel Colascione <dancol@dancol.org> writes:
> 
> > On 11/14/2014 03:31 AM, Matthew Leach wrote:
> >> Matthew Leach <matthew@mattleach.net> writes:
> >> 
> >
> > I don't think the new behavior should be the default. 
> 
> It seems as though that is the consensus.  Revised patch included that
> turns off the feature by default.

Thanks, I pushed this in your name, and I'm closing the bug.





^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2014-11-21 10:10 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-28  2:47 bug#1702: feature request: correctly display single file zip archive Chong Yidong
2009-01-16 20:09 ` xah lee
2014-11-13 18:39   ` bug#1702: [PATCH]: " Matthew Leach
2014-11-13 18:50     ` Eli Zaretskii
2014-11-13 19:26       ` Matthew Leach
2014-11-13 19:39         ` Eli Zaretskii
2014-11-13 20:03           ` Matthew Leach
2014-11-13 20:25             ` Eli Zaretskii
2014-11-13 20:50               ` Matthew Leach
2014-11-14  5:27                 ` Eli Zaretskii
2014-11-14 11:06                   ` Matthew Leach
2014-11-14 11:31                     ` Matthew Leach
2014-11-18 13:04                       ` Daniel Colascione
2014-11-18 20:12                         ` Matthew Leach
2014-11-21 10:10                           ` Eli Zaretskii
2014-11-13 19:51         ` Lars Magne Ingebrigtsen
2008-12-25 18:30           ` bug#1702: " xah lee
2014-11-18 13:22             ` bug#1702: [PATCH]: " Rasmus
2014-11-13 19:58           ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).