Function: tar-mode
tar-mode is an autoloaded, interactive and byte-compiled function
defined in tar-mode.el.gz.
Signature
(tar-mode)
Documentation
Major mode for viewing a tar file as a dired-like listing of its contents.
You can move around using the usual cursor motion commands.
Letters no longer insert themselves.Type RET (tar-extract) to pull a file out of the tar file and into its own buffer;
or click mouse-2 on the file's line in the Tar mode buffer.
Type C (tar-copy) to copy an entry from the tar file into another file on disk.
If you edit a sub-file of this archive (as with the RET (tar-extract) command) and
save it with C-x C-s (save-buffer), the contents of that buffer will be
saved back into the tar-file buffer; in this way you can edit a file
inside of a tar archive without extracting it and re-archiving it.
See also: variables tar-update-datestamp and tar-anal-blocksize.
- negative-argument
<down> tar-next-line
<follow-link> mouse-face
<mouse-2> tar-mouse-extract
<up> tar-previous-line
C tar-copy
C-d tar-flag-deleted
C-n tar-next-line
C-p tar-previous-line
DEL tar-unflag-backwards
E tar-extract-other-window
G tar-chgrp-entry
I tar-new-entry
M tar-chmod-entry
O tar-chown-entry
R tar-rename-entry
RET tar-extract
SPC tar-next-line
SPC..~ undefined
d tar-flag-deleted
g revert-buffer
n tar-next-line
o tar-extract-other-window
p tar-previous-line
u tar-unflag
v tar-view
w woman-tar-extract-file
x tar-expunge
..\x3FFFFF digit-argument
..\x3FFFFF tar-extract
In addition to any hooks its parent mode special-mode might have run,
this mode runs the hook tar-mode-hook, as the final or penultimate
step during initialization.
Probably introduced at or before Emacs version 20.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
;;;###autoload
(define-derived-mode tar-mode special-mode "Tar"
"Major mode for viewing a tar file as a dired-like listing of its contents.
You can move around using the usual cursor motion commands.
Letters no longer insert themselves.\\<tar-mode-map>
Type \\[tar-extract] to pull a file out of the tar file and into its own buffer;
or click mouse-2 on the file's line in the Tar mode buffer.
Type \\[tar-copy] to copy an entry from the tar file into another file on disk.
If you edit a sub-file of this archive (as with the \\[tar-extract] command) and
save it with \\[save-buffer], the contents of that buffer will be
saved back into the tar-file buffer; in this way you can edit a file
inside of a tar archive without extracting it and re-archiving it.
See also: variables `tar-update-datestamp' and `tar-anal-blocksize'.
\\{tar-mode-map}"
(and buffer-file-name
(file-writable-p buffer-file-name)
(setq buffer-read-only nil)) ; undo what `special-mode' did
(make-local-variable 'tar-parse-info)
(setq-local require-final-newline nil) ; binary data, dude...
(setq-local local-enable-local-variables nil)
(setq-local next-line-add-newlines nil)
(setq-local tar-file-name-coding-system
(or file-name-coding-system
default-file-name-coding-system
locale-coding-system))
;; Prevent loss of data when saving the file.
(setq-local file-precious-flag t)
(buffer-disable-undo)
(widen)
;; Now move the Tar data into an auxiliary buffer, so we can use the main
;; buffer for the summary.
(cl-assert (not (tar-data-swapped-p)))
(setq-local revert-buffer-function #'tar-mode-revert)
;; We started using write-contents-functions, but this hook is not
;; used during auto-save, so we now use
;; write-region-annotate-functions which hooks at a lower-level.
(add-hook 'write-region-annotate-functions #'tar-write-region-annotate nil t)
(add-hook 'kill-buffer-hook #'tar-mode-kill-buffer-hook nil t)
(add-hook 'change-major-mode-hook #'tar-change-major-mode-hook nil t)
;; Tar data is made of bytes, not chars.
(set-buffer-multibyte nil) ;Hopefully a no-op.
(setq-local tar-data-buffer (generate-new-buffer
(format " *tar-data %s*"
(file-name-nondirectory
(or buffer-file-name (buffer-name))))))
(condition-case err
(progn
(tar-swap-data)
(tar-summarize-buffer)
(tar-next-line 0))
(error
;; If summarizing caused an error, then maybe the buffer doesn't contain
;; tar data. Rather than show a mysterious empty buffer, let's
;; revert to fundamental-mode.
(fundamental-mode)
(signal (car err) (cdr err)))))