aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-09-20 17:08:54 +0000
committerDave Love2000-09-20 17:08:54 +0000
commitb246235beafc86142b3e20d2c5772750293c1147 (patch)
tree5e5c4d5fb6f6253d5c70706458016c7f262a40a3
parent36e44f628900f82e2acce927eb41092421aa82b0 (diff)
downloademacs-b246235beafc86142b3e20d2c5772750293c1147.tar.gz
emacs-b246235beafc86142b3e20d2c5772750293c1147.zip
*** empty log message ***
-rw-r--r--lisp/gnus/ChangeLog2
-rw-r--r--lisp/gnus/frown.xbm6
-rw-r--r--lisp/gnus/smile.xbm6
-rw-r--r--lisp/gnus/smiley-ems.el154
-rw-r--r--lisp/gnus/wry.xbm6
5 files changed, 174 insertions, 0 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index 847ab7eb586..8d9173344ab 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,5 +1,7 @@
12000-09-20 Dave Love <fx@gnu.org> 12000-09-20 Dave Love <fx@gnu.org>
2 2
3 * smiley-ems.el, frown.xbm, smile.xbm, wry.xbm: New files.
4
3 * mail-source.el (mail-source-delete-incoming): Set to t, assuming 5 * mail-source.el (mail-source-delete-incoming): Set to t, assuming
4 we'll be careful merging development changes. 6 we'll be careful merging development changes.
5 7
diff --git a/lisp/gnus/frown.xbm b/lisp/gnus/frown.xbm
new file mode 100644
index 00000000000..838a5bdd048
--- /dev/null
+++ b/lisp/gnus/frown.xbm
@@ -0,0 +1,6 @@
1#define frown_width 13
2#define frown_height 14
3static unsigned char frown_bits[] = {
4 0xf8, 0x03, 0x0c, 0x06, 0x02, 0x08, 0x0d, 0x16, 0x59, 0x13, 0x41, 0x10,
5 0x41, 0x10, 0xe1, 0x10, 0x01, 0x10, 0xf1, 0x11, 0x1a, 0x0b, 0x06, 0x0c,
6 0x18, 0x03, 0xe0, 0x00};
diff --git a/lisp/gnus/smile.xbm b/lisp/gnus/smile.xbm
new file mode 100644
index 00000000000..80504fb82ac
--- /dev/null
+++ b/lisp/gnus/smile.xbm
@@ -0,0 +1,6 @@
1#define smile_width 13
2#define smile_height 14
3static unsigned char smile_bits[] = {
4 0xf8, 0x03, 0x0c, 0x06, 0x02, 0x08, 0x19, 0x13, 0x59, 0x13, 0x41, 0x10,
5 0x41, 0x10, 0xe5, 0x14, 0x0d, 0x16, 0x19, 0x13, 0xf2, 0x09, 0x46, 0x0c,
6 0x18, 0x03, 0xe0, 0x00};
diff --git a/lisp/gnus/smiley-ems.el b/lisp/gnus/smiley-ems.el
new file mode 100644
index 00000000000..3ccb8b155c3
--- /dev/null
+++ b/lisp/gnus/smiley-ems.el
@@ -0,0 +1,154 @@
1;;; smiley-ems.el --- displaying smiley faces
2;; Copyright (C) 2000 Free Software Foundation, Inc.
3
4;; Author: Dave Love <fx@gnu.org>
5;; Keywords: news mail multimedia
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software; you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation; either version 2, or (at your option)
12;; any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs; see the file COPYING. If not, write to the
21;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22;; Boston, MA 02111-1307, USA.
23
24;;; Commentary:
25
26;; A re-written, simplified version of Wes Hardaker's XEmacs smiley.el
27;; which might be merged back to smiley.el if we get an assignment for
28;; that. We don't have assignments for the images smiley.el uses, but
29;; I'm not sure we need that degree of rococoness and they shouldn't
30;; have a yellow background by default. Also, using XBM means we can
31;; display the images more generally. -- fx
32
33;;; Test smileys: :-) :-\ :-( :-/
34
35;;; Code:
36
37(require 'nnheader)
38
39(defgroup smiley nil
40 "Turn :-)'s into real images."
41 :group 'gnus-visual)
42
43;; Maybe this should go.
44(defcustom smiley-data-directory (nnheader-find-etc-directory "smilies")
45 "*Location of the smiley faces files."
46 :type 'directory
47 :group 'smiley)
48
49;; The XEmacs version has a baroque, if not rococo, set of these.
50(defcustom smiley-regexp-alist
51 '(("\\([:;]-?)\\)\\W" 1 "smile.xbm")
52 ("\\(:-[/\\]\\)\\W" 1 "wry.xbm")
53 ("\\(:-[({]\\)\\W" 1 "frown.xbm"))
54 "*A list of regexps to map smilies to images.
55The elements are (REGEXP MATCH FILE), where MATCH is the submatch in
56rgexp to replace with IMAGE. IMAGE is the name of an XBM file in
57`smiley-data-directory'."
58 :type '(repeat (list regexp
59 (integer :tag "Regexp match number")
60 (string :tag "Image name")))
61 :set (lambda (symbol value)
62 (set-default symbol value)
63 (smiley-update-cache))
64 :initialize 'custom-initialize-default
65 :group 'smiley)
66
67(defvar smiley-cached-regexp-alist nil)
68
69(defun smiley-update-cache ()
70 (dolist (elt smiley-regexp-alist)
71 (let* ((data-directory smiley-data-directory)
72 (image (find-image (list (list :type 'xbm
73 :file (nth 2 elt)
74 :ascent 100)))))
75 (if image
76 (push (list (car elt) (cadr elt) image)
77 smiley-cached-regexp-alist)))))
78
79(defvar smiley-active nil
80 "Non-nil means smilies in the buffer will be displayed.")
81(make-variable-buffer-local 'smiley-active)
82
83(defvar smiley-mouse-map
84 (let ((map (make-sparse-keymap)))
85 (define-key map [down-mouse-2] 'ignore) ; override widget
86 (define-key map [mouse-2]
87 'smiley-mouse-toggle-buffer)
88 map))
89
90;;;###autoload
91(defun smiley-region (start end)
92 "Replace in the region `smiley-regexp-alist' matches with corresponding images."
93 (interactive "r")
94 (when (display-graphic-p)
95 (mapc (lambda (o)
96 (if (eq 'smiley (overlay-get o 'smiley))
97 (delete-overlay o)))
98 (overlays-in start end))
99 (unless smiley-cached-regexp-alist
100 (smiley-update-cache))
101 (save-excursion
102 (let ((beg (or start (point-min)))
103 buffer-read-only entry beg group overlay image)
104 (dolist (entry smiley-cached-regexp-alist)
105 (setq group (nth 1 entry))
106 (goto-char beg)
107 (while (re-search-forward (car entry) end t)
108 (when image
109 (setq overlay (make-overlay (match-beginning group)
110 (match-end group)))
111 (overlay-put overlay
112 'display `(when smiley-active ,@(nth 2 entry)))
113 (overlay-put overlay 'mouse-face 'highlight)
114 (overlay-put overlay 'smiley t)
115 (overlay-put overlay
116 'help-echo "mouse-2: toggle smilies in buffer")
117 (overlay-put overlay 'keymap smiley-mouse-map))))))
118 (setq smiley-active t)))
119
120(defun smiley-toggle-buffer (&optional arg)
121 "Toggle displaying smiley faces.
122With arg, turn displaying on if and only if arg is positive."
123 (interactive "P")
124 (if (numberp arg)
125 (setq smiley-active (> arg 0))
126 (setq smiley-active (not smiley-active))))
127
128(defun smiley-mouse-toggle-buffer (event)
129 "Toggle displaying smiley faces.
130With arg, turn displaying on if and only if arg is positive."
131 (interactive "e")
132 (save-excursion
133 (save-window-excursion
134 (mouse-set-point event)
135 (smiley-toggle-buffer))))
136
137(eval-when-compile (defvar gnus-article-buffer))
138
139(defun gnus-smiley-display (&optional arg)
140 "Display textual emoticaons (\"smilies\") as small graphical icons.
141With arg, turn displaying on if and only if arg is positive."
142 (interactive "P")
143 (save-excursion
144 (set-buffer gnus-article-buffer)
145 (save-restriction
146 (widen)
147 (article-goto-body)
148 (smiley-region (point-min) (point-max))
149 (if (and (numberp arg) (<= arg 0))
150 (smiley-toggle-buffer arg)))))
151
152(provide 'smiley)
153
154;;; smiley-ems.el ends here
diff --git a/lisp/gnus/wry.xbm b/lisp/gnus/wry.xbm
new file mode 100644
index 00000000000..1716f111cef
--- /dev/null
+++ b/lisp/gnus/wry.xbm
@@ -0,0 +1,6 @@
1#define wry_width 13
2#define wry_height 14
3static unsigned char wry_bits[] = {
4 0xf8, 0x03, 0x0c, 0x06, 0x02, 0x08, 0x19, 0x13, 0x59, 0x12, 0x41, 0x10,
5 0x41, 0x10, 0xe1, 0x10, 0x0d, 0x10, 0x79, 0x10, 0xe2, 0x0b, 0x06, 0x0f,
6 0x18, 0x03, 0xe0, 0x00};