Commit 28f7e981 authored by Eric Abrahamsen's avatar Eric Abrahamsen

Make pinyin to Chinese character mapping available to elisp

* leim/ Build the file pinyin.el from
* lisp/international/titdic-cnv.el (pinyin-convert): New function that
  writes the library pinyin.el, containing a new constant
* .gitignore: Ignore the generated pinyin.el file.
parent 13e6275e
Pipeline #850 passed with stage
in 53 minutes and 59 seconds
......@@ -199,6 +199,7 @@ lisp/international/charscript.el
# Documentation.
......@@ -84,7 +84,8 @@ MISC= \
${leimdir}/quail/PY.el \
${leimdir}/quail/ZIRANMA.el \
${leimdir}/quail/CTLau.el \
${leimdir}/quail/CTLau-b5.el \
## All the generated .el files.
......@@ -142,6 +143,9 @@ ${leimdir}/ja-dic/ja-dic.el: $(srcdir)/SKK-DIC/SKK-JISYO.L
$(AM_V_GEN)$(RUN_EMACS) -batch -l ja-dic-cnv \
-f batch-skkdic-convert -dir "$(leimdir)/ja-dic" "$<"
${srcdir}/../lisp/language/pinyin.el: ${srcdir}/MISC-DIC/
$(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $@
.PHONY: bootstrap-clean distclean maintainer-clean extraclean
......@@ -1203,6 +1203,38 @@ to store generated Quail packages."
(miscdic-convert filename dir))))
(kill-emacs 0))
(defun pinyin-convert ()
"Convert text file into an elisp library.
The library is named pinyin.el, and contains the constant
(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,\
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]")
(delete-region pos (point))
(while (not (eobp))
(insert "(\"")
(skip-chars-forward "a-z")
(insert "\" . \"")
(delete-char 1)
(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.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment