Subject: bug#15884: 24.3; image-dired is mixing up buffers

From: [email-masked]
Date: Wed, 13 Nov 2013 09:36:29 -0700

When in an `image-dired-thumbnail-mode' buffer the movement functions
(`image-dired-forward-image' and `image-dired-backward-image') get
confused if the corresponding dired buffer is not visible and throws the
point to the end of the thumbnail buffer making navigation impossible.
Changing the definition of `image-dired-track-original-file' from the
original,

    (defun image-dired-track-original-file ()
      "Track the original file in the associated dired buffer.
    See documentation for `image-dired-toggle-movement-tracking'.
    Interactive use only useful if `image-dired-track-movement' is nil."
      (interactive)
      (let ((old-buf (current-buffer))
            (dired-buf (image-dired-associated-dired-buffer))
            (file-name (image-dired-original-file-name)))
        (when (and (buffer-live-p dired-buf) file-name)
          (set-buffer dired-buf)
          (if (not (dired-goto-file file-name))
              (message "Could not track file")
            (set-window-point
             (image-dired-get-buffer-window dired-buf) (point)))
          (set-buffer old-buf))))

to the following

    (defun image-dired-track-original-file ()
      "Track the original file in the associated dired buffer.
    See documentation for `image-dired-toggle-movement-tracking'.
    Interactive use only useful if `image-dired-track-movement' is nil."
      (interactive)
      (let ((old-buf (current-buffer))
            (dired-buf (image-dired-associated-dired-buffer))
            (file-name (image-dired-original-file-name)))
        (when (and (buffer-live-p dired-buf) file-name)
          (set-buffer dired-buf)
          (if (not (dired-goto-file file-name))
              (message "Could not track file")
            (let ((window (image-dired-get-buffer-window dired-buf)))
              (if window (set-window-point window (point))
                (message "Could not find associated dired buffer."))))
          (set-buffer old-buf))))

fixes this bug.

Best, Eric