Function: tsang-quick-converter
tsang-quick-converter is a byte-compiled function defined in
titdic-cnv.el.gz.
Signature
(tsang-quick-converter DICBUF TSANG-P BIG5-P)
Source Code
;; Defined in /usr/src/emacs/lisp/international/titdic-cnv.el.gz
;; Generate a code of a Quail package in the current buffer from Tsang
;; dictionary in the buffer DICBUF. The input method name of the
;; Quail package is NAME, and the title string is TITLE.
;; TSANG-P is non-nil, generate 倉頡 input method. Otherwise
;; generate 簡易 (simple version of 倉頡). If BIG5-P is non-nil, the
;; input method is for inputting Big5 characters. Otherwise the input
;; method is for inputting CNS characters.
(defun tsang-quick-converter (dicbuf tsang-p big5-p)
(let ((fulltitle (if tsang-p "倉頡" "簡易"))
dic)
(goto-char (point-max))
(insert (format "\"中文輸入【%s】%s
漢語%s輸入鍵盤
[Q 手] [W 田] [E 水] [R 口] [T 廿] [Y 卜] [U 山] [I 戈] [O 人] [P 心]
[A 日] [S 尸] [D 木] [F 火] [G 土] [H 竹] [J 十] [K 大] [L 中]
[Z ] [X 難] [C 金] [V 女] [B 月] [N 弓] [M 一]
\\\\<quail-translation-docstring>\"\n"
fulltitle (if big5-p "BIG5" "CNS") fulltitle))
(insert " '((\".\" . quail-next-translation-block)
(\",\" . quail-prev-translation-block))
nil nil)\n\n")
(insert "(quail-define-rules\n")
(with-current-buffer dicbuf
;; Handle double CR line ends, which result when checking out of
;; CVS on MS-Windows.
(goto-char (point-min))
(search-forward "A440")
(beginning-of-line)
(let ((table (make-hash-table :test 'equal))
val)
(while (not (eobp))
(forward-char 5)
(let ((trans (char-to-string (following-char)))
key)
(re-search-forward "\\([A-Z]+\\)\r*$" nil t)
(setq key (downcase
(if (or tsang-p
(<= (- (match-end 1) (match-beginning 1)) 1))
(match-string 1)
(string (char-after (match-beginning 1))
(char-after (1- (match-end 1)))))))
(setq val (gethash key table))
(if val (setq trans (concat val trans)))
(puthash key trans table)
(forward-line 1)))
(maphash (lambda (key val) (setq dic (cons (cons key val) dic)))
table)))
(setq dic (sort dic (lambda (x y) (string< (car x ) (car y)))))
(dolist (elt dic)
(insert (format "(%S\t%S)\n" (car elt) (cdr elt))))
(let ((punctuation '((";" ";﹔,、﹐﹑" ";﹔,、﹐﹑")
(":" ":︰﹕.。‧﹒·" ":︰﹕.。・﹒·")
("'" "’‘" "’‘")
("\"" "”“〝〞〃" "”“〝〞〃")
("\\" "\﹨╲" "\﹨╲")
("|" "|︱︳∣" "︱︲\x114019|")
("/" "/∕╱" "/∕╱")
("?" "?﹖" "?﹖")
("<" "〈<﹤︿∠" "〈<﹤︿∠")
(">" "〉>﹥﹀" "〉>﹦﹀")
("[" "〔【﹝︹︻「『﹁﹃" "〔【﹝︹︻「『﹁﹃")
("]" "〕】﹞︺︼」』﹂﹄" "〕】﹞︺︼」』﹂﹄")
("{" "{﹛︷ " "{﹛︷ ")
("}" "}﹜︸" "}﹜︸")
("`" "‵′" "′‵")
("~" "~﹋﹌︴﹏" "∼﹋﹌\x11401B\x11401C")
("!" "!﹗" "!﹗")
("@" "@﹫" "@﹫")
("#" "#﹟" "#﹟")
("$" "$﹩" "$﹩")
("%" "%﹪" "%﹪")
("&" "&﹠" "&﹠")
("*" "*﹡※☆★" "*﹡※☆★")
("(" "(﹙︵" "(﹙︵")
(")" ")﹚︶" ")﹚︶")
("-" "–—¯ ̄-﹣" "—–‾\x114061-﹣")
("_" "_ˍ" "_\x114063")
("=" "=﹦" "=﹥")
("+" "+﹢" "+﹢"))))
(dolist (elt punctuation)
(insert (format "(%S %S)\n" (concat "z" (car elt))
(if big5-p (nth 1 elt) (nth 2 elt))))))
(insert ")\n")))