From: ueno Date: Thu, 11 Aug 2005 08:18:07 +0000 (+0000) Subject: * riece-ruby.el: Moved add-on stuff to riece-eval-ruby.el. X-Git-Tag: channel-coding-branchpoint~155 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=5313efcf4a339659c685e786c3625aa324fe17c2;p=elisp%2Friece.git * riece-ruby.el: Moved add-on stuff to riece-eval-ruby.el. * riece-eval-ruby.el: New add-on. * COMPILE (riece-modules): Add riece-eval-ruby. * Makefile.am (EXTRA_DIST): Add riece-eval-ruby.el. --- diff --git a/lisp/COMPILE b/lisp/COMPILE index 0215da6..ba93344 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -77,7 +77,8 @@ riece-toolbar riece-eval riece-google - riece-keepalive)))) + riece-keepalive + riece-eval-ruby)))) (defvar riece-icons '("riece-command-quit.xpm" diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 9723310..eac74b6 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,5 +1,13 @@ 2005-08-11 Daiki Ueno + * riece-ruby.el: Moved add-on stuff to riece-eval-ruby.el. + + * riece-eval-ruby.el: New add-on. + * COMPILE (riece-modules): Add riece-eval-ruby. + * Makefile.am (EXTRA_DIST): Add riece-eval-ruby.el. + +2005-08-11 Daiki Ueno + * server.rb (Server::unescape): Fixed. * riece-ruby.el: Implement add-on API. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index bacc2da..c185dda 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -16,7 +16,7 @@ EXTRA_DIST = COMPILE ChangeLog ChangeLog.Liece \ riece-lsdb.el riece-xface.el riece-ctlseq.el riece-ignore.el \ riece-hangman.el riece-biff.el riece-kakasi.el riece-foolproof.el \ riece-yank.el riece-toolbar.el riece-eval.el riece-google.el \ - riece-keepalive.el url-riece.el \ + riece-keepalive.el riece-eval-ruby.el url-riece.el \ riece-command-previous-channel.xpm riece-command-next-channel.xpm \ riece-submit-bug-report.xpm \ server.rb diff --git a/lisp/riece-eval-ruby.el b/lisp/riece-eval-ruby.el new file mode 100644 index 0000000..21ff25d --- /dev/null +++ b/lisp/riece-eval-ruby.el @@ -0,0 +1,52 @@ +(require 'riece-ruby) +(require 'riece-message) + +(defvar riece-eval-ruby-enabled nil) + +(defconst riece-eval-ruby-description + "Evaluate an input string as Ruby program.") + +(defun riece-eval-ruby-exit-handler (name) + (riece-ruby-inspect name) + (let* ((data (copy-sequence riece-ruby-data)) + (length (length data)) + (index 0)) + (while (< index length) + (if (eq (aref data index) ?\n) + (aset data index ? )) + (setq index (1+ index))) + (riece-send-string + (format "NOTICE %s :%s\r\n" + (riece-identity-prefix + (riece-ruby-property name 'riece-eval-ruby-target)) + data)) + (riece-display-message + (riece-make-message (riece-current-nickname) + (riece-ruby-property name 'riece-eval-ruby-target) + data + 'notice)))) + +(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))) + (let ((name (riece-ruby-execute + (substring (riece-message-text message) + (match-end 0))))) + (riece-ruby-set-property name + 'riece-eval-ruby-target + (riece-message-target message)) + (riece-ruby-set-exit-handler name + #'riece-eval-ruby-exit-handler)))) + +(defun riece-eval-ruby-insinuate () + (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-disable () + (setq riece-eval-ruby-enabled nil)) + +(provide 'riece-eval-ruby) \ No newline at end of file diff --git a/lisp/riece-ruby.el b/lisp/riece-ruby.el index fe5c6f1..d56bc62 100644 --- a/lisp/riece-ruby.el +++ b/lisp/riece-ruby.el @@ -93,11 +93,6 @@ Use `riece-ruby-set-exit-handler' to set this variable.") "An alist mapping from program name to the property list. Use `riece-ruby-set-property' to set this variable.") -(defvar riece-ruby-enabled nil) - -(defconst riece-ruby-description - "Evaluate an input string as Ruby program.") - (defun riece-ruby-substitute-variables (program alist) (setq program (copy-sequence program)) (while alist @@ -321,49 +316,6 @@ Use `riece-ruby-set-property' to set this variable.") (defun riece-ruby-property (name property) (cdr (assoc property (cdr (assoc name riece-ruby-property-alist))))) -(defun riece-ruby-exit-handler (name) - (riece-ruby-inspect name) - (let* ((data (copy-sequence riece-ruby-data)) - (length (length data)) - (index 0)) - (while (< index length) - (if (eq (aref data index) ?\n) - (aset data index ? )) - (setq index (1+ index))) - (riece-send-string - (format "NOTICE %s :%s\r\n" - (riece-identity-prefix - (riece-ruby-property name 'riece-ruby-target)) - data)) - (riece-display-message - (riece-make-message (riece-current-nickname) - (riece-ruby-property name 'riece-ruby-target) - data - 'notice)))) - -(defun riece-ruby-display-message-function (message) - (if (and riece-ruby-enabled - (riece-message-own-p message) - (string-match "^,ruby\\s-+" (riece-message-text message))) - (let ((name (riece-ruby-execute - (substring (riece-message-text message) - (match-end 0))))) - (riece-ruby-set-property name - 'riece-ruby-target - (riece-message-target message)) - (riece-ruby-set-exit-handler name - #'riece-ruby-exit-handler)))) - -(defun riece-ruby-insinuate () - (add-hook 'riece-after-display-message-functions - 'riece-ruby-display-message-function)) - -(defun riece-ruby-enable () - (setq riece-ruby-enabled t)) - -(defun riece-ruby-disable () - (setq riece-ruby-enabled nil)) - (provide 'riece-ruby) ;;; riece-ruby.el ends here