]> git.eshelyaron.com Git - emacs.git/commitdiff
image-dired: Add new commands for beginning/end of buffer
authorStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 01:23:49 +0000 (03:23 +0200)
committerStefan Kangas <stefan@marxist.se>
Wed, 27 Oct 2021 01:32:37 +0000 (03:32 +0200)
* lisp/image-dired.el (image-dired-beginning-of-buffer)
(image-dired-end-of-buffer): New commands.
(image-dired-thumbnail-mode-map): Bind new beginning of buffer command
to '<' and 'M-<', and end of buffer command to '>' and 'M->'.

lisp/image-dired.el

index b54404b09031cd733573b0d82af7ae9aea058c10..cd18ca1565472bc04d0247f789259a4a1aa29c9c 100644 (file)
@@ -1444,6 +1444,28 @@ image."
       (image-dired-track-original-file))
   (image-dired-display-thumb-properties))
 
+(defun image-dired-beginning-of-buffer ()
+  "Move to the first image in the buffer and display properties."
+  (interactive nil image-dired-thumbnail-mode)
+  (goto-char (point-min))
+  (while (and (not (image-at-point-p))
+              (not (eobp)))
+    (forward-char 1))
+  (when image-dired-track-movement
+    (image-dired-track-original-file))
+  (image-dired-display-thumb-properties))
+
+(defun image-dired-end-of-buffer ()
+  "Move to the last image in the buffer and display properties."
+  (interactive nil image-dired-thumbnail-mode)
+  (goto-char (point-max))
+  (while (and (not (image-at-point-p))
+              (not (bobp)))
+    (forward-char -1))
+  (when image-dired-track-movement
+    (image-dired-track-original-file))
+  (image-dired-display-thumb-properties))
+
 (defun image-dired-format-properties-string (buf file props comment)
   "Format display properties.
 BUF is the associated dired buffer, FILE is the original image file
@@ -1590,6 +1612,11 @@ 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 "d" 'image-dired-flag-thumb-original-file)
     (define-key map [delete] 'image-dired-flag-thumb-original-file)
     (define-key map "m" 'image-dired-mark-thumb-original-file)