Mercurial > emacs
annotate lisp/jka-compr.el @ 101061:d7b4cff6207d
Remove gs.elc dependency.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sat, 10 Jan 2009 13:07:48 +0000 |
parents | a9dc0e7c3f2b |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
13337 | 1 ;;; jka-compr.el --- reading/writing/loading compressed files |
2 | |
74442 | 3 ;; Copyright (C) 1993, 1994, 1995, 1997, 1999, 2000, 2001, 2002, 2003, |
100908 | 4 ;; 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. |
6002 | 5 |
6 ;; Author: jka@ece.cmu.edu (Jay K. Adams) | |
17976 | 7 ;; Maintainer: FSF |
6002 | 8 ;; Keywords: data |
9 | |
13514
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
10 ;; This file is part of GNU Emacs. |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
11 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93611
diff
changeset
|
12 ;; GNU Emacs is free software: you can redistribute it and/or modify |
13514
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
13 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93611
diff
changeset
|
14 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93611
diff
changeset
|
15 ;; (at your option) any later version. |
13514
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
16 |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
17 ;; GNU Emacs is distributed in the hope that it will be useful, |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
20 ;; GNU General Public License for more details. |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
21 |
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
22 ;; You should have received a copy of the GNU General Public License |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93611
diff
changeset
|
23 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
13514
0e46e8075a1d
(auto-compression-mode): Make arg optional.
Richard M. Stallman <rms@gnu.org>
parents:
13337
diff
changeset
|
24 |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
34732
diff
changeset
|
25 ;;; Commentary: |
6002 | 26 |
14169 | 27 ;; This package implements low-level support for reading, writing, |
28 ;; and loading compressed files. It hooks into the low-level file | |
29 ;; I/O functions (including write-region and insert-file-contents) so | |
30 ;; that they automatically compress or uncompress a file if the file | |
31 ;; appears to need it (based on the extension of the file name). | |
32 ;; Packages like Rmail, VM, GNUS, and Info should be able to work | |
33 ;; with compressed files without modification. | |
6002 | 34 |
35 | |
14169 | 36 ;; INSTRUCTIONS: |
37 ;; | |
32497 | 38 ;; To use jka-compr, invoke the command `auto-compression-mode' (which |
39 ;; see), or customize the variable of the same name. Its operation | |
40 ;; should be transparent to the user (except for messages appearing when | |
41 ;; a file is being compressed or uncompressed). | |
14169 | 42 ;; |
43 ;; The variable, jka-compr-compression-info-list can be used to | |
44 ;; customize jka-compr to work with other compression programs. | |
45 ;; The default value of this variable allows jka-compr to work with | |
46 ;; Unix compress and gzip. | |
47 ;; | |
48 ;; If you don't want messages about compressing and decompressing | |
75423
d03ddfe8401e
(jka-compr-shell): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
49 ;; to show up in the echo area, you can set the compress-msg and |
d03ddfe8401e
(jka-compr-shell): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
50 ;; decompress-msg fields of the jka-compr-compression-info-list to |
14169 | 51 ;; nil. |
6002 | 52 |
53 | |
14169 | 54 ;; APPLICATION NOTES: |
55 ;; | |
56 ;; crypt++ | |
45720 | 57 ;; jka-compr can coexist with crypt++ if you take all the decompression |
14169 | 58 ;; entries out of the crypt-encoding-list. Clearly problems will arise if |
59 ;; you have two programs trying to compress/decompress files. jka-compr | |
60 ;; will not "work with" crypt++ in the following sense: you won't be able to | |
61 ;; decode encrypted compressed files--that is, files that have been | |
62 ;; compressed then encrypted (in that order). Theoretically, crypt++ and | |
63 ;; jka-compr could properly handle a file that has been encrypted then | |
64 ;; compressed, but there is little point in trying to compress an encrypted | |
65 ;; file. | |
66 ;; | |
6002 | 67 |
68 | |
14169 | 69 ;; ACKNOWLEDGMENTS |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
70 ;; |
14169 | 71 ;; jka-compr is a V19 adaptation of jka-compr for V18 of Emacs. Many people |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
72 ;; have made helpful suggestions, reported bugs, and even fixed bugs in |
14169 | 73 ;; jka-compr. I recall the following people as being particularly helpful. |
74 ;; | |
75 ;; Jean-loup Gailly | |
76 ;; David Hughes | |
77 ;; Richard Pieri | |
78 ;; Daniel Quinlan | |
79 ;; Chris P. Ross | |
80 ;; Rick Sladkey | |
81 ;; | |
82 ;; Andy Norman's ange-ftp was the inspiration for the original jka-compr for | |
83 ;; Version 18 of Emacs. | |
84 ;; | |
85 ;; After I had made progress on the original jka-compr for V18, I learned of a | |
86 ;; package written by Kazushi Jam Marukawa, called jam-zcat, that did exactly | |
87 ;; what I was trying to do. I looked over the jam-zcat source code and | |
88 ;; probably got some ideas from it. | |
89 ;; | |
6002 | 90 |
91 ;;; Code: | |
92 | |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
93 (require 'jka-cmpr-hook) |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
94 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
95 (defcustom jka-compr-shell "sh" |
100171 | 96 "Shell to be used for calling compression programs. |
75423
d03ddfe8401e
(jka-compr-shell): Doc fix.
Juanma Barranquero <lekktu@gmail.com>
parents:
75347
diff
changeset
|
97 NOTE: Not used in MS-DOS and Windows systems." |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
98 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
99 :group 'jka-compr) |
6002 | 100 |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
101 (defvar jka-compr-use-shell |
21633
185e8e424ee9
(jka-compr-use-shell) [ms-dos, windows-nt]: Do not use a shell.
Richard M. Stallman <rms@gnu.org>
parents:
20893
diff
changeset
|
102 (not (memq system-type '(ms-dos windows-nt)))) |
6002 | 103 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
104 (defvar jka-compr-really-do-compress nil |
60781
4dec7a239cfa
(jka-compr-really-do-compress): Make variable buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
54521
diff
changeset
|
105 "Non-nil in a buffer whose visited file was uncompressed on visiting it. |
4dec7a239cfa
(jka-compr-really-do-compress): Make variable buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
54521
diff
changeset
|
106 This means compress the data on writing the file, even if the |
4dec7a239cfa
(jka-compr-really-do-compress): Make variable buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
54521
diff
changeset
|
107 data appears to be compressed already.") |
4dec7a239cfa
(jka-compr-really-do-compress): Make variable buffer-local.
Richard M. Stallman <rms@gnu.org>
parents:
54521
diff
changeset
|
108 (make-variable-buffer-local 'jka-compr-really-do-compress) |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
109 (put 'jka-compr-really-do-compress 'permanent-local t) |
7617
edc853e14f7b
(jka-compr-op-table, jka-compr-file-name-handler-entry): Move defvars.
Richard M. Stallman <rms@gnu.org>
parents:
7616
diff
changeset
|
110 |
6002 | 111 |
112 (put 'compression-error 'error-conditions '(compression-error file-error error)) | |
113 | |
114 | |
11635
b56f6afa16ec
(jka-compr-write-region): Handle the append
Richard M. Stallman <rms@gnu.org>
parents:
11621
diff
changeset
|
115 (defvar jka-compr-acceptable-retval-list '(0 2 141)) |
6002 | 116 |
117 | |
118 (defun jka-compr-error (prog args infile message &optional errfile) | |
119 | |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
120 (let ((errbuf (get-buffer-create " *jka-compr-error*"))) |
16940
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
121 (with-current-buffer errbuf |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
122 (widen) (erase-buffer) |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
123 (insert (format "Error while executing \"%s %s < %s\"\n\n" |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
124 prog |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
125 (mapconcat 'identity args " ") |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
126 infile)) |
6002 | 127 |
16940
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
128 (and errfile |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
129 (insert-file-contents errfile))) |
6002 | 130 (display-buffer errbuf)) |
131 | |
16940
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
132 (signal 'compression-error |
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
133 (list "Opening input file" (format "error %s" message) infile))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
134 |
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
135 |
40782
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
136 (defcustom jka-compr-dd-program "/bin/dd" |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
137 "How to invoke `dd'." |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
138 :type 'string |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
139 :group 'jka-compr) |
6002 | 140 |
141 | |
6041
649926e9c1a8
(jka-compr-partial-uncompress): Make dd give you
Richard M. Stallman <rms@gnu.org>
parents:
6002
diff
changeset
|
142 (defvar jka-compr-dd-blocksize 256) |
6002 | 143 |
144 | |
145 (defun jka-compr-partial-uncompress (prog message args infile beg len) | |
146 "Call program PROG with ARGS args taking input from INFILE. | |
147 Fourth and fifth args, BEG and LEN, specify which part of the output | |
8065
31eb7a0e2763
(jka-compr-partial-uncompress): Handle the case where
Richard M. Stallman <rms@gnu.org>
parents:
7976
diff
changeset
|
148 to keep: LEN chars starting BEG chars from the beginning." |
40782
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
149 (let ((start (point)) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
150 (prefix beg)) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
151 (if (and jka-compr-use-shell jka-compr-dd-program) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
152 ;; Put the uncompression output through dd |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
153 ;; to discard the part we don't want. |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
154 (let ((skip (/ beg jka-compr-dd-blocksize)) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
155 (err-file (jka-compr-make-temp-name)) |
75494
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
156 ;; call-process barfs if default-directory is inaccessible. |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
157 (default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
158 (if (and default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
159 (file-accessible-directory-p default-directory)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
160 default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
161 (file-name-directory infile))) |
40782
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
162 count) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
163 ;; Update PREFIX based on the text that we won't read in. |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
164 (setq prefix (- beg (* skip jka-compr-dd-blocksize)) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
165 count (and len (1+ (/ (+ len prefix) jka-compr-dd-blocksize)))) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
166 (unwind-protect |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
167 (or (memq (call-process |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
168 jka-compr-shell infile t nil "-c" |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
169 (format |
42231
054cf5ce349b
(jka-compr-partial-uncompress): Use null-device instead of a literal
Eli Zaretskii <eliz@gnu.org>
parents:
41102
diff
changeset
|
170 "%s %s 2> %s | %s bs=%d skip=%d %s 2> %s" |
40782
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
171 prog |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
172 (mapconcat 'identity args " ") |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
173 err-file |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
174 jka-compr-dd-program |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
175 jka-compr-dd-blocksize |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
176 skip |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
177 ;; dd seems to be unreliable about |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
178 ;; providing the last block. So, always |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
179 ;; read one more than you think you need. |
42231
054cf5ce349b
(jka-compr-partial-uncompress): Use null-device instead of a literal
Eli Zaretskii <eliz@gnu.org>
parents:
41102
diff
changeset
|
180 (if count (format "count=%d" (1+ count)) "") |
054cf5ce349b
(jka-compr-partial-uncompress): Use null-device instead of a literal
Eli Zaretskii <eliz@gnu.org>
parents:
41102
diff
changeset
|
181 null-device)) |
40782
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
182 jka-compr-acceptable-retval-list) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
183 (jka-compr-error prog args infile message err-file)) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
184 (jka-compr-delete-temp-file err-file))) |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
185 ;; Run the uncompression program directly. |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
186 ;; We get the whole file and must delete what we don't want. |
3a4d800ced48
(jka-compr-partial-uncompress): Support an alternative of not using dd.
Richard M. Stallman <rms@gnu.org>
parents:
39829
diff
changeset
|
187 (jka-compr-call-process prog message infile t nil args)) |
6002 | 188 |
8065
31eb7a0e2763
(jka-compr-partial-uncompress): Handle the case where
Richard M. Stallman <rms@gnu.org>
parents:
7976
diff
changeset
|
189 ;; Delete the stuff after what we want, if there is any. |
6002 | 190 (and |
6041
649926e9c1a8
(jka-compr-partial-uncompress): Make dd give you
Richard M. Stallman <rms@gnu.org>
parents:
6002
diff
changeset
|
191 len |
8065
31eb7a0e2763
(jka-compr-partial-uncompress): Handle the case where
Richard M. Stallman <rms@gnu.org>
parents:
7976
diff
changeset
|
192 (< (+ start prefix len) (point)) |
6041
649926e9c1a8
(jka-compr-partial-uncompress): Make dd give you
Richard M. Stallman <rms@gnu.org>
parents:
6002
diff
changeset
|
193 (delete-region (+ start prefix len) (point))) |
6002 | 194 |
8065
31eb7a0e2763
(jka-compr-partial-uncompress): Handle the case where
Richard M. Stallman <rms@gnu.org>
parents:
7976
diff
changeset
|
195 ;; Delete the stuff before what we want. |
6002 | 196 (delete-region start (+ start prefix)))) |
197 | |
198 | |
199 (defun jka-compr-call-process (prog message infile output temp args) | |
75494
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
200 ;; call-process barfs if default-directory is inaccessible. |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
201 (let ((default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
202 (if (and default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
203 (file-accessible-directory-p default-directory)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
204 default-directory |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
205 (file-name-directory infile)))) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
206 (if jka-compr-use-shell |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
207 (let ((err-file (jka-compr-make-temp-name)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
208 (coding-system-for-read (or coding-system-for-read 'undecided)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
209 (coding-system-for-write 'no-conversion)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
210 (unwind-protect |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
211 (or (memq |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
212 (call-process jka-compr-shell infile |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
213 (if (stringp output) nil output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
214 nil |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
215 "-c" |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
216 (format "%s %s 2> %s %s" |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
217 prog |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
218 (mapconcat 'identity args " ") |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
219 err-file |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
220 (if (stringp output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
221 (concat "> " output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
222 ""))) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
223 jka-compr-acceptable-retval-list) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
224 (jka-compr-error prog args infile message err-file)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
225 (jka-compr-delete-temp-file err-file))) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
226 (or (eq 0 |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
227 (apply 'call-process |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
228 prog infile (if (stringp output) temp output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
229 nil args)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
230 (jka-compr-error prog args infile message)) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
231 (and (stringp output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
232 (with-current-buffer temp |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
233 (write-region (point-min) (point-max) output) |
04d75deb3a31
(jka-compr-partial-uncompress, jka-compr-call-process): Rebind
Chong Yidong <cyd@stupidchicken.com>
parents:
75423
diff
changeset
|
234 (erase-buffer)))))) |
6002 | 235 |
236 | |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
237 ;; Support for temp files. Much of this was inspired if not lifted |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
238 ;; from ange-ftp. |
6002 | 239 |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
240 (defcustom jka-compr-temp-name-template |
22100
eb3f36cc775f
(jka-compr-temp-name-template): Use temporary-file-directory.
Richard M. Stallman <rms@gnu.org>
parents:
22090
diff
changeset
|
241 (expand-file-name "jka-com" temporary-file-directory) |
17441
41a10d128e3b
(jka-compr-temp-name-template): Fix editing error.
Richard M. Stallman <rms@gnu.org>
parents:
17411
diff
changeset
|
242 "Prefix added to all temp files created by jka-compr. |
17411
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
243 There should be no more than seven characters after the final `/'." |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
244 :type 'string |
f0ff96a35eb8
Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents:
16940
diff
changeset
|
245 :group 'jka-compr) |
6002 | 246 |
247 (defun jka-compr-make-temp-name (&optional local-copy) | |
248 "This routine will return the name of a new file." | |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25285
diff
changeset
|
249 (make-temp-file jka-compr-temp-name-template)) |
6002 | 250 |
26039
fb6b9c37cdc4
Use make-temp-file.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
25285
diff
changeset
|
251 (defalias 'jka-compr-delete-temp-file 'delete-file) |
6002 | 252 |
253 | |
254 (defun jka-compr-write-region (start end file &optional append visit) | |
255 (let* ((filename (expand-file-name file)) | |
256 (visit-file (if (stringp visit) (expand-file-name visit) filename)) | |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
257 (info (jka-compr-get-compression-info visit-file)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
258 (magic (and info (jka-compr-info-file-magic-bytes info)))) |
6002 | 259 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
260 ;; If we uncompressed this file when visiting it, |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
261 ;; then recompress it when writing it |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
262 ;; even if the contents look compressed already. |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
263 (if (and jka-compr-really-do-compress |
95366
52e3cee99f90
* progmodes/flymake.el (flymake-save-buffer-in-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
264 (or (null start) |
52e3cee99f90
* progmodes/flymake.el (flymake-save-buffer-in-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
265 (= (- end start) (buffer-size)))) |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
266 (setq magic nil)) |
6002 | 267 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
268 (if (and info |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
269 ;; If the contents to be written out |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
270 ;; are properly compressed already, |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
271 ;; don't try to compress them over again. |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
272 (not (and magic |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
273 (equal (if (stringp start) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
274 (substring start 0 (min (length start) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
275 (length magic))) |
95368
f77d335546ac
(jka-compr-write-region): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95366
diff
changeset
|
276 (let* ((from (or start (point-min))) |
f77d335546ac
(jka-compr-write-region): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95366
diff
changeset
|
277 (to (min (or end (point-max)) |
f77d335546ac
(jka-compr-write-region): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
95366
diff
changeset
|
278 (+ from (length magic))))) |
95366
52e3cee99f90
* progmodes/flymake.el (flymake-save-buffer-in-file):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94678
diff
changeset
|
279 (buffer-substring from to))) |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
280 magic)))) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
281 (let ((can-append (jka-compr-info-can-append info)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
282 (compress-program (jka-compr-info-compress-program info)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
283 (compress-message (jka-compr-info-compress-message info)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
284 (compress-args (jka-compr-info-compress-args info)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
285 (base-name (file-name-nondirectory visit-file)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
286 temp-file temp-buffer |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
287 ;; we need to leave `last-coding-system-used' set to its |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
288 ;; value after calling write-region the first time, so |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
289 ;; that `basic-save-buffer' sees the right value. |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
290 (coding-system-used last-coding-system-used)) |
6002 | 291 |
54521
36922d8fd700
(jka-compr-compression-info-list): Add tbz and dz.
Juri Linkov <juri@jurta.org>
parents:
53477
diff
changeset
|
292 (or compress-program |
36922d8fd700
(jka-compr-compression-info-list): Add tbz and dz.
Juri Linkov <juri@jurta.org>
parents:
53477
diff
changeset
|
293 (error "No compression program defined")) |
36922d8fd700
(jka-compr-compression-info-list): Add tbz and dz.
Juri Linkov <juri@jurta.org>
parents:
53477
diff
changeset
|
294 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
295 (setq temp-buffer (get-buffer-create " *jka-compr-wr-temp*")) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
296 (with-current-buffer temp-buffer |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
297 (widen) (erase-buffer)) |
6002 | 298 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
299 (if (and append |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
300 (not can-append) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
301 (file-exists-p filename)) |
6002 | 302 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
303 (let* ((local-copy (file-local-copy filename)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
304 (local-file (or local-copy filename))) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
305 |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
306 (setq temp-file local-file)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
307 |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
308 (setq temp-file (jka-compr-make-temp-name))) |
6002 | 309 |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
310 (and |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
311 compress-message |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
312 (message "%s %s..." compress-message base-name)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
313 |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
314 (jka-compr-run-real-handler 'write-region |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
315 (list start end temp-file t 'dont)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
316 ;; save value used by the real write-region |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
317 (setq coding-system-used last-coding-system-used) |
6002 | 318 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
319 ;; Here we must read the output of compress program as is |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
320 ;; without any code conversion. |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
321 (let ((coding-system-for-read 'no-conversion)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
322 (jka-compr-call-process compress-program |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
323 (concat compress-message |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
324 " " base-name) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
325 temp-file |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
326 temp-buffer |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
327 nil |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
328 compress-args)) |
6002 | 329 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
330 (with-current-buffer temp-buffer |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
331 (let ((coding-system-for-write 'no-conversion)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
332 (if (memq system-type '(ms-dos windows-nt)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
333 (setq buffer-file-type t) ) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
334 (jka-compr-run-real-handler 'write-region |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
335 (list (point-min) (point-max) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
336 filename |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
337 (and append can-append) 'dont)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
338 (erase-buffer)) ) |
6002 | 339 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
340 (jka-compr-delete-temp-file temp-file) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
341 |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
342 (and |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
343 compress-message |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
344 (message "%s %s...done" compress-message base-name)) |
6002 | 345 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
346 (cond |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
347 ((eq visit t) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
348 (setq buffer-file-name filename) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
349 (setq jka-compr-really-do-compress t) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
350 (set-visited-file-modtime)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
351 ((stringp visit) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
352 (setq buffer-file-name visit) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
353 (let ((buffer-file-name filename)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
354 (set-visited-file-modtime)))) |
6002 | 355 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
356 (and (or (eq visit t) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
357 (eq visit nil) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
358 (stringp visit)) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
359 (message "Wrote %s" visit-file)) |
22360
09dbe38a603f
(jka-compr-write-region): Ensure
Karl Heuer <kwzh@gnu.org>
parents:
22194
diff
changeset
|
360 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
361 ;; ensure `last-coding-system-used' has an appropriate value |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
362 (setq last-coding-system-used coding-system-used) |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
363 |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
364 nil) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
365 |
26987
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
366 (jka-compr-run-real-handler 'write-region |
af30e0897839
(jka-compr-info-file-magic-bytes): New function.
Richard M. Stallman <rms@gnu.org>
parents:
26039
diff
changeset
|
367 (list start end filename append visit))))) |
6002 | 368 |
369 | |
6218
f4d5338c2142
(jka-compr-insert-file-contents): Handle 5th arg.
Richard M. Stallman <rms@gnu.org>
parents:
6041
diff
changeset
|
370 (defun jka-compr-insert-file-contents (file &optional visit beg end replace) |
6002 | 371 (barf-if-buffer-read-only) |
372 | |
373 (and (or beg end) | |
374 visit | |
375 (error "Attempt to visit less than an entire file")) | |
376 | |
377 (let* ((filename (expand-file-name file)) | |
378 (info (jka-compr-get-compression-info filename))) | |
379 | |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
380 (if (not info) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
381 |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
382 (jka-compr-run-real-handler 'insert-file-contents |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
383 (list file visit beg end replace)) |
6002 | 384 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
385 (let ((uncompress-message (jka-compr-info-uncompress-message info)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
386 (uncompress-program (jka-compr-info-uncompress-program info)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
387 (uncompress-args (jka-compr-info-uncompress-args info)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
388 (base-name (file-name-nondirectory filename)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
389 (notfound nil) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
390 (local-copy |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
391 (jka-compr-run-real-handler 'file-local-copy (list filename))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
392 local-file |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
393 size start) |
6002 | 394 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
395 (setq local-file (or local-copy filename)) |
6002 | 396 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
397 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
398 visit |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
399 (setq buffer-file-name filename)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
400 |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
401 (unwind-protect ; to make sure local-copy gets deleted |
6002 | 402 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
403 (progn |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
404 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
405 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
406 uncompress-message |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
407 (message "%s %s..." uncompress-message base-name)) |
6002 | 408 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
409 (condition-case error-code |
6002 | 410 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
411 (let ((coding-system-for-read 'no-conversion)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
412 (if replace |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
413 (goto-char (point-min))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
414 (setq start (point)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
415 (if (or beg end) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
416 (jka-compr-partial-uncompress uncompress-program |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
417 (concat uncompress-message |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
418 " " base-name) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
419 uncompress-args |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
420 local-file |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
421 (or beg 0) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
422 (if (and beg end) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
423 (- end beg) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
424 end)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
425 ;; If visiting, bind off buffer-file-name so that |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
426 ;; file-locking will not ask whether we should |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
427 ;; really edit the buffer. |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
428 (let ((buffer-file-name |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
429 (if visit nil buffer-file-name))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
430 (jka-compr-call-process uncompress-program |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
431 (concat uncompress-message |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
432 " " base-name) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
433 local-file |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
434 t |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
435 nil |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
436 uncompress-args))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
437 (setq size (- (point) start)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
438 (if replace |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
439 (delete-region (point) (point-max))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
440 (goto-char start)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
441 (error |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
442 ;; If the file we wanted to uncompress does not exist, |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
443 ;; handle that according to VISIT as `insert-file-contents' |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
444 ;; would, maybe signaling the same error it normally would. |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
445 (if (and (eq (car error-code) 'file-error) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
446 (eq (nth 3 error-code) local-file)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
447 (if visit |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
448 (setq notfound error-code) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
449 (signal 'file-error |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
450 (cons "Opening input file" |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
451 (nthcdr 2 error-code)))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
452 ;; If the uncompression program can't be found, |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
453 ;; signal that as a non-file error |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
454 ;; so that find-file-noselect-1 won't handle it. |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
455 (if (and (eq (car error-code) 'file-error) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
456 (equal (cadr error-code) "Searching for program")) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
457 (error "Uncompression program `%s' not found" |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
458 (nth 3 error-code))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
459 (signal (car error-code) (cdr error-code)))))) |
6002 | 460 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
461 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
462 local-copy |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
463 (file-exists-p local-copy) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
464 (delete-file local-copy))) |
6002 | 465 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
466 (unless notfound |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
467 (decode-coding-inserted-region |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
468 (point) (+ (point) size) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
469 (jka-compr-byte-compiler-base-file-name file) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
470 visit beg end replace)) |
49377
e5099d153f94
(jka-compr-insert-file-contents): Read a process
Kenichi Handa <handa@m17n.org>
parents:
47180
diff
changeset
|
471 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
472 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
473 visit |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
474 (progn |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
475 (unlock-buffer) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
476 (setq buffer-file-name filename) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
477 (setq jka-compr-really-do-compress t) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
478 (set-visited-file-modtime))) |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
479 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
480 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
481 uncompress-message |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
482 (message "%s %s...done" uncompress-message base-name)) |
6002 | 483 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
484 (and |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
485 visit |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
486 notfound |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
487 (signal 'file-error |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
488 (cons "Opening input file" (nth 2 notfound)))) |
6002 | 489 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
490 ;; This is done in insert-file-contents after we return. |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
491 ;; That is a little weird, but better to go along with it now |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
492 ;; than to change it now. |
22484
661650f543ee
(jka-compr-insert-file-contents): Don't run
Richard M. Stallman <rms@gnu.org>
parents:
22360
diff
changeset
|
493 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
494 ;; ;; Run the functions that insert-file-contents would. |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
495 ;; (let ((p after-insert-file-functions) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
496 ;; (insval size)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
497 ;; (while p |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
498 ;; (setq insval (funcall (car p) size)) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
499 ;; (if insval |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
500 ;; (progn |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
501 ;; (or (integerp insval) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
502 ;; (signal 'wrong-type-argument |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
503 ;; (list 'integerp insval))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
504 ;; (setq size insval))) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
505 ;; (setq p (cdr p)))) |
8774
ade4b542a74c
(jka-compr-compression-info-list): Expand regular
Richard M. Stallman <rms@gnu.org>
parents:
8593
diff
changeset
|
506 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
507 (or (jka-compr-info-compress-program info) |
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
508 (message "You can't save this buffer because compression program is not defined")) |
54521
36922d8fd700
(jka-compr-compression-info-list): Add tbz and dz.
Juri Linkov <juri@jurta.org>
parents:
53477
diff
changeset
|
509 |
93611
014868cc0301
(jka-compr-insert-file-contents): Reduce indentation slightly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79721
diff
changeset
|
510 (list filename size))))) |
6002 | 511 |
512 | |
513 (defun jka-compr-file-local-copy (file) | |
514 (let* ((filename (expand-file-name file)) | |
515 (info (jka-compr-get-compression-info filename))) | |
516 | |
517 (if info | |
518 | |
519 (let ((uncompress-message (jka-compr-info-uncompress-message info)) | |
520 (uncompress-program (jka-compr-info-uncompress-program info)) | |
521 (uncompress-args (jka-compr-info-uncompress-args info)) | |
522 (base-name (file-name-nondirectory filename)) | |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
523 (local-copy |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
524 (jka-compr-run-real-handler 'file-local-copy (list filename))) |
6002 | 525 (temp-file (jka-compr-make-temp-name t)) |
11635
b56f6afa16ec
(jka-compr-write-region): Handle the append
Richard M. Stallman <rms@gnu.org>
parents:
11621
diff
changeset
|
526 (temp-buffer (get-buffer-create " *jka-compr-flc-temp*")) |
6002 | 527 local-file) |
528 | |
529 (setq local-file (or local-copy filename)) | |
530 | |
531 (unwind-protect | |
532 | |
16940
6d680b18a47b
(jka-compr-error): Use with-current-buffer.
Richard M. Stallman <rms@gnu.org>
parents:
16630
diff
changeset
|
533 (with-current-buffer temp-buffer |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
534 |
6002 | 535 (and |
536 uncompress-message | |
537 (message "%s %s..." uncompress-message base-name)) | |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
538 |
18906 | 539 ;; Here we must read the output of uncompress program |
540 ;; and write it to TEMP-FILE without any code | |
541 ;; conversion. An appropriate code conversion (if | |
542 ;; necessary) is done by the later I/O operation | |
543 ;; (e.g. load). | |
544 (let ((coding-system-for-read 'no-conversion) | |
545 (coding-system-for-write 'no-conversion)) | |
6002 | 546 |
18906 | 547 (jka-compr-call-process uncompress-program |
548 (concat uncompress-message | |
549 " " base-name) | |
550 local-file | |
551 t | |
552 nil | |
553 uncompress-args) | |
6002 | 554 |
18906 | 555 (and |
556 uncompress-message | |
557 (message "%s %s...done" uncompress-message base-name)) | |
558 | |
559 (write-region | |
560 (point-min) (point-max) temp-file nil 'dont))) | |
6002 | 561 |
562 (and | |
563 local-copy | |
564 (file-exists-p local-copy) | |
565 (delete-file local-copy)) | |
566 | |
567 (kill-buffer temp-buffer)) | |
568 | |
569 temp-file) | |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
570 |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
571 (jka-compr-run-real-handler 'file-local-copy (list filename))))) |
6002 | 572 |
573 | |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
574 ;; Support for loading compressed files. |
6002 | 575 (defun jka-compr-load (file &optional noerror nomessage nosuffix) |
576 "Documented as original." | |
577 | |
578 (let* ((local-copy (jka-compr-file-local-copy file)) | |
579 (load-file (or local-copy file))) | |
580 | |
581 (unwind-protect | |
582 | |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
583 (let (inhibit-file-name-operation |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
584 inhibit-file-name-handlers) |
6002 | 585 (or nomessage |
586 (message "Loading %s..." file)) | |
587 | |
12758
a285eaa710ac
(jka-compr-load): Bind load-force-doc-strings.
Richard M. Stallman <rms@gnu.org>
parents:
11635
diff
changeset
|
588 (let ((load-force-doc-strings t)) |
a285eaa710ac
(jka-compr-load): Bind load-force-doc-strings.
Richard M. Stallman <rms@gnu.org>
parents:
11635
diff
changeset
|
589 (load load-file noerror t t)) |
6002 | 590 (or nomessage |
27512
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
591 (message "Loading %s...done." file)) |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
592 ;; Fix up the load history to point at the right library. |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
593 (let ((l (assoc load-file load-history))) |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
594 ;; Remove .gz and .elc?. |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
595 (while (file-name-extension file) |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
596 (setq file (file-name-sans-extension file))) |
b7020186895e
(jka-compr-load): Fix up load-history.
Dave Love <fx@gnu.org>
parents:
26987
diff
changeset
|
597 (setcar l file))) |
6002 | 598 |
599 (jka-compr-delete-temp-file local-copy)) | |
600 | |
601 t)) | |
12922
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
602 |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
603 (defun jka-compr-byte-compiler-base-file-name (file) |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
604 (let ((info (jka-compr-get-compression-info file))) |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
605 (if (and info (jka-compr-info-strip-extension info)) |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
606 (save-match-data |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
607 (substring file 0 (string-match (jka-compr-info-regexp info) file))) |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
608 file))) |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
609 |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
610 (put 'write-region 'jka-compr 'jka-compr-write-region) |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
611 (put 'insert-file-contents 'jka-compr 'jka-compr-insert-file-contents) |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
612 (put 'file-local-copy 'jka-compr 'jka-compr-file-local-copy) |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
613 (put 'load 'jka-compr 'jka-compr-load) |
12922
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
614 (put 'byte-compiler-base-file-name 'jka-compr |
e171a85fd6b0
(jka-compr-byte-compiler-base-file-name): New function.
Richard M. Stallman <rms@gnu.org>
parents:
12758
diff
changeset
|
615 'jka-compr-byte-compiler-base-file-name) |
6002 | 616 |
61946
982afd92d8bb
Many functions and vars moved to jka-compr-hook.el.
Richard M. Stallman <rms@gnu.org>
parents:
61601
diff
changeset
|
617 ;;;###autoload |
20132
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
618 (defvar jka-compr-inhibit nil |
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
619 "Non-nil means inhibit automatic uncompression temporarily. |
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
620 Lisp programs can bind this to t to do that. |
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
621 It is not recommended to set this variable permanently to anything but nil.") |
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
622 |
61946
982afd92d8bb
Many functions and vars moved to jka-compr-hook.el.
Richard M. Stallman <rms@gnu.org>
parents:
61601
diff
changeset
|
623 ;;;###autoload |
6002 | 624 (defun jka-compr-handler (operation &rest args) |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
625 (save-match-data |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
626 (let ((jka-op (get operation 'jka-compr))) |
20132
b691f68b0757
(jka-compr-inhibit): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
19004
diff
changeset
|
627 (if (and jka-op (not jka-compr-inhibit)) |
7976
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
628 (apply jka-op args) |
b72b84744a85
Use plists to record handlers.
Richard M. Stallman <rms@gnu.org>
parents:
7617
diff
changeset
|
629 (jka-compr-run-real-handler operation args))))) |
6002 | 630 |
7066 | 631 ;; If we are given an operation that we don't handle, |
632 ;; call the Emacs primitive for that operation, | |
633 ;; and manipulate the inhibit variables | |
634 ;; to prevent the primitive from calling our handler again. | |
635 (defun jka-compr-run-real-handler (operation args) | |
636 (let ((inhibit-file-name-handlers | |
637 (cons 'jka-compr-handler | |
638 (and (eq inhibit-file-name-operation operation) | |
639 inhibit-file-name-handlers))) | |
640 (inhibit-file-name-operation operation)) | |
641 (apply operation args))) | |
642 | |
62108
5b31557e355c
(jka-compr-uninstall): Add autoload cookie.
Eli Zaretskii <eliz@gnu.org>
parents:
61946
diff
changeset
|
643 ;;;###autoload |
6002 | 644 (defun jka-compr-uninstall () |
645 "Uninstall jka-compr. | |
7066 | 646 This removes the entries in `file-name-handler-alist' and `auto-mode-alist' |
11296
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
647 and `inhibit-first-line-modes-suffixes' that were added |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
648 by `jka-compr-installed'." |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
649 ;; Delete from inhibit-first-line-modes-suffixes |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
650 ;; what jka-compr-install added. |
69163
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
651 (mapc |
11296
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
652 (function (lambda (x) |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
653 (and (jka-compr-info-strip-extension x) |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
654 (setq inhibit-first-line-modes-suffixes |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
655 (delete (jka-compr-info-regexp x) |
c271ed10f874
(jka-compr-install): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents:
11179
diff
changeset
|
656 inhibit-first-line-modes-suffixes))))) |
69163
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
657 jka-compr-compression-info-list--internal) |
6002 | 658 |
659 (let* ((fnha (cons nil file-name-handler-alist)) | |
660 (last fnha)) | |
661 | |
662 (while (cdr last) | |
663 (if (eq (cdr (car (cdr last))) 'jka-compr-handler) | |
664 (setcdr last (cdr (cdr last))) | |
665 (setq last (cdr last)))) | |
666 | |
667 (setq file-name-handler-alist (cdr fnha))) | |
668 | |
669 (let* ((ama (cons nil auto-mode-alist)) | |
670 (last ama) | |
671 entry) | |
672 | |
673 (while (cdr last) | |
674 (setq entry (car (cdr last))) | |
69163
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
675 (if (or (member entry jka-compr-mode-alist-additions--internal) |
9493
0160fca3dee1
(jka-compr-mode-compression-info-list): Add .tgz extension.
Richard M. Stallman <rms@gnu.org>
parents:
9084
diff
changeset
|
676 (and (consp (cdr entry)) |
0160fca3dee1
(jka-compr-mode-compression-info-list): Add .tgz extension.
Richard M. Stallman <rms@gnu.org>
parents:
9084
diff
changeset
|
677 (eq (nth 2 entry) 'jka-compr))) |
6002 | 678 (setcdr last (cdr (cdr last))) |
679 (setq last (cdr last)))) | |
49597
e88404e8f2cf
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
49418
diff
changeset
|
680 |
19004
f2ce7e947ec9
(jka-compr-added-to-file-coding-system-alist): New var.
Richard M. Stallman <rms@gnu.org>
parents:
18906
diff
changeset
|
681 (setq auto-mode-alist (cdr ama))) |
f2ce7e947ec9
(jka-compr-added-to-file-coding-system-alist): New var.
Richard M. Stallman <rms@gnu.org>
parents:
18906
diff
changeset
|
682 |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
683 (while jka-compr-added-to-file-coding-system-alist |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
684 (setq file-coding-system-alist |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
685 (delq (car (member (pop jka-compr-added-to-file-coding-system-alist) |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
686 file-coding-system-alist)) |
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
687 file-coding-system-alist))) |
39829
79ed34b0c0df
(jka-compr-load-suffixes): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
688 |
79ed34b0c0df
(jka-compr-load-suffixes): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38412
diff
changeset
|
689 ;; Remove the suffixes that were added by jka-compr. |
69163
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
690 (dolist (suff jka-compr-load-suffixes--internal) |
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
691 (setq load-file-rep-suffixes (delete suff load-file-rep-suffixes))) |
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
692 |
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
693 (setq jka-compr-compression-info-list--internal nil |
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
694 jka-compr-mode-alist-additions--internal nil |
d70e9ee4bf88
(jka-compr-uninstall): Replace `mapcar' with `mapc'.
Luc Teirlinck <teirllm@auburn.edu>
parents:
68651
diff
changeset
|
695 jka-compr-load-suffixes--internal nil)) |
6002 | 696 |
697 (provide 'jka-compr) | |
698 | |
66805
8068044e970e
Require 'jka-cmpr-hook.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
64762
diff
changeset
|
699 ;; arch-tag: 3f15b630-e9a7-46c4-a22a-94afdde86ebc |
38412
253f761ad37b
Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents:
34732
diff
changeset
|
700 ;;; jka-compr.el ends here |