* server.rb: Added logging feature.
[riece] / lisp / riece-eval-ruby.el
index 21ff25d..c280df7 100644 (file)
@@ -1,6 +1,46 @@
+;;; riece-eval-ruby.el --- evaluate Ruby programs in channels
+;; Copyright (C) 1998-2005 Daiki Ueno
+
+;; Author: Daiki Ueno <ueno@unixuser.org>
+;; Created: 1998-09-28
+;; Keywords: IRC, riece, Ruby
+
+;; 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:
+
+;; To use, add the following line to your ~/.riece/init.el:
+;; (add-to-list 'riece-addons 'riece-eval-ruby)
+
+;;; Code:
+
 (require 'riece-ruby)
 (require 'riece-message)
 
+(defgroup riece-eval-ruby nil
+  "Evaluate Ruby programs in channels."
+  :group 'riece)
+
+(defcustom riece-eval-ruby-prefix-regexp "^,ruby\\s-+"
+  "Pattern of of the prefix for sending Ruby programs."
+  :type 'string
+  :group 'riece-eval-ruby)
+
 (defvar riece-eval-ruby-enabled nil)
 
 (defconst riece-eval-ruby-description
@@ -8,7 +48,7 @@
 
 (defun riece-eval-ruby-exit-handler (name)
   (riece-ruby-inspect name)
-  (let* ((data (copy-sequence riece-ruby-data))
+  (let* ((data (copy-sequence (or riece-ruby-data "nil")))
         (length (length data))
         (index 0))
     (while (< index length)
@@ -29,7 +69,8 @@
 (defun riece-eval-ruby-display-message-function (message)
   (if (and riece-eval-ruby-enabled
           (riece-message-own-p message)
-          (string-match "^,ruby\\s-+" (riece-message-text message)))
+          (string-match riece-eval-ruby-prefix-regexp
+                        (riece-message-text message)))
       (let ((name (riece-ruby-execute
                   (substring (riece-message-text message)
                              (match-end 0)))))
@@ -49,4 +90,6 @@
 (defun riece-eval-ruby-disable ()
   (setq riece-eval-ruby-enabled nil))
 
-(provide 'riece-eval-ruby)
\ No newline at end of file
+(provide 'riece-eval-ruby)
+
+;;; riece-eval-ruby.el ends here