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 | |
| 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.
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | leim/Makefile.in | 6 | ||||
| -rw-r--r-- | lisp/international/titdic-cnv.el | 32 |
3 files changed, 38 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore index 81d3adfb57e..355824f3903 100644 --- a/.gitignore +++ b/.gitignore | |||
| @@ -199,6 +199,7 @@ lisp/international/charscript.el | |||
| 199 | lisp/international/cp51932.el | 199 | lisp/international/cp51932.el |
| 200 | lisp/international/eucjp-ms.el | 200 | lisp/international/eucjp-ms.el |
| 201 | lisp/international/uni-*.el | 201 | lisp/international/uni-*.el |
| 202 | lisp/language/pinyin.el | ||
| 202 | 203 | ||
| 203 | # Documentation. | 204 | # Documentation. |
| 204 | *.aux | 205 | *.aux |
diff --git a/leim/Makefile.in b/leim/Makefile.in index c2fc8c41f23..4307d500876 100644 --- a/leim/Makefile.in +++ b/leim/Makefile.in | |||
| @@ -84,7 +84,8 @@ MISC= \ | |||
| 84 | ${leimdir}/quail/PY.el \ | 84 | ${leimdir}/quail/PY.el \ |
| 85 | ${leimdir}/quail/ZIRANMA.el \ | 85 | ${leimdir}/quail/ZIRANMA.el \ |
| 86 | ${leimdir}/quail/CTLau.el \ | 86 | ${leimdir}/quail/CTLau.el \ |
| 87 | ${leimdir}/quail/CTLau-b5.el | 87 | ${leimdir}/quail/CTLau-b5.el \ |
| 88 | ${srcdir}/../lisp/language/pinyin.el | ||
| 88 | 89 | ||
| 89 | ## All the generated .el files. | 90 | ## All the generated .el files. |
| 90 | TIT_MISC = ${TIT_GB} ${TIT_BIG5} ${MISC} | 91 | TIT_MISC = ${TIT_GB} ${TIT_BIG5} ${MISC} |
| @@ -142,6 +143,9 @@ ${leimdir}/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L | |||
| 142 | $(AM_V_GEN)$(RUN_EMACS) -batch -l ja-dic-cnv \ | 143 | $(AM_V_GEN)$(RUN_EMACS) -batch -l ja-dic-cnv \ |
| 143 | -f batch-skkdic-convert -dir "$(leimdir)/ja-dic" "$<" | 144 | -f batch-skkdic-convert -dir "$(leimdir)/ja-dic" "$<" |
| 144 | 145 | ||
| 146 | ${srcdir}/../lisp/language/pinyin.el: ${srcdir}/MISC-DIC/pinyin.map | ||
| 147 | $(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $@ | ||
| 148 | |||
| 145 | 149 | ||
| 146 | .PHONY: bootstrap-clean distclean maintainer-clean extraclean | 150 | .PHONY: bootstrap-clean distclean maintainer-clean extraclean |
| 147 | 151 | ||
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 | ||