Function: tar-next-file-displayer
tar-next-file-displayer is a byte-compiled function defined in
tar-mode.el.gz.
Signature
(tar-next-file-displayer FILE REGEXP N)
Documentation
Return a closure to display the next file after FILE that matches REGEXP.
Source Code
;; Defined in /usr/src/emacs/lisp/tar-mode.el.gz
(defun tar-next-file-displayer (file regexp n)
"Return a closure to display the next file after FILE that matches REGEXP."
(let ((short (replace-regexp-in-string "\\`.*!" "" file))
next)
;; The tar buffer chops off leading "./", so do the same
;; here.
(setq short (replace-regexp-in-string "\\`\\./" "" file))
(tar-goto-file short)
(while (and (not next)
;; Stop if we reach the end/start of the buffer.
(if (> n 0)
(not (eobp))
(not (save-excursion
(beginning-of-line)
(bobp)))))
(tar-next-line n)
(when-let* ((descriptor (ignore-errors (tar-get-descriptor))))
(let ((candidate (tar-header-name descriptor))
(buffer (current-buffer)))
(when (and candidate
(string-match-p regexp candidate))
(setq next (lambda ()
(kill-buffer (current-buffer))
(switch-to-buffer buffer)
(tar-extract)))))))
(unless next
;; If we didn't find a next/prev file, then restore
;; point.
(tar-goto-file short))
next))