1 ;;; riece-foolproof.el --- prevent miss-operation in the command buffer
2 ;; Copyright (C) 2004 TAKAHASHI Kaoru
4 ;; Author: TAKAHASHI 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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
26 ;; NOTE: This is an add-on module for Riece.
31 (require 'riece-identity)
32 (require 'riece-display))
34 (defconst riece-foolproof-description
35 "Prevent miss-operation in the command buffer.")
37 (defun riece-foolproof-get-channel-window (identity)
39 (cdr (riece-identity-assoc
40 identity riece-channel-buffer-alist))))
42 (defun riece-foolproof-command-send-message-function ()
43 (when (get 'riece-foolproof 'riece-addon-enabled)
44 (unless (or (not riece-channel-buffer-mode)
45 (riece-foolproof-get-channel-window
46 riece-current-channel))
47 (error "Channel %s is not displayed"
48 (riece-identity-prefix riece-current-channel)))
49 (when (text-property-not-all
50 (riece-line-beginning-position) (riece-line-end-position)
52 (error "Invisible text included: %s"
53 (buffer-substring-no-properties
54 (riece-line-beginning-position)
55 (riece-line-end-position))))
56 (when executing-kbd-macro
57 (error "%s" "Forbidden to run keyboard macro"))))
59 (defun riece-foolproof-insinuate ()
60 (add-hook 'riece-command-send-message-hook
61 'riece-foolproof-command-send-message-function))
63 (defun riece-foolproof-uninstall ()
64 (remove-hook 'riece-command-send-message-hook
65 'riece-foolproof-command-send-message-function))
67 (provide 'riece-foolproof)
69 ;;; riece-foolproof.el ends here