diff options
| -rw-r--r-- | lisp/uncompress.el | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/lisp/uncompress.el b/lisp/uncompress.el index cdfa1882d38..9da57a32d4d 100644 --- a/lisp/uncompress.el +++ b/lisp/uncompress.el | |||
| @@ -24,10 +24,12 @@ | |||
| 24 | ;;; Commentary: | 24 | ;;; Commentary: |
| 25 | 25 | ||
| 26 | ;; This package can be used to arrange for automatic uncompress of | 26 | ;; This package can be used to arrange for automatic uncompress of |
| 27 | ;; files packed with the UNIX compress(1) utility when they are visited. | 27 | ;; compressed files when they are visited. |
| 28 | ;; All that's necessary is to load it. This can conveniently be done from | 28 | ;; All that's necessary is to load it. This can conveniently be done from |
| 29 | ;; your .emacs file. | 29 | ;; your .emacs file. |
| 30 | 30 | ||
| 31 | ;; M-x auto-compression-mode is a more modern replacement for this package. | ||
| 32 | |||
| 31 | ;;; Code: | 33 | ;;; Code: |
| 32 | 34 | ||
| 33 | ;; When we are about to make a backup file, | 35 | ;; When we are about to make a backup file, |
| @@ -50,6 +52,9 @@ | |||
| 50 | (or (assoc "\\.gz$" auto-mode-alist) | 52 | (or (assoc "\\.gz$" auto-mode-alist) |
| 51 | (setq auto-mode-alist | 53 | (setq auto-mode-alist |
| 52 | (cons '("\\.gz$" . uncompress-while-visiting) auto-mode-alist))) | 54 | (cons '("\\.gz$" . uncompress-while-visiting) auto-mode-alist))) |
| 55 | (or (assoc "\\.tgz$" auto-mode-alist) | ||
| 56 | (setq auto-mode-alist | ||
| 57 | (cons '("\\.tgz$" . uncompress-while-visiting) auto-mode-alist))) | ||
| 53 | 58 | ||
| 54 | (defun uncompress-while-visiting () | 59 | (defun uncompress-while-visiting () |
| 55 | "Temporary \"major mode\" used for .Z and .gz files, to uncompress them. | 60 | "Temporary \"major mode\" used for .Z and .gz files, to uncompress them. |
| @@ -61,7 +66,11 @@ It then selects a major mode from the uncompressed file name and contents." | |||
| 61 | (if (and (not (null buffer-file-name)) | 66 | (if (and (not (null buffer-file-name)) |
| 62 | (string-match "\\.gz$" buffer-file-name)) | 67 | (string-match "\\.gz$" buffer-file-name)) |
| 63 | (set-visited-file-name | 68 | (set-visited-file-name |
| 64 | (substring buffer-file-name 0 (match-beginning 0))))) | 69 | (substring buffer-file-name 0 (match-beginning 0))) |
| 70 | (if (and (not (null buffer-file-name)) | ||
| 71 | (string-match "\\.tgz$" buffer-file-name)) | ||
| 72 | (set-visited-file-name | ||
| 73 | (concat (substring buffer-file-name 0 (match-beginning 0)) ".tar"))))) | ||
| 65 | (message "Uncompressing...") | 74 | (message "Uncompressing...") |
| 66 | (let ((buffer-read-only nil)) | 75 | (let ((buffer-read-only nil)) |
| 67 | (shell-command-on-region (point-min) (point-max) uncompress-program t)) | 76 | (shell-command-on-region (point-min) (point-max) uncompress-program t)) |