[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master e8dd6c9: Move point in the dired buffer with `n'/`p
From: |
Lars Ingebrigtsen |
Subject: |
[Emacs-diffs] master e8dd6c9: Move point in the dired buffer with `n'/`p' in an image-mode buffer |
Date: |
Wed, 9 Oct 2019 01:00:45 -0400 (EDT) |
branch: master
commit e8dd6c9d832faf8445fccbc65f05a5e6e6d48ba7
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>
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.
---
lisp/image-mode.el | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/lisp/image-mode.el b/lisp/image-mode.el
index a869907..3421025 100644
--- a/lisp/image-mode.el
+++ b/lisp/image-mode.el
@@ -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.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master e8dd6c9: Move point in the dired buffer with `n'/`p' in an image-mode buffer,
Lars Ingebrigtsen <=