Mercurial > emacs
annotate lisp/arc-mode.el @ 83361:39de99cd3f08
Prevent resource allocation explosion when C-x 5 2 is used on xterms.
* lisp/term/xterm.el (terminal-init-xterm): Protect function-key-map
against multiple invocations on the same terminal.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-401
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Wed, 07 Sep 2005 23:17:07 +0000 |
parents | 41bb365f41c4 |
children | d2f6c64a5b45 2d92f5c9d6ae |
rev | line source |
---|---|
11880 | 1 ;;; arc-mode.el --- simple editing of archives |
2 | |
64762
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64528
diff
changeset
|
3 ;; Copyright (C) 1995, 1997, 1998, 2002, 2003, 2004, |
41bb365f41c4
Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
64528
diff
changeset
|
4 ;; 2005 Free Software Foundation, Inc. |
11880 | 5 |
53397
2843dc1a9a6f
Update author email addr.
Richard M. Stallman <rms@gnu.org>
parents:
52401
diff
changeset
|
6 ;; Author: Morten Welinder <terra@gnu.org> |
11880 | 7 ;; Keywords: archives msdog editing major-mode |
8 ;; Favourite-brand-of-beer: None, I hate beer. | |
9 | |
14169 | 10 ;; This file is part of GNU Emacs. |
11 | |
12 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
13 ;; it under the terms of the GNU General Public License as published by | |
14 ;; the Free Software Foundation; either version 2, or (at your option) | |
15 ;; any later version. | |
16 | |
17 ;; GNU Emacs is distributed in the hope that it will be useful, | |
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
20 ;; GNU General Public License for more details. | |
21 | |
22 ;; You should have received a copy of the GNU General Public License | |
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
64091 | 24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
25 ;; Boston, MA 02110-1301, USA. | |
11880 | 26 |
27 ;;; Commentary: | |
14169 | 28 |
11880 | 29 ;; NAMING: "arc" is short for "archive" and does not refer specifically |
30 ;; to files whose name end in ".arc" | |
31 ;; | |
32 ;; This code does not decode any files internally, although it does | |
33 ;; understand the directory level of the archives. For this reason, | |
34 ;; you should expect this code to need more fiddling than tar-mode.el | |
35 ;; (although it at present has fewer bugs :-) In particular, I have | |
36 ;; not tested this under Ms-Dog myself. | |
37 ;; ------------------------------------- | |
38 ;; INTERACTION: arc-mode.el should play together with | |
39 ;; | |
40 ;; * ange-ftp.el: Remote archives (i.e., ones that ange-ftp has brought | |
41 ;; to you) are handled by doing all updates on a local | |
42 ;; copy. When you make changes to a remote file the | |
43 ;; changes will first take effect when the archive buffer | |
44 ;; is saved. You will be warned about this. | |
45 ;; | |
46 ;; * dos-fns.el: (Part of Emacs 19). You get automatic ^M^J <--> ^J | |
47 ;; conversion. | |
48 ;; | |
49 ;; arc-mode.el does not work well with crypt++.el; for the archives as | |
50 ;; such this could be fixed (but wouldn't be useful) by declaring such | |
51 ;; archives to be "remote". For the members this is a general Emacs | |
52 ;; problem that 19.29's file formats may fix. | |
53 ;; ------------------------------------- | |
54 ;; ARCHIVE TYPES: Currently only the archives below are handled, but the | |
55 ;; structure for handling just about anything is in place. | |
56 ;; | |
57 ;; Arc Lzh Zip Zoo | |
58 ;; -------------------------------- | |
59 ;; View listing Intern Intern Intern Intern | |
60 ;; Extract member Y Y Y Y | |
61 ;; Save changed member Y Y Y Y | |
62 ;; Add new member N N N N | |
63 ;; Delete member Y Y Y Y | |
64 ;; Rename member Y Y N N | |
65 ;; Chmod - Y Y - | |
66 ;; Chown - Y - - | |
67 ;; Chgrp - Y - - | |
68 ;; | |
69 ;; Special thanks to Bill Brodie <wbrodie@panix.com> for very useful tips | |
70 ;; on the first released version of this package. | |
71 ;; | |
72 ;; This code is partly based on tar-mode.el from Emacs. | |
73 ;; ------------------------------------- | |
74 ;; ARCHIVE STRUCTURES: | |
75 ;; (This is mostly for myself.) | |
76 ;; | |
77 ;; ARC A series of (header,file). No interactions among members. | |
78 ;; | |
79 ;; LZH A series of (header,file). Headers are checksummed. No | |
80 ;; interaction among members. | |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
81 ;; Headers come in three flavours called level 0, 1 and 2 headers. |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
82 ;; Level 2 header is free of DOS specific restrictions and most |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
83 ;; prevalently used. Also level 1 and 2 headers consist of base |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
84 ;; and extension headers. For more details see |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
85 ;; http://homepage1.nifty.com/dangan/en/Content/Program/Java/jLHA/Notes/Notes.html |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
86 ;; http://www.osirusoft.com/joejared/lzhformat.html |
11880 | 87 ;; |
88 ;; ZIP A series of (lheader,fil) followed by a "central directory" | |
89 ;; which is a series of (cheader) followed by an end-of- | |
90 ;; central-dir record possibly followed by junk. The e-o-c-d | |
91 ;; links to c-d. cheaders link to lheaders which are basically | |
92 ;; cut-down versions of the cheaders. | |
93 ;; | |
94 ;; ZOO An archive header followed by a series of (header,file). | |
95 ;; Each member header points to the next. The archive is | |
96 ;; terminated by a bogus header with a zero next link. | |
97 ;; ------------------------------------- | |
42704 | 98 ;; HOOKS: `foo' means one of the supported archive types. |
11880 | 99 ;; |
100 ;; archive-mode-hook | |
101 ;; archive-foo-mode-hook | |
102 ;; archive-extract-hooks | |
103 | |
104 ;;; Code: | |
105 | |
106 ;; ------------------------------------------------------------------------- | |
107 ;; Section: Configuration. | |
108 | |
19926 | 109 (defgroup archive nil |
110 "Simple editing of archives." | |
111 :group 'data) | |
112 | |
113 (defgroup archive-arc nil | |
114 "ARC-specific options to archive." | |
115 :group 'archive) | |
116 | |
117 (defgroup archive-lzh nil | |
118 "LZH-specific options to archive." | |
119 :group 'archive) | |
11880 | 120 |
19926 | 121 (defgroup archive-zip nil |
122 "ZIP-specific options to archive." | |
123 :group 'archive) | |
124 | |
125 (defgroup archive-zoo nil | |
126 "ZOO-specific options to archive." | |
127 :group 'archive) | |
128 | |
129 (defcustom archive-tmpdir | |
43679 | 130 ;; make-temp-name is safe here because we use this name |
131 ;; to create a directory. | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
132 (make-temp-name |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
133 (expand-file-name (if (eq system-type 'ms-dos) "ar" "archive.tmp") |
22096
2f9cb89376a6
(archive-tmpdir): Use temporary-file-directory.
Richard M. Stallman <rms@gnu.org>
parents:
22086
diff
changeset
|
134 temporary-file-directory)) |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
135 "Directory for temporary files made by `arc-mode.el'." |
19926 | 136 :type 'directory |
137 :group 'archive) | |
11880 | 138 |
19926 | 139 (defcustom archive-remote-regexp "^/[^/:]*[^/:.]:" |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
140 "*Regexp recognizing archive files names that are not local. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
141 A non-local file is one whose file name is not proper outside Emacs. |
19926 | 142 A local copy of the archive will be used when updating." |
143 :type 'regexp | |
144 :group 'archive) | |
11880 | 145 |
19926 | 146 (defcustom archive-extract-hooks nil |
147 "*Hooks to run when an archive member has been extracted." | |
148 :type 'hook | |
149 :group 'archive) | |
11880 | 150 ;; ------------------------------ |
151 ;; Arc archive configuration | |
152 | |
153 ;; We always go via a local file since there seems to be no reliable way | |
154 ;; to extract to stdout without junk getting added. | |
19926 | 155 (defcustom archive-arc-extract |
11880 | 156 '("arc" "x") |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
157 "*Program and its options to run in order to extract an arc file member. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
158 Extraction should happen to the current directory. Archive and member |
19926 | 159 name will be added." |
160 :type '(list (string :tag "Program") | |
161 (repeat :tag "Options" | |
162 :inline t | |
163 (string :format "%v"))) | |
164 :group 'archive-arc) | |
11880 | 165 |
19926 | 166 (defcustom archive-arc-expunge |
11880 | 167 '("arc" "d") |
168 "*Program and its options to run in order to delete arc file members. | |
19926 | 169 Archive and member names will be added." |
170 :type '(list (string :tag "Program") | |
171 (repeat :tag "Options" | |
172 :inline t | |
173 (string :format "%v"))) | |
174 :group 'archive-arc) | |
11880 | 175 |
19926 | 176 (defcustom archive-arc-write-file-member |
11880 | 177 '("arc" "u") |
178 "*Program and its options to run in order to update an arc file member. | |
19926 | 179 Archive and member name will be added." |
180 :type '(list (string :tag "Program") | |
181 (repeat :tag "Options" | |
182 :inline t | |
183 (string :format "%v"))) | |
184 :group 'archive-arc) | |
11880 | 185 ;; ------------------------------ |
186 ;; Lzh archive configuration | |
187 | |
19926 | 188 (defcustom archive-lzh-extract |
11880 | 189 '("lha" "pq") |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
190 "*Program and its options to run in order to extract an lzh file member. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
191 Extraction should happen to standard output. Archive and member name will |
19926 | 192 be added." |
193 :type '(list (string :tag "Program") | |
194 (repeat :tag "Options" | |
195 :inline t | |
196 (string :format "%v"))) | |
197 :group 'archive-lzh) | |
11880 | 198 |
19926 | 199 (defcustom archive-lzh-expunge |
11880 | 200 '("lha" "d") |
201 "*Program and its options to run in order to delete lzh file members. | |
19926 | 202 Archive and member names will be added." |
203 :type '(list (string :tag "Program") | |
204 (repeat :tag "Options" | |
205 :inline t | |
206 (string :format "%v"))) | |
207 :group 'archive-lzh) | |
11880 | 208 |
19926 | 209 (defcustom archive-lzh-write-file-member |
11880 | 210 '("lha" "a") |
211 "*Program and its options to run in order to update an lzh file member. | |
19926 | 212 Archive and member name will be added." |
213 :type '(list (string :tag "Program") | |
214 (repeat :tag "Options" | |
215 :inline t | |
216 (string :format "%v"))) | |
217 :group 'archive-lzh) | |
11880 | 218 ;; ------------------------------ |
219 ;; Zip archive configuration | |
220 | |
19926 | 221 (defcustom archive-zip-extract |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
222 (if (and (not (executable-find "unzip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
223 (executable-find "pkunzip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
224 '("pkunzip" "-e" "-o-") |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
225 '("unzip" "-qq" "-c")) |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
226 "*Program and its options to run in order to extract a zip file member. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
227 Extraction should happen to standard output. Archive and member name will |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
228 be added. If `archive-zip-use-pkzip' is non-nil then this program is |
19926 | 229 expected to extract to a file junking the directory part of the name." |
230 :type '(list (string :tag "Program") | |
231 (repeat :tag "Options" | |
232 :inline t | |
233 (string :format "%v"))) | |
234 :group 'archive-zip) | |
11880 | 235 |
13966
82eeef849f8b
(archive-summarize-files): Doc fix.
Karl Heuer <kwzh@gnu.org>
parents:
13539
diff
changeset
|
236 ;; For several reasons the latter behaviour is not desirable in general. |
11880 | 237 ;; (1) It uses more disk space. (2) Error checking is worse or non- |
238 ;; existent. (3) It tends to do funny things with other systems' file | |
239 ;; names. | |
240 | |
19926 | 241 (defcustom archive-zip-expunge |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
242 (if (and (not (executable-find "zip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
243 (executable-find "pkzip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
244 '("pkzip" "-d") |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
245 '("zip" "-d" "-q")) |
11880 | 246 "*Program and its options to run in order to delete zip file members. |
19926 | 247 Archive and member names will be added." |
248 :type '(list (string :tag "Program") | |
249 (repeat :tag "Options" | |
250 :inline t | |
251 (string :format "%v"))) | |
252 :group 'archive-zip) | |
11880 | 253 |
19926 | 254 (defcustom archive-zip-update |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
255 (if (and (not (executable-find "zip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
256 (executable-find "pkzip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
257 '("pkzip" "-u" "-P") |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
258 '("zip" "-q")) |
11880 | 259 "*Program and its options to run in order to update a zip file member. |
260 Options should ensure that specified directory will be put into the zip | |
19926 | 261 file. Archive and member name will be added." |
262 :type '(list (string :tag "Program") | |
263 (repeat :tag "Options" | |
264 :inline t | |
265 (string :format "%v"))) | |
266 :group 'archive-zip) | |
11880 | 267 |
19926 | 268 (defcustom archive-zip-update-case |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
269 (if (and (not (executable-find "zip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
270 (executable-find "pkzip")) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
271 '("pkzip" "-u" "-P") |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
272 '("zip" "-q" "-k")) |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
273 "*Program and its options to run in order to update a case fiddled zip member. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
274 Options should ensure that specified directory will be put into the zip file. |
19926 | 275 Archive and member name will be added." |
276 :type '(list (string :tag "Program") | |
277 (repeat :tag "Options" | |
278 :inline t | |
279 (string :format "%v"))) | |
280 :group 'archive-zip) | |
11880 | 281 |
19926 | 282 (defcustom archive-zip-case-fiddle t |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
283 "*If non-nil then zip file members may be down-cased. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
284 This case fiddling will only happen for members created by a system |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
285 that uses caseless file names." |
19926 | 286 :type 'boolean |
287 :group 'archive-zip) | |
11880 | 288 ;; ------------------------------ |
289 ;; Zoo archive configuration | |
290 | |
19926 | 291 (defcustom archive-zoo-extract |
11880 | 292 '("zoo" "xpq") |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
293 "*Program and its options to run in order to extract a zoo file member. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
294 Extraction should happen to standard output. Archive and member name will |
19926 | 295 be added." |
296 :type '(list (string :tag "Program") | |
297 (repeat :tag "Options" | |
298 :inline t | |
299 (string :format "%v"))) | |
300 :group 'archive-zoo) | |
11880 | 301 |
19926 | 302 (defcustom archive-zoo-expunge |
11880 | 303 '("zoo" "DqPP") |
304 "*Program and its options to run in order to delete zoo file members. | |
19926 | 305 Archive and member names will be added." |
306 :type '(list (string :tag "Program") | |
307 (repeat :tag "Options" | |
308 :inline t | |
309 (string :format "%v"))) | |
310 :group 'archive-zoo) | |
11880 | 311 |
19926 | 312 (defcustom archive-zoo-write-file-member |
11880 | 313 '("zoo" "a") |
314 "*Program and its options to run in order to update a zoo file member. | |
19926 | 315 Archive and member name will be added." |
316 :type '(list (string :tag "Program") | |
317 (repeat :tag "Options" | |
318 :inline t | |
319 (string :format "%v"))) | |
320 :group 'archive-zoo) | |
11880 | 321 ;; ------------------------------------------------------------------------- |
322 ;; Section: Variables | |
323 | |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
324 (defvar archive-subtype nil "Symbol describing archive type.") |
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
325 (defvar archive-file-list-start nil "Position of first contents line.") |
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
326 (defvar archive-file-list-end nil "Position just after last contents line.") |
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
327 (defvar archive-proper-file-start nil "Position of real archive's start.") |
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
328 (defvar archive-read-only nil "Non-nil if the archive is read-only on disk.") |
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
329 (defvar archive-local-name nil "Name of local copy of remote archive.") |
61414
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
330 (defvar archive-mode-map |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
331 (let ((map (make-keymap))) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
332 (suppress-keymap map) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
333 (define-key map " " 'archive-next-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
334 (define-key map "a" 'archive-alternate-display) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
335 ;;(define-key map "c" 'archive-copy) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
336 (define-key map "d" 'archive-flag-deleted) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
337 (define-key map "\C-d" 'archive-flag-deleted) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
338 (define-key map "e" 'archive-extract) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
339 (define-key map "f" 'archive-extract) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
340 (define-key map "\C-m" 'archive-extract) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
341 (define-key map "g" 'revert-buffer) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
342 (define-key map "h" 'describe-mode) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
343 (define-key map "m" 'archive-mark) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
344 (define-key map "n" 'archive-next-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
345 (define-key map "\C-n" 'archive-next-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
346 (define-key map [down] 'archive-next-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
347 (define-key map "o" 'archive-extract-other-window) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
348 (define-key map "p" 'archive-previous-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
349 (define-key map "q" 'quit-window) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
350 (define-key map "\C-p" 'archive-previous-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
351 (define-key map [up] 'archive-previous-line) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
352 (define-key map "r" 'archive-rename-entry) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
353 (define-key map "u" 'archive-unflag) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
354 (define-key map "\M-\C-?" 'archive-unmark-all-files) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
355 (define-key map "v" 'archive-view) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
356 (define-key map "x" 'archive-expunge) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
357 (define-key map "\177" 'archive-unflag-backwards) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
358 (define-key map "E" 'archive-extract-other-window) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
359 (define-key map "M" 'archive-chmod-entry) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
360 (define-key map "G" 'archive-chgrp-entry) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
361 (define-key map "O" 'archive-chown-entry) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
362 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
363 (if (fboundp 'command-remapping) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
364 (progn |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
365 (define-key map [remap advertised-undo] 'archive-undo) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
366 (define-key map [remap undo] 'archive-undo)) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
367 (substitute-key-definition 'advertised-undo 'archive-undo map global-map) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
368 (substitute-key-definition 'undo 'archive-undo map global-map)) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
369 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
370 (define-key map |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
371 (if (featurep 'xemacs) 'button2 [mouse-2]) 'archive-extract) |
61414
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
372 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
373 (if (featurep 'xemacs) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
374 () ; out of luck |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
375 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
376 (define-key map [menu-bar immediate] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
377 (cons "Immediate" (make-sparse-keymap "Immediate"))) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
378 (define-key map [menu-bar immediate alternate] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
379 '(menu-item "Alternate Display" archive-alternate-display |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
380 :enable (boundp (archive-name "alternate-display")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
381 :help "Toggle alternate file info display")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
382 (define-key map [menu-bar immediate view] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
383 '(menu-item "View This File" archive-view |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
384 :help "Display file at cursor in View Mode")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
385 (define-key map [menu-bar immediate display] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
386 '(menu-item "Display in Other Window" archive-display-other-window |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
387 :help "Display file at cursor in another window")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
388 (define-key map [menu-bar immediate find-file-other-window] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
389 '(menu-item "Find in Other Window" archive-extract-other-window |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
390 :help "Edit file at cursor in another window")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
391 (define-key map [menu-bar immediate find-file] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
392 '(menu-item "Find This File" archive-extract |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
393 :help "Extract file at cursor and edit it")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
394 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
395 (define-key map [menu-bar mark] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
396 (cons "Mark" (make-sparse-keymap "Mark"))) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
397 (define-key map [menu-bar mark unmark-all] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
398 '(menu-item "Unmark All" archive-unmark-all-files |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
399 :help "Unmark all marked files")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
400 (define-key map [menu-bar mark deletion] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
401 '(menu-item "Flag" archive-flag-deleted |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
402 :help "Flag file at cursor for deletion")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
403 (define-key map [menu-bar mark unmark] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
404 '(menu-item "Unflag" archive-unflag |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
405 :help "Unmark file at cursor")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
406 (define-key map [menu-bar mark mark] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
407 '(menu-item "Mark" archive-mark |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
408 :help "Mark file at cursor")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
409 |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
410 (define-key map [menu-bar operate] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
411 (cons "Operate" (make-sparse-keymap "Operate"))) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
412 (define-key map [menu-bar operate chown] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
413 '(menu-item "Change Owner..." archive-chown-entry |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
414 :enable (fboundp (archive-name "chown-entry")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
415 :help "Change owner of marked files")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
416 (define-key map [menu-bar operate chgrp] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
417 '(menu-item "Change Group..." archive-chgrp-entry |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
418 :enable (fboundp (archive-name "chgrp-entry")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
419 :help "Change group ownership of marked files")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
420 (define-key map [menu-bar operate chmod] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
421 '(menu-item "Change Mode..." archive-chmod-entry |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
422 :enable (fboundp (archive-name "chmod-entry")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
423 :help "Change mode (permissions) of marked files")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
424 (define-key map [menu-bar operate rename] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
425 '(menu-item "Rename to..." archive-rename-entry |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
426 :enable (fboundp (archive-name "rename-entry")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
427 :help "Rename marked files")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
428 ;;(define-key map [menu-bar operate copy] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
429 ;; '(menu-item "Copy to..." archive-copy)) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
430 (define-key map [menu-bar operate expunge] |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
431 '(menu-item "Expunge Marked Files" archive-expunge |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
432 :help "Delete all flagged files from archive")) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
433 map)) |
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
434 "Local keymap for archive mode listings.") |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
435 (defvar archive-file-name-indent nil "Column where file names start.") |
11880 | 436 |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
437 (defvar archive-remote nil "Non-nil if the archive is outside file system.") |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
438 (make-variable-buffer-local 'archive-remote) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
439 (put 'archive-remote 'permanent-local t) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
440 |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
441 (defvar archive-member-coding-system nil "Coding-system of archive member.") |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
442 (make-variable-buffer-local 'archive-member-coding-system) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
443 |
11880 | 444 (defvar archive-alternate-display nil |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
445 "Non-nil when alternate information is shown.") |
11880 | 446 (make-variable-buffer-local 'archive-alternate-display) |
447 (put 'archive-alternate-display 'permanent-local t) | |
448 | |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
449 (defvar archive-superior-buffer nil "In archive members, points to archive.") |
11880 | 450 (put 'archive-superior-buffer 'permanent-local t) |
451 | |
50136
ad28e7a35442
* files.el (recover-session): Error if there are no previous
John Paul Wallington <jpw@pobox.com>
parents:
49588
diff
changeset
|
452 (defvar archive-subfile-mode nil "Non-nil in archive member buffers.") |
11880 | 453 (make-variable-buffer-local 'archive-subfile-mode) |
454 (put 'archive-subfile-mode 'permanent-local t) | |
455 | |
16291 | 456 (defvar archive-files nil |
457 "Vector of file descriptors. | |
458 Each descriptor is a vector of the form | |
459 [EXT-FILE-NAME INT-FILE-NAME CASE-FIDDLED MODE ...]") | |
11880 | 460 (make-variable-buffer-local 'archive-files) |
12024
8e31a35ac027
(archive-lemacs): New variable.
Karl Heuer <kwzh@gnu.org>
parents:
11887
diff
changeset
|
461 |
11880 | 462 ;; ------------------------------------------------------------------------- |
463 ;; Section: Support functions. | |
464 | |
465 (defsubst archive-name (suffix) | |
466 (intern (concat "archive-" (symbol-name archive-subtype) "-" suffix))) | |
467 | |
468 (defun archive-l-e (str &optional len) | |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
469 "Convert little endian string/vector STR to integer. |
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
470 Alternatively, STR may be a buffer position in the current buffer |
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
471 in which case a second argument, length LEN, should be supplied." |
11880 | 472 (if (stringp str) |
473 (setq len (length str)) | |
474 (setq str (buffer-substring str (+ str len)))) | |
475 (let ((result 0) | |
476 (i 0)) | |
477 (while (< i len) | |
478 (setq i (1+ i) | |
479 result (+ (ash result 8) (aref str (- len i))))) | |
480 result)) | |
481 | |
482 (defun archive-int-to-mode (mode) | |
37645
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
483 "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------." |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
484 ;; FIXME: merge with tar-grind-file-mode. |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
485 (string |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
486 (if (zerop (logand 8192 mode)) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
487 (if (zerop (logand 16384 mode)) ?- ?d) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
488 ?c) ; completeness |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
489 (if (zerop (logand 256 mode)) ?- ?r) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
490 (if (zerop (logand 128 mode)) ?- ?w) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
491 (if (zerop (logand 64 mode)) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
492 (if (zerop (logand 1024 mode)) ?- ?S) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
493 (if (zerop (logand 1024 mode)) ?x ?s)) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
494 (if (zerop (logand 32 mode)) ?- ?r) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
495 (if (zerop (logand 16 mode)) ?- ?w) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
496 (if (zerop (logand 8 mode)) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
497 (if (zerop (logand 2048 mode)) ?- ?S) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
498 (if (zerop (logand 2048 mode)) ?x ?s)) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
499 (if (zerop (logand 4 mode)) ?- ?r) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
500 (if (zerop (logand 2 mode)) ?- ?w) |
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
501 (if (zerop (logand 1 mode)) ?- ?x))) |
11880 | 502 |
503 (defun archive-calc-mode (oldmode newmode &optional error) | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
504 "From the integer OLDMODE and the string NEWMODE calculate a new file mode. |
11880 | 505 NEWMODE may be an octal number including a leading zero in which case it |
506 will become the new mode.\n | |
507 NEWMODE may also be a relative specification like \"og-rwx\" in which case | |
508 OLDMODE will be modified accordingly just like chmod(2) would have done.\n | |
509 If optional third argument ERROR is non-nil an error will be signaled if | |
510 the mode is invalid. If ERROR is nil then nil will be returned." | |
511 (cond ((string-match "^0[0-7]*$" newmode) | |
512 (let ((result 0) | |
513 (len (length newmode)) | |
514 (i 1)) | |
515 (while (< i len) | |
516 (setq result (+ (lsh result 3) (aref newmode i) (- ?0)) | |
517 i (1+ i))) | |
518 (logior (logand oldmode 65024) result))) | |
519 ((string-match "^\\([agou]+\\)\\([---+=]\\)\\([rwxst]+\\)$" newmode) | |
520 (let ((who 0) | |
521 (result oldmode) | |
522 (op (aref newmode (match-beginning 2))) | |
523 (bits 0) | |
524 (i (match-beginning 3))) | |
525 (while (< i (match-end 3)) | |
526 (let ((rwx (aref newmode i))) | |
527 (setq bits (logior bits (cond ((= rwx ?r) 292) | |
528 ((= rwx ?w) 146) | |
529 ((= rwx ?x) 73) | |
530 ((= rwx ?s) 3072) | |
531 ((= rwx ?t) 512))) | |
532 i (1+ i)))) | |
533 (while (< who (match-end 1)) | |
534 (let* ((whoc (aref newmode who)) | |
535 (whomask (cond ((= whoc ?a) 4095) | |
536 ((= whoc ?u) 1472) | |
537 ((= whoc ?g) 2104) | |
538 ((= whoc ?o) 7)))) | |
539 (if (= op ?=) | |
540 (setq result (logand result (lognot whomask)))) | |
541 (if (= op ?-) | |
542 (setq result (logand result (lognot (logand whomask bits)))) | |
543 (setq result (logior result (logand whomask bits))))) | |
544 (setq who (1+ who))) | |
545 result)) | |
546 (t | |
547 (if error | |
548 (error "Invalid mode specification: %s" newmode))))) | |
549 | |
550 (defun archive-dosdate (date) | |
551 "Stringify dos packed DATE record." | |
552 (let ((year (+ 1980 (logand (ash date -9) 127))) | |
553 (month (logand (ash date -5) 15)) | |
554 (day (logand date 31))) | |
555 (if (or (> month 12) (< month 1)) | |
556 "" | |
557 (format "%2d-%s-%d" | |
558 day | |
559 (aref ["Jan" "Feb" "Mar" "Apr" "May" "Jun" | |
560 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"] (1- month)) | |
561 year)))) | |
562 | |
563 (defun archive-dostime (time) | |
564 "Stringify dos packed TIME record." | |
565 (let ((hour (logand (ash time -11) 31)) | |
39180
f952f4f3d625
(archive-dostime): Fix a typo in minutes' computation.
Eli Zaretskii <eliz@gnu.org>
parents:
38409
diff
changeset
|
566 (minute (logand (ash time -5) 63)) |
11880 | 567 (second (* 2 (logand time 31)))) ; 2 seconds resolution |
568 (format "%02d:%02d:%02d" hour minute second))) | |
569 | |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
570 (defun archive-unixdate (low high) |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
571 "Stringify Unix (LOW HIGH) date." |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
572 (let ((str (current-time-string (cons high low)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
573 (format "%s-%s-%s" |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
574 (substring str 8 10) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
575 (substring str 4 7) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
576 (substring str 20 24)))) |
11880 | 577 |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
578 (defun archive-unixtime (low high) |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
579 "Stringify Unix (LOW HIGH) time." |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
580 (let ((str (current-time-string (cons high low)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
581 (substring str 11 19))) |
11880 | 582 |
583 (defun archive-get-lineno () | |
584 (if (>= (point) archive-file-list-start) | |
585 (count-lines archive-file-list-start | |
586 (save-excursion (beginning-of-line) (point))) | |
587 0)) | |
588 | |
589 (defun archive-get-descr (&optional noerror) | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
590 "Return the descriptor vector for file at point. |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
591 Does not signal an error if optional argument NOERROR is non-nil." |
11880 | 592 (let ((no (archive-get-lineno))) |
593 (if (and (>= (point) archive-file-list-start) | |
594 (< no (length archive-files))) | |
595 (let ((item (aref archive-files no))) | |
596 (if (vectorp item) | |
597 item | |
598 (if (not noerror) | |
599 (error "Entry is not a regular member of the archive")))) | |
600 (if (not noerror) | |
601 (error "Line does not describe a member of the archive"))))) | |
602 ;; ------------------------------------------------------------------------- | |
603 ;; Section: the mode definition | |
604 | |
12437
c3597b66e4bf
(archive-mode): Add autoload cookie.
Richard M. Stallman <rms@gnu.org>
parents:
12304
diff
changeset
|
605 ;;;###autoload |
11880 | 606 (defun archive-mode (&optional force) |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
607 "Major mode for viewing an archive file in a dired-like way. |
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
608 You can move around using the usual cursor motion commands. |
11880 | 609 Letters no longer insert themselves. |
610 Type `e' to pull a file out of the archive and into its own buffer; | |
611 or click mouse-2 on the file's line in the archive mode buffer. | |
612 | |
613 If you edit a sub-file of this archive (as with the `e' command) and | |
614 save it, the contents of that buffer will be saved back into the | |
615 archive. | |
616 | |
617 \\{archive-mode-map}" | |
618 ;; This is not interactive because you shouldn't be turning this | |
619 ;; mode on and off. You can corrupt things that way. | |
620 (if (zerop (buffer-size)) | |
621 ;; At present we cannot create archives from scratch | |
622 (funcall default-major-mode) | |
623 (if (and (not force) archive-files) nil | |
624 (let* ((type (archive-find-type)) | |
37645
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
625 (typename (capitalize (symbol-name type)))) |
11880 | 626 (kill-all-local-variables) |
627 (make-local-variable 'archive-subtype) | |
628 (setq archive-subtype type) | |
629 | |
630 ;; Buffer contains treated image of file before the file contents | |
631 (make-local-variable 'revert-buffer-function) | |
632 (setq revert-buffer-function 'archive-mode-revert) | |
633 (auto-save-mode 0) | |
634 | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
635 ;; Remote archives are not written by a hook. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
636 (if archive-remote nil |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
637 (add-hook 'write-contents-functions 'archive-write-file nil t)) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
638 |
11880 | 639 (make-local-variable 'require-final-newline) |
640 (setq require-final-newline nil) | |
22472
7d99675ff55f
(archive-mode): Locally bind local-enable-local-variables, not
Richard M. Stallman <rms@gnu.org>
parents:
22327
diff
changeset
|
641 (make-local-variable 'local-enable-local-variables) |
7d99675ff55f
(archive-mode): Locally bind local-enable-local-variables, not
Richard M. Stallman <rms@gnu.org>
parents:
22327
diff
changeset
|
642 (setq local-enable-local-variables nil) |
11880 | 643 |
23481
4e3bead33d34
(archive-mode): Locally set file-precious-flag.
Richard M. Stallman <rms@gnu.org>
parents:
23467
diff
changeset
|
644 ;; Prevent loss of data when saving the file. |
4e3bead33d34
(archive-mode): Locally set file-precious-flag.
Richard M. Stallman <rms@gnu.org>
parents:
23467
diff
changeset
|
645 (make-local-variable 'file-precious-flag) |
4e3bead33d34
(archive-mode): Locally set file-precious-flag.
Richard M. Stallman <rms@gnu.org>
parents:
23467
diff
changeset
|
646 (setq file-precious-flag t) |
4e3bead33d34
(archive-mode): Locally set file-precious-flag.
Richard M. Stallman <rms@gnu.org>
parents:
23467
diff
changeset
|
647 |
11880 | 648 (make-local-variable 'archive-read-only) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
649 ;; Archives which are inside other archives and whose |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
650 ;; names are invalid for this OS, can't be written. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
651 (setq archive-read-only |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
652 (or (not (file-writable-p (buffer-file-name))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
653 (and archive-subfile-mode |
22174
18a455216af7
(archive-file-name-invalid-regexp): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
22096
diff
changeset
|
654 (string-match file-name-invalid-regexp |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
655 (aref archive-subfile-mode 0))))) |
11880 | 656 |
657 ;; Should we use a local copy when accessing from outside Emacs? | |
658 (make-local-variable 'archive-local-name) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
659 |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
660 ;; An archive can contain another archive whose name is invalid |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
661 ;; on local filesystem. Treat such archives as remote. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
662 (or archive-remote |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
663 (setq archive-remote |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
664 (or (string-match archive-remote-regexp (buffer-file-name)) |
22174
18a455216af7
(archive-file-name-invalid-regexp): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
22096
diff
changeset
|
665 (string-match file-name-invalid-regexp |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
666 (buffer-file-name))))) |
11880 | 667 |
668 (setq major-mode 'archive-mode) | |
669 (setq mode-name (concat typename "-Archive")) | |
670 ;; Run archive-foo-mode-hook and archive-mode-hook | |
62714
ec0621e2b94f
(archive-mode): Use run-mode-hooks.
Lute Kamstra <lute@gnu.org>
parents:
61414
diff
changeset
|
671 (run-mode-hooks (archive-name "mode-hook") 'archive-mode-hook) |
11880 | 672 (use-local-map archive-mode-map)) |
673 | |
674 (make-local-variable 'archive-proper-file-start) | |
675 (make-local-variable 'archive-file-list-start) | |
676 (make-local-variable 'archive-file-list-end) | |
677 (make-local-variable 'archive-file-name-indent) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
678 (archive-summarize nil) |
11880 | 679 (setq buffer-read-only t)))) |
680 | |
681 ;; Archive mode is suitable only for specially formatted data. | |
682 (put 'archive-mode 'mode-class 'special) | |
683 | |
61414
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
684 (let ((item1 '(archive-subfile-mode " Archive"))) |
11880 | 685 (or (member item1 minor-mode-alist) |
61414
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
686 (setq minor-mode-alist (cons item1 minor-mode-alist)))) |
11880 | 687 ;; ------------------------------------------------------------------------- |
688 (defun archive-find-type () | |
689 (widen) | |
690 (goto-char (point-min)) | |
691 ;; The funny [] here make it unlikely that the .elc file will be treated | |
692 ;; as an archive by other software. | |
693 (let (case-fold-search) | |
694 (cond ((looking-at "[P]K\003\004") 'zip) | |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
695 ((looking-at "..-l[hz][0-9ds]-") 'lzh) |
11880 | 696 ((looking-at "....................[\334]\247\304\375") 'zoo) |
697 ((and (looking-at "\C-z") ; signature too simple, IMHO | |
698 (string-match "\\.[aA][rR][cC]$" | |
699 (or buffer-file-name (buffer-name)))) | |
700 'arc) | |
38409
153f1b1f2efd
Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents:
38072
diff
changeset
|
701 (t (error "Buffer format not recognized"))))) |
11880 | 702 ;; ------------------------------------------------------------------------- |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
703 (defun archive-summarize (&optional shut-up) |
11880 | 704 "Parse the contents of the archive file in the current buffer. |
705 Place a dired-like listing on the front; | |
706 then narrow to it, so that only that listing | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
707 is visible (and the real data of the buffer is hidden). |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
708 Optional argument SHUT-UP, if non-nil, means don't print messages |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
709 when parsing the archive." |
11880 | 710 (widen) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
711 (set-buffer-multibyte nil) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
712 (let ((inhibit-read-only t)) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
713 (or shut-up |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
714 (message "Parsing archive file...")) |
11880 | 715 (buffer-disable-undo (current-buffer)) |
716 (setq archive-files (funcall (archive-name "summarize"))) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
717 (or shut-up |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
718 (message "Parsing archive file...done.")) |
11880 | 719 (setq archive-proper-file-start (point-marker)) |
720 (narrow-to-region (point-min) (point)) | |
721 (set-buffer-modified-p nil) | |
722 (buffer-enable-undo)) | |
723 (goto-char archive-file-list-start) | |
724 (archive-next-line 0)) | |
725 | |
726 (defun archive-resummarize () | |
727 "Recreate the contents listing of an archive." | |
728 (let ((modified (buffer-modified-p)) | |
729 (no (archive-get-lineno)) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
730 (inhibit-read-only t)) |
11880 | 731 (widen) |
732 (delete-region (point-min) archive-proper-file-start) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
733 (archive-summarize t) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
734 (restore-buffer-modified-p modified) |
11880 | 735 (goto-char archive-file-list-start) |
736 (archive-next-line no))) | |
737 | |
738 (defun archive-summarize-files (files) | |
16291 | 739 "Insert a description of a list of files annotated with proper mouse face." |
11880 | 740 (setq archive-file-list-start (point-marker)) |
741 (setq archive-file-name-indent (if files (aref (car files) 1) 0)) | |
742 ;; We don't want to do an insert for each element since that takes too | |
743 ;; long when the archive -- which has to be moved in memory -- is large. | |
744 (insert | |
745 (apply | |
746 (function concat) | |
747 (mapcar | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
748 (lambda (fil) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
749 ;; Using `concat' here copies the text also, so we can add |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
750 ;; properties without problems. |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
751 (let ((text (concat (aref fil 0) "\n"))) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
752 (if (featurep 'xemacs) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
753 () ; out of luck |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
754 (add-text-properties |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
755 (aref fil 1) (aref fil 2) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
756 '(mouse-face highlight |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
757 help-echo "mouse-2: extract this file into a buffer") |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
758 text)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
759 text)) |
11880 | 760 files))) |
761 (setq archive-file-list-end (point-marker))) | |
762 | |
763 (defun archive-alternate-display () | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
764 "Toggle alternative display. |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
765 To avoid very long lines archive mode does not show all information. |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
766 This function changes the set of information shown for each files." |
11880 | 767 (interactive) |
768 (setq archive-alternate-display (not archive-alternate-display)) | |
769 (archive-resummarize)) | |
770 ;; ------------------------------------------------------------------------- | |
771 ;; Section: Local archive copy handling | |
772 | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
773 (defun archive-unique-fname (fname dir) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
774 "Make sure a file FNAME can be created uniquely in directory DIR. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
775 |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
776 If FNAME can be uniquely created in DIR, it is returned unaltered. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
777 If FNAME is something our underlying filesystem can't grok, or if another |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
778 file by that name already exists in DIR, a unique new name is generated |
37645
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
779 using `make-temp-file', and the generated name is returned." |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
780 (let ((fullname (expand-file-name fname dir)) |
22174
18a455216af7
(archive-file-name-invalid-regexp): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
22096
diff
changeset
|
781 (alien (string-match file-name-invalid-regexp fname))) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
782 (if (or alien (file-exists-p fullname)) |
37645
3fa9dd549e89
(archive-int-to-mode): Construct the string directly.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
32484
diff
changeset
|
783 (make-temp-file |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
784 (expand-file-name |
49238
86973b914660
(archive-arc-rename-entry): Fix error message.
Kim F. Storm <storm@cua.dk>
parents:
49166
diff
changeset
|
785 (if (if (fboundp 'msdos-long-file-names) |
86973b914660
(archive-arc-rename-entry): Fix error message.
Kim F. Storm <storm@cua.dk>
parents:
49166
diff
changeset
|
786 (not (msdos-long-file-names))) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
787 "am" |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
788 "arc-mode.") |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
789 dir)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
790 fullname))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
791 |
11880 | 792 (defun archive-maybe-copy (archive) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
793 (let ((coding-system-for-write 'no-conversion)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
794 (if archive-remote |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
795 (let ((start (point-max)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
796 ;; Sometimes ARCHIVE is invalid while its actual name, as |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
797 ;; recorded in its parent archive, is not. For example, an |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
798 ;; archive bar.zip inside another archive foo.zip gets a name |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
799 ;; "foo.zip:bar.zip", which is invalid on DOS/Windows. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
800 ;; So use the actual name if available. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
801 (archive-name |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
802 (or (and archive-subfile-mode (aref archive-subfile-mode 0)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
803 archive))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
804 (make-directory archive-tmpdir t) |
55184
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
805 ;; If ARCHIVE includes leading directories, make sure they |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
806 ;; exist under archive-tmpdir. |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
807 (let ((arch-dir (file-name-directory archive))) |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
808 (if arch-dir |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
809 (make-directory (concat |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
810 (file-name-as-directory archive-tmpdir) |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
811 arch-dir) |
9e01303c94ac
(archive-maybe-copy): If ARCHIVE includes leading
Eli Zaretskii <eliz@gnu.org>
parents:
53397
diff
changeset
|
812 t))) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
813 (setq archive-local-name |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
814 (archive-unique-fname archive-name archive-tmpdir)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
815 (save-restriction |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
816 (widen) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
817 (write-region start (point-max) archive-local-name nil 'nomessage)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
818 archive-local-name) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
819 (if (buffer-modified-p) (save-buffer)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
820 archive))) |
11880 | 821 |
822 (defun archive-maybe-update (unchanged) | |
823 (if archive-remote | |
824 (let ((name archive-local-name) | |
825 (modified (buffer-modified-p)) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
826 (coding-system-for-read 'no-conversion) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
827 (lno (archive-get-lineno)) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
828 (inhibit-read-only t)) |
11880 | 829 (if unchanged nil |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
830 (setq archive-files nil) |
11880 | 831 (erase-buffer) |
832 (insert-file-contents name) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
833 (archive-mode t) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
834 (goto-char archive-file-list-start) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
835 (archive-next-line lno)) |
11880 | 836 (archive-delete-local name) |
837 (if (not unchanged) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
838 (message |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
839 "Buffer `%s' must be saved for changes to take effect" |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
840 (buffer-name (current-buffer)))) |
11880 | 841 (set-buffer-modified-p (or modified (not unchanged)))))) |
842 | |
843 (defun archive-delete-local (name) | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
844 "Delete file NAME and its parents up to and including `archive-tmpdir'." |
11880 | 845 (let ((again t) |
846 (top (directory-file-name (file-name-as-directory archive-tmpdir)))) | |
847 (condition-case nil | |
848 (delete-file name) | |
849 (error nil)) | |
850 (while again | |
851 (setq name (directory-file-name (file-name-directory name))) | |
852 (condition-case nil | |
853 (delete-directory name) | |
854 (error nil)) | |
855 (if (string= name top) (setq again nil))))) | |
856 ;; ------------------------------------------------------------------------- | |
857 ;; Section: Member extraction | |
858 | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
859 (defun archive-file-name-handler (op &rest args) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
860 (or (eq op 'file-exists-p) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
861 (let ((file-name-handler-alist nil)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
862 (apply op args)))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
863 |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
864 (defun archive-set-buffer-as-visiting-file (filename) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
865 "Set the current buffer as if it were visiting FILENAME." |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
866 (save-excursion |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
867 (goto-char (point-min)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
868 (let ((coding |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
869 (or coding-system-for-read |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
870 (and set-auto-coding-function |
24381
b3c0f3ad64d8
(archive-set-buffer-as-visiting-file): Save
Eli Zaretskii <eliz@gnu.org>
parents:
23481
diff
changeset
|
871 (save-excursion |
b3c0f3ad64d8
(archive-set-buffer-as-visiting-file): Save
Eli Zaretskii <eliz@gnu.org>
parents:
23481
diff
changeset
|
872 (funcall set-auto-coding-function |
b3c0f3ad64d8
(archive-set-buffer-as-visiting-file): Save
Eli Zaretskii <eliz@gnu.org>
parents:
23481
diff
changeset
|
873 filename (- (point-max) (point-min))))) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
874 ;; dos-w32.el defines find-operation-coding-system for |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
875 ;; DOS/Windows systems which preserves the coding-system |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
876 ;; of existing files. We want it to act here as if the |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
877 ;; extracted file existed. |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
878 (let ((file-name-handler-alist |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
879 '(("" . archive-file-name-handler)))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
880 (car (find-operation-coding-system 'insert-file-contents |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
881 filename t)))))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
882 (if (and (not coding-system-for-read) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
883 (not enable-multibyte-characters)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
884 (setq coding |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
885 (coding-system-change-text-conversion coding 'raw-text))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
886 (if (and coding |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
887 (not (eq coding 'no-conversion))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
888 (decode-coding-region (point-min) (point-max) coding) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
889 (setq last-coding-system-used coding)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
890 (set-buffer-modified-p nil) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
891 (kill-local-variable 'buffer-file-coding-system) |
50835
b7770bea6205
(archive-set-buffer-as-visiting-file): Use
Kenichi Handa <handa@m17n.org>
parents:
50136
diff
changeset
|
892 (after-insert-file-set-coding (- (point-max) (point-min)))))) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
893 |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
894 (define-obsolete-function-alias 'archive-mouse-extract 'archive-extract "22.1") |
11880 | 895 |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
896 (defun archive-extract (&optional other-window-p event) |
11880 | 897 "In archive mode, extract this entry of the archive into its own buffer." |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
898 (interactive (list nil last-input-event)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
899 (if event (mouse-set-point event)) |
11880 | 900 (let* ((view-p (eq other-window-p 'view)) |
901 (descr (archive-get-descr)) | |
902 (ename (aref descr 0)) | |
903 (iname (aref descr 1)) | |
904 (archive-buffer (current-buffer)) | |
905 (arcdir default-directory) | |
906 (archive (buffer-file-name)) | |
907 (arcname (file-name-nondirectory archive)) | |
908 (bufname (concat (file-name-nondirectory iname) " (" arcname ")")) | |
909 (extractor (archive-name "extract")) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
910 ;; Members with file names which aren't valid for the |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
911 ;; underlying filesystem, are treated as read-only. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
912 (read-only-p (or archive-read-only |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
913 view-p |
22174
18a455216af7
(archive-file-name-invalid-regexp): Remove.
Eli Zaretskii <eliz@gnu.org>
parents:
22096
diff
changeset
|
914 (string-match file-name-invalid-regexp ename))) |
11880 | 915 (buffer (get-buffer bufname)) |
916 (just-created nil)) | |
917 (if buffer | |
918 nil | |
919 (setq archive (archive-maybe-copy archive)) | |
920 (setq buffer (get-buffer-create bufname)) | |
921 (setq just-created t) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
922 (with-current-buffer buffer |
11880 | 923 (setq buffer-file-name |
924 (expand-file-name (concat arcname ":" iname))) | |
925 (setq buffer-file-truename | |
926 (abbreviate-file-name buffer-file-name)) | |
927 ;; Set the default-directory to the dir of the superior buffer. | |
928 (setq default-directory arcdir) | |
929 (make-local-variable 'archive-superior-buffer) | |
930 (setq archive-superior-buffer archive-buffer) | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
931 (add-hook 'write-file-functions 'archive-write-file-member nil t) |
11880 | 932 (setq archive-subfile-mode descr) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
933 (if (and |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
934 (null |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
935 (let (;; We may have to encode file name arguement for |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
936 ;; external programs. |
22834
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
937 (coding-system-for-write |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
938 (and enable-multibyte-characters |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
939 file-name-coding-system)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
940 ;; We read an archive member by no-conversion at |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
941 ;; first, then decode appropriately by calling |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
942 ;; archive-set-buffer-as-visiting-file later. |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
943 (coding-system-for-read 'no-conversion)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
944 (condition-case err |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
945 (if (fboundp extractor) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
946 (funcall extractor archive ename) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
947 (archive-*-extract archive ename |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
948 (symbol-value extractor))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
949 (error |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
950 (ding (message "%s" (error-message-string err))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
951 nil)))) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
952 just-created) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
953 (progn |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
954 (set-buffer-modified-p nil) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
955 (kill-buffer buffer)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
956 (archive-set-buffer-as-visiting-file ename) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
957 (goto-char (point-min)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
958 (rename-buffer bufname) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
959 (setq buffer-read-only read-only-p) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
960 (setq buffer-undo-list nil) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
961 (set-buffer-modified-p nil) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
962 (setq buffer-saved-size (buffer-size)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
963 (normal-mode) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
964 ;; Just in case an archive occurs inside another archive. |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
965 (when (derived-mode-p 'archive-mode) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
966 (setq archive-remote t) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
967 (if read-only-p (setq archive-read-only t)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
968 ;; We will write out the archive ourselves if it is |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
969 ;; part of another archive. |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
970 (remove-hook 'write-contents-functions 'archive-write-file t)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
971 (run-hooks 'archive-extract-hooks) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
972 (if archive-read-only |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
973 (message "Note: altering this archive is not implemented.")))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
974 (archive-maybe-update t)) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
975 (or (not (buffer-name buffer)) |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
976 (cond |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
977 (view-p (view-buffer buffer (and just-created 'kill-buffer))) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
978 ((eq other-window-p 'display) (display-buffer buffer)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
979 (other-window-p (switch-to-buffer-other-window buffer)) |
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
980 (t (switch-to-buffer buffer)))))) |
11880 | 981 |
982 (defun archive-*-extract (archive name command) | |
983 (let* ((default-directory (file-name-as-directory archive-tmpdir)) | |
984 (tmpfile (expand-file-name (file-name-nondirectory name) | |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
985 default-directory)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
986 exit-status success) |
11880 | 987 (make-directory (directory-file-name default-directory) t) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
988 (setq exit-status |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
989 (apply 'call-process |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
990 (car command) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
991 nil |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
992 nil |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
993 nil |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
994 (append (cdr command) (list archive name)))) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
995 (cond ((and (numberp exit-status) (= exit-status 0)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
996 (if (not (file-exists-p tmpfile)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
997 (ding (message "`%s': no such file or directory" tmpfile)) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
998 (insert-file-contents tmpfile) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
999 (setq success t))) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1000 ((numberp exit-status) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1001 (ding |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1002 (message "`%s' exited with status %d" (car command) exit-status))) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1003 ((stringp exit-status) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1004 (ding (message "`%s' aborted: %s" (car command) exit-status))) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1005 (t |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1006 (ding (message "`%s' failed" (car command))))) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1007 (archive-delete-local tmpfile) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1008 success)) |
11880 | 1009 |
1010 (defun archive-extract-by-stdout (archive name command) | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1011 (apply 'call-process |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1012 (car command) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1013 nil |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1014 t |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1015 nil |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1016 (append (cdr command) (list archive name)))) |
11880 | 1017 |
1018 (defun archive-extract-other-window () | |
1019 "In archive mode, find this member in another window." | |
1020 (interactive) | |
1021 (archive-extract t)) | |
1022 | |
1023 (defun archive-display-other-window () | |
1024 "In archive mode, display this member in another window." | |
1025 (interactive) | |
1026 (archive-extract 'display)) | |
1027 | |
1028 (defun archive-view () | |
1029 "In archive mode, view the member on this line." | |
1030 (interactive) | |
1031 (archive-extract 'view)) | |
1032 | |
1033 (defun archive-add-new-member (arcbuf name) | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
1034 "Add current buffer to the archive in ARCBUF naming it NAME." |
11880 | 1035 (interactive |
1036 (list (get-buffer | |
1037 (read-buffer "Buffer containing archive: " | |
1038 ;; Find first archive buffer and suggest that | |
1039 (let ((bufs (buffer-list))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1040 (while (and bufs |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1041 (not (with-current-buffer (car bufs) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1042 (derived-mode-p 'archive-mode)))) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1043 (setq bufs (cdr bufs))) |
11880 | 1044 (if bufs |
1045 (car bufs) | |
1046 (error "There are no archive buffers"))) | |
1047 t)) | |
1048 (read-string "File name in archive: " | |
1049 (if buffer-file-name | |
1050 (file-name-nondirectory buffer-file-name) | |
1051 "")))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1052 (with-current-buffer arcbuf |
11880 | 1053 (or (eq major-mode 'archive-mode) |
1054 (error "Buffer is not an archive buffer")) | |
1055 (if archive-read-only | |
1056 (error "Archive is read-only"))) | |
1057 (if (eq arcbuf (current-buffer)) | |
1058 (error "An archive buffer cannot be added to itself")) | |
1059 (if (string= name "") | |
1060 (error "Archive members may not be given empty names")) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1061 (let ((func (with-current-buffer arcbuf |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1062 (archive-name "add-new-member"))) |
11880 | 1063 (membuf (current-buffer))) |
1064 (if (fboundp func) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1065 (with-current-buffer arcbuf |
11880 | 1066 (funcall func buffer-file-name membuf name)) |
1067 (error "Adding a new member is not supported for this archive type")))) | |
1068 ;; ------------------------------------------------------------------------- | |
1069 ;; Section: IO stuff | |
1070 | |
1071 (defun archive-write-file-member () | |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1072 (save-excursion |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1073 (save-restriction |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1074 (message "Updating archive...") |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1075 (widen) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1076 (let ((writer (with-current-buffer archive-superior-buffer |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1077 (archive-name "write-file-member"))) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1078 (archive (with-current-buffer archive-superior-buffer |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1079 (archive-maybe-copy (buffer-file-name))))) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1080 (if (fboundp writer) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1081 (funcall writer archive archive-subfile-mode) |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1082 (archive-*-write-file-member archive |
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1083 archive-subfile-mode |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1084 (symbol-value writer))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1085 (set-buffer-modified-p nil) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1086 (message "Updating archive...done")) |
21570
e21c343b0c6e
(archive-extract-by-stdout): Don't use
Eli Zaretskii <eliz@gnu.org>
parents:
20767
diff
changeset
|
1087 (set-buffer archive-superior-buffer) |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1088 (if (not archive-remote) (revert-buffer) (archive-maybe-update nil)))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1089 ;; Restore the value of last-coding-system-used, so that basic-save-buffer |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1090 ;; won't reset the coding-system of this archive member. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1091 (if (local-variable-p 'archive-member-coding-system) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1092 (setq last-coding-system-used archive-member-coding-system)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1093 t) |
11880 | 1094 |
1095 (defun archive-*-write-file-member (archive descr command) | |
1096 (let* ((ename (aref descr 0)) | |
1097 (tmpfile (expand-file-name ename archive-tmpdir)) | |
1098 (top (directory-file-name (file-name-as-directory archive-tmpdir))) | |
1099 (default-directory (file-name-as-directory top))) | |
1100 (unwind-protect | |
1101 (progn | |
1102 (make-directory (file-name-directory tmpfile) t) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1103 ;; If the member is itself an archive, write it without |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1104 ;; the dired-like listing we created. |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1105 (if (eq major-mode 'archive-mode) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1106 (archive-write-file tmpfile) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1107 (write-region (point-min) (point-max) tmpfile nil 'nomessage)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1108 ;; basic-save-buffer needs last-coding-system-used to have |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1109 ;; the value used to write the file, so save it before any |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1110 ;; further processing clobbers it (we restore it in |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1111 ;; archive-write-file-member, above). |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1112 (setq archive-member-coding-system last-coding-system-used) |
11880 | 1113 (if (aref descr 3) |
1114 ;; Set the file modes, but make sure we can read it. | |
1115 (set-file-modes tmpfile (logior ?\400 (aref descr 3)))) | |
22834
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1116 (if enable-multibyte-characters |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1117 (setq ename |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1118 (encode-coding-string ename file-name-coding-system))) |
11880 | 1119 (let ((exitcode (apply 'call-process |
1120 (car command) | |
1121 nil | |
1122 nil | |
1123 nil | |
1124 (append (cdr command) (list archive ename))))) | |
1125 (if (equal exitcode 0) | |
1126 nil | |
1127 (error "Updating was unsuccessful (%S)" exitcode)))) | |
1128 (archive-delete-local tmpfile)))) | |
1129 | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1130 (defun archive-write-file (&optional file) |
11880 | 1131 (save-excursion |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1132 (let ((coding-system-for-write 'no-conversion)) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1133 (write-region archive-proper-file-start (point-max) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1134 (or file buffer-file-name) nil t) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1135 (set-buffer-modified-p nil)) |
11880 | 1136 t)) |
1137 ;; ------------------------------------------------------------------------- | |
1138 ;; Section: Marking and unmarking. | |
1139 | |
1140 (defun archive-flag-deleted (p &optional type) | |
1141 "In archive mode, mark this member to be deleted from the archive. | |
1142 With a prefix argument, mark that many files." | |
1143 (interactive "p") | |
1144 (or type (setq type ?D)) | |
1145 (beginning-of-line) | |
1146 (let ((sign (if (>= p 0) +1 -1)) | |
1147 (modified (buffer-modified-p)) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1148 (inhibit-read-only t)) |
11880 | 1149 (while (not (zerop p)) |
1150 (if (archive-get-descr t) | |
1151 (progn | |
1152 (delete-char 1) | |
1153 (insert type))) | |
1154 (forward-line sign) | |
1155 (setq p (- p sign))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1156 (restore-buffer-modified-p modified)) |
11880 | 1157 (archive-next-line 0)) |
1158 | |
1159 (defun archive-unflag (p) | |
1160 "In archive mode, un-mark this member if it is marked to be deleted. | |
1161 With a prefix argument, un-mark that many files forward." | |
1162 (interactive "p") | |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1163 (archive-flag-deleted p ?\s)) |
11880 | 1164 |
1165 (defun archive-unflag-backwards (p) | |
1166 "In archive mode, un-mark this member if it is marked to be deleted. | |
1167 With a prefix argument, un-mark that many members backward." | |
1168 (interactive "p") | |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1169 (archive-flag-deleted (- p) ?\s)) |
11880 | 1170 |
1171 (defun archive-unmark-all-files () | |
1172 "Remove all marks." | |
1173 (interactive) | |
1174 (let ((modified (buffer-modified-p)) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1175 (inhibit-read-only t)) |
11880 | 1176 (save-excursion |
1177 (goto-char archive-file-list-start) | |
1178 (while (< (point) archive-file-list-end) | |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1179 (or (= (following-char) ?\s) |
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1180 (progn (delete-char 1) (insert ?\s))) |
11880 | 1181 (forward-line 1))) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1182 (restore-buffer-modified-p modified))) |
11880 | 1183 |
1184 (defun archive-mark (p) | |
1185 "In archive mode, mark this member for group operations. | |
1186 With a prefix argument, mark that many members. | |
1187 Use \\[archive-unmark-all-files] to remove all marks." | |
1188 (interactive "p") | |
1189 (archive-flag-deleted p ?*)) | |
1190 | |
1191 (defun archive-get-marked (mark &optional default) | |
1192 (let (files) | |
1193 (save-excursion | |
1194 (goto-char archive-file-list-start) | |
1195 (while (< (point) archive-file-list-end) | |
1196 (if (= (following-char) mark) | |
1197 (setq files (cons (archive-get-descr) files))) | |
1198 (forward-line 1))) | |
1199 (or (nreverse files) | |
1200 (and default | |
1201 (list (archive-get-descr)))))) | |
1202 ;; ------------------------------------------------------------------------- | |
1203 ;; Section: Operate | |
1204 | |
1205 (defun archive-next-line (p) | |
1206 (interactive "p") | |
1207 (forward-line p) | |
1208 (or (eobp) | |
1209 (forward-char archive-file-name-indent))) | |
1210 | |
1211 (defun archive-previous-line (p) | |
1212 (interactive "p") | |
1213 (archive-next-line (- p))) | |
1214 | |
1215 (defun archive-chmod-entry (new-mode) | |
12791
61bbb487bf2c
Standardize layout of doc strings.
Richard M. Stallman <rms@gnu.org>
parents:
12756
diff
changeset
|
1216 "Change the protection bits associated with all marked or this member. |
11880 | 1217 The new protection bits can either be specified as an octal number or |
64528
54d2ccd509bc
(archive-get-descr, archive-alternate-display): Doc fixes.
Juanma Barranquero <lekktu@gmail.com>
parents:
64091
diff
changeset
|
1218 as a relative change like \"g+rw\" as for chmod(2)." |
11880 | 1219 (interactive "sNew mode (octal or relative): ") |
1220 (if archive-read-only (error "Archive is read-only")) | |
1221 (let ((func (archive-name "chmod-entry"))) | |
1222 (if (fboundp func) | |
1223 (progn | |
1224 (funcall func new-mode (archive-get-marked ?* t)) | |
1225 (archive-resummarize)) | |
1226 (error "Setting mode bits is not supported for this archive type")))) | |
1227 | |
1228 (defun archive-chown-entry (new-uid) | |
1229 "Change the owner of all marked or this member." | |
1230 (interactive "nNew uid: ") | |
1231 (if archive-read-only (error "Archive is read-only")) | |
1232 (let ((func (archive-name "chown-entry"))) | |
1233 (if (fboundp func) | |
1234 (progn | |
1235 (funcall func new-uid (archive-get-marked ?* t)) | |
1236 (archive-resummarize)) | |
1237 (error "Setting owner is not supported for this archive type")))) | |
1238 | |
1239 (defun archive-chgrp-entry (new-gid) | |
1240 "Change the group of all marked or this member." | |
1241 (interactive "nNew gid: ") | |
1242 (if archive-read-only (error "Archive is read-only")) | |
1243 (let ((func (archive-name "chgrp-entry"))) | |
1244 (if (fboundp func) | |
1245 (progn | |
1246 (funcall func new-gid (archive-get-marked ?* t)) | |
1247 (archive-resummarize)) | |
1248 (error "Setting group is not supported for this archive type")))) | |
1249 | |
1250 (defun archive-expunge () | |
1251 "Do the flagged deletions." | |
1252 (interactive) | |
1253 (let (files) | |
1254 (save-excursion | |
1255 (goto-char archive-file-list-start) | |
1256 (while (< (point) archive-file-list-end) | |
1257 (if (= (following-char) ?D) | |
1258 (setq files (cons (aref (archive-get-descr) 0) files))) | |
1259 (forward-line 1))) | |
1260 (setq files (nreverse files)) | |
1261 (and files | |
1262 (or (not archive-read-only) | |
1263 (error "Archive is read-only")) | |
1264 (or (yes-or-no-p (format "Really delete %d member%s? " | |
1265 (length files) | |
1266 (if (null (cdr files)) "" "s"))) | |
1267 (error "Operation aborted")) | |
1268 (let ((archive (archive-maybe-copy (buffer-file-name))) | |
1269 (expunger (archive-name "expunge"))) | |
1270 (if (fboundp expunger) | |
1271 (funcall expunger archive files) | |
1272 (archive-*-expunge archive files (symbol-value expunger))) | |
1273 (archive-maybe-update nil) | |
1274 (if archive-remote | |
1275 (archive-resummarize) | |
1276 (revert-buffer)))))) | |
1277 | |
1278 (defun archive-*-expunge (archive files command) | |
1279 (apply 'call-process | |
1280 (car command) | |
1281 nil | |
1282 nil | |
1283 nil | |
1284 (append (cdr command) (cons archive files)))) | |
1285 | |
1286 (defun archive-rename-entry (newname) | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1287 "Change the name associated with this entry in the archive file." |
11880 | 1288 (interactive "sNew name: ") |
1289 (if archive-read-only (error "Archive is read-only")) | |
1290 (if (string= newname "") | |
1291 (error "Archive members may not be given empty names")) | |
1292 (let ((func (archive-name "rename-entry")) | |
1293 (descr (archive-get-descr))) | |
1294 (if (fboundp func) | |
1295 (progn | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1296 (funcall func |
22834
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1297 (if enable-multibyte-characters |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1298 (encode-coding-string newname file-name-coding-system) |
926aae368e61
(archive-set-buffer-as-visiting-file): Give FILENAME
Kenichi Handa <handa@m17n.org>
parents:
22830
diff
changeset
|
1299 newname) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1300 descr) |
11880 | 1301 (archive-resummarize)) |
1302 (error "Renaming is not supported for this archive type")))) | |
1303 | |
1304 ;; Revert the buffer and recompute the dired-like listing. | |
23383
7af3fdca3189
(archive-mode-revert): Arg no-auto-save renamed from no-autosave.
Karl Heuer <kwzh@gnu.org>
parents:
22834
diff
changeset
|
1305 (defun archive-mode-revert (&optional no-auto-save no-confirm) |
11880 | 1306 (let ((no (archive-get-lineno))) |
1307 (setq archive-files nil) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1308 (let ((revert-buffer-function nil) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1309 (coding-system-for-read 'no-conversion)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1310 (set-buffer-multibyte nil) |
11880 | 1311 (revert-buffer t t)) |
1312 (archive-mode) | |
1313 (goto-char archive-file-list-start) | |
1314 (archive-next-line no))) | |
1315 | |
1316 (defun archive-undo () | |
1317 "Undo in an archive buffer. | |
1318 This doesn't recover lost files, it just undoes changes in the buffer itself." | |
1319 (interactive) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1320 (let ((inhibit-read-only t)) |
11880 | 1321 (undo))) |
1322 ;; ------------------------------------------------------------------------- | |
1323 ;; Section: Arc Archives | |
1324 | |
1325 (defun archive-arc-summarize () | |
1326 (let ((p 1) | |
1327 (totalsize 0) | |
1328 (maxlen 8) | |
1329 files | |
1330 visual) | |
1331 (while (and (< (+ p 29) (point-max)) | |
1332 (= (char-after p) ?\C-z) | |
1333 (> (char-after (1+ p)) 0)) | |
1334 (let* ((namefld (buffer-substring (+ p 2) (+ p 2 13))) | |
1335 (fnlen (or (string-match "\0" namefld) 13)) | |
1336 (efnname (substring namefld 0 fnlen)) | |
1337 (csize (archive-l-e (+ p 15) 4)) | |
1338 (moddate (archive-l-e (+ p 19) 2)) | |
1339 (modtime (archive-l-e (+ p 21) 2)) | |
1340 (ucsize (archive-l-e (+ p 25) 4)) | |
1341 (fiddle (string= efnname (upcase efnname))) | |
1342 (ifnname (if fiddle (downcase efnname) efnname)) | |
1343 (text (format " %8d %-11s %-8s %s" | |
1344 ucsize | |
1345 (archive-dosdate moddate) | |
1346 (archive-dostime modtime) | |
1347 ifnname))) | |
1348 (setq maxlen (max maxlen fnlen) | |
1349 totalsize (+ totalsize ucsize) | |
1350 visual (cons (vector text | |
1351 (- (length text) (length ifnname)) | |
1352 (length text)) | |
1353 visual) | |
1354 files (cons (vector efnname ifnname fiddle nil (1- p)) | |
1355 files) | |
1356 p (+ p 29 csize)))) | |
1357 (goto-char (point-min)) | |
1358 (let ((dash (concat "- -------- ----------- -------- " | |
1359 (make-string maxlen ?-) | |
1360 "\n"))) | |
1361 (insert "M Length Date Time File\n" | |
1362 dash) | |
1363 (archive-summarize-files (nreverse visual)) | |
1364 (insert dash | |
1365 (format " %8d %d file%s" | |
1366 totalsize | |
1367 (length files) | |
1368 (if (= 1 (length files)) "" "s")) | |
1369 "\n")) | |
1370 (apply 'vector (nreverse files)))) | |
1371 | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1372 (defun archive-arc-rename-entry (newname descr) |
11880 | 1373 (if (string-match "[:\\\\/]" newname) |
49238
86973b914660
(archive-arc-rename-entry): Fix error message.
Kim F. Storm <storm@cua.dk>
parents:
49166
diff
changeset
|
1374 (error "File names in arc files must not contain a directory component")) |
11880 | 1375 (if (> (length newname) 12) |
1376 (error "File names in arc files are limited to 12 characters")) | |
1377 (let ((name (concat newname (substring "\0\0\0\0\0\0\0\0\0\0\0\0\0" | |
1378 (length newname)))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1379 (inhibit-read-only t)) |
11880 | 1380 (save-restriction |
1381 (save-excursion | |
1382 (widen) | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1383 (set-buffer-multibyte nil) |
11880 | 1384 (goto-char (+ archive-proper-file-start (aref descr 4) 2)) |
1385 (delete-char 13) | |
1386 (insert name))))) | |
1387 ;; ------------------------------------------------------------------------- | |
1388 ;; Section: Lzh Archives | |
1389 | |
1390 (defun archive-lzh-summarize () | |
1391 (let ((p 1) | |
1392 (totalsize 0) | |
1393 (maxlen 8) | |
1394 files | |
1395 visual) | |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1396 (while (progn (goto-char p) ;beginning of a base header. |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1397 (looking-at "\\(.\\|\n\\)\\(.\\|\n\\)-l[hz][0-9ds]-")) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1398 (let* ((hsize (char-after p)) ;size of the base header (level 0 and 1) |
51158
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1399 (csize (archive-l-e (+ p 7) 4)) ;size of a compressed file to follow (level 0 and 2), |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1400 ;size of extended headers + the compressed file to follow (level 1). |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1401 (ucsize (archive-l-e (+ p 11) 4)) ;size of an uncompressed file. |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1402 (time1 (archive-l-e (+ p 15) 2)) ;date/time (MSDOS format in level 0, 1 headers |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1403 (time2 (archive-l-e (+ p 17) 2)) ;and UNIX format in level 2 header.) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1404 (hdrlvl (char-after (+ p 20))) ;header level |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1405 thsize ;total header size (base + extensions) |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1406 fnlen efnname fiddle ifnname width p2 |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1407 neh ;beginning of next extension header (level 1 and 2) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1408 mode modestr uid gid text dir prname |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1409 gname uname modtime moddate) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1410 (if (= hdrlvl 3) (error "can't handle lzh level 3 header type")) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1411 (when (or (= hdrlvl 0) (= hdrlvl 1)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1412 (setq fnlen (char-after (+ p 21))) ;filename length |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1413 (setq efnname (let ((str (buffer-substring (+ p 22) (+ p 22 fnlen)))) ;filename from offset 22 |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1414 (if file-name-coding-system |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1415 (decode-coding-string str file-name-coding-system) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1416 (string-as-multibyte str)))) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1417 (setq p2 (+ p 22 fnlen))) ; |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1418 (if (= hdrlvl 1) |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1419 (setq neh (+ p2 3)) ;specific to level 1 header |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1420 (if (= hdrlvl 2) |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1421 (setq neh (+ p 24)))) ;specific to level 2 header |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1422 (if neh ;if level 1 or 2 we expect extension headers to follow |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1423 (let* ((ehsize (archive-l-e neh 2)) ;size of the extension header |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1424 (etype (char-after (+ neh 2)))) ;extension type |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1425 (while (not (= ehsize 0)) |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1426 (cond |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1427 ((= etype 1) ;file name |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1428 (let ((i (+ neh 3))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1429 (while (< i (+ neh ehsize)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1430 (setq efnname (concat efnname (char-to-string (char-after i)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1431 (setq i (1+ i))))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1432 ((= etype 2) ;directory name |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1433 (let ((i (+ neh 3))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1434 (while (< i (+ neh ehsize)) |
49238
86973b914660
(archive-arc-rename-entry): Fix error message.
Kim F. Storm <storm@cua.dk>
parents:
49166
diff
changeset
|
1435 (setq dir (concat dir |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1436 (if (= (char-after i) |
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1437 255) |
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1438 "/" |
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1439 (char-to-string |
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1440 (char-after i))))) |
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1441 (setq i (1+ i))))) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1442 ((= etype 80) ;Unix file permission |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1443 (setq mode (archive-l-e (+ neh 3) 2))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1444 ((= etype 81) ;UNIX file group/user ID |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1445 (progn (setq uid (archive-l-e (+ neh 3) 2)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1446 (setq gid (archive-l-e (+ neh 5) 2)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1447 ((= etype 82) ;UNIX file group name |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1448 (let ((i (+ neh 3))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1449 (while (< i (+ neh ehsize)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1450 (setq gname (concat gname (char-to-string (char-after i)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1451 (setq i (1+ i))))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1452 ((= etype 83) ;UNIX file user name |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1453 (let ((i (+ neh 3))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1454 (while (< i (+ neh ehsize)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1455 (setq uname (concat uname (char-to-string (char-after i)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1456 (setq i (1+ i))))) |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1457 ) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1458 (setq neh (+ neh ehsize)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1459 (setq ehsize (archive-l-e neh 2)) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1460 (setq etype (char-after (+ neh 2)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1461 ;;get total header size for level 1 and 2 headers |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1462 (setq thsize (- neh p)))) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1463 (if (= hdrlvl 0) ;total header size |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1464 (setq thsize hsize)) |
49509
389fbac8d443
(archive-lzh-summarize): Fix previous change.
Juanma Barranquero <lekktu@gmail.com>
parents:
49437
diff
changeset
|
1465 (setq fiddle (if efnname (string= efnname (upcase efnname)))) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1466 (setq ifnname (if fiddle (downcase efnname) efnname)) |
49238
86973b914660
(archive-arc-rename-entry): Fix error message.
Kim F. Storm <storm@cua.dk>
parents:
49166
diff
changeset
|
1467 (setq prname (if dir (concat dir ifnname) ifnname)) |
49509
389fbac8d443
(archive-lzh-summarize): Fix previous change.
Juanma Barranquero <lekktu@gmail.com>
parents:
49437
diff
changeset
|
1468 (setq width (if prname (string-width prname) 0)) |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1469 (setq modestr (if mode (archive-int-to-mode mode) "??????????")) |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1470 (setq moddate (if (= hdrlvl 2) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1471 (archive-unixdate time1 time2) ;level 2 header in UNIX format |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1472 (archive-dosdate time2))) ;level 0 and 1 header in DOS format |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1473 (setq modtime (if (= hdrlvl 2) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1474 (archive-unixtime time1 time2) |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1475 (archive-dostime time1))) |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1476 (setq text (if archive-alternate-display |
11880 | 1477 (format " %8d %5S %5S %s" |
1478 ucsize | |
1479 (or uid "?") | |
1480 (or gid "?") | |
1481 ifnname) | |
1482 (format " %10s %8d %-11s %-8s %s" | |
1483 modestr | |
1484 ucsize | |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1485 moddate |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1486 modtime |
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1487 prname))) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1488 (setq maxlen (max maxlen width) |
11880 | 1489 totalsize (+ totalsize ucsize) |
1490 visual (cons (vector text | |
49437
3a18e49975cb
(archive-unixdate): Corrected the date field string.
Richard M. Stallman <rms@gnu.org>
parents:
49238
diff
changeset
|
1491 (- (length text) (length prname)) |
11880 | 1492 (length text)) |
1493 visual) | |
20767
ad6c6f1bd674
(archive-find-type): Accept d or s after digit, for lzh.
Richard M. Stallman <rms@gnu.org>
parents:
20239
diff
changeset
|
1494 files (cons (vector prname ifnname fiddle mode (1- p)) |
51158
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1495 files)) |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1496 (cond ((= hdrlvl 1) |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1497 (setq p (+ p hsize 2 csize))) |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1498 ((or (= hdrlvl 2) (= hdrlvl 0)) |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1499 (setq p (+ p thsize 2 csize)))) |
00d0f607793b
(archive-lzh-summarize): Calculate correct total
Richard M. Stallman <rms@gnu.org>
parents:
50835
diff
changeset
|
1500 )) |
11880 | 1501 (goto-char (point-min)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1502 (set-buffer-multibyte default-enable-multibyte-characters) |
11880 | 1503 (let ((dash (concat (if archive-alternate-display |
1504 "- -------- ----- ----- " | |
1505 "- ---------- -------- ----------- -------- ") | |
1506 (make-string maxlen ?-) | |
1507 "\n")) | |
1508 (header (if archive-alternate-display | |
1509 "M Length Uid Gid File\n" | |
1510 "M Filemode Length Date Time File\n")) | |
1511 (sumline (if archive-alternate-display | |
1512 " %8d %d file%s" | |
1513 " %8d %d file%s"))) | |
1514 (insert header dash) | |
1515 (archive-summarize-files (nreverse visual)) | |
1516 (insert dash | |
1517 (format sumline | |
1518 totalsize | |
1519 (length files) | |
1520 (if (= 1 (length files)) "" "s")) | |
1521 "\n")) | |
1522 (apply 'vector (nreverse files)))) | |
1523 | |
1524 (defconst archive-lzh-alternate-display t) | |
1525 | |
1526 (defun archive-lzh-extract (archive name) | |
1527 (archive-extract-by-stdout archive name archive-lzh-extract)) | |
1528 | |
1529 (defun archive-lzh-resum (p count) | |
1530 (let ((sum 0)) | |
1531 (while (> count 0) | |
1532 (setq count (1- count) | |
1533 sum (+ sum (char-after p)) | |
1534 p (1+ p))) | |
1535 (logand sum 255))) | |
1536 | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1537 (defun archive-lzh-rename-entry (newname descr) |
11880 | 1538 (save-restriction |
1539 (save-excursion | |
1540 (widen) | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1541 (set-buffer-multibyte nil) |
11880 | 1542 (let* ((p (+ archive-proper-file-start (aref descr 4))) |
1543 (oldhsize (char-after p)) | |
1544 (oldfnlen (char-after (+ p 21))) | |
1545 (newfnlen (length newname)) | |
1546 (newhsize (+ oldhsize newfnlen (- oldfnlen))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1547 (inhibit-read-only t)) |
11880 | 1548 (if (> newhsize 255) |
1549 (error "The file name is too long")) | |
1550 (goto-char (+ p 21)) | |
1551 (delete-char (1+ oldfnlen)) | |
1552 (insert newfnlen newname) | |
1553 (goto-char p) | |
1554 (delete-char 2) | |
1555 (insert newhsize (archive-lzh-resum p newhsize)))))) | |
1556 | |
1557 (defun archive-lzh-ogm (newval files errtxt ofs) | |
64086
2aeabf7911c9
(archive-lzh-ogm): Reorder save excursion/restriction.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63891
diff
changeset
|
1558 (save-excursion |
2aeabf7911c9
(archive-lzh-ogm): Reorder save excursion/restriction.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63891
diff
changeset
|
1559 (save-restriction |
11880 | 1560 (widen) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1561 (set-buffer-multibyte nil) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1562 (dolist (fil files) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1563 (let* ((p (+ archive-proper-file-start (aref fil 4))) |
11880 | 1564 (hsize (char-after p)) |
1565 (fnlen (char-after (+ p 21))) | |
1566 (p2 (+ p 22 fnlen)) | |
1567 (creator (if (>= (- hsize fnlen) 24) (char-after (+ p2 2)) 0)) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1568 (inhibit-read-only t)) |
11880 | 1569 (if (= creator ?U) |
1570 (progn | |
1571 (or (numberp newval) | |
1572 (setq newval (funcall newval (archive-l-e (+ p2 ofs) 2)))) | |
1573 (goto-char (+ p2 ofs)) | |
1574 (delete-char 2) | |
1575 (insert (logand newval 255) (lsh newval -8)) | |
1576 (goto-char (1+ p)) | |
1577 (delete-char 1) | |
1578 (insert (archive-lzh-resum (1+ p) hsize))) | |
1579 (message "Member %s does not have %s field" | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1580 (aref fil 1) errtxt))))))) |
11880 | 1581 |
1582 (defun archive-lzh-chown-entry (newuid files) | |
1583 (archive-lzh-ogm newuid files "an uid" 10)) | |
1584 | |
1585 (defun archive-lzh-chgrp-entry (newgid files) | |
1586 (archive-lzh-ogm newgid files "a gid" 12)) | |
1587 | |
1588 (defun archive-lzh-chmod-entry (newmode files) | |
1589 (archive-lzh-ogm | |
1590 ;; This should work even though newmode will be dynamically accessed. | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1591 (lambda (old) (archive-calc-mode old newmode t)) |
11880 | 1592 files "a unix-style mode" 8)) |
1593 ;; ------------------------------------------------------------------------- | |
1594 ;; Section: Zip Archives | |
1595 | |
1596 (defun archive-zip-summarize () | |
1597 (goto-char (- (point-max) (- 22 18))) | |
1598 (search-backward-regexp "[P]K\005\006") | |
48226
65903e252ec1
(archive-zip-summarize): Don't hardcode (point-min) = 1.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
45363
diff
changeset
|
1599 (let ((p (+ (point-min) (archive-l-e (+ (point) 16) 4))) |
11880 | 1600 (maxlen 8) |
1601 (totalsize 0) | |
1602 files | |
1603 visual) | |
1604 (while (string= "PK\001\002" (buffer-substring p (+ p 4))) | |
1605 (let* ((creator (char-after (+ p 5))) | |
63891
d7d21c20c225
(archive-extract): Make it work as a mouse binding.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
63889
diff
changeset
|
1606 ;; (method (archive-l-e (+ p 10) 2)) |
11880 | 1607 (modtime (archive-l-e (+ p 12) 2)) |
1608 (moddate (archive-l-e (+ p 14) 2)) | |
1609 (ucsize (archive-l-e (+ p 24) 4)) | |
1610 (fnlen (archive-l-e (+ p 28) 2)) | |
1611 (exlen (archive-l-e (+ p 30) 2)) | |
12304
3cf4df625c3b
(archive-zip-summarize): Handle per-file comments in central directory.
Richard M. Stallman <rms@gnu.org>
parents:
12024
diff
changeset
|
1612 (fclen (archive-l-e (+ p 32) 2)) |
11880 | 1613 (lheader (archive-l-e (+ p 42) 4)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1614 (efnname (let ((str (buffer-substring (+ p 46) (+ p 46 fnlen)))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1615 (if file-name-coding-system |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1616 (decode-coding-string str file-name-coding-system) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1617 (string-as-multibyte str)))) |
11880 | 1618 (isdir (and (= ucsize 0) |
1619 (string= (file-name-nondirectory efnname) ""))) | |
1620 (mode (cond ((memq creator '(2 3)) ; Unix + VMS | |
1621 (archive-l-e (+ p 40) 2)) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1622 ((memq creator '(0 5 6 7 10 11 15)) ; Dos etc. |
11880 | 1623 (logior ?\444 |
1624 (if isdir (logior 16384 ?\111) 0) | |
1625 (if (zerop | |
1626 (logand 1 (char-after (+ p 38)))) | |
1627 ?\222 0))) | |
1628 (t nil))) | |
1629 (modestr (if mode (archive-int-to-mode mode) "??????????")) | |
1630 (fiddle (and archive-zip-case-fiddle | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1631 (not (not (memq creator '(0 2 4 5 9)))) |
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1632 (string= (upcase efnname) efnname))) |
11880 | 1633 (ifnname (if fiddle (downcase efnname) efnname)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1634 (width (string-width ifnname)) |
11880 | 1635 (text (format " %10s %8d %-11s %-8s %s" |
1636 modestr | |
1637 ucsize | |
1638 (archive-dosdate moddate) | |
1639 (archive-dostime modtime) | |
1640 ifnname))) | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1641 (setq maxlen (max maxlen width) |
11880 | 1642 totalsize (+ totalsize ucsize) |
1643 visual (cons (vector text | |
1644 (- (length text) (length ifnname)) | |
1645 (length text)) | |
1646 visual) | |
1647 files (cons (if isdir | |
1648 nil | |
1649 (vector efnname ifnname fiddle mode | |
1650 (list (1- p) lheader))) | |
1651 files) | |
12304
3cf4df625c3b
(archive-zip-summarize): Handle per-file comments in central directory.
Richard M. Stallman <rms@gnu.org>
parents:
12024
diff
changeset
|
1652 p (+ p 46 fnlen exlen fclen)))) |
11880 | 1653 (goto-char (point-min)) |
1654 (let ((dash (concat "- ---------- -------- ----------- -------- " | |
1655 (make-string maxlen ?-) | |
1656 "\n"))) | |
1657 (insert "M Filemode Length Date Time File\n" | |
1658 dash) | |
1659 (archive-summarize-files (nreverse visual)) | |
1660 (insert dash | |
1661 (format " %8d %d file%s" | |
1662 totalsize | |
1663 (length files) | |
1664 (if (= 1 (length files)) "" "s")) | |
1665 "\n")) | |
1666 (apply 'vector (nreverse files)))) | |
1667 | |
1668 (defun archive-zip-extract (archive name) | |
45362
854ecfb3a883
(archive-zip-use-pkzip): Variable deleted.
Richard M. Stallman <rms@gnu.org>
parents:
43679
diff
changeset
|
1669 (if (equal (car archive-zip-extract) "pkzip") |
11880 | 1670 (archive-*-extract archive name archive-zip-extract) |
1671 (archive-extract-by-stdout archive name archive-zip-extract))) | |
1672 | |
1673 (defun archive-zip-write-file-member (archive descr) | |
1674 (archive-*-write-file-member | |
1675 archive | |
1676 descr | |
1677 (if (aref descr 2) archive-zip-update-case archive-zip-update))) | |
1678 | |
1679 (defun archive-zip-chmod-entry (newmode files) | |
1680 (save-restriction | |
1681 (save-excursion | |
1682 (widen) | |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1683 (set-buffer-multibyte nil) |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1684 (dolist (fil files) |
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1685 (let* ((p (+ archive-proper-file-start (car (aref fil 4)))) |
11880 | 1686 (creator (char-after (+ p 5))) |
1687 (oldmode (aref fil 3)) | |
1688 (newval (archive-calc-mode oldmode newmode t)) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1689 (inhibit-read-only t)) |
11880 | 1690 (cond ((memq creator '(2 3)) ; Unix + VMS |
1691 (goto-char (+ p 40)) | |
1692 (delete-char 2) | |
1693 (insert (logand newval 255) (lsh newval -8))) | |
22062
029145c16497
(archive-tmpdir): Make the prefix of the temporary
Eli Zaretskii <eliz@gnu.org>
parents:
21570
diff
changeset
|
1694 ((memq creator '(0 5 6 7 10 11 15)) ; Dos etc. |
11880 | 1695 (goto-char (+ p 38)) |
1696 (insert (logior (logand (char-after (point)) 254) | |
1697 (logand (logxor 1 (lsh newval -7)) 1))) | |
1698 (delete-char 1)) | |
1699 (t (message "Don't know how to change mode for this member")))) | |
63889
abe14daaa679
Bind inhibit-read-only rather than buffer-read-only.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
62714
diff
changeset
|
1700 )))) |
11880 | 1701 ;; ------------------------------------------------------------------------- |
1702 ;; Section: Zoo Archives | |
1703 | |
1704 (defun archive-zoo-summarize () | |
1705 (let ((p (1+ (archive-l-e 25 4))) | |
1706 (maxlen 8) | |
1707 (totalsize 0) | |
1708 files | |
1709 visual) | |
1710 (while (and (string= "\334\247\304\375" (buffer-substring p (+ p 4))) | |
1711 (> (archive-l-e (+ p 6) 4) 0)) | |
1712 (let* ((next (1+ (archive-l-e (+ p 6) 4))) | |
1713 (moddate (archive-l-e (+ p 14) 2)) | |
1714 (modtime (archive-l-e (+ p 16) 2)) | |
1715 (ucsize (archive-l-e (+ p 20) 4)) | |
1716 (namefld (buffer-substring (+ p 38) (+ p 38 13))) | |
13339
13b7b667b18f
(archive-zoo-summarize): Handle archives with long file names.
Richard M. Stallman <rms@gnu.org>
parents:
12791
diff
changeset
|
1717 (dirtype (char-after (+ p 4))) |
13b7b667b18f
(archive-zoo-summarize): Handle archives with long file names.
Richard M. Stallman <rms@gnu.org>
parents:
12791
diff
changeset
|
1718 (lfnlen (if (= dirtype 2) (char-after (+ p 56)) 0)) |
13b7b667b18f
(archive-zoo-summarize): Handle archives with long file names.
Richard M. Stallman <rms@gnu.org>
parents:
12791
diff
changeset
|
1719 (ldirlen (if (= dirtype 2) (char-after (+ p 57)) 0)) |
20239
5bf13ca1dbac
(archive-zoo-summarize): Properly handle the case of
Andreas Schwab <schwab@suse.de>
parents:
19998
diff
changeset
|
1720 (fnlen (or (string-match "\0" namefld) 13)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1721 (efnname (let ((str |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1722 (concat |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1723 (if (> ldirlen 0) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1724 (concat (buffer-substring |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1725 (+ p 58 lfnlen) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1726 (+ p 58 lfnlen ldirlen -1)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1727 "/") |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1728 "") |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1729 (if (> lfnlen 0) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1730 (buffer-substring (+ p 58) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1731 (+ p 58 lfnlen -1)) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1732 (substring namefld 0 fnlen))))) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1733 (if file-name-coding-system |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1734 (decode-coding-string str file-name-coding-system) |
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1735 (string-as-multibyte str)))) |
13339
13b7b667b18f
(archive-zoo-summarize): Handle archives with long file names.
Richard M. Stallman <rms@gnu.org>
parents:
12791
diff
changeset
|
1736 (fiddle (and (= lfnlen 0) (string= efnname (upcase efnname)))) |
11880 | 1737 (ifnname (if fiddle (downcase efnname) efnname)) |
22830
d79de5a60ee8
(archive-summarize): Set buffer unibyte before
Eli Zaretskii <eliz@gnu.org>
parents:
22782
diff
changeset
|
1738 (width (string-width ifnname)) |
11880 | 1739 (text (format " %8d %-11s %-8s %s" |
1740 ucsize | |
1741 (archive-dosdate moddate) | |
1742 (archive-dostime modtime) | |
1743 ifnname))) | |
32484
bb1bfa010bf3
(archive-zoo-summarize): Fix from gnu.emacs.bug.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
29681
diff
changeset
|
1744 (setq maxlen (max maxlen width) |
11880 | 1745 totalsize (+ totalsize ucsize) |
1746 visual (cons (vector text | |
1747 (- (length text) (length ifnname)) | |
1748 (length text)) | |
1749 visual) | |
1750 files (cons (vector efnname ifnname fiddle nil (1- p)) | |
1751 files) | |
1752 p next))) | |
1753 (goto-char (point-min)) | |
1754 (let ((dash (concat "- -------- ----------- -------- " | |
1755 (make-string maxlen ?-) | |
1756 "\n"))) | |
1757 (insert "M Length Date Time File\n" | |
1758 dash) | |
1759 (archive-summarize-files (nreverse visual)) | |
1760 (insert dash | |
1761 (format " %8d %d file%s" | |
1762 totalsize | |
1763 (length files) | |
1764 (if (= 1 (length files)) "" "s")) | |
1765 "\n")) | |
1766 (apply 'vector (nreverse files)))) | |
1767 | |
1768 (defun archive-zoo-extract (archive name) | |
1769 (archive-extract-by-stdout archive name archive-zoo-extract)) | |
1770 ;; ------------------------------------------------------------------------- | |
23467
dd5bbd8db2f5
(arc-mode): Provide arc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
23383
diff
changeset
|
1771 ;; This line was a mistake; it is kept now for compatibility. |
dd5bbd8db2f5
(arc-mode): Provide arc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
23383
diff
changeset
|
1772 ;; rms 15 Oct 98 |
11880 | 1773 (provide 'archive-mode) |
1774 | |
23467
dd5bbd8db2f5
(arc-mode): Provide arc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
23383
diff
changeset
|
1775 (provide 'arc-mode) |
dd5bbd8db2f5
(arc-mode): Provide arc-mode.
Richard M. Stallman <rms@gnu.org>
parents:
23383
diff
changeset
|
1776 |
61414
9918f801db35
(archive-mode-map): Move initialization into
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55184
diff
changeset
|
1777 ;; arch-tag: e5966a01-35ec-4f27-8095-a043a79b457b |
38409
153f1b1f2efd
Emacs lisp coding convention fixes.
Pavel Janík <Pavel@Janik.cz>
parents:
38072
diff
changeset
|
1778 ;;; arc-mode.el ends here |