diff options
| author | Eric Abrahamsen | 2019-01-30 12:31:49 -0800 |
|---|---|---|
| committer | Eric Abrahamsen | 2019-02-24 10:57:05 -0800 |
| commit | 28f7e981c10cddd06b879a79ade214f273ba4498 (patch) | |
| tree | 23f4b61a4ce0bd333776626c8e29df634b16c18c /lisp | |
| parent | 13e6275e58c3dc84fbb65bc9d05eb875e3096f5f (diff) | |
| download | emacs-28f7e981c10cddd06b879a79ade214f273ba4498.tar.gz emacs-28f7e981c10cddd06b879a79ade214f273ba4498.zip | |
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')
| -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." | |||
| 1203 | (miscdic-convert filename dir)))) | 1203 | (miscdic-convert filename dir)))) |
| 1204 | (kill-emacs 0)) | 1204 | (kill-emacs 0)) |
| 1205 | 1205 | ||
| 1206 | (defun pinyin-convert () | ||
| 1207 | "Convert text file pinyin.map into an elisp library. | ||
| 1208 | The library is named pinyin.el, and contains the constant | ||
| 1209 | `pinyin-character-map'." | ||
| 1210 | (let ((src-file (car command-line-args-left)) | ||
| 1211 | (dst-file (cadr command-line-args-left)) | ||
| 1212 | (coding-system-for-write 'utf-8-unix)) | ||
| 1213 | (with-temp-file dst-file | ||
| 1214 | (insert ";; This file is automatically generated from pinyin.map,\ | ||
| 1215 | by the\n;; function pinyin-convert.\n\n") | ||
| 1216 | (insert "(defconst pinyin-character-map\n'(") | ||
| 1217 | (let ((pos (point))) | ||
| 1218 | (insert-file-contents src-file) | ||
| 1219 | (goto-char pos) | ||
| 1220 | (re-search-forward "^[a-z]") | ||
| 1221 | (beginning-of-line) | ||
| 1222 | (delete-region pos (point)) | ||
| 1223 | (while (not (eobp)) | ||
| 1224 | (insert "(\"") | ||
| 1225 | (skip-chars-forward "a-z") | ||
| 1226 | (insert "\" . \"") | ||
| 1227 | (delete-char 1) | ||
| 1228 | (end-of-line) | ||
| 1229 | (while (= (preceding-char) ?\r) | ||
| 1230 | (delete-char -1)) | ||
| 1231 | (insert "\")") | ||
| 1232 | (forward-line 1))) | ||
| 1233 | (insert ")\n\"An alist holding correspondences between pinyin syllables\ | ||
| 1234 | and\nChinese characters.\")\n\n") | ||
| 1235 | (insert "(provide 'pinyin)\n")) | ||
| 1236 | (kill-emacs 0))) | ||
| 1237 | |||
| 1206 | ;; Prevent "Local Variables" above confusing Emacs. | 1238 | ;; Prevent "Local Variables" above confusing Emacs. |
| 1207 | 1239 | ||
| 1208 | 1240 | ||