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)
34 (require 'riece-identity)
35 (require 'riece-display))
37 (defvar riece-foolproof-enabled nil)
39 (defconst riece-foolproof-description
40 "Channel miss killer")
42 (defun riece-foolproof-get-channel-window (identity)
44 (cdr (riece-identity-assoc
45 identity riece-channel-buffer-alist))))
47 (defun riece-foolproof-command-send-message-function ()
48 (when riece-foolproof-enabled
49 (unless (or (not riece-channel-buffer-mode)
50 (riece-foolproof-get-channel-window
51 riece-current-channel))
52 (error "Channel %s is not displayed"
53 (riece-identity-prefix riece-current-channel)))
54 (when (text-property-not-all
55 (riece-line-beginning-position) (riece-line-end-position)
57 (error "Invisible text included: %s"
58 (buffer-substring-no-properties
59 (riece-line-beginning-position)
60 (riece-line-end-position))))
61 (when executing-kbd-macro
62 (error "%s" "Forbidden to run keyboard macro"))))
64 (defun riece-foolproof-insinuate ()
65 (add-hook 'riece-command-send-message-hook
66 'riece-foolproof-command-send-message-function))
68 (defun riece-foolproof-enable ()
69 (setq riece-foolproof-enabled t))
71 (defun riece-foolproof-disable ()
72 (setq riece-foolproof-enabled nil))
74 (provide 'riece-foolproof)
76 ;;; riece-foolproof.el ends here