From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs 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 Organization: JURTA Message-ID: <877h1kxsaw.fsf@mail.jurta.org> References: <874nwsbcc4.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1324850149 23806 80.91.229.12 (25 Dec 2011 21:55:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 25 Dec 2011 21:55:49 +0000 (UTC) Cc: 10347@debbugs.gnu.org To: Daniel Brooks Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 25 22:55:45 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew2g-00027X-4H for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 22:55:42 +0100 Original-Received: from localhost ([::1]:52986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2f-0002pO-B8 for geb-bug-gnu-emacs@m.gmane.org; Sun, 25 Dec 2011 16:55:41 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:43746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2b-0002kw-23 for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:38 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rew2Y-0000Dq-CA for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:37 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52073) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rew2Y-0000Dd-6d for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:55:34 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Rew4w-0005vR-EV for bug-gnu-emacs@gnu.org; Sun, 25 Dec 2011 16:58:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Dec 2011 21:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10347 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10347-submit@debbugs.gnu.org id=B10347.132485025822722 (code B ref 10347); Sun, 25 Dec 2011 21:58:02 +0000 Original-Received: (at 10347) by debbugs.gnu.org; 25 Dec 2011 21:57:38 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew4Y-0005uR-JF for submit@debbugs.gnu.org; Sun, 25 Dec 2011 16:57:38 -0500 Original-Received: from smarty.dreamhost.com ([208.113.175.8]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Rew4W-0005uI-Ro for 10347@debbugs.gnu.org; Sun, 25 Dec 2011 16:57:37 -0500 Original-Received: from ps18281.dreamhostps.com (ps18281.dreamhost.com [69.163.218.105]) by smarty.dreamhost.com (Postfix) with ESMTP id EB96F6840C7; Sun, 25 Dec 2011 13:55:06 -0800 (PST) Original-Received: from localhost (ps18281.dreamhostps.com [69.163.218.105]) by ps18281.dreamhostps.com (Postfix) with ESMTP id 7C1AE451C686; Sun, 25 Dec 2011 13:54:30 -0800 (PST) In-Reply-To: (Daniel Brooks's message of "Thu, 22 Dec 2011 14:23:30 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 25 Dec 2011 16:58:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.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-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:55193 Archived-At: > 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