summaryrefslogtreecommitdiff
path: root/lisp/image-dired.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/image-dired.el')
-rw-r--r--lisp/image-dired.el339
1 files changed, 193 insertions, 146 deletions
diff --git a/lisp/image-dired.el b/lisp/image-dired.el
index 48f9cd0767c..cf878ae1223 100644
--- a/lisp/image-dired.el
+++ b/lisp/image-dired.el
@@ -67,9 +67,9 @@
;;
;; * For `image-dired-get-exif-data' and `image-dired-set-exif-data' to work,
;; the command line tool `exiftool' is needed. It can be found here:
-;; http://www.sno.phy.queensu.ca/~phil/exiftool/. These two functions
-;; are, among other things, used for writing comments to image files
-;; using `image-dired-thumbnail-set-image-description' and to create
+;; https://exiftool.org/. These two functions are, among other
+;; things, used for writing comments to image files using
+;; `image-dired-thumbnail-set-image-description' and to create
;; "unique" file names using `image-dired-get-exif-file-name' (used by
;; `image-dired-copy-with-exif-file-name').
;;
@@ -164,8 +164,7 @@
(defcustom image-dired-dir (locate-user-emacs-file "image-dired/")
"Directory where thumbnail images are stored."
- :type 'directory
- :group 'image-dired)
+ :type 'directory)
(defcustom image-dired-thumbnail-storage 'use-image-dired-dir
"How to store image-dired's thumbnail files.
@@ -181,51 +180,44 @@ that allows sharing of thumbnails across different programs."
(const :tag "Use image-dired-dir" use-image-dired-dir)
(const :tag "Thumbnail Managing Standard (normal 128x128)" standard)
(const :tag "Thumbnail Managing Standard (large 256x256)" standard-large)
- (const :tag "Per-directory" per-directory))
- :group 'image-dired)
+ (const :tag "Per-directory" per-directory)))
(defcustom image-dired-db-file
(expand-file-name ".image-dired_db" image-dired-dir)
"Database file where file names and their associated tags are stored."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-temp-image-file
(expand-file-name ".image-dired_temp" image-dired-dir)
"Name of temporary image file used by various commands."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-gallery-dir
(expand-file-name ".image-dired_gallery" image-dired-dir)
"Directory to store generated gallery html pages.
This path needs to be \"shared\" to the public so that it can access
the index.html page that image-dired creates."
- :type 'directory
- :group 'image-dired)
+ :type 'directory)
(defcustom image-dired-gallery-image-root-url
"https://your.own.server/image-diredpics"
"URL where the full size images are to be found.
Note that this path has to be configured in your web server. Image-Dired
expects to find pictures in this directory."
- :type 'string
- :group 'image-dired)
+ :type 'string)
(defcustom image-dired-gallery-thumb-image-root-url
"https://your.own.server/image-diredthumbs"
"URL where the thumbnail images are to be found.
Note that this path has to be configured in your web server. Image-Dired
expects to find pictures in this directory."
- :type 'string
- :group 'image-dired)
+ :type 'string)
(defcustom image-dired-cmd-create-thumbnail-program
"convert"
"Executable used to create thumbnail.
Used together with `image-dired-cmd-create-thumbnail-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-create-thumbnail-options
'("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
@@ -236,14 +228,12 @@ Available format specifiers are: %w which is replaced by
%f which is replaced by the file name of the original image and %t
which is replaced by the file name of the thumbnail file."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-create-temp-image-program "convert"
"Executable used to create temporary image.
Used together with `image-dired-cmd-create-temp-image-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-create-temp-image-options
'("-size" "%wx%h" "%f[0]" "-resize" "%wx%h>" "-strip" "jpeg:%t")
@@ -254,8 +244,7 @@ the calculated max size for width and height in the image display window,
%f which is replaced by the file name of the original image and %t which
is replaced by the file name of the temporary file."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-pngnq-program
(or (executable-find "pngnq")
@@ -264,8 +253,7 @@ is replaced by the file name of the temporary file."
It quantizes colors of PNG images down to 256 colors or fewer
using the NeuQuant algorithm."
:version "26.1"
- :type '(choice (const :tag "Not Set" nil) file)
- :group 'image-dired)
+ :type '(choice (const :tag "Not Set" nil) file))
(defcustom image-dired-cmd-pngnq-options
'("-f" "%t")
@@ -273,15 +261,13 @@ using the NeuQuant algorithm."
Available format specifiers are the same as in
`image-dired-cmd-create-thumbnail-options'."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-pngcrush-program (executable-find "pngcrush")
"The file name of the `pngcrush' program.
It optimizes the compression of PNG images. Also it adds PNG textual chunks
with the information required by the Thumbnail Managing Standard."
- :type '(choice (const :tag "Not Set" nil) file)
- :group 'image-dired)
+ :type '(choice (const :tag "Not Set" nil) file))
(defcustom image-dired-cmd-pngcrush-options
`("-q"
@@ -299,14 +285,12 @@ Available format specifiers are the same as in
`image-dired-cmd-create-thumbnail-options', with %q for a
temporary file name (typically generated by pnqnq)."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-optipng-program (executable-find "optipng")
"The file name of the `optipng' program."
:version "26.1"
- :type '(choice (const :tag "Not Set" nil) file)
- :group 'image-dired)
+ :type '(choice (const :tag "Not Set" nil) file))
(defcustom image-dired-cmd-optipng-options '("-o5" "%t")
"Arguments passed to `image-dired-cmd-optipng-program'.
@@ -314,8 +298,7 @@ Available format specifiers are described in
`image-dired-cmd-create-thumbnail-options'."
:version "26.1"
:type '(repeat (string :tag "Argument"))
- :link '(url-link "man:optipng(1)")
- :group 'image-dired)
+ :link '(url-link "man:optipng(1)"))
(defcustom image-dired-cmd-create-standard-thumbnail-options
(append '("-size" "%wx%h" "%f[0]")
@@ -331,15 +314,13 @@ Available format specifiers are described in
Available format specifiers are the same as in
`image-dired-cmd-create-thumbnail-options', with %m for file modification time."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-rotate-thumbnail-program
"mogrify"
"Executable used to rotate thumbnail.
Used together with `image-dired-cmd-rotate-thumbnail-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-rotate-thumbnail-options
'("-rotate" "%d" "%t")
@@ -350,15 +331,13 @@ number of (positive) degrees to rotate the image, normally 90 or 270
\(for 90 degrees right and left), %t which is replaced by the file name
of the thumbnail file."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-rotate-original-program
"jpegtran"
"Executable used to rotate original image.
Used together with `image-dired-cmd-rotate-original-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-rotate-original-options
'("-rotate" "%d" "-copy" "all" "-outfile" "%t" "%o")
@@ -370,28 +349,24 @@ number of (positive) degrees to rotate the image, normally 90 or
original image file name and %t which is replaced by
`image-dired-temp-image-file'."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-temp-rotate-image-file
(expand-file-name ".image-dired_rotate_temp" image-dired-dir)
"Temporary file for rotate operations."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-rotate-original-ask-before-overwrite t
"Confirm overwrite of original file after rotate operation.
If non-nil, ask user for confirmation before overwriting the
original file with `image-dired-temp-rotate-image-file'."
- :type 'boolean
- :group 'image-dired)
+ :type 'boolean)
(defcustom image-dired-cmd-write-exif-data-program
"exiftool"
"Program used to write EXIF data to image.
Used together with `image-dired-cmd-write-exif-data-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-write-exif-data-options
'("-%t=%v" "%f")
@@ -401,15 +376,13 @@ Available format specifiers are: %f which is replaced by
the image file name, %t which is replaced by the tag name and %v
which is replaced by the tag value."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-cmd-read-exif-data-program
"exiftool"
"Program used to read EXIF data to image.
Used together with `image-dired-cmd-read-exif-data-options'."
- :type 'file
- :group 'image-dired)
+ :type 'file)
(defcustom image-dired-cmd-read-exif-data-options
'("-s" "-s" "-s" "-%t" "%f")
@@ -418,15 +391,13 @@ Used with `image-dired-cmd-read-exif-data-program'.
Available format specifiers are: %f which is replaced
by the image file name and %t which is replaced by the tag name."
:version "26.1"
- :type '(repeat (string :tag "Argument"))
- :group 'image-dired)
+ :type '(repeat (string :tag "Argument")))
(defcustom image-dired-gallery-hidden-tags
(list "private" "hidden" "pending")
"List of \"hidden\" tags.
Used by `image-dired-gallery-generate' to leave out \"hidden\" images."
- :type '(repeat string)
- :group 'image-dired)
+ :type '(repeat string))
(defcustom image-dired-thumb-size
(cond
@@ -436,29 +407,37 @@ Used by `image-dired-gallery-generate' to leave out \"hidden\" images."
"Size of thumbnails, in pixels.
This is the default size for both `image-dired-thumb-width'
and `image-dired-thumb-height'."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-thumb-width image-dired-thumb-size
"Width of thumbnails, in pixels."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-thumb-height image-dired-thumb-size
"Height of thumbnails, in pixels."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-thumb-relief 2
"Size of button-like border around thumbnails."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-thumb-margin 2
"Size of the margin around thumbnails.
This is where you see the cursor."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
+
+(defcustom image-dired-thumb-visible-marks t
+ "Make marks visible in thumbnail buffer.
+If non-nil, apply the `image-dired-thumb-mark' face to marked
+images."
+ :type 'boolean
+ :version "28.1")
+
+(defface image-dired-thumb-mark
+ '((t (:background "orange")))
+ "Background-color for marked images in thumbnail buffer."
+ :group 'image-dired
+ :version "28.1")
(defcustom image-dired-line-up-method 'dynamic
"Default method for line-up of thumbnails in thumbnail buffer.
@@ -471,34 +450,29 @@ and No line-up means that no automatic line-up will be done."
(const :tag "Dynamic" dynamic)
(const :tag "Fixed" fixed)
(const :tag "Interactive" interactive)
- (const :tag "No line-up" none))
- :group 'image-dired)
+ (const :tag "No line-up" none)))
(defcustom image-dired-thumbs-per-row 3
"Number of thumbnails to display per row in thumb buffer."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-display-window-width-correction 1
"Number to be used to correct image display window width.
Change if the default (1) does not work (i.e. if the image does not
completely fit)."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-display-window-height-correction 0
"Number to be used to correct image display window height.
Change if the default (0) does not work (i.e. if the image does not
completely fit)."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defcustom image-dired-track-movement t
"The current state of the tracking and mirroring.
For more information, see the documentation for
`image-dired-toggle-movement-tracking'."
- :type 'boolean
- :group 'image-dired)
+ :type 'boolean)
(defcustom image-dired-append-when-browsing nil
"Append thumbnails in thumbnail buffer when browsing.
@@ -508,8 +482,7 @@ images in the thumbnail buffer. If you enable this and want to clean
the thumbnail buffer because it is filled with too many thumbnails,
just call `image-dired-display-thumb' to display only the image at point.
This value can be toggled using `image-dired-toggle-append-browsing'."
- :type 'boolean
- :group 'image-dired)
+ :type 'boolean)
(defcustom image-dired-dired-disp-props t
"If non-nil, display properties for dired file when browsing.
@@ -517,16 +490,14 @@ Used by `image-dired-next-line-and-display',
`image-dired-previous-line-and-display' and `image-dired-mark-and-display-next'.
If the database file is large, this can slow down image browsing in
dired and you might want to turn it off."
- :type 'boolean
- :group 'image-dired)
+ :type 'boolean)
(defcustom image-dired-display-properties-format "%b: %f (%t): %c"
"Display format for thumbnail properties.
%b is replaced with associated dired buffer name, %f with file name
\(without path) of original image file, %t with the list of tags and %c
with the comment."
- :type 'string
- :group 'image-dired)
+ :type 'string)
(defcustom image-dired-external-viewer
;; TODO: Use mailcap, dired-guess-shell-alist-default,
@@ -539,20 +510,17 @@ Including parameters. Used when displaying original image from
`image-dired-thumbnail-mode'."
:version "27.1"
:type '(choice string
- (const :tag "Not Set" nil))
- :group 'image-dired)
+ (const :tag "Not Set" nil)))
(defcustom image-dired-main-image-directory "~/pics/"
"Name of main image directory, if any.
Used by `image-dired-copy-with-exif-file-name'."
- :type 'string
- :group 'image-dired)
+ :type 'string)
(defcustom image-dired-show-all-from-dir-max-files 50
"Maximum number of files to show using `image-dired-show-all-from-dir'
before warning the user."
- :type 'integer
- :group 'image-dired)
+ :type 'integer)
(defmacro image-dired--with-db-file (&rest body)
"Run BODY in a temp buffer containing `image-dired-db-file'.
@@ -684,6 +652,8 @@ Each item has the form (ORIGINAL-FILE TARGET-FILE).")
"Maximum number of concurrent jobs permitted for generating images.
Increase at own risk.")
+(defvar image-dired-tag-history nil "Variable holding the tag history.")
+
(defun image-dired-pngnq-thumb (spec)
"Quantize thumbnail described by format SPEC with pngnq(1)."
(let ((process
@@ -704,7 +674,7 @@ Increase at own risk.")
(thumb (cdr (assq ?t spec))))
(rename-file nq8 thumb t)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))))
+ (string-replace "\n" "" status)))))
process))
(defun image-dired-pngcrush-thumb (spec)
@@ -726,7 +696,7 @@ Increase at own risk.")
(unless (and (eq (process-status process) 'exit)
(zerop (process-exit-status process)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))
+ (string-replace "\n" "" status)))
(when (memq (process-status process) '(exit signal))
(let ((temp (cdr (assq ?q spec))))
(delete-file temp)))))
@@ -744,7 +714,7 @@ Increase at own risk.")
(unless (and (eq (process-status process) 'exit)
(zerop (process-exit-status process)))
(message "command %S %s" (process-command process)
- (replace-regexp-in-string "\n" "" status)))))
+ (string-replace "\n" "" status)))))
process))
(defun image-dired-create-thumb-1 (original-file thumbnail-file)
@@ -794,7 +764,7 @@ Increase at own risk.")
(zerop (process-exit-status process))))
(message "Thumb could not be created for %s: %s"
(abbreviate-file-name original-file)
- (replace-regexp-in-string "\n" "" status))
+ (string-replace "\n" "" status))
(set-file-modes thumbnail-file #o600)
(clear-image-cache thumbnail-file)
;; PNG thumbnail has been created since we are
@@ -829,6 +799,22 @@ Queued items live in `image-dired-queue'."
(list (list original-file thumbnail-file))))
(run-at-time 0 nil #'image-dired-thumb-queue-run))
+(defmacro image-dired--with-marked (&rest body)
+ "Eval BODY with point on each marked thumbnail.
+If no marked file could be found, execute BODY on the current
+thumbnail."
+ `(with-current-buffer image-dired-thumbnail-buffer
+ (let (found)
+ (save-mark-and-excursion
+ (goto-char (point-min))
+ (while (not (eobp))
+ (when (image-dired-thumb-file-marked-p)
+ (setq found t)
+ ,@body)
+ (forward-char)))
+ (unless found
+ ,@body))))
+
;;;###autoload
(defun image-dired-dired-toggle-marked-thumbs (&optional arg)
"Toggle thumbnails in front of file names in the dired buffer.
@@ -992,6 +978,19 @@ Restore any changes to the window configuration made by calling
(set-window-configuration image-dired-saved-window-configuration)
(message "No saved window configuration")))
+(defun image-dired--line-up-with-method ()
+ "Line up thumbnails according to `image-dired-line-up-method'."
+ (cond ((eq 'dynamic image-dired-line-up-method)
+ (image-dired-line-up-dynamic))
+ ((eq 'fixed image-dired-line-up-method)
+ (image-dired-line-up))
+ ((eq 'interactive image-dired-line-up-method)
+ (image-dired-line-up-interactive))
+ ((eq 'none image-dired-line-up-method)
+ nil)
+ (t
+ (image-dired-line-up-dynamic))))
+
;;;###autoload
(defun image-dired-display-thumbs (&optional arg append do-not-pop)
"Display thumbnails of all marked files, in `image-dired-thumbnail-buffer'.
@@ -1033,16 +1032,7 @@ thumbnail buffer to be selected."
(if do-not-pop
(display-buffer buf)
(pop-to-buffer buf))
- (cond ((eq 'dynamic image-dired-line-up-method)
- (image-dired-line-up-dynamic))
- ((eq 'fixed image-dired-line-up-method)
- (image-dired-line-up))
- ((eq 'interactive image-dired-line-up-method)
- (image-dired-line-up-interactive))
- ((eq 'none image-dired-line-up-method)
- nil)
- (t
- (image-dired-line-up-dynamic))))))
+ (image-dired--line-up-with-method))))
;;;###autoload
(defun image-dired-show-all-from-dir (dir)
@@ -1108,7 +1098,7 @@ FILE-TAGS is an alist in the following form:
(end-of-line)
(insert (format ";%s" tag))))
(goto-char (point-max))
- (insert (format "\n%s;%s" file tag))))
+ (insert (format "%s;%s\n" file tag))))
(save-buffer))))
(defun image-dired-remove-tag (files tag)
@@ -1123,11 +1113,12 @@ FILE-TAGS is an alist in the following form:
(error "Files must be a string or a list of strings!")))
(dolist (file files)
(goto-char (point-min))
- (when (search-forward-regexp (format "^%s" file) nil t)
+ (when (search-forward-regexp (format "^%s;" file) nil t)
(end-of-line)
(setq end (point))
(beginning-of-line)
- (when (search-forward-regexp (format "\\(;%s\\)" tag) end t)
+ (when (search-forward-regexp
+ (format "\\(;%s\\)\\($\\|;\\)" tag) end t)
(delete-region (match-beginning 1) (match-end 1))
;; Check if file should still be in the database. If
;; it has no tags or comments, it will be removed.
@@ -1135,11 +1126,7 @@ FILE-TAGS is an alist in the following form:
(setq end (point))
(beginning-of-line)
(when (not (search-forward ";" end t))
- (kill-line 1)
- ;; If on empty line at end of buffer
- (and (eobp)
- (looking-at "^$")
- (delete-char -1)))))))
+ (kill-line 1))))))
(save-buffer)))
(defun image-dired-list-tags (file)
@@ -1162,7 +1149,9 @@ FILE-TAGS is an alist in the following form:
(defun image-dired-tag-files (arg)
"Tag marked file(s) in dired. With prefix ARG, tag file at point."
(interactive "P")
- (let ((tag (read-string "Tags to add (separate tags with a semicolon): "))
+ (let ((tag (completing-read
+ "Tags to add (separate tags with a semicolon): "
+ image-dired-tag-history nil nil nil 'image-dired-tag-history))
files)
(if arg
(setq files (list (dired-get-filename)))
@@ -1174,19 +1163,24 @@ FILE-TAGS is an alist in the following form:
files))))
(defun image-dired-tag-thumbnail ()
- "Tag current thumbnail."
+ "Tag current or marked thumbnails."
(interactive)
- (let ((tag (read-string "Tags to add (separate tags with a semicolon): ")))
- (image-dired-write-tags (list (cons (image-dired-original-file-name) tag))))
- (image-dired-update-property
- 'tags (image-dired-list-tags (image-dired-original-file-name))))
+ (let ((tag (completing-read
+ "Tags to add (separate tags with a semicolon): "
+ image-dired-tag-history nil nil nil 'image-dired-tag-history)))
+ (image-dired--with-marked
+ (image-dired-write-tags
+ (list (cons (image-dired-original-file-name) tag)))
+ (image-dired-update-property
+ 'tags (image-dired-list-tags (image-dired-original-file-name))))))
;;;###autoload
(defun image-dired-delete-tag (arg)
"Remove tag for selected file(s).
With prefix argument ARG, remove tag from file at point."
(interactive "P")
- (let ((tag (read-string "Tag to remove: "))
+ (let ((tag (completing-read "Tag to remove: " image-dired-tag-history
+ nil nil nil 'image-dired-tag-history))
files)
(if arg
(setq files (list (dired-get-filename)))
@@ -1194,12 +1188,14 @@ With prefix argument ARG, remove tag from file at point."
(image-dired-remove-tag files tag)))
(defun image-dired-tag-thumbnail-remove ()
- "Remove tag from thumbnail."
+ "Remove tag from current or marked thumbnails."
(interactive)
- (let ((tag (read-string "Tag to remove: ")))
- (image-dired-remove-tag (image-dired-original-file-name) tag))
- (image-dired-update-property
- 'tags (image-dired-list-tags (image-dired-original-file-name))))
+ (let ((tag (completing-read "Tag to remove: " image-dired-tag-history
+ nil nil nil 'image-dired-tag-history)))
+ (image-dired--with-marked
+ (image-dired-remove-tag (image-dired-original-file-name) tag)
+ (image-dired-update-property
+ 'tags (image-dired-list-tags (image-dired-original-file-name))))))
(defun image-dired-original-file-name ()
"Get original file name for thumbnail or display image at point."
@@ -1404,14 +1400,15 @@ dired."
(message "No image, or image with correct properties, at point.")
(with-current-buffer dired-buf
(message "%s" file-name)
- (if (dired-goto-file file-name)
- (cond ((eq command 'mark) (dired-mark 1))
- ((eq command 'unmark) (dired-unmark 1))
- ((eq command 'toggle)
- (if (image-dired-dired-file-marked-p)
- (dired-unmark 1)
- (dired-mark 1)))
- ((eq command 'flag) (dired-flag-file-deletion 1))))))))
+ (when (dired-goto-file file-name)
+ (cond ((eq command 'mark) (dired-mark 1))
+ ((eq command 'unmark) (dired-unmark 1))
+ ((eq command 'toggle)
+ (if (image-dired-dired-file-marked-p)
+ (dired-unmark 1)
+ (dired-mark 1)))
+ ((eq command 'flag) (dired-flag-file-deletion 1)))
+ (image-dired-thumb-update-marks))))))
(defun image-dired-mark-thumb-original-file ()
"Mark original image file in associated dired buffer."
@@ -1538,8 +1535,10 @@ You probably want to use this together with
'("Image-Dired"
["Quit" quit-window]
["Delete thumbnail from buffer" image-dired-delete-char]
- ["Remove tag from thumbnail" image-dired-tag-thumbnail-remove]
- ["Tag thumbnail" image-dired-tag-thumbnail]
+ ["Delete marked images" image-dired-delete-marked]
+ ["Remove tag from current or marked thumbnails"
+ image-dired-tag-thumbnail-remove]
+ ["Tag current or marked thumbnails" image-dired-tag-thumbnail]
["Comment thumbnail" image-dired-comment-thumbnail]
["Refresh thumb" image-dired-refresh-thumb]
["Dynamic line up" image-dired-line-up-dynamic]
@@ -1623,7 +1622,6 @@ You probably want to use this together with
special-mode "image-dired-thumbnail"
"Browse and manipulate thumbnail images using dired.
Use `image-dired-minor-mode' to get a nice setup."
- :group 'image-dired
(buffer-disable-undo)
(add-hook 'file-name-at-point-functions 'image-dired-file-name-at-point nil t))
@@ -1631,7 +1629,6 @@ Use `image-dired-minor-mode' to get a nice setup."
special-mode "image-dired-image-display"
"Mode for displaying and manipulating original image.
Resized or in full-size."
- :group 'image-dired
(buffer-disable-undo)
(image-mode-setup-winprops)
(setq cursor-type nil)
@@ -2193,7 +2190,7 @@ FILE-COMMENTS is an alist on the following form:
(insert (format "comment:%s;" comment)))
;; File does not exist in database - add it.
(goto-char (point-max))
- (insert (format "\n%s;comment:%s" file comment))))
+ (insert (format "%s;comment:%s\n" file comment))))
(save-buffer))))
(defun image-dired-update-property (prop value)
@@ -2311,16 +2308,67 @@ non-nil."
(image-dired-track-original-file))
(image-dired-display-thumb-properties))
+(defun image-dired-thumb-file-marked-p ()
+ "Check if file is marked in associated dired buffer."
+ (let ((file-name (image-dired-original-file-name))
+ (dired-buf (image-dired-associated-dired-buffer)))
+ (when (and dired-buf file-name)
+ (with-current-buffer dired-buf
+ (when (dired-goto-file file-name)
+ (image-dired-dired-file-marked-p))))))
+
+(defun image-dired-delete-marked ()
+ "Delete current or marked thumbnails and associated images."
+ (interactive)
+ (with-current-buffer (image-dired-associated-dired-buffer)
+ (dired-do-delete))
+ (image-dired--with-marked
+ (image-dired-delete-char)
+ (backward-char))
+ (image-dired--line-up-with-method))
+
+(defun image-dired-thumb-update-marks ()
+ "Update the marks in the thumbnail buffer."
+ (when image-dired-thumb-visible-marks
+ (with-current-buffer image-dired-thumbnail-buffer
+ (save-mark-and-excursion
+ (goto-char (point-min))
+ (let ((inhibit-read-only t))
+ (while (not (eobp))
+ (with-silent-modifications
+ (if (image-dired-thumb-file-marked-p)
+ (add-face-text-property (point) (1+ (point))
+ 'image-dired-thumb-mark)
+ (remove-text-properties (point) (1+ (point))
+ '(face image-dired-thumb-mark))))
+ (forward-char)))))))
+
+(defun image-dired-mouse-toggle-mark-1 ()
+ "Toggle dired mark for current thumbnail.
+Track this in associated dired buffer if `image-dired-track-movement' is
+non-nil."
+ (when image-dired-track-movement
+ (image-dired-track-original-file))
+ (image-dired-toggle-mark-thumb-original-file))
+
(defun image-dired-mouse-toggle-mark (event)
"Use mouse EVENT to toggle dired mark for thumbnail.
+Toggle marks of all thumbnails in region, if it's active.
Track this in associated dired buffer if `image-dired-track-movement' is
non-nil."
(interactive "e")
- (mouse-set-point event)
- (goto-char (posn-point (event-end event)))
- (if image-dired-track-movement
- (image-dired-track-original-file))
- (image-dired-toggle-mark-thumb-original-file))
+ (if (use-region-p)
+ (let ((end (region-end)))
+ (save-excursion
+ (goto-char (region-beginning))
+ (while (<= (point) end)
+ (when (image-dired-image-at-point-p)
+ (image-dired-mouse-toggle-mark-1))
+ (forward-char))))
+ (mouse-set-point event)
+ (goto-char (posn-point (event-end event)))
+ (image-dired-mouse-toggle-mark-1))
+ (image-dired-thumb-update-marks))
(defun image-dired-dired-display-properties ()
"Display properties for dired file in the echo area."
@@ -2553,7 +2601,6 @@ easy-to-use form."
(let ((files (dired-get-marked-files)))
(pop-to-buffer-same-window "*Image-Dired Edit Meta Data*")
(kill-all-local-variables)
- (make-local-variable 'widget-example-repeat)
(let ((inhibit-read-only t))
(erase-buffer))
(remove-overlays)