annotate lisp/gnus/smiley.el @ 120:cca96a509cfe r20-1b12

Import from CVS: tag r20-1b12
author cvs
date Mon, 13 Aug 2007 09:25:29 +0200
parents 360340f9fd5f
children b980b6286996
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; smiley.el --- displaying smiley faces
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
2 ;; Copyright (C) 1996,97 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Author: Wes Hardaker <hardaker@ece.ucdavis.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Keywords: fun
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Boston, MA 02111-1307, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; comments go here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Test smileys: :-] :-o :-) ;-) :-\ :-| :-d :-P 8-| :-(
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; To use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; (require 'smiley)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; (add-hook 'gnus-article-display-hook 'gnus-smiley-display t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
36 ;; The smilies were drawn by Joe Reiss <jreiss@vt.edu>.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
37
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (require 'annotations)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
39 (require 'messagexmas)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
40 (require 'cl)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
41 (require 'custom)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
42
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
43 (defgroup smiley nil
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
44 "Turn :-)'s into real images (XEmacs)."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
45 :group 'gnus-visual)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
47 (defcustom smiley-data-directory (message-xmas-find-glyph-directory "smilies")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
48 "Location of the smiley faces files."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
49 :type 'directory
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
50 :group 'smiley)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
52 ;; Notice the subtle differences in the regular expressions in the
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
53 ;; two alists below.
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
54
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
55 (defcustom smiley-deformed-regexp-alist
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
56 '(("\\(:-*[<«]+\\)\\W" 1 "FaceAngry.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
57 ("\\(:-+\\]+\\)\\W" 1 "FaceGoofy.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
58 ("\\(:-*D\\)\\W" 1 "FaceGrinning.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
59 ("\\(:-*[)>}»]+\\)\\W" 1 "FaceHappy.xpm")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
60 ("\\(:-*[/\\\"]\\)[^/]\\W" 1 "FaceIronic.xpm")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 ("\\([8|]-*[|Oo%]\\)\\W" 1 "FaceKOed.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
62 ("\\([:|]-*#+\\)\\W" 1 "FaceNyah.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
63 ("\\(:-*[({]+\\)\\W" 1 "FaceSad.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
64 ("\\(:-*[Oo\*]\\)\\W" 1 "FaceStartled.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
65 ("\\(:-*|\\)\\W" 1 "FaceStraight.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
66 ("\\(:-*p\\)\\W" 1 "FaceTalking.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
67 ("\\(:-*d\\)\\W" 1 "FaceTasty.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
68 ("\\(;-*[>)}»]+\\)\\W" 1 "FaceWinking.xpm")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
69 ("\\(:-*[Vvµ]\\)\\W" 1 "FaceWry.xpm")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
70 ("\\([:|]-*P\\)\\W" 1 "FaceYukky.xpm"))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
71 "Normal and deformed faces for smilies."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
72 :type '(repeat (list regexp
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
73 (integer :tag "Match")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
74 (string :tag "Image")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
75 :group 'smiley)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
76
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
77 (defcustom smiley-nosey-regexp-alist
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
78 '(("\\(:-+[<«]+\\)\\W" 1 "FaceAngry.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
79 ("\\(:-+\\]+\\)\\W" 1 "FaceGoofy.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
80 ("\\(:-+D\\)\\W" 1 "FaceGrinning.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
81 ("\\(:-+[}»]+\\)\\W" 1 "FaceHappy.xpm")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
82 ("\\(:-*)+\\)\\W" 1 "FaceHappy.xpm")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
83 ("\\(:-+[/\\\"]+\\)\\W" 1 "FaceIronic.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
84 ("\\([8|]-+[|Oo%]\\)\\W" 1 "FaceKOed.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
85 ("\\([:|]-+#+\\)\\W" 1 "FaceNyah.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86 ("\\(:-+[({]+\\)\\W" 1 "FaceSad.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 ("\\(:-+[Oo\*]\\)\\W" 1 "FaceStartled.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
88 ("\\(:-+|\\)\\W" 1 "FaceStraight.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
89 ("\\(:-+p\\)\\W" 1 "FaceTalking.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 ("\\(:-+d\\)\\W" 1 "FaceTasty.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
91 ("\\(;-+[>)}»]+\\)\\W" 1 "FaceWinking.xpm")
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
92 ("\\(:-+[Vvµ]\\)\\W" 1 "FaceWry.xpm")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
93 ("\\(][:8B]-[)>]\\)\\W" 1 "FaceDevilish.xpm")
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
94 ("\\([:|]-+P\\)\\W" 1 "FaceYukky.xpm"))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
95 "Smileys with noses. These get less false matches."
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
96 :type '(repeat (list regexp
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
97 (integer :tag "Match")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
98 (string :tag "Image")))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
99 :group 'smiley)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
100
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
101 (defcustom smiley-regexp-alist smiley-deformed-regexp-alist
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
102 "A list of regexps to map smilies to real images.
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
103 Defaults to the contents of `smiley-deformed-regexp-alist'.
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
104 An alternative is `smiley-nosey-regexp-alist' that matches less
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
105 aggressively.
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
106 If this is a symbol, take its value."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
107 :type '(radio (variable-item smiley-deformed-regexp-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
108 (variable-item smiley-nosey-regexp-alist)
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
109 symbol
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
110 (repeat (list regexp
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
111 (integer :tag "Match")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
112 (string :tag "Image"))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
113 :group 'smiley)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
115 (defcustom smiley-flesh-color "yellow"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
116 "Flesh color."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
117 :type 'string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
118 :group 'smiley)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
120 (defcustom smiley-features-color "black"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
121 "Features color."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
122 :type 'string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
123 :group 'smiley)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
124
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
125 (defcustom smiley-tongue-color "red"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
126 "Tongue color."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
127 :type 'string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
128 :group 'smiley)
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 2
diff changeset
129
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
130 (defcustom smiley-circle-color "black"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
131 "Circle color."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
132 :type 'string
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
133 :group 'smiley)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
135 (defcustom smiley-mouse-face 'highlight
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
136 "Face used for mouse highlighting in the smiley buffer.
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
137
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
138 Smiley buttons will be displayed in this face when the cursor is
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
139 above them."
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
140 :type 'face
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
141 :group 'smiley)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
142
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 (defvar smiley-glyph-cache nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (defvar smiley-running-xemacs (string-match "XEmacs" emacs-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
147 (defvar smiley-map (make-sparse-keymap "smiley-keys")
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
148 "Keymap to toggle smiley states.")
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
149
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
150 (define-key smiley-map [(button2)] 'smiley-toggle-extent)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
151
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 (defun smiley-create-glyph (smiley pixmap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 smiley-running-xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (cdr-safe (assoc pixmap smiley-glyph-cache))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
157 (let* ((xpm-color-symbols
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 (and (featurep 'xpm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 (append `(("flesh" ,smiley-flesh-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ("features" ,smiley-features-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ("tongue" ,smiley-tongue-color))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 xpm-color-symbols)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (glyph (make-glyph
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (cons 'x (expand-file-name pixmap smiley-data-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (cons 'tty smiley)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (setq smiley-glyph-cache (cons (cons pixmap glyph) smiley-glyph-cache))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (set-glyph-face glyph 'default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 glyph))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
171 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defun smiley-region (beg end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "Smilify the region between point and mark."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (interactive "r")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (smiley-buffer (current-buffer) beg end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
177 (defun smiley-toggle-extent (event)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
178 "Toggle smiley at given point"
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
179 (interactive "e")
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
180 (let* ((ant (event-glyph-extent event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
181 (pt (event-closest-point event))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
182 ext)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
183 (if (annotationp ant)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
184 (when (extentp (setq ext (extent-property ant 'smiley-extent)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
185 (set-extent-property ext 'invisible nil)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
186 (hide-annotation ant))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
187 (when pt
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
188 (while (setq ext (extent-at pt (event-buffer event) nil ext 'at))
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
189 (when (annotationp (setq ant
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
190 (extent-property ext 'smiley-annotation)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
191 (reveal-annotation ant)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
192 (set-extent-property ext 'invisible t)))))))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
193
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
194 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun smiley-buffer (&optional buffer st nd)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (interactive)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
197 (when (featurep 'x)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
198 (save-excursion
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
199 (when buffer
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
200 (set-buffer buffer))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
201 (let ((buffer-read-only nil)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
202 (alist (if (symbolp smiley-regexp-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
203 (symbol-value smiley-regexp-alist)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
204 smiley-regexp-alist))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
205 entry regexp beg group file)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
206 (goto-char (or st (point-min)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
207 (setq beg (point))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
208 ;; loop through alist
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
209 (while (setq entry (pop alist))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
210 (setq regexp (car entry)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
211 group (cadr entry)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
212 file (caddr entry))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
213 (goto-char beg)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
214 (while (re-search-forward regexp nd t)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
215 (let* ((start (match-beginning group))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
216 (end (match-end group))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
217 (glyph (smiley-create-glyph (buffer-substring start end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
218 file)))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
219 (when glyph
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
220 (mapcar 'delete-annotation (annotations-at end))
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
221 (let ((ext (make-extent start end))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
222 (ant (make-annotation glyph end 'text)))
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
223 ;; set text extent params
70
131b0175ea99 Import from CVS: tag r20-0b30
cvs
parents: 30
diff changeset
224 (set-extent-property ext 'end-open t)
98
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
225 (set-extent-property ext 'start-open t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
226 (set-extent-property ext 'invisible t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
227 (set-extent-property ext 'keymap smiley-map)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
228 (set-extent-property ext 'mouse-face smiley-mouse-face)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
229 (set-extent-property ext 'intangible t)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
230 ;; set annotation params
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
231 (set-extent-property ant 'mouse-face smiley-mouse-face)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
232 (set-extent-property ant 'keymap smiley-map)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
233 ;; remember each other
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
234 (set-extent-property ant 'smiley-extent ext)
0d2f883870bc Import from CVS: tag r20-1b1
cvs
parents: 70
diff changeset
235 (set-extent-property ext 'smiley-annotation ant))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
236 (when (smiley-end-paren-p start end)
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
237 (make-annotation ")" end 'text))
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
238 (goto-char end)))))))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun smiley-end-paren-p (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "Try to guess whether the current smiley is an end-paren smiley."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (when (and (re-search-backward "[()]" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (= (following-char) ?\()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (or (not (re-search-forward "[()]" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (= (char-after (1- (point))) ?\()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
108
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
251 (defvar gnus-article-buffer)
360340f9fd5f Import from CVS: tag r20-1b6
cvs
parents: 98
diff changeset
252 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (defun gnus-smiley-display ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (set-buffer gnus-article-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 ;; We skip the headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (unless (search-forward "\n\n" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (goto-char (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (smiley-buffer (current-buffer) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (provide 'smiley)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;;; smiley.el ends here