1 ;;; riece-foolproof.el --- channel miss killer
2 ;; Copyright (C) 2004 TAKAHASHI Kaoru
4 ;; Author: TAKAHASHI "beatmaria" Kaoru <kaoru@kaisei.org>
5 ;; Keywords: IRC, riece
7 ;; This file is part of Riece.
9 ;; This program is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation; either version 2, or (at
12 ;; your option) any later version.
14 ;; This program is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; 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 channel miss hold in check
28 ;; To use, add the following line to your ~/.riece/init.el:
29 ;; (add-to-list 'riece-addons 'riece-foolproof)
33 (eval-when-compile (require 'riece))
35 (defvar riece-foolproof-enabled nil)
37 (defconst riece-foolproof-description
38 "Disable channel miss")
40 (defun riece-foolproof-command-enter-message ()
41 "Send the current line to the current channel."
43 (when (riece-foolproof)
44 (riece-command-enter-message)))
46 (defun riece-foolproof-command-enter-message-as-notice ()
47 "Send the current line to the current channel as NOTICE."
49 (when (riece-foolproof)
50 (riece-command-enter-message-as-notice)))
52 (defun riece-foolproof-get-channel-window (identity)
54 (cdr (riece-identity-assoc
55 identity riece-channel-buffer-alist))))
57 (defun riece-foolproof-insinuate ()
58 (defadvice riece-command-send-message (before riece-foolproof)
59 (unless (or (not riece-channel-buffer-mode)
60 (riece-foolproof-get-channel-window
61 riece-current-channel))
62 (error "%s is not displayed. (maybe channel miss)"
63 (riece-identity-prefix riece-current-channel)))))
65 (defun riece-foolproof-enable ()
66 (ad-enable-advice 'riece-command-send-message 'before 'riece-foolproof)
67 (ad-activate 'riece-command-send-message)
68 (setq riece-foolproof-enabled t))
70 (defun riece-foolproof-disable ()
71 (ad-disable-advice 'riece-command-send-message 'before 'riece-foolproof)
72 (ad-activate 'riece-command-send-message)
73 (setq riece-foolproof-enabled nil))
75 (provide 'riece-foolproof)
77 ;;; riece-foolproof.el ends here