Function: image-mode--next-file
image-mode--next-file is a byte-compiled function defined in
image-mode.el.gz.
Signature
(image-mode--next-file FILE N)
Documentation
Go to the next image file in the parent buffer of FILE.
This is typically a Dired buffer, but may also be a tar/archive buffer. Return the next image file from that buffer. If N is negative, go to the previous file.
Source Code
;; Defined in /usr/src/emacs/lisp/image-mode.el.gz
(defun image-mode--next-file (file n)
"Go to the next image file in the parent buffer of FILE.
This is typically a Dired buffer, but may also be a tar/archive buffer.
Return the next image file from that buffer.
If N is negative, go to the previous file."
(let ((regexp (image-file-name-regexp))
(buffers (image-mode--directory-buffers file))
next)
(dolist (buffer buffers)
;; We do this traversal for all the Dired buffers open on this
;; directory. There probably is just one, but we want to move
;; point in all of them.
(save-window-excursion
(switch-to-buffer (cdr buffer) t t)
(cl-case (car buffer)
(dired
(dired-goto-file file)
(let (found)
(while (and (not found)
;; Stop if we reach the end/start of the buffer.
(if (> n 0)
(not (eobp))
(not (bobp))))
(dired-next-line n)
(let ((candidate (dired-get-filename nil t)))
(when (and candidate
(string-match-p regexp candidate))
(setq found candidate))))
(if found
(setq next found)
;; If we didn't find a next/prev file, then restore
;; point.
(dired-goto-file file))))
(archive
(setq next (archive-next-file-displayer file regexp n)))
(tar
(setq next (tar-next-file-displayer file regexp n))))))
next))