* riece-foolproof.el: New add-on.
authorTAKAHASHI Kaoru <kaoru@kaisei.org>
Thu, 10 Jun 2004 14:05:58 +0000 (14:05 +0000)
committerTAKAHASHI Kaoru <kaoru@kaisei.org>
Thu, 10 Jun 2004 14:05:58 +0000 (14:05 +0000)
* COMPILE (riece-modules): Add riece-foolproof.
* Makefile.am (EXTRA_DIST): Add riece-foolproof.el.

lisp/COMPILE
lisp/ChangeLog
lisp/Makefile.am
lisp/riece-foolproof.el [new file with mode: 0644]

index 6073246..709cb1d 100644 (file)
@@ -55,6 +55,7 @@
                riece-doctor
                riece-alias
                riece-skk-kakutei
                riece-doctor
                riece-alias
                riece-skk-kakutei
+               riece-foolproof
                riece-guess
                riece-history
                riece-button
                riece-guess
                riece-history
                riece-button
index fab4685..72fded6 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-10  TAKAHASHI Kaoru  <kaoru@kaisei.org>
+
+       * riece-foolproof.el: New add-on.
+       * COMPILE (riece-modules): Add riece-foolproof.
+       * Makefile.am (EXTRA_DIST): Add riece-foolproof.el.
+
 2004-06-10  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-commands.el (riece-command-change-mode): Don't send ":" to
 2004-06-10  Daiki Ueno  <ueno@unixuser.org>
 
        * riece-commands.el (riece-command-change-mode): Don't send ":" to
index 7e9e8bf..746eb36 100644 (file)
@@ -12,7 +12,7 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \
        riece-guess.el riece-history.el riece-button.el riece-keyword.el \
        riece-menu.el riece-icon.el riece-async.el riece-lsdb.el \
        riece-xface.el riece-ctlseq.el riece-ignore.el riece-hangman.el \
        riece-guess.el riece-history.el riece-button.el riece-keyword.el \
        riece-menu.el riece-icon.el riece-async.el riece-lsdb.el \
        riece-xface.el riece-ctlseq.el riece-ignore.el riece-hangman.el \
-       riece-biff.el riece-kakasi.el
+       riece-biff.el riece-kakasi.el riece-foolproof.el
 
 CLEANFILES = auto-autoloads.el custom-load.el *.elc
 FLAGS ?= -batch -q -no-site-file
 
 CLEANFILES = auto-autoloads.el custom-load.el *.elc
 FLAGS ?= -batch -q -no-site-file
diff --git a/lisp/riece-foolproof.el b/lisp/riece-foolproof.el
new file mode 100644 (file)
index 0000000..226d654
--- /dev/null
@@ -0,0 +1,77 @@
+;;; riece-foolproof.el --- channel miss killer
+;; Copyright (C) 2004 TAKAHASHI Kaoru
+
+;; Author: TAKAHASHI "beatmaria" Kaoru <kaoru@kaisei.org>
+;; Keywords: IRC, riece
+
+;; This file is part of Riece.
+
+;; This program is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License as
+;; published by the Free Software Foundation; either version 2, or (at
+;; your option) any later version.
+
+;; This program is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
+
+;;; Commentary:
+
+;; This add-on channel miss hold in check
+
+;; To use, add the following line to your ~/.riece/init.el:
+;; (add-to-list 'riece-addons 'riece-foolproof)
+
+;;; Code:
+
+(eval-when-compile (require 'riece))
+
+(defvar riece-foolproof-enabled nil)
+
+(defconst riece-foolproof-description
+  "Disable channel miss")
+
+(defun riece-foolproof-command-enter-message ()
+  "Send the current line to the current channel."
+  (interactive)
+  (when (riece-foolproof)
+    (riece-command-enter-message)))
+
+(defun riece-foolproof-command-enter-message-as-notice ()
+  "Send the current line to the current channel as NOTICE."
+  (interactive)
+  (when (riece-foolproof)
+    (riece-command-enter-message-as-notice)))
+
+(defun riece-foolproof-get-channel-window (identity)
+  (get-buffer-window
+   (cdr (riece-identity-assoc
+        identity riece-channel-buffer-alist))))
+
+(defun riece-foolproof-insinuate ()
+  (defadvice riece-command-send-message (before riece-foolproof)
+    (unless (or (not riece-channel-buffer-mode)
+               (riece-foolproof-get-channel-window
+                riece-current-channel))
+      (error "%s is not displayed. (maybe channel miss)"
+            (riece-identity-prefix riece-current-channel)))))
+
+(defun riece-foolproof-enable ()
+  (ad-enable-advice 'riece-command-send-message 'before 'riece-foolproof)
+  (ad-activate 'riece-command-send-message)
+  (setq riece-foolproof-enabled t))
+
+(defun riece-foolproof-disable ()
+  (ad-disable-advice 'riece-command-send-message 'before 'riece-foolproof)
+  (ad-activate 'riece-command-send-message)
+  (setq riece-foolproof-enabled nil))
+
+(provide 'riece-foolproof)
+
+;;; riece-foolproof.el ends here