diff options
| author | Glenn Morris | 2013-07-20 12:29:02 -0700 |
|---|---|---|
| committer | Glenn Morris | 2013-07-20 12:29:02 -0700 |
| commit | d828e5f94255c799cf7ecb4bbe5cbc00828fbfdb (patch) | |
| tree | b19c354928b8bde4d6442eb8443125df556a077e | |
| parent | c4074c9f63a25a6266c3dd0e7692bf6f518201cb (diff) | |
| download | emacs-d828e5f94255c799cf7ecb4bbe5cbc00828fbfdb.tar.gz emacs-d828e5f94255c799cf7ecb4bbe5cbc00828fbfdb.zip | |
image-dired.el: use with-current-buffer
* lisp/image-dired.el (image-dired-track-original-file):
Use with-current-buffer.
(image-dired-track-thumbnail): Use with-current-buffer.
Avoid changing point of wrong window.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/image-dired.el | 46 |
2 files changed, 26 insertions, 25 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 83c33768fe5..95b4a2a2b6f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -5,6 +5,11 @@ | |||
| 5 | (def-gdb-preempt-display-buffer): Add explicit format. | 5 | (def-gdb-preempt-display-buffer): Add explicit format. |
| 6 | 6 | ||
| 7 | * image-dired.el (image-dired-track-original-file): | 7 | * image-dired.el (image-dired-track-original-file): |
| 8 | Use with-current-buffer. | ||
| 9 | (image-dired-track-thumbnail): Use with-current-buffer. | ||
| 10 | Avoid changing point of wrong window. | ||
| 11 | |||
| 12 | * image-dired.el (image-dired-track-original-file): | ||
| 8 | Avoid changing point of wrong window. (Bug#14909) | 13 | Avoid changing point of wrong window. (Bug#14909) |
| 9 | 14 | ||
| 10 | 2013-07-20 Richard Copley <rcopley@gmail.com> (tiny change) | 15 | 2013-07-20 Richard Copley <rcopley@gmail.com> (tiny change) |
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index b196bf77671..f26ad5dcd0e 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el | |||
| @@ -1039,16 +1039,14 @@ With prefix argument ARG, remove tag from file at point." | |||
| 1039 | See documentation for `image-dired-toggle-movement-tracking'. | 1039 | See documentation for `image-dired-toggle-movement-tracking'. |
| 1040 | Interactive use only useful if `image-dired-track-movement' is nil." | 1040 | Interactive use only useful if `image-dired-track-movement' is nil." |
| 1041 | (interactive) | 1041 | (interactive) |
| 1042 | (let* ((old-buf (current-buffer)) | 1042 | (let* ((dired-buf (image-dired-associated-dired-buffer)) |
| 1043 | (dired-buf (image-dired-associated-dired-buffer)) | ||
| 1044 | (file-name (image-dired-original-file-name)) | 1043 | (file-name (image-dired-original-file-name)) |
| 1045 | (window (image-dired-get-buffer-window dired-buf))) | 1044 | (window (image-dired-get-buffer-window dired-buf))) |
| 1046 | (when (and (buffer-live-p dired-buf) file-name) | 1045 | (and (buffer-live-p dired-buf) file-name |
| 1047 | (set-buffer dired-buf) | 1046 | (with-current-buffer dired-buf |
| 1048 | (if (not (dired-goto-file file-name)) | 1047 | (if (not (dired-goto-file file-name)) |
| 1049 | (message "Could not track file") | 1048 | (message "Could not track file") |
| 1050 | (if window (set-window-point window (point)))) | 1049 | (if window (set-window-point window (point)))))))) |
| 1051 | (set-buffer old-buf)))) | ||
| 1052 | 1050 | ||
| 1053 | (defun image-dired-toggle-movement-tracking () | 1051 | (defun image-dired-toggle-movement-tracking () |
| 1054 | "Turn on and off `image-dired-track-movement'. | 1052 | "Turn on and off `image-dired-track-movement'. |
| @@ -1065,24 +1063,22 @@ position in the other buffer." | |||
| 1065 | This is almost the same as what `image-dired-track-original-file' does, | 1063 | This is almost the same as what `image-dired-track-original-file' does, |
| 1066 | but the other way around." | 1064 | but the other way around." |
| 1067 | (let ((file (dired-get-filename)) | 1065 | (let ((file (dired-get-filename)) |
| 1068 | (old-buf (current-buffer)) | 1066 | prop-val found window) |
| 1069 | prop-val found) | ||
| 1070 | (when (get-buffer image-dired-thumbnail-buffer) | 1067 | (when (get-buffer image-dired-thumbnail-buffer) |
| 1071 | (set-buffer image-dired-thumbnail-buffer) | 1068 | (with-current-buffer image-dired-thumbnail-buffer |
| 1072 | (goto-char (point-min)) | 1069 | (goto-char (point-min)) |
| 1073 | (while (and (not (eobp)) | 1070 | (while (and (not (eobp)) |
| 1074 | (not found)) | 1071 | (not found)) |
| 1075 | (if (and (setq prop-val | 1072 | (if (and (setq prop-val |
| 1076 | (get-text-property (point) 'original-file-name)) | 1073 | (get-text-property (point) 'original-file-name)) |
| 1077 | (string= prop-val file)) | 1074 | (string= prop-val file)) |
| 1078 | (setq found t)) | 1075 | (setq found t)) |
| 1079 | (if (not found) | 1076 | (if (not found) |
| 1080 | (forward-char 1))) | 1077 | (forward-char 1))) |
| 1081 | (when found | 1078 | (when found |
| 1082 | (set-window-point | 1079 | (if (setq window (image-dired-thumbnail-window)) |
| 1083 | (image-dired-thumbnail-window) (point)) | 1080 | (set-window-point window (point))) |
| 1084 | (image-dired-display-thumb-properties)) | 1081 | (image-dired-display-thumb-properties)))))) |
| 1085 | (set-buffer old-buf)))) | ||
| 1086 | 1082 | ||
| 1087 | (defun image-dired-dired-next-line (&optional arg) | 1083 | (defun image-dired-dired-next-line (&optional arg) |
| 1088 | "Call `dired-next-line', then track thumbnail. | 1084 | "Call `dired-next-line', then track thumbnail. |