From: ueno Date: Fri, 28 May 2004 03:56:48 +0000 (+0000) Subject: * riece-message.el (riece-message-set-speaker): New function. X-Git-Tag: riece-1_0_0~6 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=0525a334e2469ad21d50fa715d94e041455869a7;p=elisp%2Friece.git * riece-message.el (riece-message-set-speaker): New function. (riece-message-set-target): New function. (riece-message-set-text): New function. (riece-message-set-type): New function. (riece-message-set-own-p): New function. * riece-kakasi.el: New add-on. * COMPILE (riece-modules): Add riece-kakasi. * Makefile.am (EXTRA_DIST): Add riece-kakasi.el. --- diff --git a/lisp/COMPILE b/lisp/COMPILE index 798db28..6073246 100644 --- a/lisp/COMPILE +++ b/lisp/COMPILE @@ -67,7 +67,8 @@ riece-ctlseq riece-ignore riece-hangman - riece-biff)))) + riece-biff + riece-kakasi)))) (defun riece-compile-modules (modules) (let ((load-path (cons nil load-path))) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 788185e..7db01d2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,15 @@ +2004-05-28 Daiki Ueno + + * riece-message.el (riece-message-set-speaker): New function. + (riece-message-set-target): New function. + (riece-message-set-text): New function. + (riece-message-set-type): New function. + (riece-message-set-own-p): New function. + + * riece-kakasi.el: New add-on. + * COMPILE (riece-modules): Add riece-kakasi. + * Makefile.am (EXTRA_DIST): Add riece-kakasi.el. + 2004-05-27 OHASHI Akira * riece-biff.el: New add-on. diff --git a/lisp/Makefile.am b/lisp/Makefile.am index a1d1d18..7e9e8bf 100644 --- a/lisp/Makefile.am +++ b/lisp/Makefile.am @@ -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-biff.el + riece-biff.el riece-kakasi.el CLEANFILES = auto-autoloads.el custom-load.el *.elc FLAGS ?= -batch -q -no-site-file diff --git a/lisp/riece-kakasi.el b/lisp/riece-kakasi.el new file mode 100644 index 0000000..58c6999 --- /dev/null +++ b/lisp/riece-kakasi.el @@ -0,0 +1,77 @@ +;;; riece-kakasi.el --- convert Japanese to roman string by kakasi +;; Copyright (C) 1998-2004 Daiki Ueno + +;; Author: Daiki Ueno +;; Created: 1998-09-28 +;; 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: + +;; To use, add the following line to your ~/.riece/init.el: +;; (add-to-list 'riece-addons 'riece-kakasi) + +;;; Code: + +(defvar riece-kakasi-enabled nil) + +(defvar riece-kakasi-description + "Convert Japanese to roman string by kakasi") + +(defvar riece-kakasi-process nil) + +(require 'riece-message) + +(defun riece-kakasi-convert-string (string) + (process-send-string riece-kakasi-process (concat string "\n")) + (save-excursion + (set-buffer (process-buffer riece-kakasi-process)) + (while (progn + (goto-char (point-min)) + (not (search-forward "\n" nil t))) + (accept-process-output riece-kakasi-process)) + (prog1 (buffer-substring (point-min) (1- (point))) + (delete-region (point-min) (point))))) + +(defun riece-kakasi-message-filter (message) + (if riece-kakasi-enabled + (riece-message-set-text message + (riece-kakasi-convert-string + (riece-message-text message)))) + message) + +(defun riece-kakasi-insinuate () + (add-hook 'riece-message-filter-functions 'riece-kakasi-message-filter)) + +(defun riece-kakasi-enable () + (setq riece-kakasi-process + (start-process "kakasi" (generate-new-buffer " *riece-kakasi*") + "kakasi" "-Ha" "-Ka" "-Ja" "-Ea" "-ka")) + (with-current-buffer (process-buffer riece-kakasi-process) + (buffer-disable-undo) + (erase-buffer)) + (setq riece-kakasi-enabled t)) + +(defun riece-kakasi-disable () + (kill-buffer (process-buffer riece-kakasi-process)) + (setq riece-kakasi-enabled nil)) + +(provide 'riece-kakasi) + +;;; riece-kakasi.el ends here diff --git a/lisp/riece-message.el b/lisp/riece-message.el index 6bbd35f..4eccca7 100644 --- a/lisp/riece-message.el +++ b/lisp/riece-message.el @@ -217,6 +217,27 @@ Currently possible values are `action' and `notice'." "Return t if MESSAGE is not from the network." (aref message 4)) +(defun riece-message-set-speaker (message speaker) + "Set the sender of MESSAGE." + (aset message 0 speaker)) + +(defun riece-message-set-target (message target) + "Set the receiver of MESSAGE." + (aset message 1 target)) + +(defun riece-message-set-text (message text) + "Set the text part of MESSAGE." + (aset message 2 text)) + +(defun riece-message-set-type (message type) + "Set the type of MESSAGE. +Currently possible values are `action' and `notice'." + (aset message 3 type)) + +(defun riece-message-set-own-p (message own-p) + "Set t if MESSAGE is not from the network." + (aset message 4 own-p)) + (defun riece-message-private-p (message) "Return t if MESSAGE is a private message." (not (or (riece-channel-p (riece-identity-prefix