From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.bugs Subject: bug#34215: 27.0.50; Provide elisp access to Chinese pinyin-to-character mapping Date: Thu, 31 Jan 2019 11:35:32 -0800 Message-ID: <87a7jghb7f.fsf@ericabrahamsen.net> References: <87imyafyts.fsf@ericabrahamsen.net> <83r2cy3y69.fsf@gnu.org> <87a7jmf06v.fsf@ericabrahamsen.net> <83ef8y3r40.fsf@gnu.org> <875zu9gb96.fsf@ericabrahamsen.net> <83a7jl51c5.fsf@gnu.org> <87va27cq35.fsf@ericabrahamsen.net> <83ftta138k.fsf@gnu.org> <87munhnavf.fsf@ericabrahamsen.net> <87imy5na7t.fsf@ericabrahamsen.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="45130"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: 34215@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jan 31 20:36:25 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gpI8M-000BXr-12 for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Jan 2019 20:36:22 +0100 Original-Received: from localhost ([127.0.0.1]:59844 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpI8L-0003Ax-0q for geb-bug-gnu-emacs@m.gmane.org; Thu, 31 Jan 2019 14:36:21 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48653) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpI83-000394-Gr for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:36:04 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpI82-0002Sg-Gp for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:36:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54084) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpI82-0002Sa-D5 for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:36:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gpI82-0003aE-4s for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:36:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <87imyafyts.fsf@ericabrahamsen.net> Resent-From: Eric Abrahamsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 31 Jan 2019 19:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34215 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.154896335413760 (code B ref -1); Thu, 31 Jan 2019 19:36:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 31 Jan 2019 19:35:54 +0000 Original-Received: from localhost ([127.0.0.1]:53365 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gpI7t-0003Zs-IP for submit@debbugs.gnu.org; Thu, 31 Jan 2019 14:35:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:34209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gpI7r-0003Zb-Kp for submit@debbugs.gnu.org; Thu, 31 Jan 2019 14:35:52 -0500 Original-Received: from lists.gnu.org ([209.51.188.17]:49650) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpI7m-0002Lu-CG for submit@debbugs.gnu.org; Thu, 31 Jan 2019 14:35:46 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:48577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpI7l-0002tB-5v for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:35:46 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpI7j-0002KT-Up for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:35:45 -0500 Original-Received: from [195.159.176.226] (port=34846 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gpI7j-0002HZ-M4 for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 14:35:43 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1gpI7e-000Adz-Ll for bug-gnu-emacs@gnu.org; Thu, 31 Jan 2019 20:35:38 +0100 X-Injected-Via-Gmane: http://gmane.org/ Cancel-Lock: sha1:P+KmbKtW87hyte99cJOzvrCfV2o= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:154939 Archived-At: --=-=-= Content-Type: text/plain Robert Pluim writes: > Eric Abrahamsen writes: > >> >> Oh, after reading a couple of "make" tutorials, I see maybe the make >> rule could be simplified to: >> >> ${leimdir}/../lisp/language/pinyin.el: ${srcdir}/MISC-DIC/pinyin.map >> $(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $0 > > $@ , I think. Ah, right you are, thanks. I was wondering why that wasn't working. This version should do the trick; it also gitignores the generated file. Eric --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Make-pinyin-to-Chinese-character-mapping-available-t.patch >From 2395d1a62e66206c04b7069d372fdb4f10787863 Mon Sep 17 00:00:00 2001 From: Eric Abrahamsen Date: Wed, 30 Jan 2019 12:31:49 -0800 Subject: [PATCH 1/2] 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. --- .gitignore | 1 + leim/Makefile.in | 6 +++++- lisp/international/titdic-cnv.el | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 53f41f0f3e..f3d5ccb0f8 100644 --- a/.gitignore +++ b/.gitignore @@ -199,6 +199,7 @@ lisp/international/charscript.el lisp/international/cp51932.el lisp/international/eucjp-ms.el lisp/international/uni-*.el +lisp/language/pinyin.el # Documentation. *.aux diff --git a/leim/Makefile.in b/leim/Makefile.in index c2fc8c41f2..4307d50087 100644 --- a/leim/Makefile.in +++ b/leim/Makefile.in @@ -84,7 +84,8 @@ MISC= ${leimdir}/quail/PY.el \ ${leimdir}/quail/ZIRANMA.el \ ${leimdir}/quail/CTLau.el \ - ${leimdir}/quail/CTLau-b5.el + ${leimdir}/quail/CTLau-b5.el \ + ${srcdir}/../lisp/language/pinyin.el ## All the generated .el files. TIT_MISC = ${TIT_GB} ${TIT_BIG5} ${MISC} @@ -142,6 +143,9 @@ ${leimdir}/ja-dic/ja-dic.el: $(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/pinyin.map + $(AM_V_GEN)${RUN_EMACS} -l titdic-cnv -f pinyin-convert $< $@ + .PHONY: bootstrap-clean distclean maintainer-clean extraclean diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index 2ce2c527b9..d33e9ff229 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el @@ -1203,6 +1203,38 @@ batch-miscdic-convert (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-emacs)) + (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. -- 2.20.1 --=-=-=--