[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: reverting CJK input methods
From: |
Kenichi Handa |
Subject: |
Re: reverting CJK input methods |
Date: |
Fri, 30 Apr 2004 10:42:17 +0900 (JST) |
User-agent: |
SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI) |
In article <address@hidden>, Werner LEMBERG <address@hidden> writes:
> Computers are much faster today, with much more memory. Ken'ichi-san,
> what do you think about activating the decode maps for all CJK quail
> input methods, and adding a function like `show-input-method-input'
> which yields the current input method's input string for the current
> character.
It's a good idea. But, as computers are much faster, I
think we can find a key for a specific character by looking
up the quail map. Please evaluate the attached code,
activate some input method, input some character, go to that
character, and do M-x quail-find-key RET.
If that is too slow, another way is to generate the decode
map on demand.
---
Ken'ichi HANDA
address@hidden
(defun quail-find-key (char map key)
(when (consp map)
(let ((translation (car map)))
(cond ((integerp translation)
(if (= translation char)
(throw 'tag key)))
((stringp translation)
(if (string-match (string char) translation)
(throw 'tag key)))
((vectorp translation)
(dotimes (i (length translation))
(let ((target (aref translation i)))
(if (integerp target)
(if (= target char)
(throw 'tag key))
(if (and (= (length target) 1)
(= (aref target 0) char))
(throw 'tag key))))))
((consp translation)
(setq translation (cdr translation))
(dotimes (i (length translation))
(let ((target (aref translation i)))
(if (integerp target)
(if (= target char)
(throw 'tag key))
(if (and (= (length target) 1)
(= (aref target 0) char))
(throw 'tag key)))))))))
(dolist (elt (cdr map))
(quail-find-key char (cdr elt) (cons (car elt) key))))
(defun quail-show-key ()
(interactive)
(let* ((char (following-char))
(key (catch 'tag
(quail-find-key char (quail-map) nil))))
(if key
(message "%c can be input by typing \"%s\""
char (apply 'string (nreverse key)))
(message "%c can't be input by the current input method" char))))