(require 'cl-lib)
(require 'wid-edit))
+\f
+;;; Customizable variables
+
(defgroup image-dired nil
"Use Dired to browse your images as thumbnails, and more."
:prefix "image-dired-"
"Database file where file names and their associated tags are stored."
:type 'file)
-
-
(defcustom image-dired-cmd-create-thumbnail-program
(if (executable-find "gm") "gm" "convert")
"Executable used to create thumbnail.
(const :tag "Disable warning" nil))
:version "29.1")
+\f
+;;; Util functions
+
(defvar image-dired-debug nil
"Non-nil means enable debug messages.")
(unless (executable-find (symbol-value executable))
(error "Executable %S not found" executable)))
+\f
+;;; Creating thumbnails
+
(defun image-dired-thumb-size (dimension)
"Return thumb size depending on `image-dired-thumbnail-storage'.
DIMENSION should be either the symbol `width' or `height'."
the time spent on generating thumbnails. Run `image-clear-cache'
and remove the cached thumbnail files between each trial run.")
-(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
;;;###autoload
(defalias 'image-dired 'image-dired-show-all-from-dir)
+\f
+;;; Tags
+
(defun image-dired-sane-db-file ()
"Check if `image-dired-db-file' exists.
If not, try to create it (including any parent directories).
(file-exists-p image-dired-db-file))
(error "Could not create %s" image-dired-db-file)))
+(defvar image-dired-tag-history nil "Variable holding the tag history.")
+
(defun image-dired-write-tags (file-tags)
"Write file tags to database.
Write each file and tag in FILE-TAGS to the database.
(image-dired-update-property
'tags (image-dired-list-tags (image-dired-original-file-name))))))
+\f
+;;; Thumbnail mode (cont.)
+
(defun image-dired-original-file-name ()
"Get original file name for thumbnail or display image at point."
(get-text-property (point) 'original-file-name))
;; 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.
arg)
(image-dired-create-thumb curr-file thumb-name)))))
+\f
+;;; Slideshow.
+
(defvar image-dired-slideshow-timer nil
"Slideshow timer.")
(interactive)
(cancel-timer image-dired-slideshow-timer))
+\f
+;;; Thumbnail mode (cont. 3)
+
(defun image-dired-delete-char ()
"Remove current thumbnail from thumbnail buffer and line up."
(interactive nil image-dired-thumbnail-mode)
(interactive)
(image-dired-rotate-original "90"))
+\f
+;;; EXIF support
+
(defun image-dired-get-exif-file-name (file)
"Use the image's EXIF information to return a unique file name.
The file name should be unique as long as you do not take more than
(copy-file curr-file new-name))
files)))
+;;; Thumbnail mode (cont.)
+
(defun image-dired-display-next-thumbnail-original (&optional arg)
"In thumbnail buffer, move to next thumbnail and display the image.
With prefix ARG, move that many thumbnails."
(interactive "p" image-dired-thumbnail-mode)
(image-dired-display-next-thumbnail-original (- arg)))
+\f
+;;; Image Comments
+
(defun image-dired-write-comments (file-comments)
"Write file comments to database.
Write file comments to one or more files.
(dired-mark 1))))
(message "%d files with matching tag marked." hits)))
+
+\f
+;;; Mouse support
+
(defun image-dired-mouse-display-image (event)
"Use mouse EVENT, call `image-dired-display-image' to display image.
Track this in associated Dired buffer if `image-dired-track-movement' is
(image-dired-track-original-file))
(image-dired-display-thumb-properties))
+
+\f
+;;; Dired marks and tags
+
(defun image-dired-thumb-file-marked-p (&optional flagged)
"Check if file is marked in associated Dired buffer.
If optional argument FLAGGED is non-nil, check if file is flagged
comment)))))
\f
-;;;; Gallery support
+\f
+;;; Gallery support
;; TODO:
;; * Support gallery creation when using per-directory thumbnail
(insert "</html>"))))
\f
-;;;; Tag support
+;;; Tag support
(defvar image-dired-widget-list nil
"List to keep track of meta data in edit buffer.")
(push (cons file tag) lst))))))
\f
-;;;; bookmark.el support
+;;; bookmark.el support
(declare-function bookmark-make-record-default
"bookmark" (&optional no-file no-context posn))
(goto-char (point-min))))
\f
-;;;; Obsolete
+;;; Obsolete
;;;###autoload
(define-obsolete-function-alias 'tumme #'image-dired "24.4")