aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Ingebrigtsen2019-10-09 07:00:34 +0200
committerLars Ingebrigtsen2019-10-09 07:00:39 +0200
commite8dd6c9d832faf8445fccbc65f05a5e6e6d48ba7 (patch)
tree4b4fc93541a852f561b3f0f0dfd51445b6647a7a
parent9db9b0b12d8baebcce053bd4fad9cd91f3b97179 (diff)
downloademacs-e8dd6c9d832faf8445fccbc65f05a5e6e6d48ba7.tar.gz
emacs-e8dd6c9d832faf8445fccbc65f05a5e6e6d48ba7.zip
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.
-rw-r--r--lisp/image-mode.el14
1 files changed, 13 insertions, 1 deletions
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index a869907669c..342102568ca 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -982,7 +982,19 @@ replacing the current Image mode buffer."
982 (throw 'image-visit-next-file (1+ idx))) 982 (throw 'image-visit-next-file (1+ idx)))
983 (setq idx (1+ idx)))) 983 (setq idx (1+ idx))))
984 (setq idx (mod (+ idx (or n 1)) (length images))) 984 (setq idx (mod (+ idx (or n 1)) (length images)))
985 (find-alternate-file (nth idx images)))) 985 (let ((image (nth idx images))
986 (dir (file-name-directory buffer-file-name)))
987 (find-alternate-file image)
988 ;; If we have dired buffer(s) open to where this image is, then
989 ;; place point on it.
990 (dolist (buffer (buffer-list))
991 (with-current-buffer buffer
992 (when (and (derived-mode-p 'dired-mode)
993 (equal (file-truename dir)
994 (file-truename default-directory)))
995 (save-window-excursion
996 (switch-to-buffer (current-buffer) t t)
997 (dired-goto-file (expand-file-name image dir)))))))))
986 998
987(defun image-previous-file (&optional n) 999(defun image-previous-file (&optional n)
988 "Visit the preceding image in the same directory as the current file. 1000 "Visit the preceding image in the same directory as the current file.