1 ;;; riece-highlight.el --- coloring IRC buffers
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 (require 'riece-globals)
30 (defgroup riece-highlight nil
31 "Highlight your IRC buffer"
36 (defgroup riece-highlight-faces nil
37 "Faces for highlight your IRC buffer"
39 :prefix "riece-highlight-"
40 :group 'riece-highlight)
42 (defcustom riece-dialogue-change-face 'riece-dialogue-change-face
43 "Face used for displaying \"*** Change:\" line."
45 :group 'riece-highlight-faces)
47 (defcustom riece-dialogue-notice-face 'riece-dialogue-notice-face
48 "Face used for displaying \"*** Notice:\" line."
50 :group 'riece-highlight-faces)
52 (defcustom riece-dialogue-wallops-face 'riece-dialogue-wallops-face
53 "Face used for displaying \"*** Wallops:\" line."
55 :group 'riece-highlight-faces)
57 (defcustom riece-dialogue-error-face 'riece-dialogue-error-face
58 "Face used for displaying \"*** Error:\" line."
60 :group 'riece-highlight-faces)
62 (defcustom riece-dialogue-info-face 'riece-dialogue-info-face
63 "Face used for displaying \"*** Info:\" line."
65 :group 'riece-highlight-faces)
67 (defcustom riece-dialogue-server-face 'riece-dialogue-server-face
68 "Face used for displaying \"(from server)\" extent."
70 :group 'riece-highlight-faces)
72 (defcustom riece-dialogue-prefix-face 'riece-dialogue-prefix-face
73 "Face used for displaying \"<nick>\" extent."
75 :group 'riece-highlight-faces)
77 (defface riece-dialogue-change-face
80 (:foreground "cyan" :bold t))
83 (:foreground "RoyalBlue" :bold t))
86 "Face used for displaying \"*** Change:\" line"
87 :group 'riece-highlight-faces)
89 (defface riece-dialogue-notice-face
92 (:foreground "green2" :bold t))
95 (:foreground "MidnightBlue" :bold t))
98 "Face used for displaying \"*** Notice:\" line"
99 :group 'riece-highlight-faces)
101 (defface riece-dialogue-wallops-face
104 (:foreground "yellow" :bold t))
107 (:foreground "blue4" :bold t))
110 "Face used for displaying \"*** Wallops:\" line"
111 :group 'riece-highlight-faces)
113 (defface riece-dialogue-error-face
116 (:foreground "cornflower blue" :bold t))
119 (:foreground "DarkGreen"))
122 "Face used for displaying \"*** Error:\" line"
123 :group 'riece-highlight-faces)
125 (defface riece-dialogue-info-face
128 (:foreground "PaleTurquoise" :bold t))
131 (:foreground "RoyalBlue"))
134 "Face used for displaying \"*** Info:\" line"
135 :group 'riece-highlight-faces)
137 (defface riece-dialogue-server-face
140 (:foreground "Gray70"))
143 (:foreground "DimGray"))
146 "Face used for displaying \"(from server)\" extent."
147 :group 'riece-highlight-faces)
149 (defface riece-dialogue-prefix-face
152 (:foreground "moccasin"))
155 (:foreground "firebrick"))
158 "Face used for displaying \"<nick>\" extent"
159 :group 'riece-highlight-faces)
161 (defcustom riece-dialogue-font-lock-keywords
163 (list (list (concat "^" riece-time-prefix-regexp
164 "\\(<[^>]+>\\|>[^<]+<\\|([^)]+)\\|{[^}]+}\\|=[^=]+=\\)")
165 '(1 riece-dialogue-prefix-face append t)))
166 ;; set property to the whole line
171 "^" riece-time-prefix-regexp "\\("
173 (symbol-value (intern (format "riece-%s-prefix" line))))
175 (list 1 (intern (format "riece-dialogue-%s-face" line)) t t)))
176 '(change notice wallops error info))
177 (list (list "(from [^)]+)$" 0 riece-dialogue-server-face t)))
178 "Default expressions to highlight in riece-dialogue-mode."
179 :type '(repeat (list string))
180 :group 'riece-highlight)
182 (defcustom riece-channel-list-default-face 'riece-channel-list-default-face
183 "Face used for displaying channels."
185 :group 'riece-highlight-faces)
187 (defcustom riece-channel-list-current-face 'riece-channel-list-current-face
188 "Face used for displaying the current channel."
190 :group 'riece-highlight-faces)
192 (defface riece-channel-list-default-face
195 (:foreground "turquoise"))
198 (:foreground "CadetBlue4"))
201 "Face used for displaying channels."
202 :group 'riece-highlight-faces)
204 (defface riece-channel-list-current-face
207 (:foreground "PaleTurquoise" :underline t))
210 (:foreground "ForestGreen" :underline t))
213 "Face used for displaying the current channel."
214 :group 'riece-highlight-faces)
216 (defcustom riece-channel-list-mark-face-alist
217 '((?* . riece-channel-list-current-face))
218 "An alist mapping marks on riece-channel-list-buffer to faces."
220 :group 'riece-highlight)
222 (defcustom riece-channel-list-font-lock-keywords
223 '(("^[ 0-9][0-9]:\\(.\\)\\(.*\\)"
224 (2 (or (cdr (assq (aref (match-string 1) 0)
225 riece-channel-list-mark-face-alist))
226 riece-channel-list-default-face))))
227 "Default expressions to highlight in riece-channel-list-mode."
228 :type '(repeat (list string))
229 :group 'riece-highlight)
231 (defun riece-dialogue-schedule-turn-on-font-lock ()
232 (add-hook 'riece-channel-mode-hook
233 'riece-dialogue-turn-on-font-lock)
234 (add-hook 'riece-others-mode-hook
235 'riece-dialogue-turn-on-font-lock)
236 (add-hook 'riece-dialogue-mode-hook
237 'riece-dialogue-turn-on-font-lock))
239 (defun riece-channel-list-schedule-turn-on-font-lock ()
240 (add-hook 'riece-channel-list-mode-hook
241 'riece-channel-list-turn-on-font-lock))
243 (defvar font-lock-support-mode)
244 (defun riece-dialogue-turn-on-font-lock ()
245 (make-local-variable 'font-lock-defaults)
246 (setq font-lock-defaults '(riece-dialogue-font-lock-keywords t))
247 (make-local-variable 'font-lock-verbose)
248 (setq font-lock-verbose nil)
249 (when (boundp 'font-lock-support-mode)
250 (make-local-variable 'font-lock-support-mode)
251 (setq font-lock-support-mode nil))
252 (make-local-hook 'font-lock-mode-hook)
253 (setq font-lock-mode-hook nil)
255 (make-local-hook 'after-change-functions)
256 (add-hook 'after-change-functions
257 'riece-dialogue-hide-prefix nil 'local))
259 (defun riece-dialogue-hide-prefix (start end length)
262 (if (looking-at riece-prefix-regexp)
263 (put-text-property (match-beginning 1) (match-end 1) 'invisible t))))
265 (defun riece-channel-list-turn-on-font-lock ()
266 (make-local-variable 'font-lock-defaults)
267 (setq font-lock-defaults '(riece-channel-list-font-lock-keywords t))
268 (make-local-variable 'font-lock-verbose)
269 (setq font-lock-verbose nil)
270 (when (boundp 'font-lock-support-mode)
271 (make-local-variable 'font-lock-support-mode)
272 (setq font-lock-support-mode nil))
273 (make-local-hook 'font-lock-mode-hook)
274 (setq font-lock-mode-hook nil)
277 (defun riece-highlight-insinuate ()
278 (put 'riece-channel-mode 'font-lock-defaults
279 '(riece-dialogue-font-lock-keywords t))
280 (put 'riece-others-mode 'font-lock-defaults
281 '(riece-dialogue-font-lock-keywords t))
282 (put 'riece-dialogue-mode 'font-lock-defaults
283 '(riece-dialogue-font-lock-keywords t))
284 (add-hook 'riece-after-load-startup-hook
285 'riece-dialogue-schedule-turn-on-font-lock)
286 (put 'riece-channel-list-mode 'font-lock-defaults
287 '(riece-channel-list-font-lock-keywords t))
288 (add-hook 'riece-after-load-startup-hook
289 'riece-channel-list-schedule-turn-on-font-lock))
291 (provide 'riece-highlight)
293 ;;; riece-highlight.el ends here