emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small bug in image-dired-track-original-file - suggestions wanted


From: Mathias Dahl
Subject: Small bug in image-dired-track-original-file - suggestions wanted
Date: Sun, 30 Mar 2008 02:48:27 +0100

There is a small bug in this code which is used to "track" the
original file name in the Dired buffer from inside the thumbnail
buffer.

(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)
      (setq file-name (file-name-nondirectory file-name))
      (set-buffer dired-buf)
      (goto-char (point-min))
      (if (not (search-forward file-name nil t))
          (message "Could not track file")
        (dired-move-to-filename)
        (set-window-point
         (image-dired-get-buffer-window dired-buf) (point)))
      (set-buffer old-buf))))

To track (find) a file in the dired buffer, a very simple search is
done, but it can get false hits. For example if you have the files "00
07.jpg" and "07.jpg", the function will find "00 07.jpg" first, when
trying to track "07.jpg", thus tracking the wrong file. I see that
there exist the `directory-listing-before-filename-regexp' variable
but it is so large that I suspect it will affect performance. Tracking
needs to be fast, and it is quite fast now.

Any ideas?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]