changeset 18555:39589a3b1b20

Add license note. (tit-encode-list): Fix typo (euc-kk -> euc-kr). (quail-cxterm-package-title-alist): New variable. (tit-make-quail-package-file-name): Name changed from tit-make-quail-package-name. (tit-process-header): Check quail-cxterm-package-title-alist to decide a package name. (titdic-convert): Call tit-make-quail-package-file-name. (batch-titdic-convert): Likewise.
author Kenichi Handa <handa@m17n.org>
date Wed, 02 Jul 1997 12:59:36 +0000
parents 179c8135c9b1
children 99e8ae18137f
files lisp/international/titdic-cnv.el
diffstat 1 files changed, 67 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/titdic-cnv.el	Wed Jul 02 12:58:31 1997 +0000
+++ b/lisp/international/titdic-cnv.el	Wed Jul 02 12:59:36 1997 +0000
@@ -1,4 +1,4 @@
-;;; titdic-cnv.el --- convert TIT dictionary to Quail package
+;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package
 
 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
 ;; Licensed to the Free Software Foundation.
@@ -24,12 +24,12 @@
 
 ;;; Comments:
 
-;; Convert TIT format dictionary (of cxterm) to quail-package.
+;; Convert cxterm dictionary (of TIT format) to quail-package.
 ;;
 ;; Usage (within Emacs):
-;;	M-x titdic-convert<CR>TIT-FILE-NAME<CR>
+;;	M-x titdic-convert<CR>CXTERM-DICTIONARY-NAME<CR>
 ;; Usage (from shell):
-;;	% emacs -batch -l titdic-convert -f batch-titdic-convert\
+;;	% emacs -batch -l titdic-cnv -f batch-titdic-convert\
 ;;		[-dir DIR] [DIR | FILE] ...
 ;;
 ;; When you run titdic-convert within Emacs, you have a chance to
@@ -37,7 +37,7 @@
 ;; converted file.  For instance, you are likely to modify TITLE,
 ;; DOCSTRING, and KEY-BINDINGS.
 
-;; TIT dictionary file (*.tit) is a line-oriented text (English,
+;; Cxterm dictionary file (*.tit) is a line-oriented text (English,
 ;; Chinese, Japanese, and Korean) file.  The whole file contains of
 ;; two parts, the definition part (`header' here after) followed by
 ;; the dictionary part (`body' here after).  All lines begin with
@@ -56,13 +56,33 @@
 
 (require 'quail)
 
-;; List of values of key "ENCODE:" and the corresponding Emacs'
+;; List of values of key "ENCODE:" and the corresponding Emacs
 ;; coding-system and language environment name.
 (defvar tit-encode-list
   '(("GB" euc-china "Chinese-GB")
     ("BIG5" cn-big5 "Chinese-BIG5")
     ("JIS" euc-japan "Japanese")
-    ("KS" euc-kk "Korean")))
+    ("KS" euc-kr "Korean")))
+
+;; List of package names and the corresponding titles.
+(defvar quail-cxterm-package-title-alist
+  '(("chinese-4corner" . "$(0(?-F(B")
+    ("chinese-array30" . "$(0#R#O(B")
+    ("chinese-ccdospy" . "$AKuF4(B")
+    ("chinese-ctlau" . "$AAuTA(B")
+    ("chinese-ctlaub" . "$(0N,Gn(B")
+    ("chinese-ecdict" . "$(05CKH(B")
+    ("chinese-etzy" . "$(06/0D(B")
+    ("chinese-punct-b5" . "$(0O:(BB")
+    ("chinese-punct" . "$A1j(BG")
+    ("chinese-py-b5" . "$(03<(BB")
+    ("chinese-py" . "$AF4(BG")
+    ("chinese-qj-b5" . "$(0)A(BB")
+    ("chinese-qj" . "$AH+(BG")
+    ("chinese-sw" . "$AJWN2(B")
+    ("chinese-tonepy" . "$A5wF4(B")
+    ("chinese-ziranma" . "$AK+F4(B")
+    ("chinese-zozy" . "$(0I\0D(B")))
 
 ;; Return a value of the key in the current line.
 (defsubst tit-read-key-value ()
@@ -70,10 +90,10 @@
       (car (read-from-string (concat "\"" (match-string 0) "\"")))))
 
 ;; Return an appropriate quail-package filename from FILENAME (TIT
-;; dictionary filename).  For instance, ".../ZOZY.tit" -> "zozy.el".
-(defun tit-make-quail-package-name (filename &optional dirname)
+;; dictionary filename).  For instance, ".../ZOZY.tit" -> "ZOZY.el".
+(defun tit-make-quail-package-file-name (filename &optional dirname)
   (expand-file-name
-   (concat (downcase (file-name-nondirectory (substring filename 0 -4))) ".el")
+   (concat (file-name-nondirectory (substring filename 0 -4)) ".el")
    dirname))
 
 ;; This value is t if we are processing phrase dictionary.
