;;; image-dired.el --- use dired to browse and manipulate your images
;;
-;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2005-2011 Free Software Foundation, Inc.
;;
;; Version: 0.4.11
;; Keywords: multimedia
(require 'widget)
(eval-when-compile
+ (require 'cl)
(require 'wid-edit))
(defgroup image-dired nil
:group 'image-dired)
(defcustom image-dired-db-file
- (locate-user-emacs-file "image-dired/.image-dired_db")
+ (expand-file-name ".image-dired_db" image-dired-dir)
"Database file where file names and their associated tags are stored."
:type 'string
:group 'image-dired)
(defcustom image-dired-temp-image-file
- (locate-user-emacs-file "image-dired/.image-dired_temp")
+ (expand-file-name ".image-dired_temp" image-dired-dir)
"Name of temporary image file used by various commands."
:type 'string
:group 'image-dired)
(defcustom image-dired-gallery-dir
- (locate-user-emacs-file "image-dired/.image-dired_gallery")
+ (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."
:group 'image-dired)
(defcustom image-dired-temp-rotate-image-file
- (locate-user-emacs-file "image-dired/.image-dired_rotate_temp")
+ (expand-file-name ".image-dired_rotate_temp" image-dired-dir)
"Temporary file for rotate operations."
:type 'string
:group 'image-dired)
"%p -s -s -s -%t \"%f\""
"Format of command used to read EXIF data.
Available options are %p which is replaced by
-`image-dired-cmd-write-exif-data-options', %f which is replaced
+`image-dired-cmd-write-exif-data-program', %f which is replaced
by the image file name and %t which is replaced by the tag name."
:type 'string
:group 'image-dired)
(call-process shell-file-name nil nil nil shell-command-switch command)))
;;;###autoload
-(defun image-dired-dired-insert-marked-thumbs ()
- "Insert thumbnails before file names of marked files in the dired buffer."
- (interactive)
+(defun image-dired-dired-toggle-marked-thumbs (&optional arg)
+ "Toggle thumbnails in front of file names in the dired buffer.
+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")
(dired-map-over-marks
- (let* ((image-pos (dired-move-to-filename))
- (image-file (dired-get-filename))
- (thumb-file (image-dired-get-thumbnail-image image-file))
+ (let* ((image-pos (dired-move-to-filename))
+ (image-file (dired-get-filename nil t))
+ thumb-file
overlay)
- ;; If image is not already added, then add it.
- (unless (delq nil (mapcar (lambda (o) (overlay-get o 'put-image))
- ;; Can't use (overlays-at (point)), BUG?
- (overlays-in (point) (1+ (point)))))
- (put-image thumb-file image-pos)
- (setq
- overlay
- (car (delq nil (mapcar (lambda (o) (and (overlay-get o 'put-image) o))
- (overlays-in (point) (1+ (point)))))))
- (overlay-put overlay 'image-file image-file)
- (overlay-put overlay 'thumb-file thumb-file)))
- nil)
+ (when (and image-file (string-match-p (image-file-name-regexp) image-file))
+ (setq thumb-file (image-dired-get-thumbnail-image image-file))
+ ;; If image is not already added, then add it.
+ (let ((cur-ov (overlays-in (point) (1+ (point)))))
+ (if cur-ov
+ (delete-overlay (car cur-ov))
+ (put-image thumb-file image-pos)
+ (setq overlay (loop for o in (overlays-in (point) (1+ (point)))
+ when (overlay-get o 'put-image) collect o into ov
+ finally return (car ov)))
+ (overlay-put overlay 'image-file image-file)
+ (overlay-put overlay 'thumb-file thumb-file)))))
+ arg ; Show or hide image on ARG next files.
+ 'show-progress) ; Update dired display after each image is updated.
(add-hook 'dired-after-readin-hook 'image-dired-dired-after-readin-hook nil t))
(defun image-dired-dired-after-readin-hook ()
With optional argument APPEND, append thumbnail to thumbnail buffer
instead of erasing it first.
-Option argument DO-NOT-POP controls if `pop-to-buffer' should be
+Optional argument DO-NOT-POP controls if `pop-to-buffer' should be
used or not. If non-nil, use `display-buffer' instead of
`pop-to-buffer'. This is used from functions like
`image-dired-next-line-and-display' and
;; If on empty line at end of buffer
(when (and (eobp)
(looking-at "^$"))
- (delete-backward-char 1))))))
+ (delete-char -1))))))
files)
(save-buffer)
(kill-buffer buf))))
(defun image-dired-read-comment (&optional file)
"Read comment for an image.
-Read comment for an image, optionally using old comment from FILE
-as initial value."
+Optionally use old comment from FILE as initial value."
(let ((comment
(read-string
"Comment: "
Track this in associated dired buffer if `image-dired-track-movement' is
non-nil."
(interactive "e")
- (let (file)
- (mouse-set-point event)
- (goto-char (posn-point (event-end event)))
- (setq file (image-dired-original-file-name))
- (if image-dired-track-movement
- (image-dired-track-original-file))
- (image-dired-create-display-image-buffer)
- (display-buffer image-dired-display-image-buffer)
- (image-dired-display-image file)))
+ (mouse-set-point event)
+ (goto-char (posn-point (event-end event)))
+ (let ((file (image-dired-original-file-name)))
+ (when file
+ (if image-dired-track-movement
+ (image-dired-track-original-file))
+ (image-dired-create-display-image-buffer)
+ (display-buffer image-dired-display-image-buffer)
+ (image-dired-display-image file))))
(defun image-dired-mouse-select-thumbnail (event)
"Use mouse EVENT to select thumbnail image.
(provide 'image-dired)
-;; arch-tag: 9d11411d-331f-4380-8b44-8adfe3a0343e
;;; image-dired.el ends here