-(defcustom smiley-features-color "black"
- "*Features color."
- :type 'string
- :group 'smiley)
-
-(defcustom smiley-tongue-color "red"
- "*Tongue color."
- :type 'string
- :group 'smiley)
-
-(defcustom smiley-circle-color "black"
- "*Circle color."
- :type 'string
- :group 'smiley)
-
-(defcustom smiley-mouse-face 'highlight
- "*Face used for mouse highlighting in the smiley buffer.
-
-Smiley buttons will be displayed in this face when the cursor is
-above them."
- :type 'face
- :group 'smiley)
-
-(defvar smiley-glyph-cache nil)
-
-(defvar smiley-map (make-sparse-keymap "smiley-keys")
- "Keymap to toggle smiley states.")
-
-(define-key smiley-map [(button2)] 'smiley-toggle-extent)
-(define-key smiley-map [(button3)] 'smiley-popup-menu)
-
-(defun smiley-popup-menu (e)
- (interactive "e")
- (popup-menu
- `("Smilies"
- ["Toggle This Smiley" (smiley-toggle-extent ,e) t]
- ["Toggle All Smilies" (smiley-toggle-extents ,e) t])))
-
-(defun smiley-create-glyph (smiley pixmap)
- (or
- (cdr-safe (assoc pixmap smiley-glyph-cache))
- (let* ((xpm-color-symbols
- (and (featurep 'xpm)
- (append `(("flesh" ,smiley-flesh-color)
- ("features" ,smiley-features-color)
- ("tongue" ,smiley-tongue-color))
- xpm-color-symbols)))
- (glyph (make-glyph
- (list
- (cons (if (featurep 'gtk) 'gtk 'x)
- (expand-file-name pixmap smiley-data-directory))
- (cons 'mswindows
- (expand-file-name pixmap smiley-data-directory))
- (cons 'tty smiley)))))
- (setq smiley-glyph-cache (cons (cons pixmap glyph) smiley-glyph-cache))
- (set-glyph-face glyph 'default)
- glyph)))
-
-(defun smiley-create-glyph-ems (smiley pixmap)
- (condition-case e
- (create-image (expand-file-name pixmap smiley-data-directory))
- (error nil)))
-
+(defvar smiley-cached-regexp-alist nil)
+
+(defun smiley-update-cache ()
+ (setq smiley-cached-regexp-alist nil)
+ (dolist (elt (if (symbolp smiley-regexp-alist)
+ (symbol-value smiley-regexp-alist)
+ smiley-regexp-alist))
+ (let ((types gnus-smiley-file-types)
+ file type)
+ (while (and (not file)
+ (setq type (pop types)))
+ (unless (file-exists-p
+ (setq file (expand-file-name (concat (nth 2 elt) "." type)
+ smiley-data-directory)))
+ (setq file nil)))
+ (when type
+ (let ((image (gnus-create-image file (intern type) nil
+ :ascent 'center)))
+ (when image
+ (push (list (car elt) (cadr elt) image)
+ smiley-cached-regexp-alist)))))))
+
+;; Not implemented:
+;; (defvar smiley-mouse-map
+;; (let ((map (make-sparse-keymap)))
+;; (define-key map [down-mouse-2] 'ignore) ; override widget
+;; (define-key map [mouse-2]
+;; 'smiley-mouse-toggle-buffer)
+;; map))