-(defun thumbs-gensym (&optional arg)
- "Generate a new uninterned symbol.
-The name is made by appending a number to PREFIX, default \"Thumbs\"."
- (let ((prefix (if (stringp arg) arg "Thumbs"))
- (num (if (integerp arg) arg
- (prog1
- thumbs-gensym-counter
- (setq thumbs-gensym-counter (1+ thumbs-gensym-counter))))))
- (make-symbol (format "%s%d" prefix num))))
+(defalias 'thumbs-gensym
+ (if (fboundp 'gensym)
+ 'gensym
+ ;; Copied from cl-macs.el
+ (defvar thumbs-gensym-counter 0)
+ (lambda (&optional prefix)
+ "Generate a new uninterned symbol.
+The name is made by appending a number to PREFIX, default \"G\"."
+ (let ((pfix (if (stringp prefix) prefix "G"))
+ (num (if (integerp prefix) prefix
+ (prog1 thumbs-gensym-counter
+ (setq thumbs-gensym-counter
+ (1+ thumbs-gensym-counter))))))
+ (make-symbol (format "%s%d" pfix num))))))
+
+(defsubst thumbs-temp-dir ()
+ (file-name-as-directory (expand-file-name thumbs-temp-dir)))
+
+(defun thumbs-temp-file ()
+ "Return a unique temporary filename for an image."
+ (format "%s%s-%s.jpg"
+ (thumbs-temp-dir)
+ thumbs-temp-prefix
+ (thumbs-gensym "T")))
+
+(defun thumbs-thumbsdir ()
+ "Return the current thumbnails directory (from `thumbs-thumbsdir').
+Create the thumbnails directory if it does not exist."
+ (let ((thumbs-thumbsdir (file-name-as-directory
+ (expand-file-name thumbs-thumbsdir))))
+ (unless (file-directory-p thumbs-thumbsdir)
+ (make-directory thumbs-thumbsdir)
+ (message "Creating thumbnails directory"))
+ thumbs-thumbsdir))