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#5475: Archives with filenames with square brackets Date: Mon, 01 Feb 2010 23:55:35 +0200 Organization: JURTA Message-ID: <87r5p4k4dk.fsf@mail.jurta.org> References: <874omakv2m.fsf@mail.jurta.org> <87eilca86n.fsf@stupidchicken.com> <83r5pc4jye.fsf@gnu.org> <87vden4h9x.fsf@stupidchicken.com> <83ljfj4fje.fsf@gnu.org> <87r5pavvrm.fsf@stupidchicken.com> <838wbiszy7.fsf@gnu.org> <87y6jfcg8b.fsf@mail.jurta.org> <83d40qj4av.fsf@gnu.org> <87aavua6gb.fsf@mail.jurta.org> <838wbei224.fsf@gnu.org> <87zl3uorzn.fsf@mail.jurta.org> <83zl3th9r4.fsf@gnu.org> <87aavtw8fs.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1265065111 24088 80.91.229.12 (1 Feb 2010 22:58:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 1 Feb 2010 22:58:31 +0000 (UTC) Cc: 5475@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 01 23:58:27 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Nc5DZ-0001p4-Pw for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Feb 2010 23:58:26 +0100 Original-Received: from localhost ([127.0.0.1]:56421 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nc5DY-0001Rj-2U for geb-bug-gnu-emacs@m.gmane.org; Mon, 01 Feb 2010 17:58:04 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nc5D8-0001HM-6l for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2010 17:57:38 -0500 Original-Received: from [199.232.76.173] (port=59755 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nc5D6-0001Ge-BR for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2010 17:57:36 -0500 Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nc5D2-0000VQ-FZ for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2010 17:57:35 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:53015) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Nc5D1-0000V1-Sl for bug-gnu-emacs@gnu.org; Mon, 01 Feb 2010 17:57:32 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1Nc56k-0006Ub-9C; Mon, 01 Feb 2010 17:51:02 -0500 X-Loop: bug-gnu-emacs@gnu.org Resent-From: Juri Linkov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 01 Feb 2010 22:51:02 +0000 Resent-Message-ID: Resent-Sender: bug-gnu-emacs@gnu.org X-Emacs-PR-Message: followup 5475 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 5475-submit@debbugs.gnu.org id=B5475.126506460824921 (code B ref 5475); Mon, 01 Feb 2010 22:51:02 +0000 Original-Received: (at 5475) by debbugs.gnu.org; 1 Feb 2010 22:50:08 +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 1Nc55p-0006Ts-Ey for submit@debbugs.gnu.org; Mon, 01 Feb 2010 17:50:08 -0500 Original-Received: from smtp-out4.starman.ee ([85.253.0.6] helo=mx2.starman.ee) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Nc55l-0006TP-Hr for 5475@debbugs.gnu.org; Mon, 01 Feb 2010 17:50:02 -0500 X-Virus-Scanned: by Amavisd-New at mx2.starman.ee Original-Received: from mail.starman.ee (82.131.53.239.cable.starman.ee [82.131.53.239]) by mx2.starman.ee (Postfix) with ESMTP id 7E0CA3F40AA; Tue, 2 Feb 2010 00:49:51 +0200 (EET) In-Reply-To: (Stefan Monnier's message of "Mon, 01 Feb 2010 10:43:01 -0500") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.92 (x86_64-pc-linux-gnu) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Mon, 01 Feb 2010 17:51:02 -0500 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) 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: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:34848 Archived-At: > AFAIK 7zip is Free Software, but adding 7z support would be a new > feature, so we would probably be better off insalling it into the > `pending' branch. Below is minimal support for the 7z format for the `pending' branch. Fortunately, 7z provides so-called "technical" mode for the list command (-slt) that outputs file information in a simple fixed format, so we could rely on it. In `archive-7z-extract' stderr is thrown away because 7z doesn't have a switch to make it silent. === modified file 'lisp/arc-mode.el' --- lisp/arc-mode.el 2010-01-28 20:06:36 +0000 +++ lisp/arc-mode.el 2010-02-01 21:48:09 +0000 @@ -52,17 +52,17 @@ ;; ARCHIVE TYPES: Currently only the archives below are handled, but the ;; structure for handling just about anything is in place. ;; -;; Arc Lzh Zip Zoo Rar -;; ---------------------------------------- -;; View listing Intern Intern Intern Intern Y -;; Extract member Y Y Y Y Y -;; Save changed member Y Y Y Y N -;; Add new member N N N N N -;; Delete member Y Y Y Y N -;; Rename member Y Y N N N -;; Chmod - Y Y - N -;; Chown - Y - - N -;; Chgrp - Y - - N +;; Arc Lzh Zip Zoo Rar 7z +;; -------------------------------------------- +;; View listing Intern Intern Intern Intern Y Y +;; Extract member Y Y Y Y Y Y +;; Save changed member Y Y Y Y N N +;; Add new member N N N N N N +;; Delete member Y Y Y Y N N +;; Rename member Y Y N N N N +;; Chmod - Y Y - N N +;; Chown - Y - - N N +;; Chgrp - Y - - N N ;; ;; Special thanks to Bill Brodie for very useful tips ;; on the first released version of this package. @@ -315,6 +315,20 @@ (defcustom archive-zoo-write-file-member :inline t (string :format "%v"))) :group 'archive-zoo) +;; ------------------------------ +;; 7z archive configuration + +(defcustom archive-7z-extract + '("7z" "x" "-so") + "Program and its options to run in order to extract a 7z file member. +Extraction should happen to standard output. Archive and member name will +be added." + :type '(list (string :tag "Program") + (repeat :tag "Options" + :inline t + (string :format "%v"))) + :group 'archive-7z) + ;; ------------------------------------------------------------------------- ;;; Section: Variables @@ -732,6 +746,7 @@ (defun archive-find-type () ((and (looking-at "MZ") (re-search-forward "Rar!" (+ (point) 100000) t)) 'rar-exe) + ((looking-at "7z\274\257\047\034") '7z) (t (error "Buffer format not recognized"))))) ;; ------------------------------------------------------------------------- @@ -1084,6 +1099,14 @@ (defun archive-extract-by-stdout (archiv nil (append (cdr command) (list archive name)))) +(defun archive-extract-by-stdout-without-stderr (archive name command) + (apply 'call-process + (car command) + nil + '(t nil) + nil + (append (cdr command) (list archive name)))) + (defun archive-extract-other-window () "In archive mode, find this member in another window." (interactive) @@ -1995,7 +2023,57 @@ (defun archive-rar-exe-extract (archive (if tmpbuf (kill-buffer tmpbuf)) (delete-file tmpfile)))) +;; ------------------------------------------------------------------------- +;;; Section: 7z Archives + +(defun archive-7z-summarize () + (let ((maxname 10) + (maxsize 5) + (file buffer-file-name) + (files ())) + (with-temp-buffer + (call-process "7z" nil t nil "l" "-slt" file) + (goto-char (point-min)) + (re-search-forward "^-+\n") + (while (re-search-forward "^Path = \\(.*\\)\n" nil t) + (goto-char (match-end 0)) + (let ((name (match-string 1)) + (size (save-excursion + (and (re-search-forward "^Size = \\(.*\\)\n") + (match-string 1)))) + (time (save-excursion + (and (re-search-forward "^Modified = \\(.*\\)\n") + (match-string 1))))) + (if (> (length name) maxname) (setq maxname (length name))) + (if (> (length size) maxsize) (setq maxsize (length size))) + (push (vector name name nil nil time nil nil size) + files)))) + (setq files (nreverse files)) + (goto-char (point-min)) + (let* ((format (format " %%%ds %%s %%s" maxsize)) + (sep (format format (make-string maxsize ?-) "-------------------" "")) + (column (length sep))) + (insert (format format "Size " "Date Time " " Filename") "\n") + (insert sep (make-string maxname ?-) "\n") + (archive-summarize-files (mapcar (lambda (desc) + (let ((text + (format format + (aref desc 7) + (aref desc 4) + (aref desc 1)))) + (vector text + column + (length text)))) + files)) + (insert sep (make-string maxname ?-) "\n") + (apply 'vector files)))) + +(defun archive-7z-extract (archive name) + ;; Throw away stderr because 7z doesn't have a switch to make it silent. + (archive-extract-by-stdout-without-stderr + archive name archive-7z-extract)) +;; ------------------------------------------------------------------------- ;;; Section `ar' archives. ;; TODO: we currently only handle the basic format of ar archives, === modified file 'lisp/files.el' --- lisp/files.el 2010-01-27 03:36:36 +0000 +++ lisp/files.el 2010-02-01 21:45:39 +0000 @@ -2252,8 +2252,8 @@ (defvar auto-mode-alist ;; The list of archive file extensions should be in sync with ;; `auto-coding-alist' with `no-conversion' coding system. ("\\.\\(\ -arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|\ -ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\)\\'" . archive-mode) +arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\ +ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7Z\\)\\'" . archive-mode) ("\\.\\(sx[dmicw]\\|od[fgpst]\\|oxt\\)\\'" . archive-mode) ;OpenOffice.org ("\\.\\(deb\\|[oi]pk\\)\\'" . archive-mode) ; Debian/Opkg packages. ;; Mailer puts message to be edited in === modified file 'lisp/international/mule.el' --- lisp/international/mule.el 2010-01-13 08:35:10 +0000 +++ lisp/international/mule.el 2010-02-01 21:43:42 +0000 @@ -1626,8 +1626,8 @@ (defcustom auto-coding-alist ;; .exe and .EXE are added to support archive-mode looking at DOS ;; self-extracting exe archives. (purecopy '(("\\.\\(\ -arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|\ -ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\)\\'" +arc\\|zip\\|lzh\\|lha\\|zoo\\|[jew]ar\\|xpi\\|rar\\|7z\\|\ +ARC\\|ZIP\\|LZH\\|LHA\\|ZOO\\|[JEW]AR\\|XPI\\|RAR\\|7z\\)\\'" . no-conversion-multibyte) ("\\.\\(exe\\|EXE\\)\\'" . no-conversion) ("\\.\\(sx[dmicw]\\|odt\\|tar\\|tgz\\)\\'" . no-conversion) -- Juri Linkov http://www.jurta.org/emacs/