11880
|
1 ;;; arc-mode.el --- simple editing of archives
|
|
2
|
|
3 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: Morten Welinder (terra@diku.dk)
|
|
6 ;; Keywords: archives msdog editing major-mode
|
|
7 ;; Favourite-brand-of-beer: None, I hate beer.
|
|
8
|
|
9 ;;; This file is part of GNU Emacs.
|
|
10 ;;;
|
|
11 ;;; GNU Emacs is free software; you can redistribute it and/or modify
|
|
12 ;;; it under the terms of the GNU General Public License as published by
|
|
13 ;;; the Free Software Foundation; either version 2, or (at your option)
|
|
14 ;;; any later version.
|
|
15 ;;;
|
|
16 ;;; GNU Emacs is distributed in the hope that it will be useful,
|
|
17 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 ;;; GNU General Public License for more details.
|
|
20 ;;;
|
|
21 ;;; You should have received a copy of the GNU General Public License
|
|
22 ;;; along with GNU Emacs; see the file COPYING. If not, write to
|
|
23 ;;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24
|
|
25 ;;; Commentary:
|
|
26 ;;
|
|
27 ;; NAMING: "arc" is short for "archive" and does not refer specifically
|
|
28 ;; to files whose name end in ".arc"
|
|
29 ;;
|
|
30 ;; This code does not decode any files internally, although it does
|
|
31 ;; understand the directory level of the archives. For this reason,
|
|
32 ;; you should expect this code to need more fiddling than tar-mode.el
|
|
33 ;; (although it at present has fewer bugs :-) In particular, I have
|
|
34 ;; not tested this under Ms-Dog myself.
|
|
35 ;; -------------------------------------
|
|
36 ;; INTERACTION: arc-mode.el should play together with
|
|
37 ;;
|
|
38 ;; * ange-ftp.el: Remote archives (i.e., ones that ange-ftp has brought
|
|
39 ;; to you) are handled by doing all updates on a local
|
|
40 ;; copy. When you make changes to a remote file the
|
|
41 ;; changes will first take effect when the archive buffer
|
|
42 ;; is saved. You will be warned about this.
|
|
43 ;;
|
|
44 ;; * dos-fns.el: (Part of Emacs 19). You get automatic ^M^J <--> ^J
|
|
45 ;; conversion.
|
|
46 ;;
|
|
47 ;; arc-mode.el does not work well with crypt++.el; for the archives as
|
|
48 ;; such this could be fixed (but wouldn't be useful) by declaring such
|
|
49 ;; archives to be "remote". For the members this is a general Emacs
|
|
50 ;; problem that 19.29's file formats may fix.
|
|
51 ;; -------------------------------------
|
|
52 ;; ARCHIVE TYPES: Currently only the archives below are handled, but the
|
|
53 ;; structure for handling just about anything is in place.
|
|
54 ;;
|
|
55 ;; Arc Lzh Zip Zoo
|
|
56 ;; --------------------------------
|
|
57 ;; View listing Intern Intern Intern Intern
|
|
58 ;; Extract member Y Y Y Y
|
|
59 ;; Save changed member Y Y Y Y
|
|
60 ;; Add new member N N N N
|
|
61 ;; Delete member Y Y Y Y
|
|
62 ;; Rename member Y Y N N
|
|
63 ;; Chmod - Y Y -
|
|
64 ;; Chown - Y - -
|
|
65 ;; Chgrp - Y - -
|
|
66 ;;
|
|
67 ;; Special thanks to Bill Brodie <wbrodie@panix.com> for very useful tips
|
|
68 ;; on the first released version of this package.
|
|
69 ;;
|
|
70 ;; This code is partly based on tar-mode.el from Emacs.
|
|
71 ;; -------------------------------------
|
|
72 ;; ARCHIVE STRUCTURES:
|
|
73 ;; (This is mostly for myself.)
|
|
74 ;;
|
|
75 ;; ARC A series of (header,file). No interactions among members.
|
|
76 ;;
|
|
77 ;; LZH A series of (header,file). Headers are checksummed. No
|
|
78 ;; interaction among members.
|
|
79 ;;
|
|
80 ;; ZIP A series of (lheader,fil) followed by a "central directory"
|
|
81 ;; which is a series of (cheader) followed by an end-of-
|
|
82 ;; central-dir record possibly followed by junk. The e-o-c-d
|
|
83 ;; links to c-d. cheaders link to lheaders which are basically
|
|
84 ;; cut-down versions of the cheaders.
|
|
85 ;;
|
|
86 ;; ZOO An archive header followed by a series of (header,file).
|
|
87 ;; Each member header points to the next. The archive is
|
|
88 ;; terminated by a bogus header with a zero next link.
|
|
89 ;; -------------------------------------
|
|
90 ;; SETUP: .emacs fodder:
|
|
91 ;;
|
|
92 ;; (setq auto-mode-alist
|
|
93 ;; (cons '("\\.\\(arc\\|zip\\|lzh\\|zoo\\)\\'" . archive-mode)
|
|
94 ;; auto-mode-alist))
|
|
95 ;; (autoload 'archive-mode "arc-mode" "Major mode for editing archives." t)
|
|
96 ;;
|
|
97 ;; Furthermore, for msdog, you need to make sure that the archives are loaded
|
|
98 ;; as binary files. For arc/zip/pak/lzh/zoo this is the default.
|
|
99 ;; -------------------------------------
|
|
100 ;; HOOKS: `foo' means one the the supported archive types.
|
|
101 ;;
|
|
102 ;; archive-mode-hook
|
|
103 ;; archive-foo-mode-hook
|
|
104 ;; archive-extract-hooks
|
|
105
|
|
106 ;;; Code:
|
|
107
|
|
108 ;; -------------------------------------------------------------------------
|
|
109 ;; Section: Configuration.
|
|
110
|
|
111 (defvar archive-dos-members t
|
|
112 "*If non-nil then recognize member files using ^M^J as line terminator
|
|
113 and do The Right Thing.")
|
|
114
|
|
115 (defvar archive-tmpdir
|
|
116 (expand-file-name
|
|
117 (make-temp-name (if (eq system-type 'ms-dos) "ar" "archive.tmp"))
|
|
118 (or (getenv "TMPDIR") (getenv "TMP") "/tmp"))
|
|
119 "*Directory for temporary files made by arc-mode.el")
|
|
120
|
|
121 (defvar archive-remote-regexp "^/[^/:]*[^/:]:"
|
|
122 "*Regexp recognizing archive files names that are not local (i.e., are
|
|
123 not proper file names outside Emacs). A local copy a the archive will
|
|
124 be used when updating.")
|
|
125
|
|
126 (defvar archive-extract-hooks nil
|
|
127 "*Hooks to run when an archive member has been extracted.")
|
|
128 ;; ------------------------------
|
|
129 ;; Arc archive configuration
|
|
130
|
|
131 ;; We always go via a local file since there seems to be no reliable way
|
|
132 ;; to extract to stdout without junk getting added.
|
|
133 (defvar archive-arc-extract
|
|
134 '("arc" "x")
|
|
135 "*Program and its options to run in order to extract an arc file member
|
|
136 to the current directory. Archive and member name will be added.")
|
|
137
|
|
138 (defvar archive-arc-expunge
|
|
139 '("arc" "d")
|
|
140 "*Program and its options to run in order to delete arc file members.
|
|
141 Archive and member names will be added.")
|
|
142
|
|
143 (defvar archive-arc-write-file-member
|
|
144 '("arc" "u")
|
|
145 "*Program and its options to run in order to update an arc file member.
|
|
146 Archive and member name will be added.")
|
|
147 ;; ------------------------------
|
|
148 ;; Lzh archive configuration
|
|
149
|
|
150 (defvar archive-lzh-extract
|
|
151 '("lha" "pq")
|
|
152 "*Program and its options to run in order to extract an lzh file member
|
|
153 to standard output. Archive and member name will be added.")
|
|
154
|
|
155 (defvar archive-lzh-expunge
|
|
156 '("lha" "d")
|
|
157 "*Program and its options to run in order to delete lzh file members.
|
|
158 Archive and member names will be added.")
|
|
159
|
|
160 (defvar archive-lzh-write-file-member
|
|
161 '("lha" "a")
|
|
162 "*Program and its options to run in order to update an lzh file member.
|
|
163 Archive and member name will be added.")
|
|
164 ;; ------------------------------
|
|
165 ;; Zip archive configuration
|
|
166
|
|
167 (defvar archive-zip-use-pkzip (memq system-type '(ms-dos windows-nt))
|
|
168 "*If non-nil then all zip options default to values suitable when using
|
|
169 pkzip and pkunzip. Only set to true for msdog systems!")
|
|
170
|
|
171 (defvar archive-zip-extract
|
|
172 (if archive-zip-use-pkzip '("pkunzip" "-e") '("unzip" "-qq" "-c"))
|
|
173 "*Program and its options to run in order to extract a zip file member
|
|
174 to standard output. Archive and member name will be added.\n
|
|
175 If `archive-zip-use-pkzip' is non-nil then this program is expected to
|
|
176 extract to a file junking the directory part of the name.")
|
|
177
|
|
178 ;; For several reasons the latter behaviour is not desireable in general.
|
|
179 ;; (1) It uses more disk space. (2) Error checking is worse or non-
|
|
180 ;; existent. (3) It tends to do funny things with other systems' file
|
|
181 ;; names.
|
|
182
|
|
183 (defvar archive-zip-expunge
|
|
184 (if archive-zip-use-pkzip '("pkzip" "-d") '("zip" "-d" "-q"))
|
|
185 "*Program and its options to run in order to delete zip file members.
|
|
186 Archive and member names will be added.")
|
|
187
|
|
188 (defvar archive-zip-update
|
|
189 (if archive-zip-use-pkzip '("pkzip" "-u") '("zip" "-q"))
|
|
190 "*Program and its options to run in order to update a zip file member.
|
|
191 Options should ensure that specified directory will be put into the zip
|
|
192 file. Archive and member name will be added.")
|
|
193
|
|
194 (defvar archive-zip-update-case
|
|
195 (if archive-zip-use-pkzip archive-zip-update '("zip" "-q" "-k"))
|
|
196 "*Program and its options to run in order to update a case fiddled
|
|
197 zip file member. Options should ensure that specified directory will
|
|
198 be put into the zip file. Archive and member name will be added.")
|
|
199
|
|
200 (defvar archive-zip-case-fiddle t
|
|
201 "*If non-nil then zip file members are mapped to lower case if created
|
|
202 by a system that under single case file names.")
|
|
203 ;; ------------------------------
|
|
204 ;; Zoo archive configuration
|
|
205
|
|
206 (defvar archive-zoo-extract
|
|
207 '("zoo" "xpq")
|
|
208 "*Program and its options to run in order to extract a zoo file member
|
|
209 to standard output. Archive and member name will be added.")
|
|
210
|
|
211 (defvar archive-zoo-expunge
|
|
212 '("zoo" "DqPP")
|
|
213 "*Program and its options to run in order to delete zoo file members.
|
|
214 Archive and member names will be added.")
|
|
215
|
|
216 (defvar archive-zoo-write-file-member
|
|
217 '("zoo" "a")
|
|
218 "*Program and its options to run in order to update a zoo file member.
|
|
219 Archive and member name will be added.")
|
|
220 ;; -------------------------------------------------------------------------
|
|
221 ;; Section: Variables
|
|
222
|
|
223 (defvar archive-subtype nil "*Symbol describing archive type.")
|
|
224 (defvar archive-file-list-start nil "*Position of first contents line.")
|
|
225 (defvar archive-file-list-end nil "*Position just after last contents line.")
|
|
226 (defvar archive-proper-file-start nil "*Position of real archive's start.")
|
|
227 (defvar archive-read-only nil "*Non-nil if the archive is read-only on disk.")
|
|
228 (defvar archive-remote nil "*Non-nil if the archive is outside file system.")
|
|
229 (defvar archive-local-name nil "*Name of local copy of remote archive.")
|
|
230 (defvar archive-mode-map nil "*Local keymap for archive mode listings.")
|
|
231 (defvar archive-file-name-indent nil "*Column where file names start.")
|
|
232
|
|
233 (defvar archive-alternate-display nil
|
|
234 "*Non-nil when alternate information is shown.")
|
|
235 (make-variable-buffer-local 'archive-alternate-display)
|
|
236 (put 'archive-alternate-display 'permanent-local t)
|
|
237
|
|
238 (defvar archive-superior-buffer nil "*In archive members, points to archive.")
|
|
239 (put 'archive-superior-buffer 'permanent-local t)
|
|
240
|
|
241 (defvar archive-subfile-mode nil "*Non-nil in archive member buffers.")
|
|
242 (make-variable-buffer-local 'archive-subfile-mode)
|
|
243 (put 'archive-subfile-mode 'permanent-local t)
|
|
244
|
|
245 ;; buffer-file-type is a per-buffer variable in the msdog configuration
|
|
246 (if (boundp 'buffer-file-type) nil
|
|
247 (defvar buffer-file-type nil
|
|
248 "*Nil for dos-style text file, non-nil otherwise.")
|
|
249 (make-variable-buffer-local 'buffer-file-type)
|
|
250 (put 'buffer-file-type 'permanent-local t)
|
|
251 (setq-default buffer-file-type nil))
|
|
252
|
|
253 (defvar archive-subfile-dos nil
|
|
254 "Negation of `buffer-file-type' which see.")
|
|
255 (make-variable-buffer-local 'archive-subfile-dos)
|
|
256 (put 'archive-subfile-dos 'permanent-local t)
|
|
257
|
|
258 (defvar archive-files nil "Vector of file descriptors. Each descriptor is
|
|
259 a vector of [ext-file-name int-file-name case-fiddled mode ...]")
|
|
260 (make-variable-buffer-local 'archive-files)
|
|
261 ;; -------------------------------------------------------------------------
|
|
262 ;; Section: Support functions.
|
|
263
|
|
264 (defsubst archive-name (suffix)
|
|
265 (intern (concat "archive-" (symbol-name archive-subtype) "-" suffix)))
|
|
266
|
|
267 (defun archive-l-e (str &optional len)
|
|
268 "Convert little endian string/vector to integer. Alternatively, first
|
|
269 argument may be a buffer position in the current buffer in which case a
|
|
270 second arguemnt, length, should be supplied."
|
|
271 (if (stringp str)
|
|
272 (setq len (length str))
|
|
273 (setq str (buffer-substring str (+ str len))))
|
|
274 (let ((result 0)
|
|
275 (i 0))
|
|
276 (while (< i len)
|
|
277 (setq i (1+ i)
|
|
278 result (+ (ash result 8) (aref str (- len i)))))
|
|
279 result))
|
|
280
|
|
281 (defun archive-int-to-mode (mode)
|
|
282 "Turn an integer like 0700 (i.e., 448) into a mode string like -rwx------"
|
|
283 (let ((str (make-string 10 ?-)))
|
|
284 (or (zerop (logand 16384 mode)) (aset str 0 ?d))
|
|
285 (or (zerop (logand 8192 mode)) (aset str 0 ?c)) ; completeness
|
|
286 (or (zerop (logand 256 mode)) (aset str 1 ?r))
|
|
287 (or (zerop (logand 128 mode)) (aset str 2 ?w))
|
|
288 (or (zerop (logand 64 mode)) (aset str 3 ?x))
|
|
289 (or (zerop (logand 32 mode)) (aset str 4 ?r))
|
|
290 (or (zerop (logand 16 mode)) (aset str 5 ?w))
|
|
291 (or (zerop (logand 8 mode)) (aset str 6 ?x))
|
|
292 (or (zerop (logand 4 mode)) (aset str 7 ?r))
|
|
293 (or (zerop (logand 2 mode)) (aset str 8 ?w))
|
|
294 (or (zerop (logand 1 mode)) (aset str 9 ?x))
|
|
295 (or (zerop (logand 1024 mode)) (aset str 3 (if (zerop (logand 64 mode))
|
|
296 ?S ?s)))
|
|
297 (or (zerop (logand 2048 mode)) (aset str 6 (if (zerop (logand 8 mode))
|
|
298 ?S ?s)))
|
|
299 str))
|
|
300
|
|
301 (defun archive-calc-mode (oldmode newmode &optional error)
|
|
302 "From the integer OLDMODE and the string NEWMODE calculate a new file
|
|
303 mode.\n
|
|
304 NEWMODE may be an octal number including a leading zero in which case it
|
|
305 will become the new mode.\n
|
|
306 NEWMODE may also be a relative specification like \"og-rwx\" in which case
|
|
307 OLDMODE will be modified accordingly just like chmod(2) would have done.\n
|
|
308 If optional third argument ERROR is non-nil an error will be signaled if
|
|
309 the mode is invalid. If ERROR is nil then nil will be returned."
|
|
310 (cond ((string-match "^0[0-7]*$" newmode)
|
|
311 (let ((result 0)
|
|
312 (len (length newmode))
|
|
313 (i 1))
|
|
314 (while (< i len)
|
|
315 (setq result (+ (lsh result 3) (aref newmode i) (- ?0))
|
|
316 i (1+ i)))
|
|
317 (logior (logand oldmode 65024) result)))
|
|
318 ((string-match "^\\([agou]+\\)\\([---+=]\\)\\([rwxst]+\\)$" newmode)
|
|
319 (let ((who 0)
|
|
320 (result oldmode)
|
|
321 (op (aref newmode (match-beginning 2)))
|
|
322 (bits 0)
|
|
323 (i (match-beginning 3)))
|
|
324 (while (< i (match-end 3))
|
|
325 (let ((rwx (aref newmode i)))
|
|
326 (setq bits (logior bits (cond ((= rwx ?r) 292)
|
|
327 ((= rwx ?w) 146)
|
|
328 ((= rwx ?x) 73)
|
|
329 ((= rwx ?s) 3072)
|
|
330 ((= rwx ?t) 512)))
|
|
331 i (1+ i))))
|
|
332 (while (< who (match-end 1))
|
|
333 (let* ((whoc (aref newmode who))
|
|
334 (whomask (cond ((= whoc ?a) 4095)
|
|
335 ((= whoc ?u) 1472)
|
|
336 ((= whoc ?g) 2104)
|
|
337 ((= whoc ?o) 7))))
|
|
338 (if (= op ?=)
|
|
339 (setq result (logand result (lognot whomask))))
|
|
340 (if (= op ?-)
|
|
341 (setq result (logand result (lognot (logand whomask bits))))
|
|
342 (setq result (logior result (logand whomask bits)))))
|
|
343 (setq who (1+ who)))
|
|
344 result))
|
|
345 (t
|
|
346 (if error
|
|
347 (error "Invalid mode specification: %s" newmode)))))
|
|
348
|
|
349 (defun archive-dosdate (date)
|
|
350 "Stringify dos packed DATE record."
|
|
351 (let ((year (+ 1980 (logand (ash date -9) 127)))
|
|
352 (month (logand (ash date -5) 15))
|
|
353 (day (logand date 31)))
|
|
354 (if (or (> month 12) (< month 1))
|
|
355 ""
|
|
356 (format "%2d-%s-%d"
|
|
357 day
|
|
358 (aref ["Jan" "Feb" "Mar" "Apr" "May" "Jun"
|
|
359 "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"] (1- month))
|
|
360 year))))
|
|
361
|
|
362 (defun archive-dostime (time)
|
|
363 "Stringify dos packed TIME record."
|
|
364 (let ((hour (logand (ash time -11) 31))
|
|
365 (minute (logand (ash time -5) 53))
|
|
366 (second (* 2 (logand time 31)))) ; 2 seconds resolution
|
|
367 (format "%02d:%02d:%02d" hour minute second)))
|
|
368
|
|
369 ;;(defun archive-unixdate (low high)
|
|
370 ;; "Stringify unix (LOW HIGH) date."
|
|
371 ;; (let ((str (current-time-string (cons high low))))
|
|
372 ;; (format "%s-%s-%s"
|
|
373 ;; (substring str 8 9)
|
|
374 ;; (substring str 4 7)
|
|
375 ;; (substring str 20 24))))
|
|
376
|
|
377 ;;(defun archive-unixtime (low high)
|
|
378 ;; "Stringify unix (LOW HIGH) time."
|
|
379 ;; (let ((str (current-time-string (cons high low))))
|
|
380 ;; (substring str 11 19)))
|
|
381
|
|
382 (defun archive-get-lineno ()
|
|
383 (if (>= (point) archive-file-list-start)
|
|
384 (count-lines archive-file-list-start
|
|
385 (save-excursion (beginning-of-line) (point)))
|
|
386 0))
|
|
387
|
|
388 (defun archive-get-descr (&optional noerror)
|
|
389 "Return the descriptor vector for file at point. Do not signal an error
|
|
390 if optional second argument NOERROR is non-nil."
|
|
391 (let ((no (archive-get-lineno)))
|
|
392 (if (and (>= (point) archive-file-list-start)
|
|
393 (< no (length archive-files)))
|
|
394 (let ((item (aref archive-files no)))
|
|
395 (if (vectorp item)
|
|
396 item
|
|
397 (if (not noerror)
|
|
398 (error "Entry is not a regular member of the archive"))))
|
|
399 (if (not noerror)
|
|
400 (error "Line does not describe a member of the archive")))))
|
|
401 ;; -------------------------------------------------------------------------
|
|
402 ;; Section: the mode definition
|
|
403
|
|
404 (defun archive-mode (&optional force)
|
|
405 "Major mode for viewing an archive file as a dired-like listing of its
|
|
406 contents. You can move around using the usual cursor motion commands.
|
|
407 Letters no longer insert themselves.
|
|
408 Type `e' to pull a file out of the archive and into its own buffer;
|
|
409 or click mouse-2 on the file's line in the archive mode buffer.
|
|
410
|
|
411 If you edit a sub-file of this archive (as with the `e' command) and
|
|
412 save it, the contents of that buffer will be saved back into the
|
|
413 archive.
|
|
414
|
|
415 \\{archive-mode-map}"
|
|
416 ;; This is not interactive because you shouldn't be turning this
|
|
417 ;; mode on and off. You can corrupt things that way.
|
|
418 (if (zerop (buffer-size))
|
|
419 ;; At present we cannot create archives from scratch
|
|
420 (funcall default-major-mode)
|
|
421 (if (and (not force) archive-files) nil
|
|
422 (let* ((type (archive-find-type))
|
|
423 (typename (copy-sequence (symbol-name type))))
|
|
424 (aset typename 0 (upcase (aref typename 0)))
|
|
425 (kill-all-local-variables)
|
|
426 (make-local-variable 'archive-subtype)
|
|
427 (setq archive-subtype type)
|
|
428
|
|
429 ;; Buffer contains treated image of file before the file contents
|
|
430 (make-local-variable 'revert-buffer-function)
|
|
431 (setq revert-buffer-function 'archive-mode-revert)
|
|
432 (auto-save-mode 0)
|
|
433 (make-local-variable 'local-write-file-hooks)
|
|
434 (add-hook 'local-write-file-hooks 'archive-write-file)
|
|
435
|
|
436 ;; Real file contents is binary
|
|
437 (make-local-variable 'require-final-newline)
|
|
438 (setq require-final-newline nil)
|
|
439 (make-local-variable 'enable-local-variables)
|
|
440 (setq enable-local-variables nil)
|
|
441 (setq buffer-file-type t)
|
|
442
|
|
443 (make-local-variable 'archive-read-only)
|
|
444 (setq archive-read-only (not (file-writable-p (buffer-file-name))))
|
|
445
|
|
446 ;; Should we use a local copy when accessing from outside Emacs?
|
|
447 (make-local-variable 'archive-local-name)
|
|
448 (make-local-variable 'archive-remote)
|
|
449 (setq archive-remote (string-match archive-remote-regexp
|
|
450 (buffer-file-name)))
|
|
451
|
|
452 (setq major-mode 'archive-mode)
|
|
453 (setq mode-name (concat typename "-Archive"))
|
|
454 ;; Run archive-foo-mode-hook and archive-mode-hook
|
|
455 (run-hooks (archive-name "mode-hook") 'archive-mode-hook)
|
|
456 (use-local-map archive-mode-map))
|
|
457
|
|
458 (make-local-variable 'archive-proper-file-start)
|
|
459 (make-local-variable 'archive-file-list-start)
|
|
460 (make-local-variable 'archive-file-list-end)
|
|
461 (make-local-variable 'archive-file-name-indent)
|
|
462 (archive-summarize)
|
|
463 (setq buffer-read-only t))))
|
|
464
|
|
465 ;; Archive mode is suitable only for specially formatted data.
|
|
466 (put 'archive-mode 'mode-class 'special)
|
|
467 ;; -------------------------------------------------------------------------
|
|
468 ;; Section: Key maps
|
|
469
|
|
470 (if archive-mode-map nil
|
|
471 (setq archive-mode-map (make-keymap))
|
|
472 (suppress-keymap archive-mode-map)
|
|
473 (define-key archive-mode-map " " 'archive-next-line)
|
|
474 (define-key archive-mode-map "a" 'archive-alternate-display)
|
|
475 ;;(define-key archive-mode-map "c" 'archive-copy)
|
|
476 (define-key archive-mode-map "d" 'archive-flag-deleted)
|
|
477 (define-key archive-mode-map "\C-d" 'archive-flag-deleted)
|
|
478 (define-key archive-mode-map "e" 'archive-extract)
|
|
479 (define-key archive-mode-map "f" 'archive-extract)
|
|
480 (define-key archive-mode-map "\C-m" 'archive-extract)
|
|
481 (define-key archive-mode-map [mouse-2] 'archive-mouse-extract)
|
|
482 (define-key archive-mode-map "g" 'revert-buffer)
|
|
483 (define-key archive-mode-map "h" 'describe-mode)
|
|
484 (define-key archive-mode-map "m" 'archive-mark)
|
|
485 (define-key archive-mode-map "n" 'archive-next-line)
|
|
486 (define-key archive-mode-map "\C-n" 'archive-next-line)
|
|
487 (define-key archive-mode-map [down] 'archive-next-line)
|
|
488 (define-key archive-mode-map "o" 'archive-extract-other-window)
|
|
489 (define-key archive-mode-map "p" 'archive-previous-line)
|
|
490 (define-key archive-mode-map "\C-p" 'archive-previous-line)
|
|
491 (define-key archive-mode-map [up] 'archive-previous-line)
|
|
492 (define-key archive-mode-map "r" 'archive-rename-entry)
|
|
493 (define-key archive-mode-map "u" 'archive-unflag)
|
|
494 (define-key archive-mode-map "\M-\C-?" 'archive-unmark-all-files)
|
|
495 (define-key archive-mode-map "v" 'archive-view)
|
|
496 (define-key archive-mode-map "x" 'archive-expunge)
|
|
497 (define-key archive-mode-map "\177" 'archive-unflag-backwards)
|
|
498 (define-key archive-mode-map "E" 'archive-extract-other-window)
|
|
499 (define-key archive-mode-map "M" 'archive-chmod-entry)
|
|
500 (define-key archive-mode-map "G" 'archive-chgrp-entry)
|
|
501 (define-key archive-mode-map "O" 'archive-chown-entry)
|
|
502 (substitute-key-definition 'undo 'archive-undo archive-mode-map global-map)
|
|
503
|
|
504 ;; Get rid of the Edit menu bar item to save space.
|
|
505 (define-key archive-mode-map [menu-bar edit] 'undefined)
|
|
506
|
|
507 (define-key archive-mode-map [menu-bar immediate]
|
|
508 (cons "Immediate" (make-sparse-keymap "Immediate")))
|
|
509 (define-key archive-mode-map [menu-bar immediate alternate]
|
|
510 '("Alternate Display" . archive-alternate-display))
|
|
511 (put 'archive-alternate-display 'menu-enable
|
|
512 '(boundp (archive-name "alternate-display")))
|
|
513 (define-key archive-mode-map [menu-bar immediate view]
|
|
514 '("View This File" . archive-view))
|
|
515 (define-key archive-mode-map [menu-bar immediate display]
|
|
516 '("Display in Other Window" . archive-display-other-window))
|
|
517 (define-key archive-mode-map [menu-bar immediate find-file-other-window]
|
|
518 '("Find in Other Window" . archive-extract-other-window))
|
|
519 (define-key archive-mode-map [menu-bar immediate find-file]
|
|
520 '("Find This File" . archive-extract))
|
|
521
|
|
522 (define-key archive-mode-map [menu-bar mark]
|
|
523 (cons "Mark" (make-sparse-keymap "Mark")))
|
|
524 (define-key archive-mode-map [menu-bar mark unmark-all]
|
|
525 '("Unmark All" . archive-unmark-all-files))
|
|
526 (define-key archive-mode-map [menu-bar mark deletion]
|
|
527 '("Flag" . archive-flag-deleted))
|
|
528 (define-key archive-mode-map [menu-bar mark unmark]
|
|
529 '("Unflag" . archive-unflag))
|
|
530 (define-key archive-mode-map [menu-bar mark mark]
|
|
531 '("Mark" . archive-mark))
|
|
532
|
|
533 (define-key archive-mode-map [menu-bar operate]
|
|
534 (cons "Operate" (make-sparse-keymap "Operate")))
|
|
535 (define-key archive-mode-map [menu-bar operate chown]
|
|
536 '("Change Owner..." . archive-chown-entry))
|
|
537 (put 'archive-chown-entry 'menu-enable
|
|
538 '(fboundp (archive-name "chown-entry")))
|
|
539 (define-key archive-mode-map [menu-bar operate chgrp]
|
|
540 '("Change Group..." . archive-chgrp-entry))
|
|
541 (put 'archive-chgrp-entry 'menu-enable
|
|
542 '(fboundp (archive-name "chgrp-entry")))
|
|
543 (define-key archive-mode-map [menu-bar operate chmod]
|
|
544 '("Change Mode..." . archive-chmod-entry))
|
|
545 (put 'archive-chmod-entry 'menu-enable
|
|
546 '(fboundp (archive-name "chmod-entry")))
|
|
547 (define-key archive-mode-map [menu-bar operate rename]
|
|
548 '("Rename to..." . archive-rename-entry))
|
|
549 (put 'archive-rename-entry 'menu-enable
|
|
550 '(fboundp (archive-name "rename-entry")))
|
|
551 ;;(define-key archive-mode-map [menu-bar operate copy]
|
|
552 ;; '("Copy to..." . archive-copy))
|
|
553 (define-key archive-mode-map [menu-bar operate expunge]
|
|
554 '("Expunge Marked Files" . archive-expunge))
|
|
555 )
|
|
556
|
|
557 (let* ((item1 '(archive-subfile-mode " Archive"))
|
|
558 (item2 '(archive-subfile-dos " Dos"))
|
|
559 (items (if (memq system-type '(ms-dos windows-nt))
|
|
560 (list item1) ; msdog has its own indicator
|
|
561 (list item1 item2))))
|
|
562 (or (member item1 minor-mode-alist)
|
|
563 (setq minor-mode-alist (append items minor-mode-alist))))
|
|
564 ;; -------------------------------------------------------------------------
|
|
565 (defun archive-find-type ()
|
|
566 (widen)
|
|
567 (goto-char (point-min))
|
|
568 ;; The funny [] here make it unlikely that the .elc file will be treated
|
|
569 ;; as an archive by other software.
|
|
570 (let (case-fold-search)
|
|
571 (cond ((looking-at "[P]K\003\004") 'zip)
|
|
572 ((looking-at "..-l[hz][0-9]-") 'lzh)
|
|
573 ((looking-at "....................[\334]\247\304\375") 'zoo)
|
|
574 ((and (looking-at "\C-z") ; signature too simple, IMHO
|
|
575 (string-match "\\.[aA][rR][cC]$"
|
|
576 (or buffer-file-name (buffer-name))))
|
|
577 'arc)
|
|
578 (t (error "Buffer format not recognized.")))))
|
|
579 ;; -------------------------------------------------------------------------
|
|
580 (defun archive-summarize ()
|
|
581 "Parse the contents of the archive file in the current buffer.
|
|
582 Place a dired-like listing on the front;
|
|
583 then narrow to it, so that only that listing
|
|
584 is visible (and the real data of the buffer is hidden)."
|
|
585 (widen)
|
|
586 (let (buffer-read-only)
|
|
587 (message "Parsing archive file...")
|
|
588 (buffer-disable-undo (current-buffer))
|
|
589 (setq archive-files (funcall (archive-name "summarize")))
|
|
590 (message "Parsing archive file...done.")
|
|
591 (setq archive-proper-file-start (point-marker))
|
|
592 (narrow-to-region (point-min) (point))
|
|
593 (set-buffer-modified-p nil)
|
|
594 (buffer-enable-undo))
|
|
595 (goto-char archive-file-list-start)
|
|
596 (archive-next-line 0))
|
|
597
|
|
598 (defun archive-resummarize ()
|
|
599 "Recreate the contents listing of an archive."
|
|
600 (let ((modified (buffer-modified-p))
|
|
601 (no (archive-get-lineno))
|
|
602 buffer-read-only)
|
|
603 (widen)
|
|
604 (delete-region (point-min) archive-proper-file-start)
|
|
605 (archive-summarize)
|
|
606 (set-buffer-modified-p modified)
|
|
607 (goto-char archive-file-list-start)
|
|
608 (archive-next-line no)))
|
|
609
|
|
610 (defun archive-summarize-files (files)
|
|
611 "Insert a desciption of a list of files annotated with proper mouse face"
|
|
612 (setq archive-file-list-start (point-marker))
|
|
613 (setq archive-file-name-indent (if files (aref (car files) 1) 0))
|
|
614 ;; We don't want to do an insert for each element since that takes too
|
|
615 ;; long when the archive -- which has to be moved in memory -- is large.
|
|
616 (insert
|
|
617 (apply
|
|
618 (function concat)
|
|
619 (mapcar
|
|
620 (lambda (fil)
|
|
621 ;; Using `concat' here copies the text also, so we can add
|
|
622 ;; properties without problems.
|
|
623 (let ((text (concat (aref fil 0) "\n")))
|
|
624 (put-text-property (aref fil 1) (aref fil 2)
|
|
625 'mouse-face 'highlight
|
|
626 text)
|
|
627 text))
|
|
628 files)))
|
|
629 (setq archive-file-list-end (point-marker)))
|
|
630
|
|
631 (defun archive-alternate-display ()
|
|
632 "Toggle alternative display. To avoid very long lines some archive mode
|
|
633 don't show all information. This function changes the set of information
|
|
634 shown for each files."
|
|
635 (interactive)
|
|
636 (setq archive-alternate-display (not archive-alternate-display))
|
|
637 (archive-resummarize))
|
|
638 ;; -------------------------------------------------------------------------
|
|
639 ;; Section: Local archive copy handling
|
|
640
|
|
641 (defun archive-maybe-copy (archive)
|
|
642 (if archive-remote
|
|
643 (let ((start (point-max)))
|
|
644 (setq archive-local-name (expand-file-name
|
|
645 (file-name-nondirectory archive)
|
|
646 archive-tmpdir))
|
|
647 (make-directory archive-tmpdir t)
|
|
648 (save-restriction
|
|
649 (widen)
|
|
650 (write-region start (point-max) archive-local-name nil 'nomessage))
|
|
651 archive-local-name)
|
|
652 (if (buffer-modified-p) (save-buffer))
|
|
653 archive))
|
|
654
|
|
655 (defun archive-maybe-update (unchanged)
|
|
656 (if archive-remote
|
|
657 (let ((name archive-local-name)
|
|
658 (modified (buffer-modified-p))
|
|
659 buffer-read-only)
|
|
660 (if unchanged nil
|
|
661 (erase-buffer)
|
|
662 (insert-file-contents name)
|
|
663 (archive-mode t))
|
|
664 (archive-delete-local name)
|
|
665 (if (not unchanged)
|
|
666 (message "Archive file must be saved for changes to take effect"))
|
|
667 (set-buffer-modified-p (or modified (not unchanged))))))
|
|
668
|
|
669 (defun archive-delete-local (name)
|
|
670 "Delete (robust) the file NAME and its parents up to and including the
|
|
671 value of `archive-tmpdir'."
|
|
672 (let ((again t)
|
|
673 (top (directory-file-name (file-name-as-directory archive-tmpdir))))
|
|
674 (condition-case nil
|
|
675 (delete-file name)
|
|
676 (error nil))
|
|
677 (while again
|
|
678 (setq name (directory-file-name (file-name-directory name)))
|
|
679 (condition-case nil
|
|
680 (delete-directory name)
|
|
681 (error nil))
|
|
682 (if (string= name top) (setq again nil)))))
|
|
683 ;; -------------------------------------------------------------------------
|
|
684 ;; Section: Member extraction
|
|
685
|
|
686 (defun archive-mouse-extract (event)
|
|
687 "Extract a file whose name you click on."
|
|
688 (interactive "e")
|
|
689 (save-excursion
|
|
690 (set-buffer (window-buffer (posn-window (event-end event))))
|
|
691 (save-excursion
|
|
692 (goto-char (posn-point (event-end event)))
|
|
693 ;; Just make sure this doesn't get an error.
|
|
694 (archive-get-descr)))
|
|
695 (select-window (posn-window (event-end event)))
|
|
696 (goto-char (posn-point (event-end event)))
|
|
697 (archive-extract))
|
|
698
|
|
699 (defun archive-extract (&optional other-window-p)
|
|
700 "In archive mode, extract this entry of the archive into its own buffer."
|
|
701 (interactive)
|
|
702 (let* ((view-p (eq other-window-p 'view))
|
|
703 (descr (archive-get-descr))
|
|
704 (ename (aref descr 0))
|
|
705 (iname (aref descr 1))
|
|
706 (archive-buffer (current-buffer))
|
|
707 (arcdir default-directory)
|
|
708 (archive (buffer-file-name))
|
|
709 (arcname (file-name-nondirectory archive))
|
|
710 (bufname (concat (file-name-nondirectory iname) " (" arcname ")"))
|
|
711 (extractor (archive-name "extract"))
|
|
712 (read-only-p (or archive-read-only view-p))
|
|
713 (buffer (get-buffer bufname))
|
|
714 (just-created nil))
|
|
715 (if buffer
|
|
716 nil
|
|
717 (setq archive (archive-maybe-copy archive))
|
|
718 (setq buffer (get-buffer-create bufname))
|
|
719 (setq just-created t)
|
|
720 (save-excursion
|
|
721 (set-buffer buffer)
|
|
722 (setq buffer-file-name
|
|
723 (expand-file-name (concat arcname ":" iname)))
|
|
724 (setq buffer-file-truename
|
|
725 (abbreviate-file-name buffer-file-name))
|
|
726 ;; Set the default-directory to the dir of the superior buffer.
|
|
727 (setq default-directory arcdir)
|
|
728 (make-local-variable 'archive-superior-buffer)
|
|
729 (setq archive-superior-buffer archive-buffer)
|
|
730 (make-local-variable 'local-write-file-hooks)
|
|
731 (add-hook 'local-write-file-hooks 'archive-write-file-member)
|
|
732 (setq archive-subfile-mode descr)
|
|
733 (setq archive-subfile-dos nil
|
|
734 buffer-file-type t)
|
|
735 (if (fboundp extractor)
|
|
736 (funcall extractor archive ename)
|
|
737 (archive-*-extract archive ename (symbol-value extractor)))
|
|
738 (if archive-dos-members (archive-check-dos))
|
|
739 (goto-char (point-min))
|
|
740 (rename-buffer bufname)
|
|
741 (setq buffer-read-only read-only-p)
|
|
742 (setq buffer-undo-list nil)
|
|
743 (set-buffer-modified-p nil)
|
|
744 (setq buffer-saved-size (buffer-size))
|
|
745 (normal-mode)
|
|
746 ;; Just in case an archive occurs inside another archive.
|
|
747 (if (eq major-mode 'archive-mode)
|
|
748 (setq archive-remote t))
|
|
749 (run-hooks 'archive-extract-hooks))
|
|
750 (archive-maybe-update t))
|
|
751 (if view-p
|
|
752 (progn
|
|
753 (view-buffer buffer)
|
|
754 (and just-created (setq view-exit-action 'kill-buffer)))
|
|
755 (if (eq other-window-p 'display)
|
|
756 (display-buffer buffer)
|
|
757 (if other-window-p
|
|
758 (switch-to-buffer-other-window buffer)
|
|
759 (switch-to-buffer buffer))))))
|
|
760
|
|
761 (defun archive-*-extract (archive name command)
|
|
762 (let* ((default-directory (file-name-as-directory archive-tmpdir))
|
|
763 (tmpfile (expand-file-name (file-name-nondirectory name)
|
|
764 default-directory)))
|
|
765 (make-directory (directory-file-name default-directory) t)
|
|
766 (apply 'call-process
|
|
767 (car command)
|
|
768 nil
|
|
769 nil
|
|
770 nil
|
|
771 (append (cdr command) (list archive name)))
|
|
772 (insert-file-contents tmpfile)
|
|
773 (archive-delete-local tmpfile)))
|
|
774
|
|
775 (defun archive-extract-by-stdout (archive name command)
|
|
776 (let ((binary-process-output t)) ; for Ms-Dos
|
|
777 (apply 'call-process
|
|
778 (car command)
|
|
779 nil
|
|
780 t
|
|
781 nil
|
|
782 (append (cdr command) (list archive name)))))
|
|
783
|
|
784 (defun archive-extract-other-window ()
|
|
785 "In archive mode, find this member in another window."
|
|
786 (interactive)
|
|
787 (archive-extract t))
|
|
788
|
|
789 (defun archive-display-other-window ()
|
|
790 "In archive mode, display this member in another window."
|
|
791 (interactive)
|
|
792 (archive-extract 'display))
|
|
793
|
|
794 (defun archive-view ()
|
|
795 "In archive mode, view the member on this line."
|
|
796 (interactive)
|
|
797 (archive-extract 'view))
|
|
798
|
|
799 (defun archive-add-new-member (arcbuf name)
|
|
800 "Add the file in the current buffer to the archive in ARCBUF naming it
|
|
801 NAME."
|
|
802 (interactive
|
|
803 (list (get-buffer
|
|
804 (read-buffer "Buffer containing archive: "
|
|
805 ;; Find first archive buffer and suggest that
|
|
806 (let ((bufs (buffer-list)))
|
|
807 (while (and bufs (not (eq (save-excursion
|
|
808 (set-buffer (car bufs))
|
|
809 major-mode)
|
|
810 'archive-mode)))
|
|
811 (setq bufs (cdr bufs)))
|
|
812 (if bufs
|
|
813 (car bufs)
|
|
814 (error "There are no archive buffers")))
|
|
815 t))
|
|
816 (read-string "File name in archive: "
|
|
817 (if buffer-file-name
|
|
818 (file-name-nondirectory buffer-file-name)
|
|
819 ""))))
|
|
820 (save-excursion
|
|
821 (set-buffer arcbuf)
|
|
822 (or (eq major-mode 'archive-mode)
|
|
823 (error "Buffer is not an archive buffer"))
|
|
824 (if archive-read-only
|
|
825 (error "Archive is read-only")))
|
|
826 (if (eq arcbuf (current-buffer))
|
|
827 (error "An archive buffer cannot be added to itself"))
|
|
828 (if (string= name "")
|
|
829 (error "Archive members may not be given empty names"))
|
|
830 (let ((func (save-excursion (set-buffer arcbuf)
|
|
831 (archive-name "add-new-member")))
|
|
832 (membuf (current-buffer)))
|
|
833 (if (fboundp func)
|
|
834 (save-excursion
|
|
835 (set-buffer arcbuf)
|
|
836 (funcall func buffer-file-name membuf name))
|
|
837 (error "Adding a new member is not supported for this archive type"))))
|
|
838 ;; -------------------------------------------------------------------------
|
|
839 ;; Section: IO stuff
|
|
840
|
|
841 (defun archive-check-dos (&optional force)
|
|
842 "*If this looks like a buffer with ^M^J as line terminator then remove
|
|
843 those ^Ms and set archive-subfile-dos."
|
|
844 (save-restriction
|
|
845 (widen)
|
|
846 (save-excursion
|
|
847 (goto-char (point-min))
|
|
848 (setq archive-subfile-dos
|
|
849 (or force (not (search-forward-regexp "[^\r]\n" nil t))))
|
|
850 (setq buffer-file-type (not archive-subfile-dos))
|
|
851 (if archive-subfile-dos
|
|
852 (let ((modified (buffer-modified-p)))
|
|
853 (buffer-disable-undo (current-buffer))
|
|
854 (goto-char (point-min))
|
|
855 (while (search-forward "\r\n" nil t)
|
|
856 (replace-match "\n"))
|
|
857 (buffer-enable-undo)
|
|
858 (set-buffer-modified-p modified))))))
|
|
859
|
|
860 (defun archive-write-file-member ()
|
|
861 (if archive-subfile-dos
|
|
862 (save-restriction
|
|
863 (widen)
|
|
864 (save-excursion
|
|
865 (goto-char (point-min))
|
|
866 ;; We don't want our ^M^J <--> ^J changes to show in the undo list
|
|
867 (let ((undo-list buffer-undo-list))
|
|
868 (unwind-protect
|
|
869 (progn
|
|
870 (setq buffer-undo-list t)
|
|
871 (while (search-forward "\n" nil t)
|
|
872 (replace-match "\r\n"))
|
|
873 (setq archive-subfile-dos nil)
|
|
874 (setq buffer-file-type t)
|
|
875 ;; OK, we're now have explicit ^M^Js -- save and re-unixfy
|
|
876 (archive-write-file-member))
|
|
877 (progn
|
|
878 (archive-check-dos t)
|
|
879 (setq buffer-undo-list undo-list))))
|
|
880 t))
|
|
881 (save-excursion
|
|
882 (save-restriction
|
|
883 (message "Updating archive...")
|
|
884 (widen)
|
|
885 (let ((writer (save-excursion (set-buffer archive-superior-buffer)
|
|
886 (archive-name "write-file-member")))
|
|
887 (archive (save-excursion (set-buffer archive-superior-buffer)
|
|
888 (buffer-file-name))))
|
|
889 (if (fboundp writer)
|
|
890 (funcall writer archive archive-subfile-mode)
|
|
891 (archive-*-write-file-member archive
|
|
892 archive-subfile-mode
|
|
893 (symbol-value writer))))
|
|
894 (set-buffer-modified-p nil)
|
|
895 (message "Updating archive...done")
|
|
896 (set-buffer archive-superior-buffer)
|
|
897 (revert-buffer)
|
|
898 t))))
|
|
899
|
|
900 (defun archive-*-write-file-member (archive descr command)
|
|
901 (let* ((ename (aref descr 0))
|
|
902 (tmpfile (expand-file-name ename archive-tmpdir))
|
|
903 (top (directory-file-name (file-name-as-directory archive-tmpdir)))
|
|
904 (default-directory (file-name-as-directory top)))
|
|
905 (unwind-protect
|
|
906 (progn
|
|
907 (make-directory (file-name-directory tmpfile) t)
|
|
908 (write-region (point-min) (point-max) tmpfile nil 'nomessage)
|
|
909 (if (aref descr 3)
|
|
910 ;; Set the file modes, but make sure we can read it.
|
|
911 (set-file-modes tmpfile (logior ?\400 (aref descr 3))))
|
|
912 (let ((exitcode (apply 'call-process
|
|
913 (car command)
|
|
914 nil
|
|
915 nil
|
|
916 nil
|
|
917 (append (cdr command) (list archive ename)))))
|
|
918 (if (equal exitcode 0)
|
|
919 nil
|
|
920 (error "Updating was unsuccessful (%S)" exitcode))))
|
|
921 (archive-delete-local tmpfile))))
|
|
922
|
|
923 (defun archive-write-file ()
|
|
924 (save-excursion
|
|
925 (write-region archive-proper-file-start (point-max) buffer-file-name nil t)
|
|
926 (set-buffer-modified-p nil)
|
|
927 t))
|
|
928 ;; -------------------------------------------------------------------------
|
|
929 ;; Section: Marking and unmarking.
|
|
930
|
|
931 (defun archive-flag-deleted (p &optional type)
|
|
932 "In archive mode, mark this member to be deleted from the archive.
|
|
933 With a prefix argument, mark that many files."
|
|
934 (interactive "p")
|
|
935 (or type (setq type ?D))
|
|
936 (beginning-of-line)
|
|
937 (let ((sign (if (>= p 0) +1 -1))
|
|
938 (modified (buffer-modified-p))
|
|
939 buffer-read-only)
|
|
940 (while (not (zerop p))
|
|
941 (if (archive-get-descr t)
|
|
942 (progn
|
|
943 (delete-char 1)
|
|
944 (insert type)))
|
|
945 (forward-line sign)
|
|
946 (setq p (- p sign)))
|
|
947 (set-buffer-modified-p modified))
|
|
948 (archive-next-line 0))
|
|
949
|
|
950 (defun archive-unflag (p)
|
|
951 "In archive mode, un-mark this member if it is marked to be deleted.
|
|
952 With a prefix argument, un-mark that many files forward."
|
|
953 (interactive "p")
|
|
954 (archive-flag-deleted p ? ))
|
|
955
|
|
956 (defun archive-unflag-backwards (p)
|
|
957 "In archive mode, un-mark this member if it is marked to be deleted.
|
|
958 With a prefix argument, un-mark that many members backward."
|
|
959 (interactive "p")
|
|
960 (archive-flag-deleted (- p) ? ))
|
|
961
|
|
962 (defun archive-unmark-all-files ()
|
|
963 "Remove all marks."
|
|
964 (interactive)
|
|
965 (let ((modified (buffer-modified-p))
|
|
966 buffer-read-only)
|
|
967 (save-excursion
|
|
968 (goto-char archive-file-list-start)
|
|
969 (while (< (point) archive-file-list-end)
|
|
970 (or (= (following-char) ? )
|
|
971 (progn (delete-char 1) (insert ? )))
|
|
972 (forward-line 1)))
|
|
973 (set-buffer-modified-p modified)))
|
|
974
|
|
975 (defun archive-mark (p)
|
|
976 "In archive mode, mark this member for group operations.
|
|
977 With a prefix argument, mark that many members.
|
|
978 Use \\[archive-unmark-all-files] to remove all marks."
|
|
979 (interactive "p")
|
|
980 (archive-flag-deleted p ?*))
|
|
981
|
|
982 (defun archive-get-marked (mark &optional default)
|
|
983 (let (files)
|
|
984 (save-excursion
|
|
985 (goto-char archive-file-list-start)
|
|
986 (while (< (point) archive-file-list-end)
|
|
987 (if (= (following-char) mark)
|
|
988 (setq files (cons (archive-get-descr) files)))
|
|
989 (forward-line 1)))
|
|
990 (or (nreverse files)
|
|
991 (and default
|
|
992 (list (archive-get-descr))))))
|
|
993 ;; -------------------------------------------------------------------------
|
|
994 ;; Section: Operate
|
|
995
|
|
996 (defun archive-next-line (p)
|
|
997 (interactive "p")
|
|
998 (forward-line p)
|
|
999 (or (eobp)
|
|
1000 (forward-char archive-file-name-indent)))
|
|
1001
|
|
1002 (defun archive-previous-line (p)
|
|
1003 (interactive "p")
|
|
1004 (archive-next-line (- p)))
|
|
1005
|
|
1006 (defun archive-chmod-entry (new-mode)
|
|
1007 "Change the protection bits associated with all marked or this member
|
|
1008 in the archive.\n\
|
|
1009 The new protection bits can either be specified as an octal number or
|
|
1010 as a relative change like \"g+rw\" as for chmod(2)"
|
|
1011 (interactive "sNew mode (octal or relative): ")
|
|
1012 (if archive-read-only (error "Archive is read-only"))
|
|
1013 (let ((func (archive-name "chmod-entry")))
|
|
1014 (if (fboundp func)
|
|
1015 (progn
|
|
1016 (funcall func new-mode (archive-get-marked ?* t))
|
|
1017 (archive-resummarize))
|
|
1018 (error "Setting mode bits is not supported for this archive type"))))
|
|
1019
|
|
1020 (defun archive-chown-entry (new-uid)
|
|
1021 "Change the owner of all marked or this member."
|
|
1022 (interactive "nNew uid: ")
|
|
1023 (if archive-read-only (error "Archive is read-only"))
|
|
1024 (let ((func (archive-name "chown-entry")))
|
|
1025 (if (fboundp func)
|
|
1026 (progn
|
|
1027 (funcall func new-uid (archive-get-marked ?* t))
|
|
1028 (archive-resummarize))
|
|
1029 (error "Setting owner is not supported for this archive type"))))
|
|
1030
|
|
1031 (defun archive-chgrp-entry (new-gid)
|
|
1032 "Change the group of all marked or this member."
|
|
1033 (interactive "nNew gid: ")
|
|
1034 (if archive-read-only (error "Archive is read-only"))
|
|
1035 (let ((func (archive-name "chgrp-entry")))
|
|
1036 (if (fboundp func)
|
|
1037 (progn
|
|
1038 (funcall func new-gid (archive-get-marked ?* t))
|
|
1039 (archive-resummarize))
|
|
1040 (error "Setting group is not supported for this archive type"))))
|
|
1041
|
|
1042 (defun archive-expunge ()
|
|
1043 "Do the flagged deletions."
|
|
1044 (interactive)
|
|
1045 (let (files)
|
|
1046 (save-excursion
|
|
1047 (goto-char archive-file-list-start)
|
|
1048 (while (< (point) archive-file-list-end)
|
|
1049 (if (= (following-char) ?D)
|
|
1050 (setq files (cons (aref (archive-get-descr) 0) files)))
|
|
1051 (forward-line 1)))
|
|
1052 (setq files (nreverse files))
|
|
1053 (and files
|
|
1054 (or (not archive-read-only)
|
|
1055 (error "Archive is read-only"))
|
|
1056 (or (yes-or-no-p (format "Really delete %d member%s? "
|
|
1057 (length files)
|
|
1058 (if (null (cdr files)) "" "s")))
|
|
1059 (error "Operation aborted"))
|
|
1060 (let ((archive (archive-maybe-copy (buffer-file-name)))
|
|
1061 (expunger (archive-name "expunge")))
|
|
1062 (if (fboundp expunger)
|
|
1063 (funcall expunger archive files)
|
|
1064 (archive-*-expunge archive files (symbol-value expunger)))
|
|
1065 (archive-maybe-update nil)
|
|
1066 (if archive-remote
|
|
1067 (archive-resummarize)
|
|
1068 (revert-buffer))))))
|
|
1069
|
|
1070 (defun archive-*-expunge (archive files command)
|
|
1071 (apply 'call-process
|
|
1072 (car command)
|
|
1073 nil
|
|
1074 nil
|
|
1075 nil
|
|
1076 (append (cdr command) (cons archive files))))
|
|
1077
|
|
1078 (defun archive-rename-entry (newname)
|
|
1079 "Change the name associated with this entry in the tar file."
|
|
1080 (interactive "sNew name: ")
|
|
1081 (if archive-read-only (error "Archive is read-only"))
|
|
1082 (if (string= newname "")
|
|
1083 (error "Archive members may not be given empty names"))
|
|
1084 (let ((func (archive-name "rename-entry"))
|
|
1085 (descr (archive-get-descr)))
|
|
1086 (if (fboundp func)
|
|
1087 (progn
|
|
1088 (funcall func (buffer-file-name) newname descr)
|
|
1089 (archive-resummarize))
|
|
1090 (error "Renaming is not supported for this archive type"))))
|
|
1091
|
|
1092 ;; Revert the buffer and recompute the dired-like listing.
|
|
1093 (defun archive-mode-revert (&optional no-autosave no-confirm)
|
|
1094 (let ((no (archive-get-lineno)))
|
|
1095 (setq archive-files nil)
|
|
1096 (let ((revert-buffer-function nil))
|
|
1097 (revert-buffer t t))
|
|
1098 (archive-mode)
|
|
1099 (goto-char archive-file-list-start)
|
|
1100 (archive-next-line no)))
|
|
1101
|
|
1102 (defun archive-undo ()
|
|
1103 "Undo in an archive buffer.
|
|
1104 This doesn't recover lost files, it just undoes changes in the buffer itself."
|
|
1105 (interactive)
|
|
1106 (let (buffer-read-only)
|
|
1107 (undo)))
|
|
1108 ;; -------------------------------------------------------------------------
|
|
1109 ;; Section: Arc Archives
|
|
1110
|
|
1111 (defun archive-arc-summarize ()
|
|
1112 (let ((p 1)
|
|
1113 (totalsize 0)
|
|
1114 (maxlen 8)
|
|
1115 files
|
|
1116 visual)
|
|
1117 (while (and (< (+ p 29) (point-max))
|
|
1118 (= (char-after p) ?\C-z)
|
|
1119 (> (char-after (1+ p)) 0))
|
|
1120 (let* ((namefld (buffer-substring (+ p 2) (+ p 2 13)))
|
|
1121 (fnlen (or (string-match "\0" namefld) 13))
|
|
1122 (efnname (substring namefld 0 fnlen))
|
|
1123 (csize (archive-l-e (+ p 15) 4))
|
|
1124 (moddate (archive-l-e (+ p 19) 2))
|
|
1125 (modtime (archive-l-e (+ p 21) 2))
|
|
1126 (ucsize (archive-l-e (+ p 25) 4))
|
|
1127 (fiddle (string= efnname (upcase efnname)))
|
|
1128 (ifnname (if fiddle (downcase efnname) efnname))
|
|
1129 (text (format " %8d %-11s %-8s %s"
|
|
1130 ucsize
|
|
1131 (archive-dosdate moddate)
|
|
1132 (archive-dostime modtime)
|
|
1133 ifnname)))
|
|
1134 (setq maxlen (max maxlen fnlen)
|
|
1135 totalsize (+ totalsize ucsize)
|
|
1136 visual (cons (vector text
|
|
1137 (- (length text) (length ifnname))
|
|
1138 (length text))
|
|
1139 visual)
|
|
1140 files (cons (vector efnname ifnname fiddle nil (1- p))
|
|
1141 files)
|
|
1142 p (+ p 29 csize))))
|
|
1143 (goto-char (point-min))
|
|
1144 (let ((dash (concat "- -------- ----------- -------- "
|
|
1145 (make-string maxlen ?-)
|
|
1146 "\n")))
|
|
1147 (insert "M Length Date Time File\n"
|
|
1148 dash)
|
|
1149 (archive-summarize-files (nreverse visual))
|
|
1150 (insert dash
|
|
1151 (format " %8d %d file%s"
|
|
1152 totalsize
|
|
1153 (length files)
|
|
1154 (if (= 1 (length files)) "" "s"))
|
|
1155 "\n"))
|
|
1156 (apply 'vector (nreverse files))))
|
|
1157
|
|
1158 (defun archive-arc-rename-entry (archive newname descr)
|
|
1159 (if (string-match "[:\\\\/]" newname)
|
|
1160 (error "File names in arc files may not contain a path"))
|
|
1161 (if (> (length newname) 12)
|
|
1162 (error "File names in arc files are limited to 12 characters"))
|
|
1163 (let ((name (concat newname (substring "\0\0\0\0\0\0\0\0\0\0\0\0\0"
|
|
1164 (length newname))))
|
|
1165 buffer-read-only)
|
|
1166 (save-restriction
|
|
1167 (save-excursion
|
|
1168 (widen)
|
|
1169 (goto-char (+ archive-proper-file-start (aref descr 4) 2))
|
|
1170 (delete-char 13)
|
|
1171 (insert name)))))
|
|
1172 ;; -------------------------------------------------------------------------
|
|
1173 ;; Section: Lzh Archives
|
|
1174
|
|
1175 (defun archive-lzh-summarize ()
|
|
1176 (let ((p 1)
|
|
1177 (totalsize 0)
|
|
1178 (maxlen 8)
|
|
1179 files
|
|
1180 visual)
|
|
1181 (while (progn (goto-char p) (looking-at "..-l[hz][0-9]-"))
|
|
1182 (let* ((hsize (char-after p))
|
|
1183 (csize (archive-l-e (+ p 7) 4))
|
|
1184 (ucsize (archive-l-e (+ p 11) 4))
|
|
1185 (modtime (archive-l-e (+ p 15) 2))
|
|
1186 (moddate (archive-l-e (+ p 17) 2))
|
|
1187 (fnlen (char-after (+ p 21)))
|
|
1188 (efnname (buffer-substring (+ p 22) (+ p 22 fnlen)))
|
|
1189 (fiddle (string= efnname (upcase efnname)))
|
|
1190 (ifnname (if fiddle (downcase efnname) efnname))
|
|
1191 (p2 (+ p 22 fnlen))
|
|
1192 (creator (if (>= (- hsize fnlen) 24) (char-after (+ p2 2)) 0))
|
|
1193 (mode (if (= creator ?U) (archive-l-e (+ p2 8) 2) ?\666))
|
|
1194 (modestr (if mode (archive-int-to-mode mode) "??????????"))
|
|
1195 (uid (if (= creator ?U) (archive-l-e (+ p2 10) 2)))
|
|
1196 (gid (if (= creator ?U) (archive-l-e (+ p2 12) 2)))
|
|
1197 (text (if archive-alternate-display
|
|
1198 (format " %8d %5S %5S %s"
|
|
1199 ucsize
|
|
1200 (or uid "?")
|
|
1201 (or gid "?")
|
|
1202 ifnname)
|
|
1203 (format " %10s %8d %-11s %-8s %s"
|
|
1204 modestr
|
|
1205 ucsize
|
|
1206 (archive-dosdate moddate)
|
|
1207 (archive-dostime modtime)
|
|
1208 ifnname))))
|
|
1209 (setq maxlen (max maxlen fnlen)
|
|
1210 totalsize (+ totalsize ucsize)
|
|
1211 visual (cons (vector text
|
|
1212 (- (length text) (length ifnname))
|
|
1213 (length text))
|
|
1214 visual)
|
|
1215 files (cons (vector efnname ifnname fiddle mode (1- p))
|
|
1216 files)
|
|
1217 p (+ p hsize 2 csize))))
|
|
1218 (goto-char (point-min))
|
|
1219 (let ((dash (concat (if archive-alternate-display
|
|
1220 "- -------- ----- ----- "
|
|
1221 "- ---------- -------- ----------- -------- ")
|
|
1222 (make-string maxlen ?-)
|
|
1223 "\n"))
|
|
1224 (header (if archive-alternate-display
|
|
1225 "M Length Uid Gid File\n"
|
|
1226 "M Filemode Length Date Time File\n"))
|
|
1227 (sumline (if archive-alternate-display
|
|
1228 " %8d %d file%s"
|
|
1229 " %8d %d file%s")))
|
|
1230 (insert header dash)
|
|
1231 (archive-summarize-files (nreverse visual))
|
|
1232 (insert dash
|
|
1233 (format sumline
|
|
1234 totalsize
|
|
1235 (length files)
|
|
1236 (if (= 1 (length files)) "" "s"))
|
|
1237 "\n"))
|
|
1238 (apply 'vector (nreverse files))))
|
|
1239
|
|
1240 (defconst archive-lzh-alternate-display t)
|
|
1241
|
|
1242 (defun archive-lzh-extract (archive name)
|
|
1243 (archive-extract-by-stdout archive name archive-lzh-extract))
|
|
1244
|
|
1245 (defun archive-lzh-resum (p count)
|
|
1246 (let ((sum 0))
|
|
1247 (while (> count 0)
|
|
1248 (setq count (1- count)
|
|
1249 sum (+ sum (char-after p))
|
|
1250 p (1+ p)))
|
|
1251 (logand sum 255)))
|
|
1252
|
|
1253 (defun archive-lzh-rename-entry (archive newname descr)
|
|
1254 (save-restriction
|
|
1255 (save-excursion
|
|
1256 (widen)
|
|
1257 (let* ((p (+ archive-proper-file-start (aref descr 4)))
|
|
1258 (oldhsize (char-after p))
|
|
1259 (oldfnlen (char-after (+ p 21)))
|
|
1260 (newfnlen (length newname))
|
|
1261 (newhsize (+ oldhsize newfnlen (- oldfnlen)))
|
|
1262 buffer-read-only)
|
|
1263 (if (> newhsize 255)
|
|
1264 (error "The file name is too long"))
|
|
1265 (goto-char (+ p 21))
|
|
1266 (delete-char (1+ oldfnlen))
|
|
1267 (insert newfnlen newname)
|
|
1268 (goto-char p)
|
|
1269 (delete-char 2)
|
|
1270 (insert newhsize (archive-lzh-resum p newhsize))))))
|
|
1271
|
|
1272 (defun archive-lzh-ogm (newval files errtxt ofs)
|
|
1273 (save-restriction
|
|
1274 (save-excursion
|
|
1275 (widen)
|
|
1276 (while files
|
|
1277 (let* ((fil (car files))
|
|
1278 (p (+ archive-proper-file-start (aref fil 4)))
|
|
1279 (hsize (char-after p))
|
|
1280 (fnlen (char-after (+ p 21)))
|
|
1281 (p2 (+ p 22 fnlen))
|
|
1282 (creator (if (>= (- hsize fnlen) 24) (char-after (+ p2 2)) 0))
|
|
1283 buffer-read-only)
|
|
1284 (if (= creator ?U)
|
|
1285 (progn
|
|
1286 (or (numberp newval)
|
|
1287 (setq newval (funcall newval (archive-l-e (+ p2 ofs) 2))))
|
|
1288 (goto-char (+ p2 ofs))
|
|
1289 (delete-char 2)
|
|
1290 (insert (logand newval 255) (lsh newval -8))
|
|
1291 (goto-char (1+ p))
|
|
1292 (delete-char 1)
|
|
1293 (insert (archive-lzh-resum (1+ p) hsize)))
|
|
1294 (message "Member %s does not have %s field"
|
|
1295 (aref fil 1) errtxt)))
|
|
1296 (setq files (cdr files))))))
|
|
1297
|
|
1298 (defun archive-lzh-chown-entry (newuid files)
|
|
1299 (archive-lzh-ogm newuid files "an uid" 10))
|
|
1300
|
|
1301 (defun archive-lzh-chgrp-entry (newgid files)
|
|
1302 (archive-lzh-ogm newgid files "a gid" 12))
|
|
1303
|
|
1304 (defun archive-lzh-chmod-entry (newmode files)
|
|
1305 (archive-lzh-ogm
|
|
1306 ;; This should work even though newmode will be dynamically accessed.
|
|
1307 (lambda (old) (archive-calc-mode old newmode t))
|
|
1308 files "a unix-style mode" 8))
|
|
1309 ;; -------------------------------------------------------------------------
|
|
1310 ;; Section: Zip Archives
|
|
1311
|
|
1312 (defun archive-zip-summarize ()
|
|
1313 (goto-char (- (point-max) (- 22 18)))
|
|
1314 (search-backward-regexp "[P]K\005\006")
|
|
1315 (let ((p (1+ (archive-l-e (+ (point) 16) 4)))
|
|
1316 (maxlen 8)
|
|
1317 (totalsize 0)
|
|
1318 files
|
|
1319 visual)
|
|
1320 (while (string= "PK\001\002" (buffer-substring p (+ p 4)))
|
|
1321 (let* ((creator (char-after (+ p 5)))
|
|
1322 (method (archive-l-e (+ p 10) 2))
|
|
1323 (modtime (archive-l-e (+ p 12) 2))
|
|
1324 (moddate (archive-l-e (+ p 14) 2))
|
|
1325 (ucsize (archive-l-e (+ p 24) 4))
|
|
1326 (fnlen (archive-l-e (+ p 28) 2))
|
|
1327 (exlen (archive-l-e (+ p 30) 2))
|
|
1328 (lheader (archive-l-e (+ p 42) 4))
|
|
1329 (efnname (buffer-substring (+ p 46) (+ p 46 fnlen)))
|
|
1330 (isdir (and (= ucsize 0)
|
|
1331 (string= (file-name-nondirectory efnname) "")))
|
|
1332 (mode (cond ((memq creator '(2 3)) ; Unix + VMS
|
|
1333 (archive-l-e (+ p 40) 2))
|
|
1334 ((memq creator '(0 5 6 7 10 11)) ; Dos etc.
|
|
1335 (logior ?\444
|
|
1336 (if isdir (logior 16384 ?\111) 0)
|
|
1337 (if (zerop
|
|
1338 (logand 1 (char-after (+ p 38))))
|
|
1339 ?\222 0)))
|
|
1340 (t nil)))
|
|
1341 (modestr (if mode (archive-int-to-mode mode) "??????????"))
|
|
1342 (fiddle (and archive-zip-case-fiddle
|
|
1343 (not (not (memq creator '(0 2 4 5 9))))))
|
|
1344 (ifnname (if fiddle (downcase efnname) efnname))
|
|
1345 (text (format " %10s %8d %-11s %-8s %s"
|
|
1346 modestr
|
|
1347 ucsize
|
|
1348 (archive-dosdate moddate)
|
|
1349 (archive-dostime modtime)
|
|
1350 ifnname)))
|
|
1351 (setq maxlen (max maxlen fnlen)
|
|
1352 totalsize (+ totalsize ucsize)
|
|
1353 visual (cons (vector text
|
|
1354 (- (length text) (length ifnname))
|
|
1355 (length text))
|
|
1356 visual)
|
|
1357 files (cons (if isdir
|
|
1358 nil
|
|
1359 (vector efnname ifnname fiddle mode
|
|
1360 (list (1- p) lheader)))
|
|
1361 files)
|
|
1362 p (+ p 46 fnlen exlen))))
|
|
1363 (goto-char (point-min))
|
|
1364 (let ((dash (concat "- ---------- -------- ----------- -------- "
|
|
1365 (make-string maxlen ?-)
|
|
1366 "\n")))
|
|
1367 (insert "M Filemode Length Date Time File\n"
|
|
1368 dash)
|
|
1369 (archive-summarize-files (nreverse visual))
|
|
1370 (insert dash
|
|
1371 (format " %8d %d file%s"
|
|
1372 totalsize
|
|
1373 (length files)
|
|
1374 (if (= 1 (length files)) "" "s"))
|
|
1375 "\n"))
|
|
1376 (apply 'vector (nreverse files))))
|
|
1377
|
|
1378 (defun archive-zip-extract (archive name)
|
|
1379 (if archive-zip-use-pkzip
|
|
1380 (archive-*-extract archive name archive-zip-extract)
|
|
1381 (archive-extract-by-stdout archive name archive-zip-extract)))
|
|
1382
|
|
1383 (defun archive-zip-write-file-member (archive descr)
|
|
1384 (archive-*-write-file-member
|
|
1385 archive
|
|
1386 descr
|
|
1387 (if (aref descr 2) archive-zip-update-case archive-zip-update)))
|
|
1388
|
|
1389 (defun archive-zip-chmod-entry (newmode files)
|
|
1390 (save-restriction
|
|
1391 (save-excursion
|
|
1392 (widen)
|
|
1393 (while files
|
|
1394 (let* ((fil (car files))
|
|
1395 (p (+ archive-proper-file-start (car (aref fil 4))))
|
|
1396 (creator (char-after (+ p 5)))
|
|
1397 (oldmode (aref fil 3))
|
|
1398 (newval (archive-calc-mode oldmode newmode t))
|
|
1399 buffer-read-only)
|
|
1400 (cond ((memq creator '(2 3)) ; Unix + VMS
|
|
1401 (goto-char (+ p 40))
|
|
1402 (delete-char 2)
|
|
1403 (insert (logand newval 255) (lsh newval -8)))
|
|
1404 ((memq creator '(0 5 6 7 10 11)) ; Dos etc.
|
|
1405 (goto-char (+ p 38))
|
|
1406 (insert (logior (logand (char-after (point)) 254)
|
|
1407 (logand (logxor 1 (lsh newval -7)) 1)))
|
|
1408 (delete-char 1))
|
|
1409 (t (message "Don't know how to change mode for this member"))))
|
|
1410 (setq files (cdr files))))))
|
|
1411 ;; -------------------------------------------------------------------------
|
|
1412 ;; Section: Zoo Archives
|
|
1413
|
|
1414 (defun archive-zoo-summarize ()
|
|
1415 (let ((p (1+ (archive-l-e 25 4)))
|
|
1416 (maxlen 8)
|
|
1417 (totalsize 0)
|
|
1418 files
|
|
1419 visual)
|
|
1420 (while (and (string= "\334\247\304\375" (buffer-substring p (+ p 4)))
|
|
1421 (> (archive-l-e (+ p 6) 4) 0))
|
|
1422 (let* ((next (1+ (archive-l-e (+ p 6) 4)))
|
|
1423 (moddate (archive-l-e (+ p 14) 2))
|
|
1424 (modtime (archive-l-e (+ p 16) 2))
|
|
1425 (ucsize (archive-l-e (+ p 20) 4))
|
|
1426 (namefld (buffer-substring (+ p 38) (+ p 38 13)))
|
|
1427 (fnlen (or (string-match "\0" namefld) 13))
|
|
1428 (efnname (substring namefld 0 fnlen))
|
|
1429 (fiddle (string= efnname (upcase efnname)))
|
|
1430 (ifnname (if fiddle (downcase efnname) efnname))
|
|
1431 (text (format " %8d %-11s %-8s %s"
|
|
1432 ucsize
|
|
1433 (archive-dosdate moddate)
|
|
1434 (archive-dostime modtime)
|
|
1435 ifnname)))
|
|
1436 (setq maxlen (max maxlen fnlen)
|
|
1437 totalsize (+ totalsize ucsize)
|
|
1438 visual (cons (vector text
|
|
1439 (- (length text) (length ifnname))
|
|
1440 (length text))
|
|
1441 visual)
|
|
1442 files (cons (vector efnname ifnname fiddle nil (1- p))
|
|
1443 files)
|
|
1444 p next)))
|
|
1445 (goto-char (point-min))
|
|
1446 (let ((dash (concat "- -------- ----------- -------- "
|
|
1447 (make-string maxlen ?-)
|
|
1448 "\n")))
|
|
1449 (insert "M Length Date Time File\n"
|
|
1450 dash)
|
|
1451 (archive-summarize-files (nreverse visual))
|
|
1452 (insert dash
|
|
1453 (format " %8d %d file%s"
|
|
1454 totalsize
|
|
1455 (length files)
|
|
1456 (if (= 1 (length files)) "" "s"))
|
|
1457 "\n"))
|
|
1458 (apply 'vector (nreverse files))))
|
|
1459
|
|
1460 (defun archive-zoo-extract (archive name)
|
|
1461 (archive-extract-by-stdout archive name archive-zoo-extract))
|
|
1462 ;; -------------------------------------------------------------------------
|
|
1463 (provide 'archive-mode)
|
|
1464
|
|
1465 ;; arc-mode.el ends here.
|