# HG changeset patch # User Thierry Volpiatto # Date 1274730052 -7200 # Node ID edb0d0e61eb8dcd4d0123a86da15019e21f20d27 # Parent bb924695adbf1ee08fc983ca83ff1ad3fb4c7c67 * lisp/image-dired.el (image-dired-dired-insert-marked-thumbs) Insert thumbnails before file names of marked files in the dired buffer. diff --git a/lisp/image-dired.el b/lisp/image-dired.el --- a/lisp/image-dired.el +++ b/lisp/image-dired.el @@ -632,26 +632,31 @@ (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-insert-marked-thumbs (arg) + "Insert or hide thumbnails before file names of marked files in the dired buffer. +With numeric prefix arg, insert or hide thumbnails on ARG next/prec files depending ARG\ +is positive or negative." + (interactive "p") + (when (eq arg 1) (setq arg nil)) ; No prefix arg. (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 'no-dir 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 ()