[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: jka-compr: support *.tbz files?
From: |
Juri Linkov |
Subject: |
Re: jka-compr: support *.tbz files? |
Date: |
Tue, 16 Mar 2004 09:16:30 +0200 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
Kai Grossjohann <address@hidden> 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/