-;;; 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.
;;; 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
;; 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
(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" . "\e$(0(?-F\e(B")
+ ("chinese-array30" . "\e$(0#R#O\e(B")
+ ("chinese-ccdospy" . "\e$AKuF4\e(B")
+ ("chinese-ctlau" . "\e$AAuTA\e(B")
+ ("chinese-ctlaub" . "\e$(0N,Gn\e(B")
+ ("chinese-ecdict" . "\e$(05CKH\e(B")
+ ("chinese-etzy" . "\e$(06/0D\e(B")
+ ("chinese-punct-b5" . "\e$(0O:\e(BB")
+ ("chinese-punct" . "\e$A1j\e(BG")
+ ("chinese-py-b5" . "\e$(03<\e(BB")
+ ("chinese-py" . "\e$AF4\e(BG")
+ ("chinese-qj-b5" . "\e$(0)A\e(BB")
+ ("chinese-qj" . "\e$AH+\e(BG")
+ ("chinese-sw" . "\e$AJWN2\e(B")
+ ("chinese-tonepy" . "\e$A5wF4\e(B")
+ ("chinese-ziranma" . "\e$AK+F4\e(B")
+ ("chinese-zozy" . "\e$(0I\0D\e(B")))
;; Return a value of the key in the current line.
(defsubst tit-read-key-value ()
(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.
;; 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")
-
- (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 "[:\e$A!K\e$(0!(!J\e(B]+\\([^:\e$A!K\e$(0!(!K\e(B]+\\)" tit-prompt)
- (substring tit-prompt (match-beginning 1) (match-end 1))
- tit-prompt)
- "\"\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")
+
+ (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 "[:\e$A!K\e$(0!(!J\e(B]+\\([^:\e$A!K\e$(0!(!K\e(B]+\\)" tit-prompt)
+ (substring tit-prompt (match-beginning 1) (match-end 1))
+ tit-prompt))
+ "\"\n"))
+ )
;; Arg GUIDANCE
(if tit-keyprompt
(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
(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)))