diff options
author | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-01-30 12:31:49 -0800 |
---|---|---|
committer | Eric Abrahamsen <eric@ericabrahamsen.net> | 2019-02-24 10:57:05 -0800 |
commit | 28f7e981c10cddd06b879a79ade214f273ba4498 (patch) | |
tree | 23f4b61a4ce0bd333776626c8e29df634b16c18c /lisp/international/titdic-cnv.el | |
parent | 13e6275e58c3dc84fbb65bc9d05eb875e3096f5f (diff) | |
download | emacs-28f7e981c10cddd06b879a79ade214f273ba4498.tar.gz |
Make pinyin to Chinese character mapping available to elisp
* leim/Makefile.in: Build the file pinyin.el from pinyin.map.
* lisp/international/titdic-cnv.el (pinyin-convert): New function that
writes the library pinyin.el, containing a new constant
`pinyin-character-map'.
* .gitignore: Ignore the generated pinyin.el file.
Diffstat (limited to 'lisp/international/titdic-cnv.el')
-rw-r--r-- | lisp/international/titdic-cnv.el | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index 2ce2c527b95..e6065fb0f76 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el @@ -1203,6 +1203,38 @@ to store generated Quail packages." (miscdic-convert filename dir)))) (kill-emacs 0)) +(defun pinyin-convert () + "Convert text file pinyin.map into an elisp library. +The library is named pinyin.el, and contains the constant +`pinyin-character-map'." + (let ((src-file (car command-line-args-left)) + (dst-file (cadr command-line-args-left)) + (coding-system-for-write 'utf-8-unix)) + (with-temp-file dst-file + (insert ";; This file is automatically generated from pinyin.map,\ + by the\n;; function pinyin-convert.\n\n") + (insert "(defconst pinyin-character-map\n'(") + (let ((pos (point))) + (insert-file-contents src-file) + (goto-char pos) + (re-search-forward "^[a-z]") + (beginning-of-line) + (delete-region pos (point)) + (while (not (eobp)) + (insert "(\"") + (skip-chars-forward "a-z") + (insert "\" . \"") + (delete-char 1) + (end-of-line) + (while (= (preceding-char) ?\r) + (delete-char -1)) + (insert "\")") + (forward-line 1))) + (insert ")\n\"An alist holding correspondences between pinyin syllables\ + and\nChinese characters.\")\n\n") + (insert "(provide 'pinyin)\n")) + (kill-emacs 0))) + ;; Prevent "Local Variables" above confusing Emacs. |