diff options
| author | Stefan Kangas | 2021-12-07 23:28:44 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-12-08 01:00:38 +0100 |
| commit | 10655ce02f97d474d1fc0c34af9975f36720cc3e (patch) | |
| tree | 78633696d37d2c5e2c7a618875d9b53d9070709e | |
| parent | 5364c571988b2bfba05870450a66767f7c134ebd (diff) | |
| download | emacs-10655ce02f97d474d1fc0c34af9975f36720cc3e.tar.gz emacs-10655ce02f97d474d1fc0c34af9975f36720cc3e.zip | |
image-dired: Navigate from image display buffer
* lisp/image-dired.el
(image-dired-mark-thumb-original-file)
(image-dired-unmark-thumb-original-file)
(image-dired-flag-thumb-original-file)
(image-dired-toggle-mark-thumb-original-file)
(image-dired-unmark-all-marks)
(image-dired-display-next-thumbnail-original)
(image-dired-display-previous-thumbnail-original): Make commands
usable from image-dired-display-image-mode.
(image-dired-display-image-mode-map): Bind above commands.
(image-dired--with-thumbnail-buffer): New macro.
| -rw-r--r-- | etc/NEWS | 12 | ||||
| -rw-r--r-- | lisp/image-dired.el | 89 |
2 files changed, 63 insertions, 38 deletions
| @@ -553,6 +553,16 @@ user options that are no longer needed are now obsolete: | |||
| 553 | 'image-dired-temp-image-file'. | 553 | 'image-dired-temp-image-file'. |
| 554 | 554 | ||
| 555 | --- | 555 | --- |
| 556 | *** Navigation and marking commands now work in image display buffer. | ||
| 557 | The following new bindings have been added: | ||
| 558 | |||
| 559 | n / SPC image-dired-display-previous-thumbnail-original | ||
| 560 | p / DEL image-dired-display-next-thumbnail-original | ||
| 561 | m image-dired-mark-thumb-original-file | ||
| 562 | d image-dired-flag-thumb-original-file | ||
| 563 | u image-dired-unmark-thumb-original-file | ||
| 564 | |||
| 565 | --- | ||
| 556 | *** Reduce dependency on external "exiftool" command. | 566 | *** Reduce dependency on external "exiftool" command. |
| 557 | The 'image-dired-copy-with-exif-file-name' no longer requires an | 567 | The 'image-dired-copy-with-exif-file-name' no longer requires an |
| 558 | external "exiftool" command to be available. The user options | 568 | external "exiftool" command to be available. The user options |
| @@ -562,7 +572,7 @@ external "exiftool" command to be available. The user options | |||
| 562 | --- | 572 | --- |
| 563 | *** New command for the thumbnail buffer. | 573 | *** New command for the thumbnail buffer. |
| 564 | The new command 'image-dired-unmark-all-marks' has been added. It is | 574 | The new command 'image-dired-unmark-all-marks' has been added. It is |
| 565 | bound to 'U' in the thumbnail buffer. | 575 | bound to 'U' in the thumbnail and display buffer. |
| 566 | 576 | ||
| 567 | --- | 577 | --- |
| 568 | *** Support Thumbnail Managing Standard v0.9.0 (Dec 2020). | 578 | *** Support Thumbnail Managing Standard v0.9.0 (Dec 2020). |
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 33f28a3440f..d75ccfece11 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el | |||
| @@ -1445,11 +1445,20 @@ for. The default is to look for `dired-marker-char'." | |||
| 1445 | "In Dired, return t if file on current line is flagged for deletion." | 1445 | "In Dired, return t if file on current line is flagged for deletion." |
| 1446 | (image-dired-dired-file-marked-p dired-del-marker)) | 1446 | (image-dired-dired-file-marked-p dired-del-marker)) |
| 1447 | 1447 | ||
| 1448 | (defmacro image-dired--with-thumbnail-buffer (&rest body) | ||
| 1449 | (declare (indent defun) (debug t)) | ||
| 1450 | `(if-let ((buf (get-buffer image-dired-thumbnail-buffer))) | ||
| 1451 | (with-current-buffer buf | ||
| 1452 | (if-let ((win (get-buffer-window buf))) | ||
| 1453 | (with-selected-window win | ||
| 1454 | ,@body) | ||
| 1455 | ,@body)) | ||
| 1456 | (user-error "No such buffer: %s" image-dired-thumbnail-buffer))) | ||
| 1457 | |||
| 1448 | (defmacro image-dired--on-file-in-dired-buffer (&rest body) | 1458 | (defmacro image-dired--on-file-in-dired-buffer (&rest body) |
| 1449 | "Run BODY with point on file at point in Dired buffer. | 1459 | "Run BODY with point on file at point in Dired buffer. |
| 1450 | Should be called from commands in `image-dired-thumbnail-mode'." | 1460 | Should be called from commands in `image-dired-thumbnail-mode'." |
| 1451 | (declare (indent defun) | 1461 | (declare (indent defun) (debug t)) |
| 1452 | (debug 1)) | ||
| 1453 | `(let ((file-name (image-dired-original-file-name)) | 1462 | `(let ((file-name (image-dired-original-file-name)) |
| 1454 | (dired-buf (image-dired-associated-dired-buffer))) | 1463 | (dired-buf (image-dired-associated-dired-buffer))) |
| 1455 | (if (not (and dired-buf file-name)) | 1464 | (if (not (and dired-buf file-name)) |
| @@ -1461,40 +1470,45 @@ Should be called from commands in `image-dired-thumbnail-mode'." | |||
| 1461 | 1470 | ||
| 1462 | (defun image-dired-mark-thumb-original-file () | 1471 | (defun image-dired-mark-thumb-original-file () |
| 1463 | "Mark original image file in associated Dired buffer." | 1472 | "Mark original image file in associated Dired buffer." |
| 1464 | (interactive nil image-dired-thumbnail-mode) | 1473 | (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1465 | (image-dired--on-file-in-dired-buffer | 1474 | (image-dired--with-thumbnail-buffer |
| 1466 | (dired-mark 1)) | 1475 | (image-dired--on-file-in-dired-buffer |
| 1467 | (image-dired-forward-image)) | 1476 | (dired-mark 1)) |
| 1477 | (image-dired-forward-image))) | ||
| 1468 | 1478 | ||
| 1469 | (defun image-dired-unmark-thumb-original-file () | 1479 | (defun image-dired-unmark-thumb-original-file () |
| 1470 | "Unmark original image file in associated Dired buffer." | 1480 | "Unmark original image file in associated Dired buffer." |
| 1471 | (interactive nil image-dired-thumbnail-mode) | 1481 | (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1472 | (image-dired--on-file-in-dired-buffer | 1482 | (image-dired--with-thumbnail-buffer |
| 1473 | (dired-unmark 1)) | 1483 | (image-dired--on-file-in-dired-buffer |
| 1474 | (image-dired-forward-image)) | 1484 | (dired-unmark 1)) |
| 1485 | (image-dired-forward-image))) | ||
| 1475 | 1486 | ||
| 1476 | (defun image-dired-flag-thumb-original-file () | 1487 | (defun image-dired-flag-thumb-original-file () |
| 1477 | "Flag original image file for deletion in associated Dired buffer." | 1488 | "Flag original image file for deletion in associated Dired buffer." |
| 1478 | (interactive nil image-dired-thumbnail-mode) | 1489 | (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1479 | (image-dired--on-file-in-dired-buffer | 1490 | (image-dired--with-thumbnail-buffer |
| 1480 | (dired-flag-file-deletion 1)) | 1491 | (image-dired--on-file-in-dired-buffer |
| 1481 | (image-dired-forward-image)) | 1492 | (dired-flag-file-deletion 1)) |
| 1493 | (image-dired-forward-image))) | ||
| 1482 | 1494 | ||
| 1483 | (defun image-dired-toggle-mark-thumb-original-file () | 1495 | (defun image-dired-toggle-mark-thumb-original-file () |
| 1484 | "Toggle mark on original image file in associated Dired buffer." | 1496 | "Toggle mark on original image file in associated Dired buffer." |
| 1485 | (interactive nil image-dired-thumbnail-mode) | 1497 | (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1486 | (image-dired--on-file-in-dired-buffer | 1498 | (image-dired--with-thumbnail-buffer |
| 1487 | (if (image-dired-dired-file-marked-p) | 1499 | (image-dired--on-file-in-dired-buffer |
| 1488 | (dired-unmark 1) | 1500 | (if (image-dired-dired-file-marked-p) |
| 1489 | (dired-mark 1)))) | 1501 | (dired-unmark 1) |
| 1502 | (dired-mark 1))))) | ||
| 1490 | 1503 | ||
| 1491 | (defun image-dired-unmark-all-marks () | 1504 | (defun image-dired-unmark-all-marks () |
| 1492 | "Remove all marks from all files in associated Dired buffer. | 1505 | "Remove all marks from all files in associated Dired buffer. |
| 1493 | Also update the marks in the thumbnail buffer." | 1506 | Also update the marks in the thumbnail buffer." |
| 1494 | (interactive nil image-dired-thumbnail-mode) | 1507 | (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) |
| 1495 | (with-current-buffer (image-dired-associated-dired-buffer) | 1508 | (image-dired--with-thumbnail-buffer |
| 1496 | (dired-unmark-all-marks)) | 1509 | (with-current-buffer (image-dired-associated-dired-buffer) |
| 1497 | (image-dired-thumb-update-marks)) | 1510 | (dired-unmark-all-marks)) |
| 1511 | (image-dired-thumb-update-marks))) | ||
| 1498 | 1512 | ||
| 1499 | (defun image-dired-jump-original-dired-buffer () | 1513 | (defun image-dired-jump-original-dired-buffer () |
| 1500 | "Jump to the Dired buffer associated with the current image file. | 1514 | "Jump to the Dired buffer associated with the current image file. |
| @@ -1638,16 +1652,16 @@ You probably want to use this together with | |||
| 1638 | (defvar image-dired-display-image-mode-map | 1652 | (defvar image-dired-display-image-mode-map |
| 1639 | (let ((map (make-sparse-keymap))) | 1653 | (let ((map (make-sparse-keymap))) |
| 1640 | (define-key map "S" #'image-dired-slideshow-start) | 1654 | (define-key map "S" #'image-dired-slideshow-start) |
| 1655 | (define-key map (kbd "SPC") #'image-dired-display-next-thumbnail-original) | ||
| 1656 | (define-key map (kbd "DEL") #'image-dired-display-previous-thumbnail-original) | ||
| 1657 | (define-key map "n" #'image-dired-display-next-thumbnail-original) | ||
| 1658 | (define-key map "p" #'image-dired-display-previous-thumbnail-original) | ||
| 1659 | (define-key map "m" #'image-dired-mark-thumb-original-file) | ||
| 1660 | (define-key map "d" #'image-dired-flag-thumb-original-file) | ||
| 1661 | (define-key map "u" #'image-dired-unmark-thumb-original-file) | ||
| 1662 | (define-key map "U" #'image-dired-unmark-all-marks) | ||
| 1641 | ;; Disable keybindings from `image-mode-map' that doesn't make sense here. | 1663 | ;; Disable keybindings from `image-mode-map' that doesn't make sense here. |
| 1642 | (define-key map "o" nil) ; image-save | 1664 | (define-key map "o" nil) ; image-save |
| 1643 | (define-key map "n" nil) ; image-next-file | ||
| 1644 | (define-key map "p" nil) ; image-previous-file | ||
| 1645 | ;; FIXME: Should be replaced with image-dired commands. | ||
| 1646 | (define-key map (kbd "DEL") nil) ; image-next-file | ||
| 1647 | (define-key map (kbd "SPC") nil) ; image-next-file | ||
| 1648 | ;; FIXME: Should be replaced with image-dired commands. | ||
| 1649 | (define-key map "m" nil) ; image-mode-mark-file | ||
| 1650 | (define-key map "u" nil) ; image-mode-unmark-file | ||
| 1651 | map) | 1665 | map) |
| 1652 | "Keymap for `image-dired-display-image-mode'.") | 1666 | "Keymap for `image-dired-display-image-mode'.") |
| 1653 | 1667 | ||
| @@ -2129,16 +2143,17 @@ function. The result is a couple of new files in | |||
| 2129 | ;;; Thumbnail mode (cont.) | 2143 | ;;; Thumbnail mode (cont.) |
| 2130 | 2144 | ||
| 2131 | (defun image-dired-display-next-thumbnail-original (&optional arg) | 2145 | (defun image-dired-display-next-thumbnail-original (&optional arg) |
| 2132 | "In thumbnail buffer, move to next thumbnail and display the image. | 2146 | "Move to the next image in the thumbnail buffer and display it. |
| 2133 | With prefix ARG, move that many thumbnails." | 2147 | With prefix ARG, move that many thumbnails." |
| 2134 | (interactive "p" image-dired-thumbnail-mode) | 2148 | (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode) |
| 2135 | (image-dired-forward-image arg t) | 2149 | (image-dired--with-thumbnail-buffer |
| 2136 | (image-dired-display-thumbnail-original-image)) | 2150 | (image-dired-forward-image arg t) |
| 2151 | (image-dired-display-thumbnail-original-image))) | ||
| 2137 | 2152 | ||
| 2138 | (defun image-dired-display-previous-thumbnail-original (arg) | 2153 | (defun image-dired-display-previous-thumbnail-original (arg) |
| 2139 | "In thumbnail buffer, move to previous thumbnail and display image. | 2154 | "Move to the previous image in the thumbnail buffer and display it. |
| 2140 | With prefix ARG, move that many thumbnails." | 2155 | With prefix ARG, move that many thumbnails." |
| 2141 | (interactive "p" image-dired-thumbnail-mode) | 2156 | (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode) |
| 2142 | (image-dired-display-next-thumbnail-original (- arg))) | 2157 | (image-dired-display-next-thumbnail-original (- arg))) |
| 2143 | 2158 | ||
| 2144 | 2159 | ||