Function: archive-mode

archive-mode is an autoloaded and byte-compiled function defined in arc-mode.el.gz.

Signature

(archive-mode &optional FORCE)

Documentation

Major mode for viewing an archive file in a dired-like way.

You can move around using the usual cursor motion commands. Letters no longer insert themselves.Type RET (archive-extract) to pull a file out of the archive and into its own buffer; or click mouse-2 on the file's line in the archive mode buffer.

If you edit a sub-file of this archive (as with the RET (archive-extract) command) and save it, the contents of that buffer will be saved back into the archive.

- negative-argument
0 digit-argument
1 digit-argument
2 digit-argument
3 digit-argument
4 digit-argument
5 digit-argument
6 digit-argument
7 digit-argument
8 digit-argument
9 digit-argument
< beginning-of-buffer
<down> archive-next-line
<follow-link> mouse-face
<mouse-2> archive-extract
<up> archive-previous-line
> end-of-buffer
? describe-mode
C archive-copy-file
C-d archive-flag-deleted
C-n archive-next-line
C-p archive-previous-line
C-x u archive-undo
DEL archive-unflag-backwards
DEL scroll-down-command
E archive-extract-other-window
G archive-chgrp-entry
M archive-chmod-entry
M-DEL archive-unmark-all-files
O archive-chown-entry
RET archive-extract
S-SPC archive-previous-line
S-SPC scroll-down-command
SPC archive-next-line
SPC scroll-up-command
SPC..~ undefined
a archive-alternate-display(var)/archive-alternate-display(fun)
d archive-flag-deleted
g revert-buffer
h describe-mode
m archive-mark
n archive-next-line
o archive-extract-other-window
p archive-previous-line
q quit-window
r archive-rename-entry
u archive-unflag
v archive-view
x archive-expunge
€..\x3FFFFF archive-extract

Probably introduced at or before Emacs version 23.1.

Source Code

;; Defined in /usr/src/emacs/lisp/arc-mode.el.gz
;; -------------------------------------------------------------------------
;;; Section: the mode definition

;;;###autoload
(defun archive-mode (&optional force)
  "Major mode for viewing an archive file in a dired-like way.
You can move around using the usual cursor motion commands.
Letters no longer insert themselves.\\<archive-mode-map>
Type \\[archive-extract] to pull a file out of the archive and into its own buffer;
or click mouse-2 on the file's line in the archive mode buffer.

If you edit a sub-file of this archive (as with the \\[archive-extract] command) and
save it, the contents of that buffer will be saved back into the
archive.

\\{archive-mode-map}"
  ;; This is not interactive because you shouldn't be turning this
  ;; mode on and off.  You can corrupt things that way.
  (if (zerop (buffer-size))
      ;; At present we cannot create archives from scratch
      (funcall (or (default-value 'major-mode) #'fundamental-mode))
    (if (and (not force) archive-files) nil
      (kill-all-local-variables)
      (let* ((type (archive-find-type))
	     (typename (capitalize (symbol-name type))))
	(setq-local archive-subtype type)

	;; Buffer contains treated image of file before the file contents
	(add-function :around (local 'revert-buffer-function)
                      #'archive--mode-revert)

	(add-hook 'write-contents-functions #'archive-write-file nil t)

        (setq-local truncate-lines t)
	(setq-local require-final-newline nil)
	(setq-local local-enable-local-variables nil)

	;; Prevent loss of data when saving the file.
	(setq-local file-precious-flag t)

	;; Archives which are inside other archives and whose
	;; names are invalid for this OS, can't be written.
	(setq-local archive-read-only
		    (or (not (file-writable-p (buffer-file-name)))
                        (and archive-subfile-mode
                             (string-match file-name-invalid-regexp
                                           (archive--file-desc-ext-file-name
                                            archive-subfile-mode)))))

	;; An archive can contain another archive whose name is invalid
	;; on local filesystem.  Treat such archives as remote.
	(or archive-remote
	    (setq archive-remote
		  (or tar-archive-from-tar ; was included in a tar archive
                      (string-match archive-remote-regexp (buffer-file-name))
		      (string-match file-name-invalid-regexp
				    (buffer-file-name)))))

	(setq major-mode #'archive-mode)
	(setq mode-name (concat typename "-Archive"))
	;; Run archive-foo-mode-hook and archive-mode-hook
	(run-mode-hooks (archive-name "mode-hook") 'archive-mode-hook)
	(use-local-map archive-mode-map))

      (setq archive-file-name-coding-system
	    (or file-name-coding-system
		default-file-name-coding-system
		locale-coding-system))
      (set-buffer-multibyte 'to)
      (archive-summarize nil)
      (setq buffer-read-only t)
      (when (and archive-visit-single-files
                 auto-compression-mode
                 (= (length archive-files) 1))
        (rename-buffer (concat " " (buffer-name)))
        (archive-extract)))))