;; Japanese prompter ;; ;; Display some sort of hint about what the japanese character under ;; the cursor is. Included functions to redefine cursor keys such that ;; this gets called when you cursor left or right. Requires hex.el for ;; the hex convertor, bigass.el for a big-ass lookup table, and a file ;; called UNIHAN.TXT which I think I got from the Unicode site. I ;; can't give you a copy because of the copyright notice, which I'm ;; reproducing here: ;; ;;# ;;# Name: Unihan database ;;# Unicode version: 2.0 ;;# Table version: 1.1 ;;# Date: 23 September 1996 ;;# Author: John H. Jenkins ;;# ;;# Copyright (c) 1996 Unicode, Inc. All Rights reserved. ;;# ;;# This file is provided as-is by Unicode, Inc. (The Unicode Consortium). ;;# No claims are made as to fitness for any particular purpose. No ;;# warranties of any kind are expressed or implied. The recipient ;;# agrees to determine applicability of information provided. If this ;;# file has been provided on magnetic media by Unicode, Inc., the sole ;;# remedy for any claim will be exchange of defective media within 90 ;;# days of receipt. ;;# ;;# Recipient is granted the right to make copies in any form for ;;# internal distribution and to freely use the information supplied ;;# in the creation of products supporting Unicode. Unicode, Inc. ;;# specifically excludes the right to re-distribute this file directly ;;# to third parties or other organizations whether for profit or not. ;;# ;;# In other words: Don't put this file on the Internet. People who want to get it ;;# over the Internet should do so directly from ftp://unicode.org. They ;;# can therefore be assured of getting the most recent and accurate version. ;;# And don't put it on CD-ROMs. ;; ;; Last frobbed, august 2001 (require 'hex) (require 'bigass) (defun blink-expand() (let* ((foo (char-after (point))) bar baz) (condition-case error (progn ;; convert to sjis and look up (setq baz (encode-coding-char foo 'shift_jis)) (setq bar (concat "0x" (upcase (concat (hex (string-to-char (substring baz 0))) (hex (string-to-char (substring baz 1))))))) (setq baz (or (nth 3 (assoc bar bigass-array)) foo)) (let ((bar (nth 2 (assoc bar bigass-array)))) (if (and bar (string-match "CJK" baz)) (save-excursion (find-file (expand-file-name "~/txt/tech/language-hackery/UNIHAN.TXT")) (goto-char (point-min)) (setq bar (concat "U\\+" (substring bar 2) "\\s-*")) (if (re-search-forward (concat bar "kDefinition\\s-*\\(.*\\)$") (point-max) t) (setq baz (concat (match-string 1)))) (if (re-search-forward (concat bar "kJapaneseKun\\s-*\\(.*\\)$") (point-max) t) (setq baz (concat baz " [kun: " (match-string 1)))) (if (re-search-forward (concat bar "kJapaneseOn\\s-*\\(.*\\)$") (point-max) t) (setq baz (concat baz " / on: " (match-string 1) "]"))) (bury-buffer)))) (setq bar (format "%c (%s): %s" foo bar baz))) (error (setq bar "can't encode"))) (message "%s" bar))) (defun forward-and-blink( &optional N ) (interactive "p") (if N (forward-char N) (forward-char 1)) (blink-expand)) (defun back-and-blink( &optional N ) (interactive "p") (if N (backward-char N) (backard-char 1)) (blink-expand)) (defun up-and-blink(&optional N) (interactive "p") (if N (previous-line N) (previous-line 1) (blink-expand))) (defun down-and-blink(&optional N) (interactive "p") (if N (next-line N) (next-line 1) (blink-expand))) (local-set-key [left] 'back-and-blink) (local-set-key [right] 'forward-and-blink) (local-set-key [up] 'up-and-blink) (local-set-key [down] 'down-and-blink) ; ("euc-jp") ; ("old-jis") ; ("sjis") ; ("junet") ; ("iso-2022-jp-2") ; extended charsets