]> git.eshelyaron.com Git - emacs.git/commitdiff
image-dired: Don't ding at beginning or end of buffer
authorStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 01:43:21 +0000 (03:43 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 02:30:35 +0000 (04:30 +0200)
* lisp/image-dired.el
(image-dired--display-thumb-properties-fun): New defun.
(image-dired-forward-image, image-dired-backward-image): Don't ding
when moving past first or last image; instead show a message, wait a
second and then show image properties.

lisp/image-dired.el

index cd18ca1565472bc04d0247f789259a4a1aa29c9c..cc8b80dd51f44abc1589eba903cca5d72aa4e681 100644 (file)
@@ -1372,6 +1372,15 @@ With prefix argument, move ARG lines."
   (if image-dired-track-movement
       (image-dired-track-thumbnail)))
 
+(defun image-dired--display-thumb-properties-fun ()
+  (let ((old-buf (current-buffer))
+        (old-point (point)))
+    (lambda ()
+      (when (and (equal (current-buffer) old-buf)
+                 (= (point) old-point))
+        (ignore-errors
+          (image-dired-display-thumb-properties))))))
+
 (defun image-dired-forward-image (&optional arg)
   "Move to next image and display properties.
 Optional prefix ARG says how many images to move; default is one
@@ -1387,11 +1396,12 @@ image."
                    (forward-char))
                  (setq pos (point))
                  (image-dired-image-at-point-p)))
-          (goto-char pos)
-        (error "At last image"))))
+          (progn (goto-char pos)
+                 (image-dired-display-thumb-properties))
+        (message "At last image")
+        (run-at-time 1 nil (image-dired--display-thumb-properties-fun)))))
   (when image-dired-track-movement
-    (image-dired-track-original-file))
-  (image-dired-display-thumb-properties))
+    (image-dired-track-original-file)))
 
 (defun image-dired-backward-image (&optional arg)
   "Move to previous image and display properties.
@@ -1408,11 +1418,12 @@ image."
                    (backward-char))
                  (setq pos (point))
                  (image-dired-image-at-point-p)))
-          (goto-char pos)
-        (error "At first image"))))
+          (progn (goto-char pos)
+                 (image-dired-display-thumb-properties))
+        (message "At first image")
+        (run-at-time 1 nil (image-dired--display-thumb-properties-fun)))))
   (when image-dired-track-movement
-    (image-dired-track-original-file))
-  (image-dired-display-thumb-properties))
+    (image-dired-track-original-file)))
 
 (defun image-dired-next-line ()
   "Move to next line and display properties."
@@ -1612,10 +1623,10 @@ You probably want to use this together with
     (define-key map "\C-p" 'image-dired-previous-line)
     (define-key map "\C-n" 'image-dired-next-line)
 
-    (define-key map "<" 'image-dired-beginning-of-buffer)
-    (define-key map ">" 'image-dired-end-of-buffer)
-    (define-key map (kbd "M-<") 'image-dired-beginning-of-buffer)
-    (define-key map (kbd "M->") 'image-dired-end-of-buffer)
+    (define-key map "<" #'image-dired-beginning-of-buffer)
+    (define-key map ">" #'image-dired-end-of-buffer)
+    (define-key map (kbd "M-<") #'image-dired-beginning-of-buffer)
+    (define-key map (kbd "M->") #'image-dired-end-of-buffer)
 
     (define-key map "d" 'image-dired-flag-thumb-original-file)
     (define-key map [delete] 'image-dired-flag-thumb-original-file)