2002-01-11 Dave Love * smiley-ems.el (smiley-regexp-alist): Add Unicode strings. (smiley-update-cache): Allow strings as well as images. (smiley-region, gnus-smiley-display): Doc fix. (smiley-region): Update to allow string display. Index: smiley-ems.el =================================================================== RCS file: /cvs/emacs/lisp/gnus/smiley-ems.el,v retrieving revision 1.9 diff -u -p -r1.9 smiley-ems.el --- smiley-ems.el 13 Dec 2000 02:07:43 -0000 1.9 +++ smiley-ems.el 11 Jan 2002 18:05:25 -0000 @@ -1,6 +1,6 @@ -;;; smiley-ems.el --- displaying smiley faces +;;; smiley-ems.el --- displaying smiley faces -*- coding: iso-2022-7bit -*- -;; Copyright (C) 2000 Free Software Foundation, Inc. +;; Copyright (C) 2000, 2001 Free Software Foundation, Inc. ;; Author: Dave Love ;; Keywords: news mail multimedia @@ -51,17 +51,28 @@ This is in addition to the normal image ;; The XEmacs version has a baroque, if not rococo, set of these. (defcustom smiley-regexp-alist - ;; Perhaps :-) should be distinct -- it does appear in the Jargon File. - '(("\\([:;]-?)\\)\\(\\W\\|\\'\\)" 1 "smile.pbm") - ("\\(:-[/\\]\\)\\(\\W\\|\\'\\)" 1 "wry.pbm") - ("\\(:-[({]\\)\\(\\W\\|\\'\\)" 1 "frown.pbm")) +;; Perhaps :-) should be distinct -- it does appear in the Jargon File. + (if (latin1-char-displayable-p ?\$,2#:(B) + '(("\\([:;]-?)\\)\\(\\W\\|\\'\\)" 1 ((margin nil) "$,2#:(B")) + ("\\(:-[/\\]\\)\\(\\W\\|\\'\\)" 1 ((margin nil) "$,2#;(B")) + ("\\(:-[({]\\)\\(\\W\\|\\'\\)" 1 ((margin nil) "$,2#9(B"))) + '(("\\([:;]-?)\\)\\(\\W\\|\\'\\)" 1 "smile.pbm") + ("\\(:-[/\\]\\)\\(\\W\\|\\'\\)" 1 "wry.pbm") + ("\\(:-[({]\\)\\(\\W\\|\\'\\)" 1 "frown.pbm"))) "*A list of regexps to map smilies to images. The elements are (REGEXP MATCH FILE), where MATCH is the submatch in rgexp to replace with IMAGE. IMAGE is the name of a PBM file in `smiley-data-directory' or the normal image search path." :type '(repeat (list regexp (integer :tag "Regexp match number") - (string :tag "Image name"))) + (choice (string :tag "Image name") + (const :tag "Smiling face character" + ((margin nil) "$,2#:(B")) + (const :tag "Frowning face character" + ((margin nil) "$,2#9(B")) + (const :tag "Black smiling face character" + ((margin nil) "$,2#;(B")) + (sexp :tag "General display property")))) :set (lambda (symbol value) (set-default symbol value) (smiley-update-cache)) @@ -73,11 +84,13 @@ rgexp to replace with IMAGE. IMAGE is t (defun smiley-update-cache () (dolist (elt smiley-regexp-alist) (let* ((data-directory smiley-data-directory) - (image (find-image (list (list :type 'pbm - :file (nth 2 elt) - :ascent 'center))))) - (if image - (push (list (car elt) (cadr elt) image) + (display (if (stringp (nth 2 elt)) + (find-image (list (list :type 'pbm + :file (nth 2 elt) + :ascent 'center))) + (nth 2 elt)))) + (if display + (push (list (car elt) (cadr elt) display) smiley-cached-regexp-alist))))) (defvar smiley-active nil @@ -93,7 +106,7 @@ rgexp to replace with IMAGE. IMAGE is t ;;;###autoload (defun smiley-region (start end) - "Display textual smileys as images. + "Display textual smileys as images or special characters. START and END specify the region; interactively, use the values of point and mark. The value of `smiley-regexp-alist' determines which smileys to operate on and which images to use for them." @@ -109,17 +122,17 @@ which smileys to operate on and which im (save-excursion (let ((beg (or start (point-min))) (inhibit-point-motion-hooks t) - group overlay image) + group overlay display) (dolist (entry smiley-cached-regexp-alist) (setq group (nth 1 entry) - image (nth 2 entry)) + display (nth 2 entry)) (goto-char beg) (while (re-search-forward (car entry) end t) - (when image + (when display (setq overlay (make-overlay (match-beginning group) (match-end group))) (overlay-put overlay - 'display `(when smiley-active ,@image)) + 'display `(when smiley-active . ,display)) (overlay-put overlay 'mouse-face 'highlight) (overlay-put overlay 'smiley t) (overlay-put overlay @@ -148,7 +161,8 @@ With arg, turn displaying on if and only (eval-when-compile (defvar gnus-article-buffer)) (defun gnus-smiley-display (&optional arg) - "Display textual emoticaons (\"smilies\") as small graphical icons. + "Display textual emoticons (\"smilies\") as small graphical icons. +May also use strings to display them. See `smiley-regexp-alist'. With arg, turn displaying on if and only if arg is positive." (interactive "P") (save-excursion