(defvar image-dired-saved-window-configuration nil
"Saved window configuration.")
+\f
+;;; Starting Image-Dired
+
;;;###autoload
(defun image-dired-dired-with-window-configuration (dir &optional arg)
"Open directory DIR and create a default window configuration.
(defalias 'image-dired 'image-dired-show-all-from-dir)
\f
-;;; Thumbnail mode (cont.)
+;;; Movement tracking
(defun image-dired-track-original-file ()
"Track the original file in the associated Dired buffer.
(setq image-dired-track-movement (not image-dired-track-movement))
(message "Movement tracking %s" (if image-dired-track-movement "on" "off")))
+\f
+;;; Navigation
(defun image-dired-forward-image (&optional arg wrap-around)
"Move to next image in the thumbnail buffer.
(image-dired-track-original-file))
(image-dired-update-header-line))
+\f
+;;; Header line
+
(defun image-dired-format-properties-string (buf file props comment)
"Format display properties.
BUF is the associated Dired buffer, FILE is the original image file
props
comment))))))
+\f
+;;; Marking and flagging
+
(defun image-dired-dired-file-marked-p (&optional marker)
"In Dired, return t if file on current line is marked.
If optional argument MARKER is non-nil, it is a character to look
"In Dired, return t if file on current line is flagged for deletion."
(image-dired-dired-file-marked-p dired-del-marker))
-(defmacro image-dired--with-thumbnail-buffer (&rest body)
- (declare (indent defun) (debug t))
- `(if-let ((buf (get-buffer image-dired-thumbnail-buffer)))
- (with-current-buffer buf
- (if-let ((win (get-buffer-window buf)))
- (with-selected-window win
- ,@body)
- ,@body))
- (user-error "No such buffer: %s" image-dired-thumbnail-buffer)))
-
(defmacro image-dired--on-file-in-dired-buffer (&rest body)
"Run BODY with point on file at point in Dired buffer.
Should be called from commands in `image-dired-thumbnail-mode'."
(when (dired-goto-file file-name)
,@body)))))
+(defmacro image-dired--with-thumbnail-buffer (&rest body)
+ (declare (indent defun) (debug t))
+ `(if-let ((buf (get-buffer image-dired-thumbnail-buffer)))
+ (with-current-buffer buf
+ (if-let ((win (get-buffer-window buf)))
+ (with-selected-window win
+ ,@body)
+ ,@body))
+ (user-error "No such buffer: %s" image-dired-thumbnail-buffer)))
+
(defmacro image-dired--do-mark-command (maybe-next update &rest body)
"Helper macro for the mark, unmark and flag commands.
Run BODY in Dired buffer.
(select-window window))
(message "Associated dired buffer not visible"))))
+\f
+;;; Major modes
+
(defvar-keymap image-dired-thumbnail-mode-map
:doc "Keymap for `image-dired-thumbnail-mode'."
"<right>" #'image-dired-forward-image
;; Use approximately as much vertical spacing as horizontal.
(setq-local line-spacing (frame-char-width)))
-\f
-;;; Display image mode
-
(define-derived-mode image-dired-display-image-mode
image-mode "image-dired-image-display"
"Mode for displaying and manipulating original image.
(remove-hook 'post-command-hook 'image-dired--slideshow-stop))))
\f
-;;; Thumbnail mode (cont. 3)
+;;; Thumbnail layout and display
(defun image-dired-delete-char ()
"Remove current thumbnail from thumbnail buffer and line up."
(message "Number must be greater than 0")
(image-dired-line-up))))
+\f
+;;; Display image from thumbnail buffer
+
(defun image-dired-thumbnail-display-external ()
"Display original image for thumbnail at point using external viewer."
(interactive nil image-dired-thumbnail-mode)
(t
(image-dired-display-image file arg)))))
+(defun image-dired-display-next-thumbnail-original (&optional arg)
+ "Move to the next image in the thumbnail buffer and display it.
+With prefix ARG, move that many thumbnails."
+ (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode)
+ (image-dired--with-thumbnail-buffer
+ (image-dired-forward-image arg t)
+ (image-dired-display-thumbnail-original-image)))
+
+(defun image-dired-display-previous-thumbnail-original (arg)
+ "Move to the previous image in the thumbnail buffer and display it.
+With prefix ARG, move that many thumbnails."
+ (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode)
+ (image-dired-display-next-thumbnail-original (- arg)))
+
+\f
+;;; Misc commands
+
(defun image-dired-rotate-original-left ()
"Rotate original image left (counter clockwise) 90 degrees.
The result of the rotation is displayed in the image display area
(image-dired--with-marked
(image-dired-rotate-original "90")))
-(defun image-dired-display-next-thumbnail-original (&optional arg)
- "Move to the next image in the thumbnail buffer and display it.
-With prefix ARG, move that many thumbnails."
- (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode)
- (image-dired--with-thumbnail-buffer
- (image-dired-forward-image arg t)
- (image-dired-display-thumbnail-original-image)))
-
-(defun image-dired-display-previous-thumbnail-original (arg)
- "Move to the previous image in the thumbnail buffer and display it.
-With prefix ARG, move that many thumbnails."
- (interactive "p" image-dired-thumbnail-mode image-dired-display-image-mode)
- (image-dired-display-next-thumbnail-original (- arg)))
-
(defun image-dired-wallpaper-set (file)
"Set the wallpaper to FILE in a graphical environment."
(interactive (list (image-dired-original-file-name))