Variable: tar-mode-hook
tar-mode-hook is a variable defined in tar-mode.el.gz.
Value
nil
Documentation
Hook run after entering Tar mode.
No problems result if this variable is not bound.
add-hook automatically binds it. (This is true for all hook variables.)
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)))))