/[emacs]/emacs/lisp/international/titdic-cnv.el
ViewVC logotype

Diff of /emacs/lisp/international/titdic-cnv.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.32 by monnier, Mon Apr 8 22:50:57 2002 UTC revision 1.33 by fx, Wed Jul 24 22:18:11 2002 UTC
# Line 1  Line 1 
1  ;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package  ;;; titdic-cnv.el --- convert cxterm dictionary (TIT format) to Quail package -*- coding:iso-2022-7bit; -*-
2    
3  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.  ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4  ;; Licensed to the Free Software Foundation.  ;; Licensed to the Free Software Foundation.
# Line 73  Line 73 
73  ;; dictionary.  The extra docstring in this alist is to add more  ;; dictionary.  The extra docstring in this alist is to add more
74  ;; information.  ;; information.
75  ;; The command describe-input-method shows the automatically generated  ;; The command describe-input-method shows the automatically generated
76  ;; docstring, then an extra docstrings while replacing the form \<VAR>  ;; docstring, then an extra docstring while replacing the form \<VAR>
77  ;; by the value of variable VAR.  For instance, the form  ;; by the value of variable VAR.  For instance, the form
78  ;; \<quail-translation-docstring> is replaced by a description about  ;; \<quail-translation-docstring> is replaced by a description about
79  ;; how to select a translation from a list of candidates.  ;; how to select a translation from a list of candidates.
# Line 84  Line 84 
84      ("chinese-ccdospy" "$AKuF4(B"      ("chinese-ccdospy" "$AKuF4(B"
85       "Pinyin base input method for Chinese charset GB2312 \(`chinese-gb2312').       "Pinyin base input method for Chinese charset GB2312 \(`chinese-gb2312').
86    
87  Pinyin is the standared roman transliteration method for Chinese.  Pinyin is the standard Roman transliteration method for Chinese.
88  For the detail of Pinyin system, see the documentation of the input  For the detail of Pinyin system, see the documentation of the input
89  method `chinese-py'.  method `chinese-py'.
90    
# Line 92  This input method works almost the same Line 92  This input method works almost the same
92  difference is that you type a single key for these Pinyin spelling.  difference is that you type a single key for these Pinyin spelling.
93      Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu($A(9(B)      Pinyin:  zh  en  eng ang ch  an  ao  ai  ong sh  ing  yu($A(9(B)
94      keyseq:   a   f   g   h   i   j   k   l   s   u   y   v      keyseq:   a   f   g   h   i   j   k   l   s   u   y   v
95  For expample:  For example:
96      Chinese:  $A0!(B    $A9{(B    $AVP(B    $AND(B    $A9b(B    $ASq(B    $AH+(B      Chinese:  $A0!(B    $A9{(B    $AVP(B    $AND(B    $A9b(B    $ASq(B    $AH+(B
97      Pinyin:   a    guo   zhong  wen  guang  yu   quan      Pinyin:   a    guo   zhong  wen  guang  yu   quan
98      Keyseq:   a1   guo4   as1   wf4  guh1  yu..6 qvj6      Keyseq:   a1   guo4   as1   wf4  guh1  yu..6 qvj6
# Line 267  SPC, 6, 3, 4, or 7 specifing a tone (SPC Line 267  SPC, 6, 3, 4, or 7 specifing a tone (SPC
267          (tit-keyprompt nil))          (tit-keyprompt nil))
268    
269      (princ ";; Quail package `")      (princ ";; Quail package `")
270      (princ package)      (princ package) (princ "' -*- coding:iso-2022-7bit; -*-\n")
271      (princ "' generated by the command `titdic-convert'\n;;\tDate: ")      (princ ";;   Generated by the command `titdic-convert'\n;;\tDate: ")
272      (princ (current-time-string))      (princ (current-time-string))
273      (princ "\n;;\tOriginal TIT dictionary file: ")      (princ "\n;;\tOriginal TIT dictionary file: ")
274      (princ (file-name-nondirectory filename))      (princ (file-name-nondirectory filename))
# Line 465  SPC, 6, 3, 4, or 7 specifing a tone (SPC Line 465  SPC, 6, 3, 4, or 7 specifing a tone (SPC
465  Optional argument DIRNAME if specified is the directory name under which  Optional argument DIRNAME if specified is the directory name under which
466  the generated Quail package is saved."  the generated Quail package is saved."
467    (interactive "FTIT dictionary file: ")    (interactive "FTIT dictionary file: ")
468    (with-temp-file  (tit-make-quail-package-file-name filename dirname)    (let ((coding-system-for-write 'iso-2022-7bit))
469      (set-buffer-file-coding-system 'iso-2022-7bit)      (with-temp-file  (tit-make-quail-package-file-name filename dirname)
470      (let ((standard-output (current-buffer)))        (set-buffer-file-coding-system 'iso-2022-7bit)
471        (with-temp-buffer        (let ((standard-output (current-buffer)))
472          (let ((coding-system-for-read 'no-conversion))          (with-temp-buffer
473            (insert-file-contents (expand-file-name filename)))            (set-buffer-multibyte nil)
474          (set-buffer-multibyte t)            (let ((coding-system-for-read 'no-conversion))
475                (insert-file-contents (expand-file-name filename)))
476                    
477          ;; Decode the buffer contents from the encoding specified by a            ;; Decode the buffer contents from the encoding specified by a
478          ;; value of the key "ENCODE:".            ;; value of the key "ENCODE:".
479          (if (not (search-forward "\nBEGIN" nil t))            (if (not (search-forward "\nBEGIN" nil t))
480              (error "TIT dictionary doesn't have body part"))                (error "TIT dictionary doesn't have body part"))
481          (let ((limit (point))            (let ((limit (point))
482                coding-system slot)                  coding-system slot)
483            (goto-char (point-min))              (goto-char (point-min))
484            (if (re-search-forward "^ENCODE:[ \t]*" limit t)              (if (re-search-forward "^ENCODE:[ \t]*" limit t)
485                (progn                  (progn
486                  (goto-char (match-end 0))                    (goto-char (match-end 0))
487                  (setq tit-encode (tit-read-key-value)))                    (setq tit-encode (tit-read-key-value)))
488              (setq tit-encode tit-default-encode))                (setq tit-encode tit-default-encode))
489            (setq slot (assoc tit-encode tit-encode-list))              (setq slot (assoc tit-encode tit-encode-list))
490            (if (not slot)              (if (not slot)
491                (error "Invalid ENCODE: value in TIT dictionary"))                  (error "Invalid ENCODE: value in TIT dictionary"))
492            (setq coding-system (nth 1 slot))              (setq coding-system (nth 1 slot))
493            (message "Decoding with coding system %s..." coding-system)              (message "Decoding with coding system %s..." coding-system)
494                (goto-char (point-min))
495                (decode-coding-region (point-min) (point-max) coding-system))
496    
497              ;; Set point the starting position of the body part.
498            (goto-char (point-min))            (goto-char (point-min))
499            (decode-coding-region (point-min) (point-max) coding-system))            (if (not (search-forward "\nBEGIN" nil t))
500                  (error "TIT dictionary can't be decoded correctly"))
501    
502          ;; Set point the starting position of the body part.            ;; Process the header part.
503          (goto-char (point-min))            (forward-line 1)
504          (if (not (search-forward "\nBEGIN" nil t))            (narrow-to-region (point-min) (point))
505              (error "TIT dictionary can't be decoded correctly"))            (tit-process-header filename)
506              (widen)
507          ;; Process the header part.  
508          (forward-line 1)            ;; Process the body part.  For speed, we turn off multibyte facility.
509          (narrow-to-region (point-min) (point))            (with-current-buffer standard-output
510          (tit-process-header filename)              (set-buffer-multibyte nil))
511          (widen)            (set-buffer-multibyte nil)
512              (tit-process-body))))))
         ;; Process the body part.  For speed, we turn off multibyte facility.  
         (with-current-buffer standard-output  
           (set-buffer-multibyte nil))  
         (set-buffer-multibyte nil)  
         (tit-process-body)))))  
513    
514  ;;;###autoload  ;;;###autoload
515  (defun batch-titdic-convert (&optional force)  (defun batch-titdic-convert (&optional force)

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.33

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26