From: William Perry <wmperry@monolith.spry.com>
Cc: ding@ifi.uio.no
Subject: smiley.el (was Re: gnus-smiley.el -- new version)
Date: Fri, 14 Jun 1996 11:42:20 -0700 [thread overview]
Message-ID: <199606141842.LAA07706@monolith.spry.com> (raw)
In-Reply-To: <199606141723.AA017493012@teal.ece.ucdavis.edu>
Here is a slightly modified version that uses a tty-specifier in the glyph
so that you do not have to check if you are in X or not. Also, its been
generalized a bit, so that you can (smiley-buffer your-fav-buffer start end)
gnus-smiley-buffer becomes a trivial wrapper. This way it can be used in
VM or Emacs-W3, etc.
The finding of the pixmap directory needs to be automatic though.
-Bill P.
;;
;; comments go here.
;;
;; To use:
;; (require 'smiley)
;; (add-hook 'gnus-article-display-hook 'gnus-smiley-display t)
(defvar smiley-data-directory "/tmp/smilies/"
"Location of the smiley faces files.")
(defvar smiley-regexp-alist '((":-*\\]" "FaceGrinning.xpm")
(":-*[oO]" "FaceStartled.xpm")
(":-*[)>]" "FaceHappy.xpm")
(";-*[>)]" "FaceWinking.xpm")
(":-[/\\]" "FaceIronic.xpm")
(":-*|" "FaceStraight.xpm")
(":-*<" "FaceAngry.xpm")
(":-*d" "FaceTasty.xpm")
(":-*[pP]" "FaceYukky.xpm")
("8-*|" "FaceKOed.xpm")
(":-*(" "FaceAngry.xpm"))
"A list of regexps to map smilies to real images.")
(defvar smiley-glyph-cache nil)
(defvar smiley-running-xemacs (string-match "XEmacs" emacs-version))
(defun smiley-create-glyph (smiley pixmap)
(and
smiley-running-xemacs
(or
(cdr-safe (assoc pixmap smiley-glyph-cache))
(let ((glyph (make-glyph
(list
(cons 'x (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-buffer (&optional buffer st nd)
(save-excursion
(and buffer (set-buffer buffer))
(let ((buffer-read-only nil)
(alist smiley-regexp-alist)
bug entry regexp)
(goto-char (or st (point-min)))
(setq beg (point))
;; loop through alist
(while (setq entry (pop alist))
(setq regexp (car entry))
(goto-char beg)
(while (re-search-forward regexp nd t)
(let* ((start (match-beginning 0))
(end (match-end 0))
(file (nth 1 entry))
(glyph (smiley-create-glyph (buffer-substring start end)
file)))
(if glyph
(progn
(let ((ext (make-extent start end)))
(set-extent-property ext 'invisible t)
(set-extent-property ext 'end-open t))
(make-annotation glyph end 'text)
(goto-char end)))))))))
(defun gnus-smiley-display ()
(interactive)
(save-excursion
(set-buffer gnus-article-buffer)
(goto-char (point-min))
;; We skip the headers.
(unless (search-forward "\n\n" nil t)
(goto-char (point-max)))
(smiley-buffer (current-buffer) (point))))
(provide 'smiley)
next prev parent reply other threads:[~1996-06-14 18:42 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
1996-06-14 17:23 gnus-smiley.el -- new version Wes Hardaker
1996-06-14 18:42 ` William Perry [this message]
1996-06-14 21:11 ` smiley.el (was Re: gnus-smiley.el -- new version) Colin Rafferty
1996-06-14 21:55 ` William Perry
1996-06-14 21:57 ` Wes Hardaker
1996-06-14 22:52 ` William Perry
1996-06-14 22:07 ` Steven L Baur
1996-06-14 22:53 ` William Perry
1996-06-14 23:14 ` Steven L Baur
1996-06-15 1:22 ` Wes Hardaker
1996-06-15 7:54 ` Lars Magne Ingebrigtsen
1996-06-15 7:59 ` Lars Magne Ingebrigtsen
1996-06-15 8:53 ` Lars Magne Ingebrigtsen
1996-06-17 13:49 ` Jan Vroonhof
1996-06-17 16:16 ` Lars Magne Ingebrigtsen
1996-06-18 16:32 ` Wes Hardaker
1996-06-18 16:54 ` Lars Magne Ingebrigtsen
1996-06-18 17:49 ` Wes Hardaker
1996-06-19 6:07 ` Lars Magne Ingebrigtsen
1996-06-18 19:23 ` Sten Drescher
1996-06-18 20:12 ` Wes Hardaker
1996-06-19 6:10 ` Lars Magne Ingebrigtsen
1996-06-19 16:36 ` Wes Hardaker
1996-06-17 16:27 ` Jan Vroonhof
1996-06-17 17:43 ` Wes Hardaker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199606141842.LAA07706@monolith.spry.com \
--to=wmperry@monolith.spry.com \
--cc=ding@ifi.uio.no \
--cc=wmperry@spry.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).