1 ;;; riece-biff.el --- biff add-on
2 ;; Copyright (C) 2004 OHASHI Akira
4 ;; Author: OHASHI Akira <bg66@koka-in.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program 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)
14 ;; This program 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.
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.
26 ;; To use, add the following line to your ~/.riece/init.el:
27 ;; (add-to-list 'riece-addons 'riece-biff)
31 (require 'riece-message)
33 (defgroup riece-biff nil
34 "Biff for new arrival messages"
37 (defcustom riece-biff-check-channels nil
38 "*If non-nil, riece-biff checks only the channel contained in this list."
39 :type '(repeat string)
42 (defcustom riece-biff-default-mode-string "[-]"
43 "*String displayed when there is no arrival message."
47 (defcustom riece-biff-biff-mode-string "[R]"
48 "*String displayed when there are new arrival messages."
52 (defvar riece-biff-mode-string 'riece-biff-default-mode-string)
54 (defvar riece-biff-enabled nil)
56 (defconst riece-biff-description
57 "Biff for new arrival messages")
59 (defun riece-biff-after-display-message-function (message)
60 (when (and riece-biff-enabled
61 (not (or (eq (window-buffer (selected-window))
62 (get-buffer riece-command-buffer))
63 (riece-message-own-p message)
64 (riece-message-type message))))
65 (when (or (null riece-biff-check-channels)
66 (member (riece-format-identity (riece-message-target message))
67 riece-biff-check-channels))
68 (setq riece-biff-mode-string 'riece-biff-biff-mode-string))))
70 (defun riece-biff-clear (&optional dummy)
71 (when riece-biff-enabled
72 (setq riece-biff-mode-string 'riece-biff-default-mode-string)))
74 (defun riece-biff-insinuate ()
75 (add-hook 'riece-after-display-message-functions
76 'riece-biff-after-display-message-function)
77 (add-hook 'riece-redisplay-buffers-hook 'riece-biff-clear)
78 (add-hook 'riece-after-switch-to-channel-functions 'riece-biff-clear)
79 (add-hook 'riece-exit-hook 'riece-biff-disable))
81 (defun riece-biff-enable ()
82 (setq global-mode-string
84 ((nlistp global-mode-string)
85 (list "" 'riece-biff-mode-string global-mode-string))
86 ((not (memq 'riece-biff-mode-string global-mode-string))
87 (append '("" riece-biff-mode-string)
88 (remove "" global-mode-string)))
91 (setq riece-biff-enabled t))
93 (defun riece-biff-disable ()
94 (setq global-mode-string
96 ((and (listp global-mode-string)
97 (memq 'riece-biff-mode-string global-mode-string))
98 (remq 'riece-biff-mode-string global-mode-string))
100 global-mode-string)))
102 (setq riece-biff-enabled nil))
104 (provide 'riece-biff)
106 ;;; riece-biff.el ends here