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)
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 (setq riece-unread-channels
42 (delete (riece-message-target message) riece-unread-channels))
43 (add-to-list 'riece-unread-channels
44 (riece-message-target message))
45 (riece-unread-update-channel-list-buffer)))
47 (defun riece-unread-channel-switch-hook ()
48 (setq riece-unread-channels
49 (delete riece-current-channel
50 riece-unread-channels))
51 (riece-unread-update-channel-list-buffer))
53 (defun riece-unread-update-channel-list-buffer ()
54 (if riece-channel-list-buffer-mode
56 (set-buffer riece-channel-list-buffer)
57 (let ((inhibit-read-only t)
59 (goto-char (point-min))
61 (if (looking-at "\\( ?[0-9]+:\\)\\([ !]\\)\\(.+\\)")
62 (let ((channel (save-match-data
63 (riece-parse-identity (match-string 3)))))
66 (if (member channel riece-unread-channels)
72 (defun riece-unread-switch-to-channel ()
74 (if (car riece-unread-channels)
75 (riece-command-switch-to-channel (car riece-unread-channels))
76 (error "No unread channel!")))
78 (defvar riece-command-mode-map)
79 (defvar riece-dialogue-mode-map)
80 (defvar riece-channel-list-mode-map)
82 (defun riece-unread-insinuate ()
83 (add-hook 'riece-after-display-message-functions
84 'riece-unread-display-message-function)
85 (add-hook 'riece-channel-switch-hook
86 'riece-unread-channel-switch-hook)
87 (add-hook 'riece-update-buffer-functions
88 'riece-unread-update-channel-list-buffer t)
89 (define-key riece-command-mode-map
90 "\C-c\C-u" 'riece-unread-switch-to-channel)
91 (define-key riece-dialogue-mode-map
92 "u" 'riece-unread-switch-to-channel)
93 (define-key riece-channel-list-mode-map
94 "u" 'riece-unread-switch-to-channel))
96 (provide 'riece-unread)
98 ;;; riece-unread.el ends here