update.
[elisp/nabe.git] / nabe.el
1 ;;; nabe.el --- Boiled-Egg like roman to kanaji converter kernel
2
3 ;; Copyright (C) 1996 MORIOKA Tomohiko
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Version: $Id: nabe.el,v 0.5 1996/11/12 09:03:23 morioka Exp $
7 ;; Keywords: input, Japanese, mule
8
9 ;; This file is not part of GNU Emacs.
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Code:
27
28 (defvar nabe-characters-to-translate "-a-zA-Z0-9.,?!~()[]#@/:;%"
29   "*characters to transfer. [nabe.el]")
30
31 (defvar nabe-kanji-key "\e ")
32 (defvar nabe-hiragana-key "\en")
33
34 (defvar nabe-roman-to-kanji-function nil)
35 (defvar nabe-roman-to-kana-function nil)
36
37 (global-set-key nabe-kanji-key          'nabe-translate-to-kanji)
38 (global-set-key nabe-hiragana-key       'nabe-translate-to-hiragana)
39
40 (defun nabe-translate-to-kanji (arg)
41   (interactive "p")
42   (let ((po (point)) (mark (or (mark t) 0)))
43     (skip-chars-backward nabe-characters-to-translate)
44     (if (and mark (< mark po) (< (point) mark))
45         (goto-char mark)
46       )
47     (if (not (eq (point) po))
48         (funcall nabe-roman-to-kanji-function (point) po)
49       )
50     (and auto-fill-function (funcall auto-fill-function))
51     ))
52
53 (defun nabe-translate-to-hiragana (arg)
54   (interactive "p")
55   (let ((po (point)) (mark (or (mark t) 0)))
56     (skip-chars-backward nabe-characters-to-translate)
57     (if (and mark (< mark po) (< (point) mark))
58         (goto-char mark)
59       )
60     (if (not (eq (point) po))
61         (save-restriction
62           (narrow-to-region (point) po)
63           (funcall nabe-roman-to-kana-function (point) po)
64           (goto-char (point-max))
65           ))
66     (and auto-fill-function (funcall auto-fill-function))
67     ))
68
69
70 ;;; @ end
71 ;;;
72
73 (provide 'nabe)
74
75 (run-hooks 'nabe-load-hook)
76
77 ;;; nabe.el ends here