1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Move point in the dired buffer with n'/p' in an image-mode buffer

* lisp/image-mode.el (image-next-file): If the image is in a dired
buffer, then move point in that buffer when advancing
(bug#21752).  This makes it easier to select images.
This commit is contained in:
Lars Ingebrigtsen 2019-10-09 07:00:34 +02:00
parent 9db9b0b12d
commit e8dd6c9d83

View file

@ -982,7 +982,19 @@ replacing the current Image mode buffer."
(throw 'image-visit-next-file (1+ idx)))
(setq idx (1+ idx))))
(setq idx (mod (+ idx (or n 1)) (length images)))
(find-alternate-file (nth idx images))))
(let ((image (nth idx images))
(dir (file-name-directory buffer-file-name)))
(find-alternate-file image)
;; If we have dired buffer(s) open to where this image is, then
;; place point on it.
(dolist (buffer (buffer-list))
(with-current-buffer buffer
(when (and (derived-mode-p 'dired-mode)
(equal (file-truename dir)
(file-truename default-directory)))
(save-window-excursion
(switch-to-buffer (current-buffer) t t)
(dired-goto-file (expand-file-name image dir)))))))))
(defun image-previous-file (&optional n)
"Visit the preceding image in the same directory as the current file.