From: Lars Magne Ingebrigtsen <larsi@ifi.uio.no>
Subject: Re: smiley.el (was Re: gnus-smiley.el -- new version)
Date: 15 Jun 1996 09:54:15 +0200 [thread overview]
Message-ID: <w8sn325y02g.fsf@aegir.ifi.uio.no> (raw)
In-Reply-To: Wes Hardaker's message of (unknown date)
Wes Hardaker <hardaker@ece.ucdavis.edu> writes:
> "[^p]\\(:/\\)" and pick the \1 out of there, or use the entire
> expression results if \1 DNE (ie, no sub-regions specified). This
> way you could more carefully watch out for things like http://,
> which (used to) gets caught. I also thought about requiring a white
> space char before the smiley. This would fix the problem as well,
> and I doubt anyone is writing them without a space in the first place.
I've fiddled with it slightly and have added a new second element to
the alist elements -- the regexp grouping number. (I haven't changed
the regexps themselves, so all use grouping 0.)
But you could say things like:
("[^/]\\(:-*[/\\]\\)" 1"FaceIronic.xpm")
to avoid matching "/:/" and stuff like that. Embellish as needed.
(Oh, and and I've added a `delete-annotation' to delete any old
smileys.)
;;
;; comments go here.
;;
;;; Test smileys: :-] :-o :-) ;-) :-< :-d :-P 8-| :-(
;; To use:
;; (require 'smiley)
;; (add-hook 'gnus-article-display-hook 'gnus-smiley-display t)
(require 'cl)
(defvar smiley-data-directory "~/sgnus/etc/smilies/"
"Location of the smiley faces files.")
(defvar smiley-regexp-alist '((":-*\\]" 0 "FaceGrinning.xpm")
(":-*[oO]" 0 "FaceStartled.xpm")
(":-*[)>]" 0 "FaceHappy.xpm")
(";-*[>)]" 0 "FaceWinking.xpm")
(":-[/\\]" 0 "FaceIronic.xpm")
(":-*|" 0 "FaceStraight.xpm")
(":-*<" 0 "FaceAngry.xpm")
(":-*d" 0 "FaceTasty.xpm")
(":-*[pP]" 0 "FaceYukky.xpm")
("8-*|" 0 "FaceKOed.xpm")
(":-*(" 0 "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-region (beg end)
"Smilify the region between point and mark."
(interactive "r")
(smiley-buffer (current-buffer) beg end))
(defun smiley-buffer (&optional buffer st nd)
(interactive)
(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)
group (cadr entry)
file (caddr entry))
(goto-char beg)
(while (re-search-forward regexp nd t)
(let* ((start (match-beginning group))
(end (match-end group))
(glyph (smiley-create-glyph (buffer-substring start end)
file)))
(if glyph
(progn
(mapcar 'delete-annotation (annotations-at end))
(let ((ext (make-extent start end)))
(set-extent-property ext 'invisible t)
(set-extent-property ext 'end-open t)
(set-extent-property ext 'intangible 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-15 7:54 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 ` smiley.el (was Re: gnus-smiley.el -- new version) William Perry
1996-06-14 21:11 ` 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 [this message]
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=w8sn325y02g.fsf@aegir.ifi.uio.no \
--to=larsi@ifi.uio.no \
/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).