aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Love2000-09-21 16:28:06 +0000
committerDave Love2000-09-21 16:28:06 +0000
commit5768681d58479ef65f2bfb7b0311db675a06c183 (patch)
treeaca10bd62620449306430737da4f369635342b14
parent370d860cb1af276062164836329d210f55e41128 (diff)
downloademacs-5768681d58479ef65f2bfb7b0311db675a06c183.tar.gz
emacs-5768681d58479ef65f2bfb7b0311db675a06c183.zip
(smiley-region): Test if display-graphic-p bound
(for Emacs 20). Tidy somewhat.
-rw-r--r--lisp/gnus/smiley-ems.el11
1 files changed, 7 insertions, 4 deletions
diff --git a/lisp/gnus/smiley-ems.el b/lisp/gnus/smiley-ems.el
index 3ccb8b155c3..1d2a9045871 100644
--- a/lisp/gnus/smiley-ems.el
+++ b/lisp/gnus/smiley-ems.el
@@ -48,6 +48,7 @@
48 48
49;; The XEmacs version has a baroque, if not rococo, set of these. 49;; The XEmacs version has a baroque, if not rococo, set of these.
50(defcustom smiley-regexp-alist 50(defcustom smiley-regexp-alist
51 ;; Perhaps :-) should be distinct -- it does appear in the Jargon File.
51 '(("\\([:;]-?)\\)\\W" 1 "smile.xbm") 52 '(("\\([:;]-?)\\)\\W" 1 "smile.xbm")
52 ("\\(:-[/\\]\\)\\W" 1 "wry.xbm") 53 ("\\(:-[/\\]\\)\\W" 1 "wry.xbm")
53 ("\\(:-[({]\\)\\W" 1 "frown.xbm")) 54 ("\\(:-[({]\\)\\W" 1 "frown.xbm"))
@@ -91,7 +92,8 @@ rgexp to replace with IMAGE. IMAGE is the name of an XBM file in
91(defun smiley-region (start end) 92(defun smiley-region (start end)
92 "Replace in the region `smiley-regexp-alist' matches with corresponding images." 93 "Replace in the region `smiley-regexp-alist' matches with corresponding images."
93 (interactive "r") 94 (interactive "r")
94 (when (display-graphic-p) 95 (when (and (fboundp 'display-graphic-p)
96 (display-graphic-p))
95 (mapc (lambda (o) 97 (mapc (lambda (o)
96 (if (eq 'smiley (overlay-get o 'smiley)) 98 (if (eq 'smiley (overlay-get o 'smiley))
97 (delete-overlay o))) 99 (delete-overlay o)))
@@ -100,16 +102,17 @@ rgexp to replace with IMAGE. IMAGE is the name of an XBM file in
100 (smiley-update-cache)) 102 (smiley-update-cache))
101 (save-excursion 103 (save-excursion
102 (let ((beg (or start (point-min))) 104 (let ((beg (or start (point-min)))
103 buffer-read-only entry beg group overlay image) 105 group overlay image)
104 (dolist (entry smiley-cached-regexp-alist) 106 (dolist (entry smiley-cached-regexp-alist)
105 (setq group (nth 1 entry)) 107 (setq group (nth 1 entry)
108 image (nth 2 entry))
106 (goto-char beg) 109 (goto-char beg)
107 (while (re-search-forward (car entry) end t) 110 (while (re-search-forward (car entry) end t)
108 (when image 111 (when image
109 (setq overlay (make-overlay (match-beginning group) 112 (setq overlay (make-overlay (match-beginning group)
110 (match-end group))) 113 (match-end group)))
111 (overlay-put overlay 114 (overlay-put overlay
112 'display `(when smiley-active ,@(nth 2 entry))) 115 'display `(when smiley-active ,@image))
113 (overlay-put overlay 'mouse-face 'highlight) 116 (overlay-put overlay 'mouse-face 'highlight)
114 (overlay-put overlay 'smiley t) 117 (overlay-put overlay 'smiley t)
115 (overlay-put overlay 118 (overlay-put overlay