1 ;;; thumbs.el --- Thumbnails previewer for images files
3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
5 ;; Author: Jean-Philippe Theberge <jphiltheberge@videotron.ca>
7 ;; Keywords: Multimedia
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
28 ;; This package create two new modes: thumbs-mode and thumbs-view-image-mode.
29 ;; It is used for basic browsing and viewing of images from within Emacs.
30 ;; Minimal image manipulation functions are also available via external
31 ;; programs. If you want to do more complex tasks like categorise and tag
32 ;; your images, use image-dired.el
34 ;; The 'convert' program from 'ImageMagick'
35 ;; [URL:http://www.imagemagick.org/] is required.
37 ;; Thanks: Alex Schroeder <alex@gnu.org> for maintaining the package at some
38 ;; time. The peoples at #emacs@freenode.net for numerous help. RMS
39 ;; for emacs and the GNU project.
41 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 ;; This is version 2.0
49 ;; Type M-x thumbs RET DIR RET to view the directory DIR in Thumbs mode.
50 ;; That should be a directory containing image files.
51 ;; from dired, C-t m enter in thumbs-mode with all marked files
52 ;; C-t a enter in thumbs-mode with all files in current-directory
53 ;; In thumbs-mode, pressing <return> on a image will bring you in image view
54 ;; mode for that image. C-h m will give you a list of available keybinding.
66 "Thumbnails previewer."
70 (defcustom thumbs-thumbsdir
(concat user-emacs-directory
"thumbs")
71 "*Directory to store thumbnails."
75 (defcustom thumbs-geometry
"100x100"
76 "*Size of thumbnails."
80 (defcustom thumbs-per-line
4
81 "Number of thumbnails per line to show in directory."
85 (defcustom thumbs-max-image-number
16
86 "Maximum number of images initially displayed in thumbs buffer."
90 (defcustom thumbs-thumbsdir-max-size
50000000
91 "Maximum size for thumbnails directory.
92 When it reaches that size (in bytes), a warning is sent."
96 ;; Unfortunately Windows XP has a program called CONVERT.EXE in
97 ;; C:/WINDOWS/SYSTEM32/ for partioning NTFS system. So Emacs
98 ;; can find the one in your ImageMagick directory, you need to
99 ;; customize this value to the absolute filename.
100 (defcustom thumbs-conversion-program
101 (if (eq system-type
'windows-nt
)
103 (or (executable-find "convert")
104 "/usr/X11R6/bin/convert"))
105 "*Name of conversion program for thumbnails generation.
106 It must be 'convert'."
110 (defcustom thumbs-setroot-command
111 "xloadimage -onroot -fullscreen *"
112 "Command to set the root window."
116 (defcustom thumbs-relief
5
117 "*Size of button-like border around thumbnails."
121 (defcustom thumbs-margin
2
122 "*Size of the margin around thumbnails.
123 This is where you see the cursor."
127 (defcustom thumbs-thumbsdir-auto-clean t
128 "If set, delete older file in the thumbnails directory.
129 Deletion is done at load time when the directory size is bigger
130 than `thumbs-thumbsdir-max-size'."
134 (defcustom thumbs-image-resizing-step
10
135 "Step by which to resize image as a percentage."
139 (defcustom thumbs-temp-dir temporary-file-directory
140 "Temporary directory to use.
141 Defaults to `temporary-file-directory'. Leaving it to
142 this value can let another user see some of your images."
146 (defcustom thumbs-temp-prefix
"emacsthumbs"
147 "Prefix to add to temp files."
151 ;; Initialize some variable, for later use.
152 (defvar thumbs-current-tmp-filename nil
153 "Temporary filename of current image.")
154 (make-variable-buffer-local 'thumbs-current-tmp-filename
)
156 (defvar thumbs-current-image-filename nil
157 "Filename of current image.")
158 (make-variable-buffer-local 'thumbs-current-image-filename
)
160 (defvar thumbs-extra-images
1
161 "Counter for showing extra images in thumbs buffer.")
162 (make-variable-buffer-local 'thumbs-extra-images
)
163 (put 'thumbs-extra-images
'permanent-local t
)
165 (defvar thumbs-current-image-size nil
166 "Size of current image.")
168 (defvar thumbs-image-num nil
169 "Number of current image.")
170 (make-variable-buffer-local 'thumbs-image-num
)
172 (defvar thumbs-buffer nil
173 "Name of buffer containing thumbnails associated with image.")
174 (make-variable-buffer-local 'thumbs-buffer
)
176 (defvar thumbs-current-dir nil
177 "Current directory.")
179 (defvar thumbs-marked-list nil
180 "List of marked files.")
181 (make-variable-buffer-local 'thumbs-marked-list
)
182 (put 'thumbs-marked-list
'permanent-local t
)
184 (defalias 'thumbs-gensym
185 (if (fboundp 'gensym
)
187 ;; Copied from cl-macs.el
188 (defvar thumbs-gensym-counter
0)
189 (lambda (&optional prefix
)
190 "Generate a new uninterned symbol.
191 The name is made by appending a number to PREFIX, default \"G\"."
192 (let ((pfix (if (stringp prefix
) prefix
"G"))
193 (num (if (integerp prefix
) prefix
194 (prog1 thumbs-gensym-counter
195 (setq thumbs-gensym-counter
196 (1+ thumbs-gensym-counter
))))))
197 (make-symbol (format "%s%d" pfix num
))))))
199 (defsubst thumbs-temp-dir
()
200 (file-name-as-directory (expand-file-name thumbs-temp-dir
)))
202 (defun thumbs-temp-file ()
203 "Return a unique temporary filename for an image."
204 (format "%s%s-%s.jpg"
207 (thumbs-gensym "T")))
209 (defun thumbs-thumbsdir ()
210 "Return the current thumbnails directory (from `thumbs-thumbsdir').
211 Create the thumbnails directory if it does not exist."
212 (let ((thumbs-thumbsdir (file-name-as-directory
213 (expand-file-name thumbs-thumbsdir
))))
214 (unless (file-directory-p thumbs-thumbsdir
)
215 (make-directory thumbs-thumbsdir t
)
216 (message "Creating thumbnails directory"))
219 (defun thumbs-cleanup-thumbsdir ()
220 "Clean the thumbnails directory.
221 If the total size of all files in `thumbs-thumbsdir' is bigger than
222 `thumbs-thumbsdir-max-size', files are deleted until the max size is
228 (let ((fattribs-list (file-attributes f
)))
229 `(,(nth 4 fattribs-list
) ,(nth 7 fattribs-list
) ,f
)))
230 (directory-files (thumbs-thumbsdir) t
(image-file-name-regexp)))
231 '(lambda (l1 l2
) (time-less-p (car l1
) (car l2
)))))
232 (dirsize (apply '+ (mapcar (lambda (x) (cadr x
)) files-list
))))
233 (while (> dirsize thumbs-thumbsdir-max-size
)
235 (message "Deleting file %s" (cadr (cdar files-list
))))
236 (delete-file (cadr (cdar files-list
)))
237 (setq dirsize
(- dirsize
(car (cdar files-list
))))
238 (setq files-list
(cdr files-list
)))))
240 ;; Check the thumbsnail directory size and clean it if necessary.
241 (when thumbs-thumbsdir-auto-clean
242 (thumbs-cleanup-thumbsdir))
244 (defun thumbs-call-convert (filein fileout action
245 &optional arg output-format action-prefix
)
246 "Call the convert program.
247 FILEIN is the input file,
248 FILEOUT is the output file,
249 ACTION is the command to send to convert.
250 Optional arguments are:
251 ARG any arguments to the ACTION command,
252 OUTPUT-FORMAT is the file format to output (default is jpeg),
253 ACTION-PREFIX is the symbol to place before the ACTION command
254 (defaults to '-' but can sometimes be '+')."
255 (call-process thumbs-conversion-program nil nil nil
256 (or action-prefix
"-")
260 (format "%s:%s" (or output-format
"jpeg") fileout
)))
262 (defun thumbs-new-image-size (s increment
)
263 "New image (a cons of width x height)."
264 (let ((d (* increment thumbs-image-resizing-step
)))
266 (round (+ (car s
) (/ (* d
(car s
)) 100)))
267 (round (+ (cdr s
) (/ (* d
(cdr s
)) 100))))))
269 (defun thumbs-resize-image-1 (&optional increment size
)
270 "Resize image in current buffer.
271 If SIZE is specified use it. Otherwise make the image larger or
272 smaller according to whether INCREMENT is 1 or -1."
273 (let* ((buffer-read-only nil
)
274 (old thumbs-current-tmp-filename
)
276 (thumbs-new-image-size thumbs-current-image-size increment
)))
277 (tmp (thumbs-temp-file)))
279 (thumbs-call-convert (or old thumbs-current-image-filename
)
281 (concat (number-to-string (car x
)) "x"
282 (number-to-string (cdr x
))))
284 (thumbs-insert-image tmp
'jpeg
0))
285 (setq thumbs-current-tmp-filename tmp
)))
287 (defun thumbs-resize-image (width height
)
288 "Resize image interactively to specified WIDTH and HEIGHT."
289 (interactive "nWidth: \nnHeight: ")
290 (thumbs-resize-image-1 nil
(cons width height
)))
292 (defun thumbs-shrink-image ()
293 "Resize image (smaller)."
295 (thumbs-resize-image-1 -
1))
297 (defun thumbs-enlarge-image ()
298 "Resize image (bigger)."
300 (thumbs-resize-image-1 1))
302 (defun thumbs-thumbname (img)
303 "Return a thumbnail name for the image IMG."
304 (convert-standard-filename
305 (let ((filename (expand-file-name img
)))
306 (format "%s%08x-%s.jpg"
309 (subst-char-in-string
313 (split-string filename
"/")))))))
315 (defun thumbs-make-thumb (img)
316 "Create the thumbnail for IMG."
317 (let ((fn (expand-file-name img
))
318 (tn (thumbs-thumbname img
)))
319 (if (or (not (file-exists-p tn
))
320 ;; This is not the right fix, but I don't understand
321 ;; the external program or why it produces a geometry
322 ;; unequal to the one requested -- rms.
323 ;;; (not (equal (thumbs-file-size tn) thumbs-geometry))
325 (thumbs-call-convert fn tn
"sample" thumbs-geometry
))
328 (defun thumbs-image-type (img)
329 "Return image type from filename IMG."
330 (cond ((string-match ".*\\.jpe?g\\'" img
) 'jpeg
)
331 ((string-match ".*\\.xpm\\'" img
) 'xpm
)
332 ((string-match ".*\\.xbm\\'" img
) 'xbm
)
333 ((string-match ".*\\.pbm\\'" img
) 'pbm
)
334 ((string-match ".*\\.gif\\'" img
) 'gif
)
335 ((string-match ".*\\.bmp\\'" img
) 'bmp
)
336 ((string-match ".*\\.png\\'" img
) 'png
)
337 ((string-match ".*\\.tiff?\\'" img
) 'tiff
)))
339 (defun thumbs-file-size (img)
341 (find-image `((:type
,(thumbs-image-type img
) :file
,img
))) t
)))
342 (concat (number-to-string (round (car i
))) "x"
343 (number-to-string (round (cdr i
))))))
346 (defun thumbs-find-thumb (img)
347 "Display the thumbnail for IMG."
349 (find-file (thumbs-make-thumb img
)))
351 (defun thumbs-insert-image (img type relief
&optional marked
)
352 "Insert image IMG at point.
353 TYPE and RELIEF will be used in constructing the image; see `image'
354 in the emacs-lisp manual for further documentation.
355 If MARKED is non-nil, the image is marked."
356 (let ((i `(image :type
,type
359 :conversion
,(if marked
'disabled
)
360 :margin
,thumbs-margin
)))
362 (set (make-local-variable 'thumbs-current-image-size
)
365 (defun thumbs-insert-thumb (img &optional marked
)
366 "Insert the thumbnail for IMG at point.
367 If MARKED is non-nil, the image is marked."
369 (thumbs-make-thumb img
) 'jpeg thumbs-relief marked
)
370 (add-text-properties (1- (point)) (point)
371 `(thumb-image-file ,img
372 help-echo
,(file-name-nondirectory img
)
373 rear-nonsticky help-echo
)))
375 (defun thumbs-do-thumbs-insertion (list)
376 "Insert all thumbnails into thumbs buffer."
378 (length (length list
))
379 (diff (- length
(* thumbs-max-image-number thumbs-extra-images
))))
382 (thumbs-insert-thumb img
383 (member img thumbs-marked-list
))
384 (when (= 0 (mod (setq i
(1+ i
)) thumbs-per-line
))
386 (unless (bobp) (newline))
387 (if (> diff
0) (message "Type + to display more images."))))
389 (defun thumbs-show-thumbs-list (list &optional dir same-window
)
390 (unless (and (display-images-p)
391 (image-type-available-p 'jpeg
))
392 (error "Required image type is not supported in this Emacs session"))
393 (funcall (if same-window
'switch-to-buffer
'pop-to-buffer
)
394 (if dir
(concat "*Thumbs: " dir
) "*THUMB-View*"))
395 (let ((inhibit-read-only t
))
398 (setq thumbs-buffer
(current-buffer))
399 (if dir
(setq default-directory dir
))
400 (thumbs-do-thumbs-insertion list
)
401 (goto-char (point-min))
402 (set (make-local-variable 'thumbs-current-dir
) default-directory
)))
405 (defun thumbs-show-from-dir (dir &optional reg same-window
)
406 "Make a preview buffer for all images in DIR.
407 Optional argument REG to select file matching a regexp,
408 and SAME-WINDOW to show thumbs in the same window."
409 (interactive "DDir: ")
410 (thumbs-show-thumbs-list
411 (directory-files dir t
(or reg
(image-file-name-regexp)))
415 (defun thumbs-dired-show-marked ()
416 "In dired, make a thumbs buffer with marked files."
418 (thumbs-show-thumbs-list (dired-get-marked-files) nil t
))
421 (defun thumbs-dired-show ()
422 "In dired, make a thumbs buffer with all files in current directory."
424 (thumbs-show-from-dir default-directory nil t
))
427 (defalias 'thumbs
'thumbs-show-from-dir
)
429 (defun thumbs-find-image (img &optional num otherwin
)
430 (let ((buffer (current-buffer)))
432 (if otherwin
'switch-to-buffer-other-window
'switch-to-buffer
)
434 (thumbs-view-image-mode)
436 (concat "image-view-mode: " (file-name-nondirectory img
)
437 " - " (number-to-string num
)))
438 (setq thumbs-buffer buffer
)
439 (let ((inhibit-read-only t
))
440 (setq thumbs-current-image-filename img
441 thumbs-current-tmp-filename nil
442 thumbs-image-num
(or num
0))
443 (delete-region (point-min)(point-max))
445 (thumbs-insert-image img
(thumbs-image-type img
) 0)))))
447 (defun thumbs-find-image-at-point (&optional img otherwin
)
448 "Display image IMG for thumbnail at point.
449 Use another window if OTHERWIN is t."
451 (let* ((i (or img
(thumbs-current-image))))
452 (thumbs-find-image i
(point) otherwin
)))
454 (defun thumbs-find-image-at-point-other-window ()
455 "Display image for thumbnail at point in the preview buffer.
456 Open another window."
458 (thumbs-find-image-at-point nil t
))
460 (defun thumbs-mouse-find-image (event)
461 "Display image for thumbnail at mouse click EVENT."
463 (mouse-set-point event
)
464 (thumbs-find-image-at-point))
466 (defun thumbs-call-setroot-command (img)
467 "Call the setroot program for IMG."
468 (run-hooks 'thumbs-before-setroot-hook
)
469 (shell-command (replace-regexp-in-string
471 (shell-quote-argument (expand-file-name img
))
472 thumbs-setroot-command nil t
))
473 (run-hooks 'thumbs-after-setroot-hook
))
475 (defun thumbs-set-image-at-point-to-root-window ()
476 "Set the image at point as the desktop wallpaper."
478 (thumbs-call-setroot-command
479 (thumbs-current-image)))
481 (defun thumbs-set-root ()
482 "Set the current image as root."
484 (thumbs-call-setroot-command
485 (or thumbs-current-tmp-filename
486 thumbs-current-image-filename
)))
488 (defun thumbs-file-alist ()
489 "Make an alist of elements (POS . FILENAME) for all images in thumb buffer."
490 (with-current-buffer thumbs-buffer
493 (goto-char (point-min))
496 (if (thumbs-current-image)
497 (push (cons (point-marker)
498 (thumbs-current-image))
503 (defun thumbs-file-list ()
504 "Make a list of file names for all images in thumb buffer."
507 (goto-char (point-min))
509 (if (thumbs-current-image)
510 (push (thumbs-current-image) list
))
514 (defun thumbs-delete-images ()
515 "Delete the image at point (and its thumbnail) (or marked files if any)."
517 (let ((files (or thumbs-marked-list
(list (thumbs-current-image)))))
518 (if (yes-or-no-p (format "Really delete %d files? " (length files
)))
519 (let ((thumbs-file-list (thumbs-file-alist))
520 (inhibit-read-only t
))
526 (delete-file (thumbs-thumbname x
)))
527 (file-error (setq failure t
)))
529 (when (rassoc x thumbs-file-list
)
530 (goto-char (car (rassoc x thumbs-file-list
)))
531 (delete-region (point) (1+ (point))))
532 (setq thumbs-marked-list
533 (delq x thumbs-marked-list
)))))))))
535 (defun thumbs-rename-images (newfile)
536 "Rename the image at point (and its thumbnail) (or marked files if any)."
537 (interactive "FRename to file or directory: ")
538 (let ((files (or thumbs-marked-list
(list (thumbs-current-image))))
540 (if (and (not (file-directory-p newfile
))
542 (if (file-exists-p newfile
)
543 (error "Renaming marked files to file name `%s'" newfile
)
544 (make-directory newfile t
)))
545 (if (yes-or-no-p (format "Really rename %d files? " (length files
)))
546 (let ((thumbs-file-list (thumbs-file-alist))
547 (inhibit-read-only t
))
551 (if (file-directory-p newfile
)
554 (file-name-nondirectory file
)
556 (rename-file file newfile
))
557 (file-error (setq failure t
)
558 (push file failures
)))
560 (when (rassoc file thumbs-file-list
)
561 (goto-char (car (rassoc file thumbs-file-list
)))
562 (delete-region (point) (1+ (point))))
563 (setq thumbs-marked-list
564 (delq file thumbs-marked-list
)))))))
566 (display-warning 'file-error
567 (format "Rename failures for %s into %s"
571 (defun thumbs-kill-buffer ()
572 "Kill the current buffer."
574 (quit-window t
(selected-window)))
576 (defun thumbs-show-image-num (num)
577 "Show the image with number NUM."
578 (let ((image-buffer (get-buffer-create "*Image*")))
579 (let ((img (cdr (nth (1- num
) (thumbs-file-alist)))))
580 (with-current-buffer image-buffer
582 (concat "image-view-mode: " (file-name-nondirectory img
)
583 " - " (number-to-string num
)))
584 (let ((inhibit-read-only t
))
586 (thumbs-insert-image img
(thumbs-image-type img
) 0)
587 (goto-char (point-min))))
588 (setq thumbs-image-num num
589 thumbs-current-image-filename img
))))
591 (defun thumbs-previous-image ()
592 "Show the previous image."
594 (let* ((i (- thumbs-image-num
1))
595 (number (length (thumbs-file-alist))))
596 (if (= i
0) (setq i
(1- number
)))
597 (thumbs-show-image-num i
)))
599 (defun thumbs-next-image ()
600 "Show the next image."
602 (let* ((i (1+ thumbs-image-num
))
603 (number (length (thumbs-file-alist))))
604 (if (= i number
) (setq i
1))
605 (thumbs-show-image-num i
)))
607 (defun thumbs-display-thumbs-buffer ()
608 "Display the associated thumbs buffer."
610 (display-buffer thumbs-buffer
))
612 (defun thumbs-redraw-buffer ()
613 "Redraw the current thumbs buffer."
615 (inhibit-read-only t
)
616 (files (thumbs-file-list)))
618 (thumbs-do-thumbs-insertion files
)
621 (defun thumbs-mark ()
622 "Mark the image at point."
624 (let ((elt (thumbs-current-image)))
626 (error "No image here"))
627 (push elt thumbs-marked-list
)
628 (let ((inhibit-read-only t
))
630 (thumbs-insert-thumb elt t
)))
631 (when (eolp) (forward-char)))
633 (defun thumbs-unmark ()
634 "Unmark the image at point."
636 (let ((elt (thumbs-current-image)))
638 (error "No image here"))
639 (setq thumbs-marked-list
(delete elt thumbs-marked-list
))
640 (let ((inhibit-read-only t
))
642 (thumbs-insert-thumb elt nil
)))
643 (when (eolp) (forward-char)))
645 ;; cleaning of old temp files
647 (directory-files (thumbs-temp-dir) t thumbs-temp-prefix
))
649 ;; Image modification routines
651 (defun thumbs-modify-image (action &optional arg
)
652 "Call convert to do ACTION on image with argument ARG.
653 ACTION and ARG should be a valid convert command."
654 (interactive "sAction: \nsValue: ")
655 (let* ((buffer-read-only nil
)
656 (old thumbs-current-tmp-filename
)
657 (tmp (thumbs-temp-file)))
659 (thumbs-call-convert (or old thumbs-current-image-filename
)
664 (thumbs-insert-image tmp
'jpeg
0))
665 (setq thumbs-current-tmp-filename tmp
)))
667 (defun thumbs-emboss-image (emboss)
668 "Emboss the image with value EMBOSS."
669 (interactive "nEmboss value: ")
670 (if (or (< emboss
3) (> emboss
31) (zerop (% emboss
2)))
671 (error "Arg must be an odd number between 3 and 31"))
672 (thumbs-modify-image "emboss" (number-to-string emboss
)))
674 (defun thumbs-monochrome-image ()
675 "Turn the image to monochrome."
677 (thumbs-modify-image "monochrome"))
679 (defun thumbs-negate-image ()
682 (thumbs-modify-image "negate"))
684 (defun thumbs-rotate-left ()
685 "Rotate the image 90 degrees counter-clockwise."
687 (thumbs-modify-image "rotate" "270"))
689 (defun thumbs-rotate-right ()
690 "Rotate the image 90 degrees clockwise."
692 (thumbs-modify-image "rotate" "90"))
694 (defun thumbs-current-image ()
695 "Return the name of the image file name at point."
696 (get-text-property (point) 'thumb-image-file
))
698 (defun thumbs-forward-char ()
699 "Move forward one image."
702 (while (and (not (eobp)) (not (thumbs-current-image)))
706 (defun thumbs-backward-char ()
707 "Move backward one image."
710 (while (and (not (bobp)) (not (thumbs-current-image)))
714 (defun thumbs-backward-line ()
720 (defun thumbs-forward-line ()
721 "Move down one line."
726 (defun thumbs-show-more-images (&optional arg
)
727 "Show more than `thumbs-max-image-number' images, if present."
729 (or arg
(setq arg
1))
730 (setq thumbs-extra-images
(+ thumbs-extra-images arg
))
733 (defun thumbs-show-name ()
734 "Show the name of the current file."
736 (let ((f (thumbs-current-image)))
737 (and f
(message "%s [%s]" f
(thumbs-file-size f
)))))
739 (defun thumbs-save-current-image ()
740 "Save the current image."
742 (let ((f (or thumbs-current-tmp-filename
743 thumbs-current-image-filename
))
744 (sa (read-from-minibuffer "Save image file as: "
745 thumbs-current-image-filename
)))
748 (defun thumbs-dired ()
749 "Use `dired' on the current thumbs directory."
751 (dired thumbs-current-dir
))
755 (defvar thumbs-mode-map
756 (let ((map (make-sparse-keymap)))
757 (define-key map
[return] 'thumbs-find-image-at-point)
758 (define-key map [mouse-2] 'thumbs-mouse-find-image)
759 (define-key map [(meta return)] 'thumbs-find-image-at-point-other-window)
760 (define-key map [(control return)] 'thumbs-set-image-at-point-to-root-window)
761 (define-key map [delete] 'thumbs-delete-images)
762 (define-key map [right] 'thumbs-forward-char)
763 (define-key map [left] 'thumbs-backward-char)
764 (define-key map [up] 'thumbs-backward-line)
765 (define-key map [down] 'thumbs-forward-line)
766 (define-key map "+" 'thumbs-show-more-images)
767 (define-key map "d" 'thumbs-dired)
768 (define-key map "m" 'thumbs-mark)
769 (define-key map "u" 'thumbs-unmark)
770 (define-key map "R" 'thumbs-rename-images)
771 (define-key map "x" 'thumbs-delete-images)
772 (define-key map "s" 'thumbs-show-name)
773 (define-key map "q" 'thumbs-kill-buffer)
775 "Keymap for `thumbs-mode'.")
777 (put 'thumbs-mode 'mode-class 'special)
778 (define-derived-mode thumbs-mode
779 fundamental-mode "thumbs"
780 "Preview images in a thumbnails buffer"
781 (setq buffer-read-only t))
783 (defvar thumbs-view-image-mode-map
784 (let ((map (make-sparse-keymap)))
785 (define-key map [prior] 'thumbs-previous-image)
786 (define-key map [next] 'thumbs-next-image)
787 (define-key map "^" 'thumbs-display-thumbs-buffer)
788 (define-key map "-" 'thumbs-shrink-image)
789 (define-key map "+" 'thumbs-enlarge-image)
790 (define-key map "<" 'thumbs-rotate-left)
791 (define-key map ">" 'thumbs-rotate-right)
792 (define-key map "e" 'thumbs-emboss-image)
793 (define-key map "r" 'thumbs-resize-image)
794 (define-key map "s" 'thumbs-save-current-image)
795 (define-key map "q" 'thumbs-kill-buffer)
796 (define-key map "w" 'thumbs-set-root)
798 "Keymap for `thumbs-view-image-mode'.")
800 ;; thumbs-view-image-mode
801 (put 'thumbs-view-image-mode 'mode-class 'special)
802 (define-derived-mode thumbs-view-image-mode
803 fundamental-mode "image-view-mode"
804 (setq buffer-read-only t))
807 (defun thumbs-dired-setroot ()
808 "In dired, call the setroot program on the image at point."
810 (thumbs-call-setroot-command (dired-get-filename)))
812 ;; Modif to dired mode map
813 (define-key dired-mode-map "\C-ta" 'thumbs-dired-show)
814 (define-key dired-mode-map "\C-tm" 'thumbs-dired-show-marked)
815 (define-key dired-mode-map "\C-tw" 'thumbs-dired-setroot)
819 ;; arch-tag: f9ac1ef8-83fc-42c0-8069-1fae43fd2e5c
820 ;;; thumbs.el ends here