@@ -163,35 +183,42 @@
   
     ;; Then, generate header part of the Quail package.
     (goto-char (point-min))
-    (insert ";; Quail package `"
-	    (substring (file-name-nondirectory buffer-file-name) 0 -3)
-	    "' generated by the command `titdic-convert'\n"
-	    ";;\tDate: " (current-time-string) "\n"
-	    ";;\tOriginal TIT dictionary file: "
-	    (file-name-nondirectory filename)
-	    "\n\n"
-	    ";;; Comment:\n\n"
-	    ";; Do byte-compile this file again after any modification.\n\n"
-	    ";;; Start of the header of original TIT dictionary.\n\n")
+    (let ((package
+	   (concat
+	    "chinese-"
+	    (substring (downcase (file-name-nondirectory buffer-file-name))
+		       0 -3))))
+      (insert ";; Quail package `"
+	      package
+	      "' generated by the command `titdic-convert'\n"
+	      ";;\tDate: " (current-time-string) "\n"
+	      ";;\tOriginal TIT dictionary file: "
+	      (file-name-nondirectory filename)
+	      "\n\n"
+	      ";;; Comment:\n\n"
+	      ";; Do byte-compile this file again after any modification.\n\n"
+	      ";;; Start of the header of original TIT dictionary.\n\n")
 
-    (goto-char (point-max))
-    (insert "\n"
-	    ";;; End of the header of original TIT dictionary.\n\n"
-	    ";;; Code:\n\n"
-	    "(require 'quail)\n\n")
+      (goto-char (point-max))
+      (insert "\n"
+	      ";;; End of the header of original TIT dictionary.\n\n"
+	      ";;; Code:\n\n"
+	      "(require 'quail)\n\n")
 
-    (insert "(quail-define-package ")
-    ;; Args NAME, LANGUAGE, TITLE
-    (insert
-     "\""
-     (concat "quail-"
-	     (substring (file-name-nondirectory buffer-file-name) 0 -3))
-     "\" \"" (nth 2 (assoc tit-encode tit-encode-list))
-     "\" \""
-     (if (string-match "[:$A!K$(0!(!J(B]+\\([^:$A!K$(0!(!K(B]+\\)" tit-prompt)
-	 (substring tit-prompt (match-beginning 1) (match-end 1))
-       tit-prompt)
-     "\"\n")
+      (insert "(quail-define-package ")
+      ;; Args NAME, LANGUAGE, TITLE
+      (let ((title (cdr (assoc package quail-cxterm-package-title-alist))))
+	(insert
+	 "\""
+	 package
+	 "\" \"" (nth 2 (assoc tit-encode tit-encode-list))
+	 "\" \""
+	 (or title
+	     (if (string-match "[:$A!K$(0!(!J(B]+\\([^:$A!K$(0!(!K(B]+\\)" tit-prompt)
+		 (substring tit-prompt (match-beginning 1) (match-end 1))
+	       tit-prompt))
+	 "\"\n"))
+      )
 
     ;; Arg GUIDANCE
     (if tit-keyprompt
@@ -309,7 +336,8 @@
       (erase-buffer)
       (let ((coding-system-for-read 'no-conversion))
 	(insert-file-contents (expand-file-name filename)))
-      (set-visited-file-name (tit-make-quail-package-name filename dirname) t)
+      (set-visited-file-name
+       (tit-make-quail-package-file-name filename dirname) t)
       (set-buffer-file-coding-system 'iso-2022-7bit)
 
       ;; Decode the buffer contents from the encoding specified by a
@@ -391,7 +419,7 @@
 	(while files
 	  (setq file (expand-file-name (car files)))
 	  (if (file-newer-than-file-p
-	       file (tit-make-quail-package-name file targetdir))
+	       file (tit-make-quail-package-file-name file targetdir))
 	      (progn
 		(message "Converting %s to quail-package..." file)
 		(titdic-convert file targetdir)))