Function: pinyin-convert

pinyin-convert is a byte-compiled function defined in titdic-cnv.el.gz.

Signature

(pinyin-convert)

Documentation

Convert text file pinyin.map into an elisp library.

The library is named pinyin.el, and contains the constant pinyin-character-map.

Source Code

;; Defined in /usr/src/emacs/lisp/international/titdic-cnv.el.gz
(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 ";;; " (file-name-nondirectory dst-file)
              "   -*- lexical-binding:t -*-
;; This file is automatically generated from pinyin.map, by the
;; 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)))