* Small bug in image-dired-track-original-file - suggestions wanted
@ 2008-03-30 1:48 Mathias Dahl
2008-03-30 22:44 ` Juri Linkov
0 siblings, 1 reply; 4+ messages in thread
From: Mathias Dahl @ 2008-03-30 1:48 UTC (permalink / raw)
To: emacs-devel
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?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Small bug in image-dired-track-original-file - suggestions wanted
2008-03-30 1:48 Small bug in image-dired-track-original-file - suggestions wanted Mathias Dahl
@ 2008-03-30 22:44 ` Juri Linkov
2008-03-31 13:35 ` Mathias Dahl
0 siblings, 1 reply; 4+ messages in thread
From: Juri Linkov @ 2008-03-30 22:44 UTC (permalink / raw)
To: Mathias Dahl; +Cc: emacs-devel
> 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?
You can use `dired-goto-file' or `dired-jump'.
--
Juri Linkov
http://www.jurta.org/emacs/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Small bug in image-dired-track-original-file - suggestions wanted
2008-03-30 22:44 ` Juri Linkov
@ 2008-03-31 13:35 ` Mathias Dahl
2008-03-31 18:08 ` Mathias Dahl
0 siblings, 1 reply; 4+ messages in thread
From: Mathias Dahl @ 2008-03-31 13:35 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> You can use `dired-goto-file' or `dired-jump'.
Thanks! I replaced some code with `dired-goto-file' and it seems to
solve the bug and it sems to have acceptable performance.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Small bug in image-dired-track-original-file - suggestions wanted
2008-03-31 13:35 ` Mathias Dahl
@ 2008-03-31 18:08 ` Mathias Dahl
0 siblings, 0 replies; 4+ messages in thread
From: Mathias Dahl @ 2008-03-31 18:08 UTC (permalink / raw)
To: Juri Linkov; +Cc: emacs-devel
> Thanks! I replaced some code with `dired-goto-file' and it seems to
> solve the bug and it sems to have acceptable performance.
And here is the fix:
diff -c /home/mathias/image-dired.el /home/mathias/prj/emacs/lisp/image-dired.el
*** /home/mathias/image-dired.el 2008-03-31 20:04:00.000000000 +0200
--- /home/mathias/prj/emacs/lisp/image-dired.el 2008-03-31
20:04:32.000000000 +0200
***************
*** 1030,1041 ****
(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))))
--- 1030,1038 ----
(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))))
***************
*** 1199,1206 ****
(defun image-dired-modify-mark-on-thumb-original-file (command)
"Modify mark in dired buffer.
! This is quite ugly but I don't know how to implemented in a better
! way. COMMAND is one of 'mark for marking file in dired, 'unmark for
unmarking file in dired or 'flag for flagging file for delete in
dired."
(let ((file-name (image-dired-original-file-name))
--- 1196,1202 ----
(defun image-dired-modify-mark-on-thumb-original-file (command)
"Modify mark in dired buffer.
! COMMAND is one of 'mark for marking file in dired, 'unmark for
unmarking file in dired or 'flag for flagging file for delete in
dired."
(let ((file-name (image-dired-original-file-name))
***************
*** 1209,1217 ****
(message "No image, or image with correct properties, at point.")
(with-current-buffer dired-buf
(message "%s" file-name)
! (setq file-name (file-name-nondirectory file-name))
! (goto-char (point-min))
! (if (search-forward file-name nil t)
(cond ((eq command 'mark) (dired-mark 1))
((eq command 'unmark) (dired-unmark 1))
((eq command 'toggle)
--- 1205,1211 ----
(message "No image, or image with correct properties, at point.")
(with-current-buffer dired-buf
(message "%s" file-name)
! (if (dired-goto-file file-name)
(cond ((eq command 'mark) (dired-mark 1))
((eq command 'unmark) (dired-unmark 1))
((eq command 'toggle)
Diff finished. Mon Mar 31 20:04:47 2008
The change that has been done is to use `dired-goto-file file-name'
instead of the too simple `search-forward', in both of these
functions.
Could someone commit this?
/Mathias
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-03-31 18:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-30 1:48 Small bug in image-dired-track-original-file - suggestions wanted Mathias Dahl
2008-03-30 22:44 ` Juri Linkov
2008-03-31 13:35 ` Mathias Dahl
2008-03-31 18:08 ` Mathias Dahl
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.