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 (eval-when-compile (require 'riece-inlines))
29 (require 'riece-globals)
32 (defgroup riece-highlight nil
33 "Highlight your IRC buffer"
38 (defgroup riece-highlight-faces nil
39 "Faces for highlight your IRC buffer"
41 :prefix "riece-highlight-"
42 :group 'riece-highlight)
44 (defcustom riece-change-face 'riece-change-face
45 "Face used for displaying \"*** Change:\" line."
47 :group 'riece-highlight-faces)
49 (defcustom riece-notice-face 'riece-notice-face
50 "Face used for displaying \"*** Notice:\" line."
52 :group 'riece-highlight-faces)
54 (defcustom riece-wallops-face 'riece-wallops-face
55 "Face used for displaying \"*** Wallops:\" line."
57 :group 'riece-highlight-faces)
59 (defcustom riece-error-face 'riece-error-face
60 "Face used for displaying \"*** Error:\" line."
62 :group 'riece-highlight-faces)
64 (defcustom riece-info-face 'riece-info-face
65 "Face used for displaying \"*** Info:\" line."
67 :group 'riece-highlight-faces)
69 (defcustom riece-server-face 'riece-server-face
70 "Face used for displaying \"(from server)\" extent."
72 :group 'riece-highlight-faces)
74 (defcustom riece-prefix-face 'riece-prefix-face
75 "Face used for displaying \"<nick>\" extent."
77 :group 'riece-highlight-faces)
79 (defface riece-change-face
82 (:foreground "cyan" :bold t))
85 (:foreground "RoyalBlue" :bold t))
88 "Face used for displaying \"*** Change:\" line"
89 :group 'riece-highlight-faces)
91 (defface riece-notice-face
94 (:foreground "green2" :bold t))
97 (:foreground "MidnightBlue" :bold t))
100 "Face used for displaying \"*** Notice:\" line"
101 :group 'riece-highlight-faces)
103 (defface riece-wallops-face
106 (:foreground "yellow" :bold t))
109 (:foreground "blue4" :bold t))
112 "Face used for displaying \"*** Wallops:\" line"
113 :group 'riece-highlight-faces)
115 (defface riece-error-face
118 (:foreground "cornflower blue" :bold t))
121 (:foreground "DarkGreen"))
124 "Face used for displaying \"*** Error:\" line"
125 :group 'riece-highlight-faces)
127 (defface riece-info-face
130 (:foreground "PaleTurquoise" :bold t))
133 (:foreground "RoyalBlue"))
136 "Face used for displaying \"*** Info:\" line"
137 :group 'riece-highlight-faces)
139 (defface riece-server-face
142 (:foreground "Gray70"))
145 (:foreground "DimGray"))
148 "Face used for displaying \"(from server)\" extent."
149 :group 'riece-highlight-faces)
151 (defface riece-prefix-face
154 (:foreground "moccasin"))
157 (:foreground "firebrick"))
160 "Face used for displaying \"<nick>\" extent"
161 :group 'riece-highlight-faces)
163 (defcustom riece-highlight-font-lock-keywords
167 "^\\(" riece-time-prefix-regexp "\\)?"
168 "\\(\\([][<>(-][][<>(-]?[^<>)]*[][<>)-][][<>)-]?\\)\\|"
169 "\\(=[^ ]*=\\|\\*\\*[^ \*]*\\*\\*\\)\\) ")
170 (3 riece-prefix-face append t)))
171 ;; set property to the whole line
176 "^\\(" riece-time-prefix-regexp "\\)?\\("
178 (symbol-value (intern (format "riece-%s-prefix" line))))
180 (list 2 (intern (format "riece-%s-face" line)) t t)))
181 '(change notice wallops error info))
182 (list (list "(from [^)]+)$" 0 riece-server-face t)))
183 "Normal and deformed faces for IRC normal line."
184 :type '(repeat (list string))
185 :group 'riece-highlight)
187 (defun riece-highlight-schedule-turn-on-font-lock ()
188 (add-hook 'riece-channel-mode-hook
189 'riece-highlight-turn-on-font-lock)
190 (add-hook 'riece-others-mode-hook
191 'riece-highlight-turn-on-font-lock)
192 (add-hook 'riece-dialogue-mode-hook
193 'riece-highlight-turn-on-font-lock))
195 (defvar font-lock-support-mode)
196 (defun riece-highlight-turn-on-font-lock ()
197 (make-local-variable 'font-lock-defaults)
198 (setq font-lock-defaults '(riece-highlight-font-lock-keywords t))
199 (make-local-variable 'font-lock-verbose)
200 (setq font-lock-verbose nil)
201 (when (boundp 'font-lock-support-mode)
202 (make-local-variable 'font-lock-support-mode)
203 (setq font-lock-support-mode nil))
204 (make-local-hook 'font-lock-mode-hook)
205 (setq font-lock-mode-hook nil)
207 (make-local-hook 'after-change-functions)
208 (add-hook 'after-change-functions
209 'riece-highlight-hide-prefix nil 'local))
211 (defun riece-highlight-hide-prefix (start end length)
214 (if (looking-at riece-prefix-regexp)
215 (put-text-property (match-beginning 1) (match-end 1) 'invisible t))))
217 (defun riece-highlight-insinuate ()
218 (put 'riece-channel-mode 'font-lock-defaults
219 '(riece-highlight-font-lock-keywords t))
220 (put 'riece-others-mode 'font-lock-defaults
221 '(riece-highlight-font-lock-keywords t))
222 (put 'riece-dialogue-mode 'font-lock-defaults
223 '(riece-highlight-font-lock-keywords t))
224 (add-hook 'riece-after-load-startup-hook
225 'riece-highlight-schedule-turn-on-font-lock))
227 (provide 'riece-highlight)
229 ;;; riece-highlight.el ends here