1 ;;; riece-biff.el --- be notified if messages arrives
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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
26 ;; NOTE: This is an add-on module for Riece.
30 (require 'riece-message)
32 (defgroup riece-biff nil
33 "Be notified if messages arrives."
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 (defconst riece-biff-description
55 "Be notified if messages arrives.")
57 (defun riece-biff-after-display-message-function (message)
58 (when (and (get 'riece-biff 'riece-addon-enabled)
59 (not (or (eq (window-buffer (selected-window))
60 (get-buffer riece-command-buffer))
61 (riece-message-own-p message)
62 (riece-message-type message))))
63 (when (or (null riece-biff-check-channels)
64 (member (riece-format-identity (riece-message-target message))
65 riece-biff-check-channels))
66 (setq riece-biff-mode-string 'riece-biff-biff-mode-string))))
68 (defun riece-biff-clear (&optional dummy)
69 (when (get 'riece-biff 'riece-addon-enabled)
70 (setq riece-biff-mode-string 'riece-biff-default-mode-string)))
72 (defun riece-biff-insinuate ()
73 (add-hook 'riece-after-display-message-functions
74 'riece-biff-after-display-message-function)
75 (add-hook 'riece-redisplay-buffers-hook 'riece-biff-clear)
76 (add-hook 'riece-after-switch-to-channel-functions 'riece-biff-clear)
77 (add-hook 'riece-exit-hook 'riece-biff-disable))
79 (defun riece-biff-uninstall ()
80 (remove-hook 'riece-after-display-message-functions
81 'riece-biff-after-display-message-function)
82 (remove-hook 'riece-redisplay-buffers-hook 'riece-biff-clear)
83 (remove-hook 'riece-after-switch-to-channel-functions 'riece-biff-clear)
84 (remove-hook 'riece-exit-hook 'riece-biff-disable))
86 (defun riece-biff-enable ()
87 (setq global-mode-string
89 ((nlistp global-mode-string)
90 (list "" 'riece-biff-mode-string global-mode-string))
91 ((not (memq 'riece-biff-mode-string global-mode-string))
92 (append '("" riece-biff-mode-string)
93 (remove "" global-mode-string)))
95 global-mode-string))))
97 (defun riece-biff-disable ()
98 (setq global-mode-string
100 ((and (listp global-mode-string)
101 (memq 'riece-biff-mode-string global-mode-string))
102 (remq 'riece-biff-mode-string global-mode-string))
104 global-mode-string)))
107 (provide 'riece-biff)
109 ;;; riece-biff.el ends here