Mercurial > emacs
annotate lisp/jka-cmpr-hook.el @ 62320:250393a33b15
*** empty log message ***
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sat, 14 May 2005 12:30:08 +0000 |
parents | 4f5570943f21 |
children | 29c6e26ca9a1 |
rev | line source |
---|---|
62107
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
1 ;;; jka-cmpr-hook.el --- preloaded code to enable jka-compr.el |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
2 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
4 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
5 ;; Author: jka@ece.cmu.edu (Jay K. Adams) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
6 ;; Maintainer: FSF |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
7 ;; Keywords: data |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
8 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
10 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
13 ;; the Free Software Foundation; either version 2, or (at your option) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
14 ;; any later version. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
15 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
20 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
24 ;; Boston, MA 02111-1307, USA. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
25 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
26 ;;; Commentary: |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
27 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
28 ;; This file contains the code to enable and disable Auto-Compression mode. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
29 ;; It is preloaded. The guts of this mode are in jka-compr.el, which |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
30 ;; is loaded only when you really try to uncompress something. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
31 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
32 ;;; Code: |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
33 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
34 (defgroup compression nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
35 "Data compression utilities" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
36 :group 'data) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
37 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
38 (defgroup jka-compr nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
39 "jka-compr customization" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
40 :group 'compression) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
41 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
42 ;;; I have this defined so that .Z files are assumed to be in unix |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
43 ;;; compress format; and .gz files, in gzip format, and .bz2 files in bzip fmt. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
44 (defcustom jka-compr-compression-info-list |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
45 ;;[regexp |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
46 ;; compr-message compr-prog compr-args |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
47 ;; uncomp-message uncomp-prog uncomp-args |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
48 ;; can-append auto-mode-flag strip-extension-flag file-magic-bytes] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
49 '(["\\.Z\\(~\\|\\.~[0-9]+~\\)?\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
50 "compressing" "compress" ("-c") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
51 "uncompressing" "uncompress" ("-c") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
52 nil t "\037\235"] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
53 ;; Formerly, these had an additional arg "-c", but that fails with |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
54 ;; "Version 0.1pl2, 29-Aug-97." (RedHat 5.1 GNU/Linux) and |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
55 ;; "Version 0.9.0b, 9-Sept-98". |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
56 ["\\.bz2\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
57 "bzip2ing" "bzip2" nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
58 "bunzip2ing" "bzip2" ("-d") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
59 nil t "BZh"] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
60 ["\\.tbz\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
61 "bzip2ing" "bzip2" nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
62 "bunzip2ing" "bzip2" ("-d") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
63 nil nil "BZh"] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
64 ["\\.tgz\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
65 "compressing" "gzip" ("-c" "-q") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
66 "uncompressing" "gzip" ("-c" "-q" "-d") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
67 t nil "\037\213"] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
68 ["\\.g?z\\(~\\|\\.~[0-9]+~\\)?\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
69 "compressing" "gzip" ("-c" "-q") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
70 "uncompressing" "gzip" ("-c" "-q" "-d") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
71 t t "\037\213"] |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
72 ;; dzip is gzip with random access. Its compression program can't |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
73 ;; read/write stdin/out, so .dz files can only be viewed without |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
74 ;; saving, having their contents decompressed with gzip. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
75 ["\\.dz\\'" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
76 nil nil nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
77 "uncompressing" "gzip" ("-c" "-q" "-d") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
78 nil t "\037\213"]) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
79 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
80 "List of vectors that describe available compression techniques. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
81 Each element, which describes a compression technique, is a vector of |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
82 the form [REGEXP COMPRESS-MSG COMPRESS-PROGRAM COMPRESS-ARGS |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
83 UNCOMPRESS-MSG UNCOMPRESS-PROGRAM UNCOMPRESS-ARGS |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
84 APPEND-FLAG STRIP-EXTENSION-FLAG FILE-MAGIC-CHARS], where: |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
85 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
86 regexp is a regexp that matches filenames that are |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
87 compressed with this format |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
88 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
89 compress-msg is the message to issue to the user when doing this |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
90 type of compression (nil means no message) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
91 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
92 compress-program is a program that performs this compression |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
93 (nil means visit file in read-only mode) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
94 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
95 compress-args is a list of args to pass to the compress program |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
96 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
97 uncompress-msg is the message to issue to the user when doing this |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
98 type of uncompression (nil means no message) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
99 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
100 uncompress-program is a program that performs this compression |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
101 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
102 uncompress-args is a list of args to pass to the uncompress program |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
103 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
104 append-flag is non-nil if this compression technique can be |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
105 appended |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
106 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
107 strip-extension-flag non-nil means strip the regexp from file names |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
108 before attempting to set the mode. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
109 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
110 file-magic-chars is a string of characters that you would find |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
111 at the beginning of a file compressed in this way. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
112 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
113 Because of the way `call-process' is defined, discarding the stderr output of |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
114 a program adds the overhead of starting a shell each time the program is |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
115 invoked." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
116 :type '(repeat (vector regexp |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
117 (choice :tag "Compress Message" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
118 (string :format "%v") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
119 (const :tag "No Message" nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
120 (choice :tag "Compress Program" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
121 (string) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
122 (const :tag "None" nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
123 (repeat :tag "Compress Arguments" string) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
124 (choice :tag "Uncompress Message" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
125 (string :format "%v") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
126 (const :tag "No Message" nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
127 (choice :tag "Uncompress Program" |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
128 (string) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
129 (const :tag "None" nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
130 (repeat :tag "Uncompress Arguments" string) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
131 (boolean :tag "Append") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
132 (boolean :tag "Strip Extension") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
133 (string :tag "Magic Bytes"))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
134 :group 'jka-compr) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
135 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
136 (defcustom jka-compr-mode-alist-additions |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
137 (list (cons "\\.tgz\\'" 'tar-mode) (cons "\\.tbz\\'" 'tar-mode)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
138 "A list of pairs to add to `auto-mode-alist' when jka-compr is installed." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
139 :type '(repeat (cons string symbol)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
140 :group 'jka-compr) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
141 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
142 (defcustom jka-compr-load-suffixes '(".gz") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
143 "List of suffixes to try when loading files." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
144 :type '(repeat string) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
145 :group 'jka-compr) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
146 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
147 ;; List of all the elements we actually added to file-coding-system-alist. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
148 (defvar jka-compr-added-to-file-coding-system-alist nil) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
149 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
150 (defvar jka-compr-file-name-handler-entry |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
151 nil |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
152 "The entry in `file-name-handler-alist' used by the jka-compr I/O functions.") |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
153 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
154 (defun jka-compr-build-file-regexp () |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
155 (mapconcat |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
156 'jka-compr-info-regexp |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
157 jka-compr-compression-info-list |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
158 "\\|")) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
159 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
160 ;;; Functions for accessing the return value of jka-compr-get-compression-info |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
161 (defun jka-compr-info-regexp (info) (aref info 0)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
162 (defun jka-compr-info-compress-message (info) (aref info 1)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
163 (defun jka-compr-info-compress-program (info) (aref info 2)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
164 (defun jka-compr-info-compress-args (info) (aref info 3)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
165 (defun jka-compr-info-uncompress-message (info) (aref info 4)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
166 (defun jka-compr-info-uncompress-program (info) (aref info 5)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
167 (defun jka-compr-info-uncompress-args (info) (aref info 6)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
168 (defun jka-compr-info-can-append (info) (aref info 7)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
169 (defun jka-compr-info-strip-extension (info) (aref info 8)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
170 (defun jka-compr-info-file-magic-bytes (info) (aref info 9)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
171 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
172 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
173 (defun jka-compr-get-compression-info (filename) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
174 "Return information about the compression scheme of FILENAME. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
175 The determination as to which compression scheme, if any, to use is |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
176 based on the filename itself and `jka-compr-compression-info-list'." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
177 (catch 'compression-info |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
178 (let ((case-fold-search nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
179 (mapcar |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
180 (function (lambda (x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
181 (and (string-match (jka-compr-info-regexp x) filename) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
182 (throw 'compression-info x)))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
183 jka-compr-compression-info-list) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
184 nil))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
185 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
186 (defun jka-compr-install () |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
187 "Install jka-compr. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
188 This adds entries to `file-name-handler-alist' and `auto-mode-alist' |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
189 and `inhibit-first-line-modes-suffixes'." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
190 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
191 (setq jka-compr-file-name-handler-entry |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
192 (cons (jka-compr-build-file-regexp) 'jka-compr-handler)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
193 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
194 (setq file-name-handler-alist (cons jka-compr-file-name-handler-entry |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
195 file-name-handler-alist)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
196 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
197 (setq jka-compr-added-to-file-coding-system-alist nil) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
198 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
199 (mapcar |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
200 (function (lambda (x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
201 ;; Don't do multibyte encoding on the compressed files. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
202 (let ((elt (cons (jka-compr-info-regexp x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
203 '(no-conversion . no-conversion)))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
204 (setq file-coding-system-alist |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
205 (cons elt file-coding-system-alist)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
206 (setq jka-compr-added-to-file-coding-system-alist |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
207 (cons elt jka-compr-added-to-file-coding-system-alist))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
208 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
209 (and (jka-compr-info-strip-extension x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
210 ;; Make entries in auto-mode-alist so that modes |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
211 ;; are chosen right according to the file names |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
212 ;; sans `.gz'. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
213 (setq auto-mode-alist |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
214 (cons (list (jka-compr-info-regexp x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
215 nil 'jka-compr) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
216 auto-mode-alist)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
217 ;; Also add these regexps to |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
218 ;; inhibit-first-line-modes-suffixes, so that a |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
219 ;; -*- line in the first file of a compressed tar |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
220 ;; file doesn't override tar-mode. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
221 (setq inhibit-first-line-modes-suffixes |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
222 (cons (jka-compr-info-regexp x) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
223 inhibit-first-line-modes-suffixes))))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
224 jka-compr-compression-info-list) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
225 (setq auto-mode-alist |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
226 (append auto-mode-alist jka-compr-mode-alist-additions)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
227 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
228 ;; Make sure that (load "foo") will find /bla/foo.el.gz. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
229 (setq load-suffixes |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
230 (apply 'append |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
231 (mapcar (lambda (suffix) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
232 (cons suffix |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
233 (mapcar (lambda (ext) (concat suffix ext)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
234 jka-compr-load-suffixes))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
235 load-suffixes)))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
236 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
237 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
238 (defun jka-compr-installed-p () |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
239 "Return non-nil if jka-compr is installed. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
240 The return value is the entry in `file-name-handler-alist' for jka-compr." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
241 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
242 (let ((fnha file-name-handler-alist) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
243 (installed nil)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
244 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
245 (while (and fnha (not installed)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
246 (and (eq (cdr (car fnha)) 'jka-compr-handler) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
247 (setq installed (car fnha))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
248 (setq fnha (cdr fnha))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
249 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
250 installed)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
251 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
252 (define-minor-mode auto-compression-mode |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
253 "Toggle automatic file compression and uncompression. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
254 With prefix argument ARG, turn auto compression on if positive, else off. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
255 Returns the new status of auto compression (non-nil means on)." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
256 :global t :group 'jka-compr |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
257 (let* ((installed (jka-compr-installed-p)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
258 (flag auto-compression-mode)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
259 (cond |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
260 ((and flag installed) t) ; already installed |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
261 ((and (not flag) (not installed)) nil) ; already not installed |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
262 (flag (jka-compr-install)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
263 (t (jka-compr-uninstall))))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
264 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
265 (defmacro with-auto-compression-mode (&rest body) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
266 "Evalute BODY with automatic file compression and uncompression enabled." |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
267 (let ((already-installed (make-symbol "already-installed"))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
268 `(let ((,already-installed (jka-compr-installed-p))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
269 (unwind-protect |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
270 (progn |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
271 (unless ,already-installed |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
272 (jka-compr-install)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
273 ,@body) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
274 (unless ,already-installed |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
275 (jka-compr-uninstall)))))) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
276 (put 'with-auto-compression-mode 'lisp-indent-function 0) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
277 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
278 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
279 ;;; This is what we need to know about jka-compr-handler |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
280 ;;; in order to decide when to call it. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
281 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
282 (put 'jka-compr-handler 'safe-magic t) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
283 (put 'jka-compr-handler 'operations '(jka-compr-byte-compiler-base-file-name |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
284 write-region insert-file-contents |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
285 file-local-copy load)) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
286 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
287 ;;; Turn on the mode. |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
288 (auto-compression-mode 1) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
289 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
290 (provide 'jka-cmpr-hook) |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
291 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
292 ;; arch-tag: 4bd73429-f400-45fe-a065-270a113e31a8 |
4f5570943f21
Renamed jka-comp-hook.el to jka-cmpr-hook.el.
Eli Zaretskii <eliz@gnu.org>
parents:
diff
changeset
|
293 ;;; jka-cmpr-hook.el ends here |