add furigana mode with ERC

 

File modified: lisp/emacs.d/ivan-erc.el lisp/emacs.d/ivan-japanese.el

Change364 at Sat Aug 28 19:22:41 2010 +0200 by Ivan Kanis <ivan@tao>

diff -r 1ddd54c5b268 -r 436c86fce945 lisp/emacs.d/ivan-japanese.el
--- a/lisp/emacs.d/ivan-japanese.el	Fri Aug 27 07:58:37 2010 +0200
+++ b/lisp/emacs.d/ivan-japanese.el	Sat Aug 28 19:22:41 2010 +0200
@@ -18,6 +18,35 @@
   (interactive)
   (activate-input-method 'japanese))
 
+(defun ivan-japanese-kakasi (input)
+  "Take a Japanese string and return INPUT in hiragana"
+  (get-buffer-create kakasi-buffer)
+  (with-temp-buffer
+    (insert input)
+    (let ((coding-system-for-read 'euc-jp)
+          (coding-system-for-write 'euc-jp))
+      (call-process-region (point-min) (point-max)
+                           "kakasi" nil kakasi-buffer nil "-JH" "-s")))
+  (prog1
+      (with-current-buffer kakasi-buffer
+        (setq kakasi-ret
+              (buffer-substring-no-properties (point-min) (point-max))))
+    (kill-buffer kakasi-buffer)))
+
+(defun ivan-japanese-kanji (string)
+  "Return t if string contains Japanese kanji"
+  (let ((length (length string))
+        (count 0)
+        (ret nil)
+        (char ?a))
+    (while (< count length)
+      (setq char (aref string count))
+      (if (and (< char ?\u9fa5)
+               (> char ?\u4e00))
+          (setq ret t))
+      (setq count (1+ count)))
+    ret))
+
 (setq quail-japanese-transliteration-rules
       '(( "a" "あ") ( "i" "い") ( "u" "う") ( "e" "え") ( "o" "お")
         ("ka" "か") ("ki" "き") ("ku" "く") ("ke" "け") ("ko" "こ")
@@ -147,7 +176,7 @@
 
 ;; Copyright (C) 2009 Ivan Kanis
 ;; Author: Ivan Kanis
-;; 
+;;
 ;;
 ;; 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


back