Gnus development mailing list
 help / color / mirror / Atom feed
* gnus-smiley.el -- new version
@ 1996-06-14 17:23 Wes Hardaker
  1996-06-14 18:42 ` smiley.el (was Re: gnus-smiley.el -- new version) William Perry
  0 siblings, 1 reply; 25+ messages in thread
From: Wes Hardaker @ 1996-06-14 17:23 UTC (permalink / raw)



Did things slightly more correctly this time:

  -- cached last glyph for faster loading (of frequent smilies :-)
  -- Used "invisible extents" rather than deleting the original region
  -- more reg-exp -> smily matching

Additionally, I made the smily faces yellow with a trasparent edge, so
they look like they really should now!  Get a new copy at
ftp.ece.ucdavis.edu:/pub/hardaker/smilies.tar.gz

:-)

Wes Hardaker
Professional Time Waster

;;
;; comments go here.
;;

;; To use:
;; (load "gnus-smiley.el")
;; (add-hook 'gnus-article-display-hook 'gnus-smiley-display t)

(defvar gnus-smiley-db-dir "/home/hardaker/lib/smilies"
  "Location of the smiley xpm faces files.")

(defvar gnus-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 gnus-smiley-glyph nil)

(defvar gnus-smiley-last-file nil)

(defun gnus-smiley-display ()
  (interactive)
  (if (and (featurep 'xpm) 
           (or (not (fboundp 'device-type)) (equal (device-type) 'x)))
      (save-excursion
	(set-buffer gnus-article-buffer)
	;; search and replace
	(let ((buffer-read-only nil)
	      (alist gnus-smiley-regexp-alist)
	      bug entry regexp)
	  (goto-char (point-min))
	  ;; We skip the headers.
	  (unless (search-forward "\n\n" nil t)
	    (goto-char (point-max)))
	  (setq beg (point))
	  ;; loop through alist
	  (while (setq entry (pop alist))
	    (setq regexp (car entry))
	    (goto-char beg)
	    (while (re-search-forward regexp nil t)
	      (let ((start (match-beginning 0))
		    (end (match-end 0))
		    (file (concat (file-name-as-directory gnus-smiley-db-dir) 
				 (nth 1 entry))))
		(if (not (equal file gnus-smiley-last-file))
		    (setq gnus-smiley-glyph (make-glyph file)))
		(if gnus-smiley-glyph
		    (progn 
		      (set-glyph-face gnus-smiley-glyph 'default)
		      (let ((ext (make-extent start end)))
			(set-extent-property ext 'invisible t)
			(set-extent-property ext 'end-open t))
		      (make-annotation gnus-smiley-glyph end 'text)
		      (goto-char end))
		  ))))))))


^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~1996-06-19 16:36 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).