From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: jka-compr: support *.tbz files? Date: Tue, 16 Mar 2004 09:16:30 +0200 Organization: JURTA Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <87fzc9i7n5.fsf@mail.jurta.org> References: <87y8qazb6s.fsf@emptyhost.emptydomain.de> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1079421585 16578 80.91.224.253 (16 Mar 2004 07:19:45 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 16 Mar 2004 07:19:45 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Tue Mar 16 08:19:40 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1B38rT-00022C-00 for ; Tue, 16 Mar 2004 08:19:39 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1B38rT-0000kI-00 for ; Tue, 16 Mar 2004 08:19:39 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B38qt-00082B-2N for emacs-devel@quimby.gnus.org; Tue, 16 Mar 2004 02:19:03 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1B38qL-00081m-7K for emacs-devel@gnu.org; Tue, 16 Mar 2004 02:18:29 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1B38po-0007gW-Co for emacs-devel@gnu.org; Tue, 16 Mar 2004 02:18:28 -0500 Original-Received: from [66.33.219.4] (helo=spork.dreamhost.com) by monty-python.gnu.org with esmtp (Exim 4.30) id 1B38pn-0007f2-6l for emacs-devel@gnu.org; Tue, 16 Mar 2004 02:17:55 -0500 Original-Received: from mail.jurta.org (80-235-32-155-dsl.mus.estpak.ee [80.235.32.155]) by spork.dreamhost.com (Postfix) with ESMTP id 96F2111DDA9; Mon, 15 Mar 2004 23:17:45 -0800 (PST) Original-To: Kai Grossjohann In-Reply-To: <87y8qazb6s.fsf@emptyhost.emptydomain.de> (Kai Grossjohann's message of "Tue, 09 Mar 2004 09:17:31 +0100") User-Agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:20524 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:20524 Kai Grossjohann writes: > I think that *.tbz is a common abbreviation for *.tar.bz2 files. It > would be useful if Emacs supported *.tbz files. > > WDYT? IWBN. > (I guess this means adding "\\.tbz\\'" as an alternative in > file-name-handler-alist and also into auto-mode-alist.) Almost. The jka-compr adds entries to `file-name-handler-alist' from `jka-compr-compression-info-list', but entries to `auto-mode-alist' are added from `jka-compr-mode-alist-additions'. And in the patch below I added it also to `dired-compress-file-suffixes' in dired-aux.el and to `dired-guess-shell-alist-default' in dired-x.el. Actually the following patch is mostly a repost of the lost mail I sent three weeks ago. It adds support for dzip to the same places in jka-compr.el, dired-aux.el and dired-x.el. dzip is a compression format completely compatible with the gzip format, which allows random access on the compressed data. Unfortunately, its compression program can't read data from stdin which is used by jka-compr.el, so its uncompressed contents can't be saved. But it is still useful to only view its contents in Emacs. This patch also provides a good alternate command for archives created without a subdirectory which extract their files into a current directory with clobbering existing files. A alternate command for such cases could be added to `dired-guess-shell-alist-default' like this: "mkdir archivename; tar -C archivename -xvf" And also `dired-guess-shell-case-fold-search' was changed from defvar to defcustom, and its default value changed from nil to t. Index: emacs/lisp/jka-compr.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/jka-compr.el,v retrieving revision 1.79 diff -c -r1.79 jka-compr.el *** emacs/lisp/jka-compr.el 3 Jan 2004 12:11:21 -0000 1.79 --- emacs/lisp/jka-compr.el 16 Mar 2004 01:05:18 -0000 *************** *** 138,143 **** --- 138,147 ---- "bzip2ing" "bzip2" nil "bunzip2ing" "bzip2" ("-d") nil t "BZh"] + ["\\.tbz\\'" + "bzip2ing" "bzip2" nil + "bunzip2ing" "bzip2" ("-d") + nil nil "BZh"] ["\\.tgz\\'" "zipping" "gzip" ("-c" "-q") "unzipping" "gzip" ("-c" "-q" "-d") *************** *** 145,151 **** ["\\.g?z\\(~\\|\\.~[0-9]+~\\)?\\'" "zipping" "gzip" ("-c" "-q") "unzipping" "gzip" ("-c" "-q" "-d") ! t t "\037\213"]) "List of vectors that describe available compression techniques. Each element, which describes a compression technique, is a vector of --- 149,162 ---- ["\\.g?z\\(~\\|\\.~[0-9]+~\\)?\\'" "zipping" "gzip" ("-c" "-q") "unzipping" "gzip" ("-c" "-q" "-d") ! t t "\037\213"] ! ;; dzip is gzip with random access. Its compression program can't ! ;; read/write stdin/out, so .dz files can only be viewed without ! ;; saving, having their contents decompressed with gzip. ! ["\\.dz\\'" ! nil nil nil ! "unzipping" "gzip" ("-c" "-q" "-d") ! nil t "\037\213"]) "List of vectors that describe available compression techniques. Each element, which describes a compression technique, is a vector of *************** *** 160,165 **** --- 171,177 ---- type of compression (nil means no message) compress-program is a program that performs this compression + (nil means visit file in read-only mode) compress-args is a list of args to pass to the compress program *************** *** 199,205 **** :group 'jka-compr) (defcustom jka-compr-mode-alist-additions ! (list (cons "\\.tgz\\'" 'tar-mode)) "A list of pairs to add to `auto-mode-alist' when jka-compr is installed." :type '(repeat (cons string symbol)) :group 'jka-compr) --- 211,217 ---- :group 'jka-compr) (defcustom jka-compr-mode-alist-additions ! (list (cons "\\.tgz\\'" 'tar-mode) (cons "\\.tbz\\'" 'tar-mode)) "A list of pairs to add to `auto-mode-alist' when jka-compr is installed." :type '(repeat (cons string symbol)) :group 'jka-compr) *************** *** 432,437 **** --- 441,449 ---- ;; that `basic-save-buffer' sees the right value. (coding-system-used last-coding-system-used)) + (or compress-program + (error "No compression program defined")) + (setq temp-buffer (get-buffer-create " *jka-compr-wr-temp*")) (with-current-buffer temp-buffer (widen) (erase-buffer)) *************** *** 630,635 **** --- 642,650 ---- ;;; (list 'integerp insval))) ;;; (setq size insval))) ;;; (setq p (cdr p)))) + + (or (jka-compr-info-compress-program info) + (message "You can't save this buffer because compression program is not defined")) (list filename size)) Index: emacs/lisp/dired-aux.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/dired-aux.el,v retrieving revision 1.114 diff -c -r1.114 dired-aux.el *** emacs/lisp/dired-aux.el 8 Feb 2004 22:38:51 -0000 1.114 --- emacs/lisp/dired-aux.el 16 Mar 2004 01:05:17 -0000 *************** *** 659,664 **** --- 660,668 ---- ;; For .z, try gunzip. It might be an old gzip file, ;; or it might be from compact? pack? (which?) but gunzip handles both. ("\\.z\\'" "" "gunzip") + ("\\.dz\\'" "" "dictunzip") + ("\\.tbz\\'" ".tar" "bunzip2") ("\\.bz2\\'" "" "bunzip2") ;; This item controls naming for compression. ("\\.tar\\'" ".tgz" nil)) Index: emacs/lisp/dired-x.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/dired-x.el,v retrieving revision 1.52 diff -c -r1.52 dired-x.el *** emacs/lisp/dired-x.el 28 Sep 2003 09:03:45 -0000 1.52 --- emacs/lisp/dired-x.el 16 Mar 2004 01:05:16 -0000 *************** *** 887,895 **** (defvar dired-guess-shell-alist-default (list ! (list "\\.tar$" '(if dired-guess-shell-gnutar ! (concat dired-guess-shell-gnutar " xvf") ! "tar xvf")) ;; REGEXPS for compressed archives must come before the .Z rule to ;; be recognized: --- 887,903 ---- (defvar dired-guess-shell-alist-default (list ! (list "\\.tar$" ! '(if dired-guess-shell-gnutar ! (concat dired-guess-shell-gnutar " xvf") ! "tar xvf") ! ;; Extract files into a separate subdirectory ! '(if dired-guess-shell-gnutar ! (concat "mkdir " (file-name-sans-extension file) ! "; " dired-guess-shell-gnutar " -C " ! (file-name-sans-extension file) " -xvf") ! (concat "mkdir " (file-name-sans-extension file) ! "; tar -C " (file-name-sans-extension file) " -xvf"))) ;; REGEXPS for compressed archives must come before the .Z rule to ;; be recognized: *************** *** 907,938 **** '(if dired-guess-shell-gnutar (concat dired-guess-shell-gnutar " zxvf") (concat "gunzip -qc * | tar xvf -")) ;; Optional decompression. '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))) ;; bzip2'ed archives ! (list "\\.tar\\.bz2$" "bunzip2 -c * | tar xvf -" ;; Optional decompression. "bunzip2") ! '("\\.shar.Z$" "zcat * | unshar") ! '("\\.shar.g?z$" "gunzip -qc * | unshar") '("\\.e?ps$" "ghostview" "xloadimage" "lpr") ! (list "\\.e?ps.g?z$" "gunzip -qc * | ghostview -" ;; Optional decompression. '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) ! (list "\\.e?ps.Z$" "zcat * | ghostview -" ;; Optional conversion to gzip format. '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") " " dired-guess-shell-znew-switches)) '("\\.patch$" "cat * | patch") ! '("\\.patch.g?z$" "gunzip -qc * | patch") ! (list "\\.patch.Z$" "zcat * | patch" ;; Optional conversion to gzip format. '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") " " dired-guess-shell-znew-switches)) '("\\.dvi$" "xdvi" "dvips") ; preview and printing '("\\.au$" "play") ; play Sun audiofiles '("\\.mpg$" "mpeg_play") --- 915,982 ---- '(if dired-guess-shell-gnutar (concat dired-guess-shell-gnutar " zxvf") (concat "gunzip -qc * | tar xvf -")) + ;; Extract files into a separate subdirectory + '(if dired-guess-shell-gnutar + (concat "mkdir " (file-name-sans-extension file) + "; " dired-guess-shell-gnutar " -C " + (file-name-sans-extension file) " -zxvf") + (concat "mkdir " (file-name-sans-extension file) + "; gunzip -qc * | tar -C " + (file-name-sans-extension file) " -xvf -")) ;; Optional decompression. '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q" ""))) + ;; bzip2'ed archives ! (list "\\.t\\(ar\\.bz2\\|bz\\)$" "bunzip2 -c * | tar xvf -" + ;; Extract files into a separate subdirectory + '(concat "mkdir " (file-name-sans-extension file) + "; bunzip2 -c * | tar -C " + (file-name-sans-extension file) " -xvf -") ;; Optional decompression. "bunzip2") ! '("\\.shar\\.Z$" "zcat * | unshar") ! '("\\.shar\\.g?z$" "gunzip -qc * | unshar") '("\\.e?ps$" "ghostview" "xloadimage" "lpr") ! (list "\\.e?ps\\.g?z$" "gunzip -qc * | ghostview -" ;; Optional decompression. '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) ! (list "\\.e?ps\\.Z$" "zcat * | ghostview -" ;; Optional conversion to gzip format. '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") " " dired-guess-shell-znew-switches)) + '("\\.patch$" "cat * | patch") ! (list "\\.patch\\.g?z$" "gunzip -qc * | patch" ! ;; Optional decompression. ! '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) ! (list "\\.patch\\.Z$" "zcat * | patch" ;; Optional conversion to gzip format. '(concat "znew" (if dired-guess-shell-gzip-quiet " -q") " " dired-guess-shell-znew-switches)) '("\\.dvi$" "xdvi" "dvips") ; preview and printing '("\\.au$" "play") ; play Sun audiofiles '("\\.mpg$" "mpeg_play") *************** *** 945,951 **** '("\\.gif$" "xloadimage") ; view gif pictures '("\\.tif$" "xloadimage") '("\\.png$" "display") ; xloadimage 4.1 doesn't grok PNG ! '("\\.jpg$" "xloadimage") '("\\.fig$" "xfig") ; edit fig pictures '("\\.out$" "xgraph") ; for plotting purposes. '("\\.tex$" "latex" "tex") --- 989,995 ---- '("\\.gif$" "xloadimage") ; view gif pictures '("\\.tif$" "xloadimage") '("\\.png$" "display") ; xloadimage 4.1 doesn't grok PNG ! '("\\.jpe?g$" "xloadimage") '("\\.fig$" "xfig") ; edit fig pictures '("\\.out$" "xgraph") ; for plotting purposes. '("\\.tex$" "latex" "tex") *************** *** 953,966 **** '("\\.pdf$" "xpdf") ; edit PDF files ;; Some other popular archivers. '("\\.zoo$" "zoo x//") - '("\\.zip$" "unzip") '("\\.lzh$" "lharc x") '("\\.arc$" "arc x") '("\\.shar$" "unshar") ;; Compression. (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) (list "\\.bz2$" "bunzip2") (list "\\.Z$" "uncompress" ;; Optional conversion to gzip format. --- 997,1014 ---- '("\\.pdf$" "xpdf") ; edit PDF files ;; Some other popular archivers. + (list "\\.zip$" "unzip" + ;; Extract files into a separate subdirectory + '(concat "unzip" (if dired-guess-shell-gzip-quiet " -q") + " -d " (file-name-sans-extension file))) '("\\.zoo$" "zoo x//") '("\\.lzh$" "lharc x") '("\\.arc$" "arc x") '("\\.shar$" "unshar") ;; Compression. (list "\\.g?z$" '(concat "gunzip" (if dired-guess-shell-gzip-quiet " -q"))) + (list "\\.dz$" "dictunzip") (list "\\.bz2$" "bunzip2") (list "\\.Z$" "uncompress" ;; Optional conversion to gzip format. *************** *** 998,1006 **** :group 'dired-x :type '(alist :key-type regexp :value-type (repeat sexp))) ! (defvar dired-guess-shell-case-fold-search nil ! "*If non-nil, `dired-guess-shell-alist-default' and ! `dired-guess-shell-alist-user' are matched case-insensitively.") (defun dired-guess-default (files) "Guess a shell commands for FILES. Return command or list of commands. --- 1046,1056 ---- :group 'dired-x :type '(alist :key-type regexp :value-type (repeat sexp))) ! (defcustom dired-guess-shell-case-fold-search t ! "If non-nil, `dired-guess-shell-alist-default' and ! `dired-guess-shell-alist-user' are matched case-insensitively." ! :group 'dired-x ! :type 'boolean) (defun dired-guess-default (files) "Guess a shell commands for FILES. Return command or list of commands. -- Juri Linkov http://www.jurta.org/emacs/