Add riece-debug-standard-output-buffer to riece-buffer-list.
[riece] / lisp / riece-biff.el
1 ;;; riece-biff.el --- biff add-on
2 ;; Copyright (C) 2004 OHASHI Akira
3
4 ;; Author: OHASHI Akira <bg66@koka-in.org>
5 ;; Keywords: IRC, riece
6
7 ;; This file is part of Riece.
8
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)
12 ;; any later version.
13
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.
18
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.
23
24 ;;; Commentary:
25
26 ;; To use, add the following line to your ~/.riece/init.el:
27 ;; (add-to-list 'riece-addons 'riece-biff)
28
29 ;;; Code:
30
31 (require 'riece-message)
32
33 (defgroup riece-biff nil
34   "Biff for new arrival messages"
35   :group 'riece)
36
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)
40   :group 'riece-biff)
41
42 (defcustom riece-biff-default-mode-string "[-]"
43   "*String displayed when there is no arrival message."
44   :type 'string
45   :group 'riece-biff)
46
47 (defcustom riece-biff-biff-mode-string "[R]"
48   "*String displayed when there are new arrival messages."
49   :type 'string
50   :group 'riece-biff)
51
52 (defcustom riece-biff-functions nil
53   "*Functions for processing new arrival messages."
54   :type 'function
55   :group 'riece-biff)
56
57 (defvar riece-biff-mode-string 'riece-biff-default-mode-string)
58
59 (defvar riece-biff-enabled nil)
60
61 (defconst riece-biff-description
62   "Biff for new arrival messages")
63
64 (defun riece-biff-after-display-message-function (message)
65   (when (and riece-biff-enabled
66              (not (or (eq (window-buffer (selected-window))
67                           (get-buffer riece-command-buffer))
68                       (riece-message-own-p message)
69                       (riece-message-type message))))
70     (when (or (null riece-biff-check-channels)
71               (member (riece-format-identity (riece-message-target message))
72                       riece-biff-check-channels))
73       (setq riece-biff-mode-string 'riece-biff-biff-mode-string)
74       (run-hook-with-args 'riece-biff-functions message))))
75
76 (defun riece-biff-clear (&optional dummy)
77   (when riece-biff-enabled
78     (setq riece-biff-mode-string 'riece-biff-default-mode-string)))
79
80 (defun riece-biff-insinuate ()
81   (add-hook 'riece-after-display-message-functions
82             'riece-biff-after-display-message-function)
83   (add-hook 'riece-redisplay-buffers-hook 'riece-biff-clear)
84   (add-hook 'riece-after-switch-to-channel-functions 'riece-biff-clear)
85   (add-hook 'riece-exit-hook 'riece-biff-disable))
86
87 (defun riece-biff-enable ()
88   (setq global-mode-string
89         (cond
90          ((nlistp global-mode-string)
91           (list "" 'riece-biff-mode-string global-mode-string))
92          ((not (memq 'riece-biff-mode-string global-mode-string))
93           (append '("" riece-biff-mode-string)
94                   (remove "" global-mode-string)))
95          (t
96           global-mode-string)))
97   (setq riece-biff-enabled t))
98
99 (defun riece-biff-disable ()
100   (setq global-mode-string
101         (cond
102          ((and (listp global-mode-string)
103                (memq 'riece-biff-mode-string global-mode-string))
104           (remq 'riece-biff-mode-string global-mode-string))
105          (t
106           global-mode-string)))
107   (riece-biff-clear)
108   (setq riece-biff-enabled nil))
109
110 (provide 'riece-biff)
111
112 ;;; riece-biff.el ends here