1 ;;; riece-unread.el --- "unread message mark" add-on
2 ;; Copyright (C) 1998-2003 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.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 ;; This add-on displays unread mark ("!") for channels which have
29 ;; To use, add the following line to your ~/.riece/init.el:
30 ;; (add-to-list 'riece-addons 'riece-unread t)
34 (eval-when-compile (require 'riece-message))
36 (defvar riece-unread-channels nil)
38 (defun riece-unread-display-message-function (message)
39 (unless (or (riece-message-own-p message)
40 (equal (riece-message-target message) riece-current-channel))
41 (add-to-list 'riece-unread-channels
42 (riece-message-target message))
43 (riece-unread-update-channel-list-buffer)))
45 (defun riece-unread-channel-switch-hook ()
46 (setq riece-unread-channels
47 (delete riece-current-channel
48 riece-unread-channels))
49 (riece-unread-update-channel-list-buffer))
51 (defun riece-unread-update-channel-list-buffer ()
52 (if riece-channel-list-buffer-mode
54 (set-buffer riece-channel-list-buffer)
55 (let ((inhibit-read-only t)
57 (goto-char (point-min))
59 (if (looking-at "\\( ?[0-9]+:\\)\\([ !]\\)\\(.+\\)")
60 (let ((channel (match-string 3)))
63 (if (member channel riece-unread-channels)
69 (defun riece-unread-insinuate ()
70 (add-hook 'riece-after-display-message-functions
71 'riece-unread-display-message-function)
72 (add-hook 'riece-channel-switch-hook
73 'riece-unread-channel-switch-hook)
74 (add-hook 'riece-update-buffers-hook
75 'riece-unread-update-channel-list-buffer))
77 (provide 'riece-unread)
79 ;;; riece-unread.el ends here