1 ;;; riece-kakasi.el --- convert Japanese to roman string by KAKASI
2 ;; Copyright (C) 1998-2004 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; NOTE: This is an add-on module for Riece.
31 (defvar riece-kakasi-enabled nil)
33 (defvar riece-kakasi-description
34 "Convert Japanese to roman string by KAKASI.")
36 (defvar riece-kakasi-process nil)
38 (require 'riece-message)
40 (defun riece-kakasi-convert-string (string)
41 (process-send-string riece-kakasi-process (concat string "\n"))
43 (set-buffer (process-buffer riece-kakasi-process))
45 (goto-char (point-min))
46 (not (search-forward "\n" nil t)))
47 (accept-process-output riece-kakasi-process))
48 (prog1 (buffer-substring (point-min) (1- (point)))
49 (delete-region (point-min) (point)))))
51 (defun riece-kakasi-message-filter (message)
52 (if riece-kakasi-enabled
53 (riece-message-set-text message
54 (riece-kakasi-convert-string
55 (riece-message-text message))))
58 (defun riece-kakasi-insinuate ()
59 (add-hook 'riece-message-filter-functions 'riece-kakasi-message-filter))
61 (defun riece-kakasi-enable ()
62 (setq riece-kakasi-process
63 (start-process "kakasi" (generate-new-buffer " *riece-kakasi*")
64 "kakasi" "-Ha" "-Ka" "-Ja" "-Ea" "-ka"))
65 (with-current-buffer (process-buffer riece-kakasi-process)
68 (setq riece-kakasi-enabled t))
70 (defun riece-kakasi-disable ()
71 (kill-buffer (process-buffer riece-kakasi-process))
72 (setq riece-kakasi-enabled nil))
74 (provide 'riece-kakasi)
76 ;;; riece-kakasi.el ends here