From: Stefan Kangas Date: Sat, 20 Aug 2022 20:44:14 +0000 (+0200) Subject: image-dired: Do more interactive mode tagging X-Git-Tag: emacs-29.0.90~1856^2~778 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=b52c3527bc56e3fb51b57f38c564dce58fff6339;p=emacs.git image-dired: Do more interactive mode tagging * lisp/image/image-dired-dired.el (image-dired-dired-toggle-marked-thumbs) (image-dired-next-line-and-display) (image-dired-previous-line-and-display) (image-dired-toggle-append-browsing) (image-dired-mark-and-display-next) (image-dired-toggle-dired-display-properties) (image-dired-dired-next-line, image-dired-dired-previous-line) (image-dired-create-thumbs, image-dired-display-thumbs-append) (image-dired-display-thumb, image-dired-dired-display-external) (image-dired-dired-display-image) (image-dired-copy-with-exif-file-name, image-dired-mark-tagged-files) (image-dired-dired-display-properties): * lisp/image/image-dired-external.el (image-dired-thumbnail-set-image-description): * lisp/image/image-dired-tags.el (image-dired-tag-files) (image-dired-tag-thumbnail, image-dired-delete-tag) (image-dired-tag-thumbnail-remove) (image-dired-dired-comment-files) (image-dired-dired-edit-comment-and-tags): * lisp/image/image-dired.el (image-dired-display-thumbs) (image-dired-track-original-file) (image-dired-toggle-movement-tracking) (image-dired-forward-image, image-dired-backward-image) (image-dired-line-up, image-dired-line-up-dynamic) (image-dired-line-up-interactive) (image-dired-thumbnail-display-external) (image-dired-display-thumbnail-original-image) (image-dired-rotate-original-left) (image-dired-rotate-original-right) (image-dired-comment-thumbnail, image-dired-delete-marked) (image-dired-rotate-thumbnail-left) (image-dired-rotate-thumbnail-right): Do interactive mode tagging. * lisp/image/image-dired.el (image-dired-delete-marked): Signal error if not in image-dired-thumbnail-mode. --- diff --git a/lisp/image/image-dired-dired.el b/lisp/image/image-dired-dired.el index 002e2d49386..2f3a66f9cde 100644 --- a/lisp/image/image-dired-dired.el +++ b/lisp/image/image-dired-dired.el @@ -53,7 +53,7 @@ If no marked file could be found, insert or hide thumbnails on the current line. ARG, if non-nil, specifies the files to use instead of the marked files. If ARG is an integer, use the next ARG (or previous -ARG, if ARG<0) files." - (interactive "P") + (interactive "P" dired-mode) (dired-map-over-marks (let ((image-pos (dired-move-to-filename)) (image-file (dired-get-filename nil t)) @@ -93,7 +93,7 @@ Otherwise, delete overlays." (defun image-dired-next-line-and-display () "Move to next Dired line and display thumbnail image." - (interactive) + (interactive nil dired-mode) (dired-next-line 1) (image-dired-display-thumbs t (or image-dired-append-when-browsing nil) t) @@ -102,7 +102,7 @@ Otherwise, delete overlays." (defun image-dired-previous-line-and-display () "Move to previous Dired line and display thumbnail image." - (interactive) + (interactive nil dired-mode) (dired-previous-line 1) (image-dired-display-thumbs t (or image-dired-append-when-browsing nil) t) @@ -111,7 +111,7 @@ Otherwise, delete overlays." (defun image-dired-toggle-append-browsing () "Toggle `image-dired-append-when-browsing'." - (interactive) + (interactive nil dired-mode) (setq image-dired-append-when-browsing (not image-dired-append-when-browsing)) (message "Append browsing %s" @@ -121,7 +121,7 @@ Otherwise, delete overlays." (defun image-dired-mark-and-display-next () "Mark current file in Dired and display next thumbnail image." - (interactive) + (interactive nil dired-mode) (dired-mark 1) (image-dired-display-thumbs t (or image-dired-append-when-browsing nil) t) @@ -130,7 +130,7 @@ Otherwise, delete overlays." (defun image-dired-toggle-dired-display-properties () "Toggle `image-dired-dired-disp-props'." - (interactive) + (interactive nil dired-mode) (setq image-dired-dired-disp-props (not image-dired-dired-disp-props)) (message "Dired display properties %s" @@ -164,7 +164,7 @@ but the other way around." "Call `dired-next-line', then track thumbnail. This can safely replace `dired-next-line'. With prefix argument, move ARG lines." - (interactive "P") + (interactive "P" dired-mode) (dired-next-line (or arg 1)) (if image-dired-track-movement (image-dired-track-thumbnail))) @@ -173,16 +173,15 @@ With prefix argument, move ARG lines." "Call `dired-previous-line', then track thumbnail. This can safely replace `dired-previous-line'. With prefix argument, move ARG lines." - (interactive "P") + (interactive "P" dired-mode) (dired-previous-line (or arg 1)) (if image-dired-track-movement (image-dired-track-thumbnail))) - ;;;###autoload (defun image-dired-jump-thumbnail-buffer () "Jump to thumbnail buffer." - (interactive) + (interactive nil dired-mode) (let ((window (image-dired-thumbnail-window)) frame) (if window @@ -259,7 +258,7 @@ Note that n, p and and will be hijacked and bound to "Create thumbnail images for all marked files in Dired. With prefix argument ARG, create thumbnails even if they already exist \(i.e. use this to refresh your thumbnails)." - (interactive "P") + (interactive "P" dired-mode) (let (thumb-name) (dolist (curr-file (dired-get-marked-files)) (setq thumb-name (image-dired-thumb-name curr-file)) @@ -275,19 +274,19 @@ With prefix argument ARG, create thumbnails even if they already exist ;;;###autoload (defun image-dired-display-thumbs-append () "Append thumbnails to `image-dired-thumbnail-buffer'." - (interactive) + (interactive nil dired-mode) (image-dired-display-thumbs nil t t)) ;;;###autoload (defun image-dired-display-thumb () "Shorthand for `image-dired-display-thumbs' with prefix argument." - (interactive) + (interactive nil dired-mode) (image-dired-display-thumbs t nil t)) ;;;###autoload (defun image-dired-dired-display-external () "Display file at point using an external viewer." - (interactive) + (interactive nil dired-mode) (let ((file (dired-get-filename))) (start-process "image-dired-external" nil image-dired-external-viewer file))) @@ -297,7 +296,7 @@ With prefix argument ARG, create thumbnails even if they already exist "Display current image file. See documentation for `image-dired-display-image' for more information. With prefix argument ARG, display image in its original size." - (interactive "P") + (interactive "P" dired-mode) (image-dired-display-image (dired-get-filename) arg)) (defun image-dired-copy-with-exif-file-name () @@ -313,7 +312,7 @@ function. The result is a couple of new files in `image-dired-main-image-directory' called 2005_05_08_12_52_00_dscn0319.jpg, 2005_05_08_14_27_45_dscn0320.jpg etc." - (interactive) + (interactive nil dired-mode) (let (new-name (files (dired-get-marked-files))) (mapc @@ -335,7 +334,7 @@ image file and stored in image-dired's database file. This command lets you input a regexp and this will be matched against all tags on all image files in the database file. The files that have a matching tag will be marked in the Dired buffer." - (interactive "sMark tagged files (regexp): ") + (interactive "sMark tagged files (regexp): " dired-mode) (image-dired-sane-db-file) (let ((hits 0) files) @@ -366,7 +365,7 @@ matching tag will be marked in the Dired buffer." (defun image-dired-dired-display-properties () "Display properties for Dired file in the echo area." - (interactive) + (interactive nil dired-mode) (let* ((file (dired-get-filename)) (file-name (file-name-nondirectory file)) (dired-buf (buffer-name (current-buffer))) diff --git a/lisp/image/image-dired-external.el b/lisp/image/image-dired-external.el index 70e00658dc0..c45287bd189 100644 --- a/lisp/image/image-dired-external.el +++ b/lisp/image/image-dired-external.el @@ -448,7 +448,7 @@ YYYY_MM_DD_HH_MM_DD_ORIG_FILE_NAME.jpg. Used from "Set the ImageDescription EXIF tag for the original image. If the image already has a value for this tag, it is used as the default value at the prompt." - (interactive) + (interactive nil image-dired-thumbnail-mode) (if (not (image-dired-image-at-point-p)) (message "No thumbnail at point") (let* ((file (image-dired-original-file-name)) diff --git a/lisp/image/image-dired-tags.el b/lisp/image/image-dired-tags.el index 97003851e0b..2ea9d9f5ebe 100644 --- a/lisp/image/image-dired-tags.el +++ b/lisp/image/image-dired-tags.el @@ -134,7 +134,7 @@ FILE-TAGS is an alist in the following form: ;;;###autoload (defun image-dired-tag-files (arg) "Tag marked file(s) in Dired. With prefix ARG, tag file at point." - (interactive "P") + (interactive "P" dired-mode) (let ((tag (completing-read "Tags to add (separate tags with a semicolon): " image-dired-tag-history nil nil nil 'image-dired-tag-history)) @@ -150,7 +150,7 @@ FILE-TAGS is an alist in the following form: (defun image-dired-tag-thumbnail () "Tag current or marked thumbnails." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let ((tag (completing-read "Tags to add (separate tags with a semicolon): " image-dired-tag-history nil nil nil 'image-dired-tag-history))) @@ -164,7 +164,7 @@ FILE-TAGS is an alist in the following form: (defun image-dired-delete-tag (arg) "Remove tag for selected file(s). With prefix argument ARG, remove tag from file at point." - (interactive "P") + (interactive "P" dired-mode) (let ((tag (completing-read "Tag to remove: " image-dired-tag-history nil nil nil 'image-dired-tag-history)) files) @@ -175,7 +175,7 @@ With prefix argument ARG, remove tag from file at point." (defun image-dired-tag-thumbnail-remove () "Remove tag from current or marked thumbnails." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let ((tag (completing-read "Tag to remove: " image-dired-tag-history nil nil nil 'image-dired-tag-history))) (image-dired--with-marked @@ -231,7 +231,7 @@ FILE-COMMENTS is an alist on the following form: ;;;###autoload (defun image-dired-dired-comment-files () "Add comment to current or marked files in Dired." - (interactive) + (interactive nil dired-mode) (let ((comment (image-dired-read-comment))) (image-dired-write-comments (mapcar @@ -279,7 +279,7 @@ Optionally use old comment from FILE as initial value." "Edit comment and tags of current or marked image files. Edit comment and tags for all marked image files in an easy-to-use form." - (interactive) + (interactive nil dired-mode) (setq image-dired-widget-list nil) ;; Setup buffer. (let ((files (dired-get-marked-files))) diff --git a/lisp/image/image-dired.el b/lisp/image/image-dired.el index 707e70201c3..04bfa6a7ba0 100644 --- a/lisp/image/image-dired.el +++ b/lisp/image/image-dired.el @@ -504,7 +504,7 @@ used or not. If non-nil, use `display-buffer' instead of `image-dired-next-line-and-display' and `image-dired-previous-line-and-display' where we do not want the thumbnail buffer to be selected." - (interactive "P") + (interactive "P" nil dired-mode) (setq image-dired--generate-thumbs-start (current-time)) (let ((buf (image-dired-create-thumbnail-buffer)) thumb-name files dired-buf) @@ -566,7 +566,7 @@ never ask for confirmation." "Track the original file in the associated Dired buffer. See documentation for `image-dired-toggle-movement-tracking'. Interactive use only useful if `image-dired-track-movement' is nil." - (interactive) + (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) (let* ((dired-buf (image-dired-associated-dired-buffer)) (file-name (image-dired-original-file-name)) (window (image-dired-get-buffer-window dired-buf))) @@ -582,7 +582,7 @@ Tracking of the movements between thumbnail and Dired buffer so that they are \"mirrored\" in the dired buffer. When this is on, moving around in the thumbnail or dired buffer will find the matching position in the other buffer." - (interactive) + (interactive nil image-dired-thumbnail-mode image-dired-display-image-mode) (setq image-dired-track-movement (not image-dired-track-movement)) (message "Movement tracking %s" (if image-dired-track-movement "on" "off"))) @@ -603,7 +603,7 @@ On reaching end or beginning of buffer, stop and show a message. If optional argument WRAP-AROUND is non-nil, wrap around: if point is on the last image, move to the last one and vice versa." - (interactive "p") + (interactive "p" image-dired-thumbnail-mode) (setq arg (or arg 1)) (let (pos) (dotimes (_ (abs arg)) @@ -633,7 +633,7 @@ point is on the last image, move to the last one and vice versa." Optional prefix ARG says how many images to move; the default is one image. Negative means move forward. On reaching end or beginning of buffer, stop and show a message." - (interactive "p") + (interactive "p" image-dired-thumbnail-mode) (image-dired-forward-image (- (or arg 1)))) (defun image-dired-next-line () @@ -1039,7 +1039,7 @@ With a negative prefix argument, prompt user for the delay." (defun image-dired-line-up () "Line up thumbnails according to `image-dired-thumbs-per-row'. See also `image-dired-line-up-dynamic'." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let ((inhibit-read-only t)) (goto-char (point-min)) (while (and (not (image-dired-image-at-point-p)) @@ -1076,7 +1076,7 @@ See also `image-dired-line-up-dynamic'." (defun image-dired-line-up-dynamic () "Line up thumbnails images dynamically. Calculate how many thumbnails fit." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let* ((char-width (frame-char-width)) (width (image-dired-window-width-pixels (image-dired-thumbnail-window))) (image-dired-thumbs-per-row @@ -1090,7 +1090,7 @@ Calculate how many thumbnails fit." (defun image-dired-line-up-interactive () "Line up thumbnails interactively. Ask user how many thumbnails should be displayed per row." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let ((image-dired-thumbs-per-row (string-to-number (read-string "How many thumbs per row: ")))) (if (not (> image-dired-thumbs-per-row 0)) @@ -1099,7 +1099,7 @@ Ask user how many thumbnails should be displayed per row." (defun image-dired-thumbnail-display-external () "Display original image for thumbnail at point using external viewer." - (interactive) + (interactive nil image-dired-thumbnail-mode) (let ((file (image-dired-original-file-name))) (if (not (image-dired-image-at-point-p)) (message "No thumbnail at point") @@ -1131,7 +1131,7 @@ based on `image-mode'." "Display current thumbnail's original image in display buffer. See documentation for `image-dired-display-image' for more information. With prefix argument ARG, display image in its original size." - (interactive "P") + (interactive "P" image-dired-thumbnail-mode) (let ((file (image-dired-original-file-name))) (if (not (string-equal major-mode "image-dired-thumbnail-mode")) (message "Not in image-dired-thumbnail-mode") @@ -1147,7 +1147,7 @@ The result of the rotation is displayed in the image display area and a confirmation is needed before the original image files is overwritten. This confirmation can be turned off using `image-dired-rotate-original-ask-before-overwrite'." - (interactive) + (interactive nil image-dired-thumbnail-mode) (image-dired-rotate-original "270")) (defun image-dired-rotate-original-right () @@ -1156,7 +1156,7 @@ The result of the rotation is displayed in the image display area and a confirmation is needed before the original image files is overwritten. This confirmation can be turned off using `image-dired-rotate-original-ask-before-overwrite'." - (interactive) + (interactive nil image-dired-thumbnail-mode) (image-dired-rotate-original "90")) (defun image-dired-display-next-thumbnail-original (&optional arg) @@ -1178,7 +1178,7 @@ With prefix ARG, move that many thumbnails." (defun image-dired-comment-thumbnail () "Add comment to current thumbnail in thumbnail buffer." - (interactive) + (interactive nil image-dired-comment-thumbnail image-dired-display-image-mode) (let* ((file (image-dired-original-file-name)) (comment (image-dired-read-comment file))) (image-dired-write-comments (list (cons file comment))) @@ -1240,7 +1240,9 @@ for deletion instead." (defun image-dired-delete-marked () "Delete current or marked thumbnails and associated images." - (interactive) + (interactive nil image-dired-thumbnail-mode) + (unless (derived-mode-p 'image-dired-thumbnail-mode) + (user-error "Not in `image-dired-thumbnail-mode'")) (image-dired--with-marked (image-dired-delete-char) (unless (bobp) @@ -1718,14 +1720,14 @@ of the thumbnail file." (defun image-dired-rotate-thumbnail-left () "Rotate thumbnail left (counter clockwise) 90 degrees." (declare (obsolete image-dired-refresh-thumb "29.1")) - (interactive) + (interactive nil image-dired-thumbnail-mode) (with-suppressed-warnings ((obsolete image-dired-rotate-thumbnail)) (image-dired-rotate-thumbnail "270"))) (defun image-dired-rotate-thumbnail-right () "Rotate thumbnail counter right (clockwise) 90 degrees." (declare (obsolete image-dired-refresh-thumb "29.1")) - (interactive) + (interactive nil image-dired-thumbnail-mode) (with-suppressed-warnings ((obsolete image-dired-rotate-thumbnail)) (image-dired-rotate-thumbnail "90")))