X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=lisp%2Friece-eval-ruby.el;h=8595a579dbb0e6cddec93c5ea839dd3e36e31f4f;hb=f409813b1c09f88165fa71218fbe66ac5978129f;hp=21ff25d20b11e79d65dae844375fe52fc3e07367;hpb=5313efcf4a339659c685e786c3625aa324fe17c2;p=elisp%2Friece.git diff --git a/lisp/riece-eval-ruby.el b/lisp/riece-eval-ruby.el index 21ff25d..8595a57 100644 --- a/lisp/riece-eval-ruby.el +++ b/lisp/riece-eval-ruby.el @@ -1,14 +1,52 @@ +;;; riece-eval-ruby.el --- evaluate input string as a Ruby program +;; Copyright (C) 1998-2005 Daiki Ueno + +;; Author: Daiki Ueno +;; 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., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. + +;;; Commentary: + +;; NOTE: This is an add-on module for Riece. + +;;; Code: + (require 'riece-ruby) (require 'riece-message) -(defvar riece-eval-ruby-enabled nil) +(defgroup riece-eval-ruby nil + "Evaluate input string as a Ruby program." + :prefix "riece-" + :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) (defconst riece-eval-ruby-description - "Evaluate an input string as Ruby program.") + "Evaluate input string as a Ruby program.") (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) @@ -27,9 +65,10 @@ 'notice)))) (defun riece-eval-ruby-display-message-function (message) - (if (and riece-eval-ruby-enabled + (if (and (get 'riece-eval-ruby 'riece-addon-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))))) @@ -43,10 +82,10 @@ (add-hook 'riece-after-display-message-functions 'riece-eval-ruby-display-message-function)) -(defun riece-eval-ruby-enable () - (setq riece-eval-ruby-enabled t)) +(defun riece-eval-ruby-uninstall () + (remove-hook 'riece-after-display-message-functions + 'riece-eval-ruby-display-message-function)) -(defun riece-eval-ruby-disable () - (setq riece-eval-ruby-enabled nil)) +(provide 'riece-eval-ruby) -(provide 'riece-eval-ruby) \ No newline at end of file +;;; riece-eval-ruby.el ends here