comparison lisp/international/titdic-cnv.el @ 75788:9099b36e6499

(titdic-convert): Force files be written with Unix-like eol format. Read files under CXTERM-DIC by raw-text. (miscdic-convert): Force files be written with Unix-like eol format.
author Kenichi Handa <handa@m17n.org>
date Sun, 11 Feb 2007 02:32:53 +0000
parents 7a1804e97bdf
children 0ccf5ac2795e
comparison
equal deleted inserted replaced
75787:db90b43ef87e 75788:9099b36e6499
469 (defun titdic-convert (filename &optional dirname) 469 (defun titdic-convert (filename &optional dirname)
470 "Convert a TIT dictionary of FILENAME into a Quail package. 470 "Convert a TIT dictionary of FILENAME into a Quail package.
471 Optional argument DIRNAME if specified is the directory name under which 471 Optional argument DIRNAME if specified is the directory name under which
472 the generated Quail package is saved." 472 the generated Quail package is saved."
473 (interactive "FTIT dictionary file: ") 473 (interactive "FTIT dictionary file: ")
474 (let ((coding-system-for-write 'iso-2022-7bit)) 474 (let ((coding-system-for-write 'iso-2022-7bit-unix))
475 (with-temp-file (tit-make-quail-package-file-name filename dirname) 475 (with-temp-file (tit-make-quail-package-file-name filename dirname)
476 (set-buffer-file-coding-system 'iso-2022-7bit) 476 ;; Explicitly speficy eol format to `unix'.
477 (set-buffer-file-coding-system 'iso-2022-7bit-unix)
477 (let ((standard-output (current-buffer))) 478 (let ((standard-output (current-buffer)))
478 (with-temp-buffer 479 (with-temp-buffer
479 (set-buffer-multibyte nil) 480 (set-buffer-multibyte nil)
480 (let ((coding-system-for-read 'no-conversion)) 481 ;; Here we must use `raw-text' instead of `no-conversion' to
482 ;; enable auto-decoding of eol format (CRLF->LF).
483 (let ((coding-system-for-read 'raw-text))
481 (insert-file-contents (expand-file-name filename))) 484 (insert-file-contents (expand-file-name filename)))
482 485
483 ;; Decode the buffer contents from the encoding specified by a 486 ;; Decode the buffer contents from the encoding specified by a
484 ;; value of the key "ENCODE:". 487 ;; value of the key "ENCODE:".
485 (if (not (search-forward "\nBEGIN" nil t)) 488 (if (not (search-forward "\nBEGIN" nil t))
1143 coding (nth 3 slot) 1146 coding (nth 3 slot)
1144 converter (nth 5 slot) 1147 converter (nth 5 slot)
1145 copyright (nth 6 slot)) 1148 copyright (nth 6 slot))
1146 (message "Converting %s to %s..." dicfile quailfile) 1149 (message "Converting %s to %s..." dicfile quailfile)
1147 (with-temp-file (expand-file-name quailfile dirname) 1150 (with-temp-file (expand-file-name quailfile dirname)
1148 (set-buffer-file-coding-system 'iso-2022-7bit) 1151 ;; Explicitly speficy eol format to `unix'.
1152 (set-buffer-file-coding-system 'iso-2022-7bit-unix)
1149 (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; ") 1153 (insert ";; Quail package `" name "' -*- coding:iso-2022-7bit; ")
1150 (insert "byte-compile-disable-print-circle:t; -*-\n"); 1154 (insert "byte-compile-disable-print-circle:t; -*-\n");
1151 (insert ";; Generated by the command `miscdic-convert'\n") 1155 (insert ";; Generated by the command `miscdic-convert'\n")
1152 (insert ";; Date: " (current-time-string) "\n") 1156 (insert ";; Date: " (current-time-string) "\n")
1153 (insert ";; Source dictionary file: " dicfile "\n") 1157 (insert ";; Source dictionary file: " dicfile "\n")