From: yamaoka Date: Thu, 17 Sep 1998 03:43:19 +0000 (+0000) Subject: * emu-mule.el: Require `cyrillic'. Suggested by MORIOKA-san. X-Git-Tag: apel-8_18~4 X-Git-Url: http://git.chise.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f356d689d05744ca626e4304f99f56d874b7e9c3;p=elisp%2Fapel.git * emu-mule.el: Require `cyrillic'. Suggested by MORIOKA-san. * emu-mule.el (decode-mime-charset-region) (decode-mime-charset-string): Cope with non existent coding systems if the third arg `lbt' has specified. --- diff --git a/ChangeLog b/ChangeLog index b77a8a1..1bc1c57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +1998-09-17 Katsumi Yamaoka + + * emu-mule.el: Require `cyrillic'. Suggested by MORIOKA-san. + + * emu-mule.el (decode-mime-charset-region) + (decode-mime-charset-string): Cope with non existent coding + systems if the third arg `lbt' has specified. + 1998-09-14 MORIOKA Tomohiko * APEL: Version 8.18 was released. diff --git a/emu-mule.el b/emu-mule.el index 617f74f..8c4eb6c 100644 --- a/emu-mule.el +++ b/emu-mule.el @@ -245,10 +245,21 @@ find-file-hooks, etc. (defun decode-mime-charset-region (start end charset &optional lbt) "Decode the text between START and END as MIME CHARSET." - (let ((cs (mime-charset-to-coding-system charset lbt))) + (let ((cs (mime-charset-to-coding-system charset lbt)) + newline) (if cs (code-convert start end cs *internal*) - ))) + (if (and lbt (setq cs (mime-charset-to-coding-system charset))) + (progn + (if (setq newline (cdr (assq lbt '((CRLF . "\r\n") (CR . "\r"))))) + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (while (search-forward newline nil t) + (replace-match "\n"))) + (code-convert (point-min) (point-max) cs *internal*)) + (code-convert start end cs *internal*))))))) (defun encode-mime-charset-string (string charset) "Encode the STRING as MIME CHARSET." @@ -259,10 +270,22 @@ find-file-hooks, etc. (defun decode-mime-charset-string (string charset &optional lbt) "Decode the STRING which is encoded in MIME CHARSET." - (let ((cs (mime-charset-to-coding-system charset lbt))) + (let ((cs (mime-charset-to-coding-system charset lbt)) + newline) (if cs (decode-coding-string string cs) - string))) + (if (and lbt (setq cs (mime-charset-to-coding-system charset))) + (progn + (if (setq newline (cdr (assq lbt '((CRLF . "\r\n") (CR . "\r"))))) + (with-temp-buffer + (insert string) + (goto-char (point-min)) + (while (search-forward newline nil t) + (replace-match "\n")) + (code-convert (point-min) (point-max) cs *internal*) + (buffer-string)) + (decode-coding-string string cs))) + string)))) (cond (running-emacs-19_29-or-later @@ -290,6 +313,8 @@ find-file-hooks, etc. ;;; @@ to coding-system ;;; +(require 'cyrillic) + (defvar mime-charset-coding-system-alist '((iso-8859-1 . *ctext*) (x-ctext . *ctext*)