(file-remote-p): Docstring fix.
[bpt/emacs.git] / lisp / thumbs.el
index f4b283b..5260d5a 100644 (file)
@@ -1,6 +1,6 @@
 ;;; thumbs.el --- Thumbnails previewer for images files
 
-;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
 ;; Author: Jean-Philippe Theberge <jphiltheberge@videotron.ca>
 ;; Maintainer: FSF
@@ -10,7 +10,7 @@
 
 ;; GNU Emacs is free software; you can redistribute it and/or modify
 ;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 2, or (at your option)
+;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
 
 ;; GNU Emacs is distributed in the hope that it will be useful,
@@ -29,7 +29,7 @@
 ;; It is used for basic browsing and viewing of images from within Emacs.
 ;; Minimal image manipulation functions are also available via external
 ;; programs.  If you want to do more complex tasks like categorise and tag
-;; your images, use tumme.el
+;; your images, use image-dired.el
 ;;
 ;; The 'convert' program from 'ImageMagick'
 ;; [URL:http://www.imagemagick.org/] is required.
@@ -67,7 +67,7 @@
   :version "22.1"
   :group 'multimedia)
 
-(defcustom thumbs-thumbsdir "~/.emacs.d/thumbs"
+(defcustom thumbs-thumbsdir (concat user-emacs-directory "thumbs")
   "*Directory to store thumbnails."
   :type 'directory
   :group 'thumbs)
@@ -93,6 +93,10 @@ When it reaches that size (in bytes), a warning is sent."
   :type 'integer
   :group 'thumbs)
 
+;; Unfortunately Windows XP has a program called CONVERT.EXE in
+;; C:/WINDOWS/SYSTEM32/ for partioning NTFS system.  So Emacs
+;; can find the one in your ImageMagick directory, you need to
+;; customize this value to the absolute filename.
 (defcustom thumbs-conversion-program
   (if (eq system-type 'windows-nt)
       "convert.exe"
@@ -174,6 +178,8 @@ this value can let another user see some of your images."
 
 (defvar thumbs-marked-list nil
   "List of marked files.")
+(make-variable-buffer-local 'thumbs-marked-list)
+(put 'thumbs-marked-list 'permanent-local t)
 
 (defalias 'thumbs-gensym
     (if (fboundp 'gensym)
@@ -246,15 +252,12 @@ ARG any arguments to the ACTION command,
 OUTPUT-FORMAT is the file format to output (default is jpeg),
 ACTION-PREFIX is the symbol to place before the ACTION command
               (defaults to '-' but can sometimes be '+')."
-  (let ((command (format "%s %s%s %s \"%s\" \"%s:%s\""
-                        thumbs-conversion-program
-                        (or action-prefix "-")
-                        action
-                        (or arg "")
-                        filein
-                        (or output-format "jpeg")
-                        fileout)))
-    (call-process shell-file-name nil nil nil "-c" command)))
+  (call-process thumbs-conversion-program nil nil nil
+               (or action-prefix "-")
+               action
+               (or arg "")
+               filein
+               (format "%s:%s" (or output-format "jpeg") fileout)))
 
 (defun thumbs-new-image-size (s increment)
   "New image (a cons of width x height)."
@@ -334,9 +337,9 @@ smaller according to whether INCREMENT is 1 or -1."
        ((string-match ".*\\.tiff?\\'" img) 'tiff)))
 
 (defun thumbs-file-size (img)
-  (let ((i (image-size (find-image `((:type ,(thumbs-image-type img) :file ,img))) t)))
-    (concat (number-to-string (round (car i)))
-           "x"
+  (let ((i (image-size
+           (find-image `((:type ,(thumbs-image-type img) :file ,img))) t)))
+    (concat (number-to-string (round (car i))) "x"
            (number-to-string (round (cdr i))))))
 
 ;;;###autoload
@@ -366,7 +369,8 @@ If MARKED is non-nil, the image is marked."
    (thumbs-make-thumb img) 'jpeg thumbs-relief marked)
   (add-text-properties (1- (point)) (point)
                     `(thumb-image-file ,img
-                      help-echo ,(file-name-nondirectory img))))
+                      help-echo ,(file-name-nondirectory img)
+                      rear-nonsticky help-echo)))
 
 (defun thumbs-do-thumbs-insertion (list)
   "Insert all thumbnails into thumbs buffer."
@@ -380,7 +384,7 @@ If MARKED is non-nil, the image is marked."
       (when (= 0 (mod (setq i (1+ i)) thumbs-per-line))
        (newline)))
     (unless (bobp) (newline))
-    (if diff (message "Type + to display more images."))))
+    (if (> diff 0) (message "Type + to display more images."))))
 
 (defun thumbs-show-thumbs-list (list &optional dir same-window)
   (unless (and (display-images-p)
@@ -488,7 +492,7 @@ Open another window."
       (let (list)
        (goto-char (point-min))
        (while (not (eobp))
-         (unless (= 0 (mod (point) (1+ thumbs-per-line)))
+         (unless (eolp)
            (if (thumbs-current-image)
                (push (cons (point-marker)
                            (thumbs-current-image))
@@ -623,8 +627,7 @@ Open another window."
     (push elt thumbs-marked-list)
     (let ((inhibit-read-only t))
       (delete-char 1)
-      (save-excursion
-       (thumbs-insert-thumb elt t))))
+      (thumbs-insert-thumb elt t)))
   (when (eolp) (forward-char)))
 
 (defun thumbs-unmark ()
@@ -636,11 +639,9 @@ Open another window."
     (setq thumbs-marked-list (delete elt thumbs-marked-list))
     (let ((inhibit-read-only t))
       (delete-char 1)
-      (save-excursion
-       (thumbs-insert-thumb elt nil))))
+      (thumbs-insert-thumb elt nil)))
   (when (eolp) (forward-char)))
 
-
 ;; cleaning of old temp files
 (mapc 'delete-file
       (directory-files (thumbs-temp-dir) t thumbs-temp-prefix))
@@ -777,8 +778,7 @@ ACTION and ARG should be a valid convert command."
 (define-derived-mode thumbs-mode
   fundamental-mode "thumbs"
   "Preview images in a thumbnails buffer"
-  (setq buffer-read-only t)
-  (set (make-local-variable 'thumbs-marked-list) nil))
+  (setq buffer-read-only t))
 
 (defvar thumbs-view-image-mode-map
   (let ((map (make-sparse-keymap)))