Function: tar-extract
tar-extract is an interactive and byte-compiled function defined in
tar-mode.el.gz.
Signature
(tar-extract &optional OTHER-WINDOW-P)
Documentation
In Tar mode, extract this entry of the tar file into its own buffer.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar-extract (&optional other-window-p)
"In Tar mode, extract this entry of the tar file into its own buffer."
(interactive)
(let* ((view-p (eq other-window-p 'view))
(descriptor (tar-get-descriptor))
(name (tar-header-name descriptor))
(tar-buffer (current-buffer))
(tarname (buffer-name))
(read-only-p (or buffer-read-only view-p))
(new-buffer-file-name (expand-file-name
;; `:' is not allowed on Windows
(concat tarname "!"
(if (string-search "/" name)
name
;; Make sure `name' contains a /
;; so set-auto-mode doesn't try
;; to look at `tarname' for hints.
(concat "./" name)))))
(buffer (get-file-buffer new-buffer-file-name))
(just-created nil))
(unless buffer
(setq buffer (tar--extract descriptor))
(setq just-created t)
(with-current-buffer buffer
(goto-char (point-min))
(setq buffer-file-name new-buffer-file-name)
(setq buffer-file-truename
(abbreviate-file-name buffer-file-name))
(archive-try-jka-compr) ;Pretty ugly hack :-(
;; Force buffer-file-coding-system to what
;; decode-coding-region actually used.
(set-buffer-file-coding-system last-coding-system-used t)
;; Set the default-directory to the dir of the
;; superior buffer.
(setq default-directory
(with-current-buffer tar-buffer
default-directory))
(set-buffer-modified-p nil)
(normal-mode) ; pick a mode.
(when (derived-mode-p 'archive-mode)
(setq-local tar-archive-from-tar t))
(setq-local tar-superior-buffer tar-buffer)
(setq-local tar-superior-descriptor descriptor)
(setq buffer-read-only read-only-p)
(tar-subfile-mode 1)))
(cond
(view-p
(view-buffer buffer (and just-created 'kill-buffer-if-not-modified)))
((eq other-window-p 'display) (display-buffer buffer))
(other-window-p (switch-to-buffer-other-window buffer))
(t (switch-to-buffer buffer)))))