all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
To: Daniel Brooks <db48x@db48x.net>
Cc: 10347@debbugs.gnu.org
Subject: bug#10347: 24.0.50; archive-mode includes warning messages from unzip in the content of extracted files
Date: Sun, 25 Dec 2011 23:27:05 +0200	[thread overview]
Message-ID: <877h1kxsaw.fsf@mail.jurta.org> (raw)
In-Reply-To: <m3mxaim7j6.fsf@db48x.net> (Daniel Brooks's message of "Thu, 22 Dec 2011 14:23:30 -0800")

> Yes, this is a good idea. However, let's avoid duplicating the code by
> defining a function. Here's what I've got so far, although it doesn't
> actually display the messages, for whatever reason.

We can't remove special treatment of the 7z archiver because it produces
large output even on successful runs, so displaying it would be annoying.

I'd rather move the logic of displaying errors to `archive-extract-by-stdout'
where `stderr-test' defines the condition when not to display the output
redirected to stderr (in case of 7z it searches for the known regexp,
otherwise checks the buffer's size).

1. Tested it with "unzip": (setq archive-zip-extract '("unzip" "-qq" "-c"))

1.1. Visiting `omni.jar' displays in the echo area:

  warning [omni.jar]:  6552040 extra bytes at beginning or within zipfile
    (attempting to process anyway)
  error [omni.jar]:  reported length of central directory is
    -6552040 bytes too long (Atari STZip zipfile?  J.H.Holm ZIPSPLIT 1.1
    zipfile?).  Compensating...

1.2. Visiting the hand-edited `browser.jar' displays in the echo area:

  content/browser/aboutDialog.xul  bad CRC 1ded366d  (should be b80ec225)

2. Tested with using "7z": (setq archive-zip-extract '("7z" "x" "-so"))

2.1. Visiting `omni.jar' displays in the echo area:

  Processing archive: omni.jar
  Error: Can not open file as archive

2.2. Visiting the hand-edited `browser.jar' displays in the echo area:

  Processing archive: browser.jar
  Extracting  content/browser/aboutDialog.xul     CRC Failed
  Sub items Errors: 1

This all errors are reported to the user and easyly noticeable.

=== modified file 'lisp/arc-mode.el'
--- lisp/arc-mode.el	2011-12-15 07:24:10 +0000
+++ lisp/arc-mode.el	2011-12-25 21:27:01 +0000
@@ -1113,13 +1114,24 @@ (defun archive-*-extract (archive name c
     (archive-delete-local tmpfile)
     success))
 
-(defun archive-extract-by-stdout (archive name command &optional stderr-file)
-  (apply 'call-process
-	 (car command)
-	 nil
-	 (if stderr-file (list t stderr-file) t)
-	 nil
-	 (append (cdr command) (list archive name))))
+(defun archive-extract-by-stdout (archive name command &optional stderr-test)
+  (let ((stderr-file (make-temp-file "arc-stderr")))
+    (unwind-protect
+	(prog1
+	    (apply 'call-process
+		   (car command)
+		   nil
+		   (if stderr-file (list t stderr-file) t)
+		   nil
+		   (append (cdr command) (list archive name)))
+	  (with-temp-buffer
+	    (insert-file-contents stderr-file)
+	    (when (if (stringp stderr-test)
+		      (not (search-forward stderr-test nil t))
+		    (> (buffer-size) 0))
+	      (message "%s" (buffer-string)))))
+      (if (file-exists-p stderr-file)
+	  (delete-file stderr-file)))))
 
 (defun archive-extract-other-window ()
   "In archive mode, find this member in another window."
@@ -2095,17 +2125,11 @@ (defun archive-7z-summarize ()
       (apply 'vector files))))
 
 (defun archive-7z-extract (archive name)
-  (let ((tmpfile (make-temp-file "7z-stderr")))
-    ;; 7z doesn't provide a `quiet' option to suppress non-essential
-    ;; stderr messages.  So redirect stderr to a temp file and display it
-    ;; in the echo area when it contains error messages.
-    (prog1 (archive-extract-by-stdout
-	    archive name archive-7z-extract tmpfile)
-      (with-temp-buffer
-	(insert-file-contents tmpfile)
-	(unless (search-forward "Everything is Ok" nil t)
-	  (message "%s" (buffer-string)))
-	(delete-file tmpfile)))))
+  ;; 7z doesn't provide a `quiet' option to suppress non-essential
+  ;; stderr messages.  So redirect stderr to a temp file and display it
+  ;; in the echo area when it contains no message indicating success.
+  (archive-extract-by-stdout
+   archive name archive-7z-extract "Everything is Ok"))
 
 (defun archive-7z-write-file-member (archive descr)
   (archive-*-write-file-member






  reply	other threads:[~2011-12-25 21:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21 21:44 bug#10347: 24.0.50; archive-mode includes warning messages from unzip in the content of extracted files Daniel Brooks
2011-12-22 20:07 ` Juri Linkov
2011-12-22 22:23   ` Daniel Brooks
2011-12-25 21:27     ` Juri Linkov [this message]
2011-12-25 21:28     ` Juri Linkov
2012-09-28 16:38 ` 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=877h1kxsaw.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    --cc=10347@debbugs.gnu.org \
    --cc=db48x@db48x.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.