emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

scratch/image-dired 3da80909eb 2/2: image-dired: Do more interactive mod


From: Stefan Kangas
Subject: scratch/image-dired 3da80909eb 2/2: image-dired: Do more interactive mode tagging
Date: Fri, 26 Aug 2022 20:43:45 -0400 (EDT)

branch: scratch/image-dired
commit 3da80909eb6a34ba8e4229cdf9289daee950cee1
Author: Stefan Kangas <stefankangas@gmail.com>
Commit: Stefan Kangas <stefankangas@gmail.com>

    image-dired: Do more interactive mode tagging
    
    * lisp/image/image-dired-external.el
    (image-dired-thumbnail-set-image-description)
    (image-dired-copy-with-exif-file-name):
    * 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-display-thumbs-append, image-dired-display-thumb)
    (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.
---
 lisp/image/image-dired-external.el |  4 ++--
 lisp/image/image-dired-tags.el     | 12 ++++++------
 lisp/image/image-dired.el          | 38 ++++++++++++++++++++------------------
 3 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/lisp/image/image-dired-external.el 
b/lisp/image/image-dired-external.el
index e7ac3ec482..176c6ac1e2 100644
--- a/lisp/image/image-dired-external.el
+++ b/lisp/image/image-dired-external.el
@@ -452,7 +452,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))
@@ -490,7 +490,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
diff --git a/lisp/image/image-dired-tags.el b/lisp/image/image-dired-tags.el
index 1f667bcc5d..62ea4b05ab 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 3ff8387833..1f5503eded 100644
--- a/lisp/image/image-dired.el
+++ b/lisp/image/image-dired.el
@@ -518,7 +518,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)
@@ -580,7 +580,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)))
@@ -596,7 +596,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")))
 
@@ -617,7 +617,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))
@@ -647,7 +647,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 ()
@@ -1053,19 +1053,19 @@ With a negative prefix argument, prompt user for the 
delay."
 ;;;###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))
 
 (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))
@@ -1102,7 +1102,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
@@ -1116,7 +1116,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))
@@ -1125,7 +1125,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")
@@ -1157,7 +1157,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")
@@ -1173,7 +1173,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 ()
@@ -1182,7 +1182,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)
@@ -1204,7 +1204,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)))
@@ -1266,7 +1266,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)
@@ -1510,14 +1512,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")))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]