diff options
| author | Stefan Kangas | 2021-11-03 22:34:51 +0100 |
|---|---|---|
| committer | Stefan Kangas | 2021-11-03 22:34:51 +0100 |
| commit | 733eff49d33dfd8df5f44def7dff7046f3ee61a4 (patch) | |
| tree | 7f8e63b735a54a19108dd359b1652d988288fc3d | |
| parent | 4422ed2c19fd9017fd9577aa0d04abdae28ac72e (diff) | |
| download | emacs-733eff49d33dfd8df5f44def7dff7046f3ee61a4.tar.gz emacs-733eff49d33dfd8df5f44def7dff7046f3ee61a4.zip | |
image-dired: Add face for flagged files
* lisp/image-dired.el (image-dired-thumb-mark): New defface.
(image-dired-thumb-update-marks): Mark flagged file with above new defface.
(image-dired-dired-file-marked-p)
(image-dired-thumb-file-marked-p): Add optional argument to be
used by 'image-dired-*-flagged-p' functions below.
(image-dired-dired-file-flagged-p)
(image-dired-thumb-file-flagged-p): New defuns.
(image-dired-thumb-mark): Improve definition with color classes.
(image-dired-thumb-visible-marks): Doc fix.
| -rw-r--r-- | etc/NEWS | 6 | ||||
| -rw-r--r-- | lisp/image-dired.el | 62 |
2 files changed, 53 insertions, 15 deletions
| @@ -260,6 +260,12 @@ Support for the GraphicsMagick command line tool ("gm") has been | |||
| 260 | added, and is used instead of ImageMagick when it is available. | 260 | added, and is used instead of ImageMagick when it is available. |
| 261 | 261 | ||
| 262 | --- | 262 | --- |
| 263 | *** New face 'image-dired-thumb-flagged'. | ||
| 264 | If 'image-dired-thumb-mark' is non-nil (the default), this face is | ||
| 265 | used for images that are flagged for deletion in the Dired buffer | ||
| 266 | associated with Image-Dired. | ||
| 267 | |||
| 268 | --- | ||
| 263 | *** Support for bookmark.el. | 269 | *** Support for bookmark.el. |
| 264 | The command 'bookmark-set' (bound to 'C-x r m') is now supported in | 270 | The command 'bookmark-set' (bound to 'C-x r m') is now supported in |
| 265 | the thumbnail view, and will create a bookmark that opens the current | 271 | the thumbnail view, and will create a bookmark that opens the current |
diff --git a/lisp/image-dired.el b/lisp/image-dired.el index 6deaaef8cee..a69c8f90178 100644 --- a/lisp/image-dired.el +++ b/lisp/image-dired.el | |||
| @@ -458,15 +458,28 @@ This is where you see the cursor." | |||
| 458 | :type 'integer) | 458 | :type 'integer) |
| 459 | 459 | ||
| 460 | (defcustom image-dired-thumb-visible-marks t | 460 | (defcustom image-dired-thumb-visible-marks t |
| 461 | "Make marks visible in thumbnail buffer. | 461 | "Make marks and flags visible in thumbnail buffer. |
| 462 | If non-nil, apply the `image-dired-thumb-mark' face to marked | 462 | If non-nil, apply the `image-dired-thumb-mark' face to marked |
| 463 | images." | 463 | images and `image-dired-thumb-flagged' to images flagged for |
| 464 | deletion." | ||
| 464 | :type 'boolean | 465 | :type 'boolean |
| 465 | :version "28.1") | 466 | :version "28.1") |
| 466 | 467 | ||
| 467 | (defface image-dired-thumb-mark | 468 | (defface image-dired-thumb-mark |
| 468 | '((t (:background "DarkOrange"))) | 469 | '((((class color) (min-colors 16)) :background "DarkOrange") |
| 469 | "Background-color for marked images in thumbnail buffer." | 470 | (((class color)) :foreground "yellow")) |
| 471 | "Face for marked images in thumbnail buffer." | ||
| 472 | :group 'image-dired | ||
| 473 | :version "29.1") | ||
| 474 | |||
| 475 | (defface image-dired-thumb-flagged | ||
| 476 | '((((class color) (min-colors 88) (background light)) :background "Red3") | ||
| 477 | (((class color) (min-colors 88) (background dark)) :background "Pink") | ||
| 478 | (((class color) (min-colors 16) (background light)) :background "Red3") | ||
| 479 | (((class color) (min-colors 16) (background dark)) :background "Pink") | ||
| 480 | (((class color) (min-colors 8)) :background "red") | ||
| 481 | (t :inverse-video t)) | ||
| 482 | "Face for images flagged for deletion in thumbnail buffer." | ||
| 470 | :group 'image-dired | 483 | :group 'image-dired |
| 471 | :version "29.1") | 484 | :version "29.1") |
| 472 | 485 | ||
| @@ -1490,11 +1503,19 @@ comment." | |||
| 1490 | props | 1503 | props |
| 1491 | comment)))))) | 1504 | comment)))))) |
| 1492 | 1505 | ||
| 1493 | (defun image-dired-dired-file-marked-p () | 1506 | (defun image-dired-dired-file-marked-p (&optional marker) |
| 1494 | "Check whether file on current line is marked or not." | 1507 | "In Dired, return t if file on current line is marked. |
| 1508 | If optional argument MARKER is non-nil, it is a character to look | ||
| 1509 | for. The default is to look for `dired-marker-char'." | ||
| 1510 | (setq marker (or marker dired-marker-char)) | ||
| 1495 | (save-excursion | 1511 | (save-excursion |
| 1496 | (beginning-of-line) | 1512 | (beginning-of-line) |
| 1497 | (looking-at-p dired-re-mark))) | 1513 | (and (looking-at dired-re-mark) |
| 1514 | (= (aref (match-string 0) 0) marker)))) | ||
| 1515 | |||
| 1516 | (defun image-dired-dired-file-flagged-p () | ||
| 1517 | "In Dired, return t if file on current line is flagged for deletion." | ||
| 1518 | (image-dired-dired-file-marked-p dired-del-marker)) | ||
| 1498 | 1519 | ||
| 1499 | (defmacro image-dired--on-file-in-dired-buffer (&rest body) | 1520 | (defmacro image-dired--on-file-in-dired-buffer (&rest body) |
| 1500 | "Run BODY with point on file at point in Dired buffer. | 1521 | "Run BODY with point on file at point in Dired buffer. |
| @@ -2408,15 +2429,23 @@ non-nil." | |||
| 2408 | (image-dired-track-original-file)) | 2429 | (image-dired-track-original-file)) |
| 2409 | (image-dired-display-thumb-properties)) | 2430 | (image-dired-display-thumb-properties)) |
| 2410 | 2431 | ||
| 2411 | (defun image-dired-thumb-file-marked-p () | 2432 | (defun image-dired-thumb-file-marked-p (&optional flagged) |
| 2412 | "Check if file is marked in associated Dired buffer." | 2433 | "Check if file is marked in associated Dired buffer. |
| 2434 | If optional argument FLAGGED is non-nil, check if file is flagged | ||
| 2435 | for deletion instead." | ||
| 2413 | (let ((file-name (image-dired-original-file-name)) | 2436 | (let ((file-name (image-dired-original-file-name)) |
| 2414 | (dired-buf (image-dired-associated-dired-buffer))) | 2437 | (dired-buf (image-dired-associated-dired-buffer))) |
| 2415 | (when (and dired-buf file-name) | 2438 | (when (and dired-buf file-name) |
| 2416 | (with-current-buffer dired-buf | 2439 | (with-current-buffer dired-buf |
| 2417 | (save-excursion | 2440 | (save-excursion |
| 2418 | (when (dired-goto-file file-name) | 2441 | (when (dired-goto-file file-name) |
| 2419 | (image-dired-dired-file-marked-p))))))) | 2442 | (if flagged |
| 2443 | (image-dired-dired-file-flagged-p) | ||
| 2444 | (image-dired-dired-file-marked-p)))))))) | ||
| 2445 | |||
| 2446 | (defun image-dired-thumb-file-flagged-p () | ||
| 2447 | "Check if file is flagged for deletion in associated Dired buffer." | ||
| 2448 | (image-dired-thumb-file-marked-p t)) | ||
| 2420 | 2449 | ||
| 2421 | (defun image-dired-delete-marked () | 2450 | (defun image-dired-delete-marked () |
| 2422 | "Delete current or marked thumbnails and associated images." | 2451 | "Delete current or marked thumbnails and associated images." |
| @@ -2437,11 +2466,14 @@ non-nil." | |||
| 2437 | (let ((inhibit-read-only t)) | 2466 | (let ((inhibit-read-only t)) |
| 2438 | (while (not (eobp)) | 2467 | (while (not (eobp)) |
| 2439 | (with-silent-modifications | 2468 | (with-silent-modifications |
| 2440 | (if (image-dired-thumb-file-marked-p) | 2469 | (cond ((image-dired-thumb-file-marked-p) |
| 2441 | (add-face-text-property (point) (1+ (point)) | 2470 | (add-face-text-property (point) (1+ (point)) |
| 2442 | 'image-dired-thumb-mark) | 2471 | 'image-dired-thumb-mark)) |
| 2443 | (remove-text-properties (point) (1+ (point)) | 2472 | ((image-dired-thumb-file-flagged-p) |
| 2444 | '(face image-dired-thumb-mark)))) | 2473 | (add-face-text-property (point) (1+ (point)) |
| 2474 | 'image-dired-thumb-flagged)) | ||
| 2475 | (t (remove-text-properties (point) (1+ (point)) | ||
| 2476 | '(face image-dired-thumb-mark))))) | ||
| 2445 | (forward-char))))))) | 2477 | (forward-char))))))) |
| 2446 | 2478 | ||
| 2447 | (defun image-dired-mouse-toggle-mark-1 () | 2479 | (defun image-dired-mouse-toggle-mark-1 () |