changeset 62891:58c1e48ab7bc

(thumbs-thumbname): The resulting thubname includes a hash value to improve its uniqueness, and has a ".jpg" extension. Also, it is now a valid filename on all systems. (thumbs-make-thumb): Use `let', not `let*'. (thumbs-show-thumbs-list): Check for JPEG availability.
author Juanma Barranquero <lekktu@gmail.com>
date Mon, 30 May 2005 09:41:49 +0000
parents 4b7fa3ee8e9e
children c61fb7ab16c7
files lisp/thumbs.el
diffstat 1 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/thumbs.el	Mon May 30 08:20:19 2005 +0000
+++ b/lisp/thumbs.el	Mon May 30 09:41:49 2005 +0000
@@ -302,18 +302,21 @@
 
 (defun thumbs-thumbname (img)
   "Return a thumbnail name for the image IMG."
-  (concat thumbs-thumbsdir "/"
-	  (subst-char-in-string
-	   ?\  ?\_
-	   (apply
-	    'concat
-	    (split-string
-	     (expand-file-name img) "/")))))
+  (convert-standard-filename
+   (let ((filename (expand-file-name img)))
+     (format "%s/%08x-%s.jpg"
+             thumbs-thumbsdir
+             (sxhash filename)
+             (subst-char-in-string
+              ?\s ?\_
+              (apply
+               'concat
+               (split-string filename "/")))))))
 
 (defun thumbs-make-thumb (img)
   "Create the thumbnail for IMG."
-  (let* ((fn (expand-file-name img))
-	 (tn (thumbs-thumbname img)))
+  (let ((fn (expand-file-name img))
+        (tn (thumbs-thumbname img)))
     (if (or (not (file-exists-p tn))
 	    ;;  This is not the right fix, but I don't understand
 	    ;;  the external program or why it produces a geometry
@@ -378,8 +381,9 @@
     (unless (bobp) (newline))))
 
 (defun thumbs-show-thumbs-list (L &optional buffer-name same-window)
-  (when (not (display-images-p))
-    (error "Images are not supported in this Emacs session"))
+  (unless (and (display-images-p)
+               (image-type-available-p 'jpeg))
+    (error "Required image type is not supported in this Emacs session"))
   (funcall (if same-window 'switch-to-buffer 'pop-to-buffer)
 	   (or buffer-name "*THUMB-View*"))
   (let ((inhibit-read-only t))