diff options
| author | Kenichi Handa | 2002-03-01 02:09:14 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-03-01 02:09:14 +0000 |
| commit | 2db182782d1ba5c91ec366e571145196d334b18d (patch) | |
| tree | a6bd2d79b26064217c1c06dd421e4369618b93dc | |
| parent | 15e44df72ae59a43b507c1426db3fb6b7d953530 (diff) | |
| download | emacs-2db182782d1ba5c91ec366e571145196d334b18d.tar.gz emacs-2db182782d1ba5c91ec366e571145196d334b18d.zip | |
(titdic-convert): Bind coding-system-for-write to 'iso-2022-7bit.
Don't work on unibyte buffer.
| -rw-r--r-- | lisp/international/titdic-cnv.el | 80 |
1 files changed, 39 insertions, 41 deletions
diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index b7ac8a93fd0..93313428099 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el | |||
| @@ -465,50 +465,48 @@ SPC, 6, 3, 4, or 7 specifing a tone (SPC:$(0?v(N(B, 6:$(0Dm(N(B, 3:$(0&9Vy | |||
| 465 | Optional argument DIRNAME if specified is the directory name under which | 465 | Optional argument DIRNAME if specified is the directory name under which |
| 466 | the generated Quail package is saved." | 466 | the generated Quail package is saved." |
| 467 | (interactive "FTIT dictionary file: ") | 467 | (interactive "FTIT dictionary file: ") |
| 468 | (with-temp-file (tit-make-quail-package-file-name filename dirname) | 468 | (let ((coding-system-for-write 'iso-2022-7bit)) |
| 469 | (set-buffer-file-coding-system 'iso-2022-7bit) | 469 | (with-temp-file (tit-make-quail-package-file-name filename dirname) |
| 470 | (let ((standard-output (current-buffer))) | 470 | (set-buffer-file-coding-system 'iso-2022-7bit) |
| 471 | (with-temp-buffer | 471 | (let ((standard-output (current-buffer))) |
| 472 | (let ((coding-system-for-read 'no-conversion)) | 472 | (with-temp-buffer |
| 473 | (insert-file-contents (expand-file-name filename))) | 473 | (let ((coding-system-for-read 'no-conversion)) |
| 474 | (set-buffer-multibyte t) | 474 | (insert-file-contents (expand-file-name filename))) |
| 475 | (set-buffer-multibyte t) | ||
| 475 | 476 | ||
| 476 | ;; Decode the buffer contents from the encoding specified by a | 477 | ;; Decode the buffer contents from the encoding specified by a |
| 477 | ;; value of the key "ENCODE:". | 478 | ;; value of the key "ENCODE:". |
| 478 | (if (not (search-forward "\nBEGIN" nil t)) | 479 | (if (not (search-forward "\nBEGIN" nil t)) |
| 479 | (error "TIT dictionary doesn't have body part")) | 480 | (error "TIT dictionary doesn't have body part")) |
| 480 | (let ((limit (point)) | 481 | (let ((limit (point)) |
| 481 | coding-system slot) | 482 | coding-system slot) |
| 483 | (goto-char (point-min)) | ||
| 484 | (if (re-search-forward "^ENCODE:[ \t]*" limit t) | ||
| 485 | (progn | ||
| 486 | (goto-char (match-end 0)) | ||
| 487 | (setq tit-encode (tit-read-key-value))) | ||
| 488 | (setq tit-encode tit-default-encode)) | ||
| 489 | (setq slot (assoc tit-encode tit-encode-list)) | ||
| 490 | (if (not slot) | ||
| 491 | (error "Invalid ENCODE: value in TIT dictionary")) | ||
| 492 | (setq coding-system (nth 1 slot)) | ||
| 493 | (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. | ||
| 482 | (goto-char (point-min)) | 498 | (goto-char (point-min)) |
| 483 | (if (re-search-forward "^ENCODE:[ \t]*" limit t) | 499 | (if (not (search-forward "\nBEGIN" nil t)) |
| 484 | (progn | 500 | (error "TIT dictionary can't be decoded correctly")) |
| 485 | (goto-char (match-end 0)) | 501 | |
| 486 | (setq tit-encode (tit-read-key-value))) | 502 | ;; Process the header part. |
| 487 | (setq tit-encode tit-default-encode)) | 503 | (forward-line 1) |
| 488 | (setq slot (assoc tit-encode tit-encode-list)) | 504 | (narrow-to-region (point-min) (point)) |
| 489 | (if (not slot) | 505 | (tit-process-header filename) |
| 490 | (error "Invalid ENCODE: value in TIT dictionary")) | 506 | (widen) |
| 491 | (setq coding-system (nth 1 slot)) | 507 | |
| 492 | (message "Decoding with coding system %s..." coding-system) | 508 | ;; Process the body part. |
| 493 | (goto-char (point-min)) | 509 | (tit-process-body)))))) |
| 494 | (decode-coding-region (point-min) (point-max) coding-system)) | ||
| 495 | |||
| 496 | ;; Set point the starting position of the body part. | ||
| 497 | (goto-char (point-min)) | ||
| 498 | (if (not (search-forward "\nBEGIN" nil t)) | ||
| 499 | (error "TIT dictionary can't be decoded correctly")) | ||
| 500 | |||
| 501 | ;; Process the header part. | ||
| 502 | (forward-line 1) | ||
| 503 | (narrow-to-region (point-min) (point)) | ||
| 504 | (tit-process-header filename) | ||
| 505 | (widen) | ||
| 506 | |||
| 507 | ;; Process the body part. For speed, we turn off multibyte facility. | ||
| 508 | (with-current-buffer standard-output | ||
| 509 | (set-buffer-multibyte nil)) | ||
| 510 | (set-buffer-multibyte nil) | ||
| 511 | (tit-process-body))))) | ||
| 512 | 510 | ||
| 513 | ;;;###autoload | 511 | ;;;###autoload |
| 514 | (defun batch-titdic-convert (&optional force) | 512 | (defun batch-titdic-convert (&optional force) |