From: keiichi Date: Thu, 21 Jan 1999 08:24:31 +0000 (+0000) Subject: (lbt-to-string): New inline function. X-Git-Tag: apel-mcs-2-199901211900~3 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=3816c68f8faae6012c2f69f2c1b9f7986ca823ea;p=elisp%2Fapel.git (lbt-to-string): New inline function. (encode-mime-charset-region): Add new optional argument `lbt'. (encode-mime-charset-string): Ditto. (decode-mime-charset-region): Use `lbt-to-string'. --- diff --git a/ChangeLog b/ChangeLog index 3f7e151..a54ea54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +1999-01-21 Keiichi Suzuki + + * mcs-xm.el (encode-mime-charset-region): Add new optional + argument `lbt'. + (encode-mime-charset-string): Ditto. + + * mcs-nemacs.el (lbt-to-string): New inline function. + (encode-mime-charset-region): Add new optional argument `lbt'. + (encode-mime-charset-string): Ditto. + + * mcs-ltn1.el (lbt-to-string): New inline function. + (encode-mime-charset-region): Add new optional argument `lbt'. + (encode-mime-charset-string): Ditto. + (decode-mime-charset-region): Use `lbt-to-string'. + + * mcs-e20.el (encode-mime-charset-region): Add new optional + argument `lbt'. + (encode-mime-charset-string): Ditto. + + * mcs-om.el (lbt-to-string): New inline function. + (encode-mime-charset-region): Add new optional argument `lbt'. + (encode-mime-charset-string): Ditto. + (decode-mime-charset-region): Use `lbt-to-string'. + (decode-mime-charset-string): Ditto. + 1998-12-24 MORIOKA Tomohiko * mcs-om.el (default-mime-charset-for-write): New variable. @@ -1243,7 +1268,7 @@ 1998-04-27 MORIOKA Tomohiko * calist.el (ctree-find-calist): Renamed from - 'ctree-match-calist-all. + 'ctree-match-calist-all. 1998-04-25 MORIOKA Tomohiko @@ -1284,7 +1309,7 @@ * APEL: Version 8.4 was released. - * EMU-ELS: Don't use HIRAGANA LETTER A ($(B$"(B) to detect character + * EMU-ELS: Don't use HIRAGANA LETTER A ($B$"(B) to detect character indexing (Emacs 20.3 or later). 1998-04-20 MORIOKA Tomohiko diff --git a/mcs-ltn1.el b/mcs-ltn1.el index 2fed09a..643bb2a 100644 --- a/mcs-ltn1.el +++ b/mcs-ltn1.el @@ -30,6 +30,14 @@ (defvar default-mime-charset 'iso-8859-1) +(defsubst lbt-to-string (lbt) + (cdr (assq lbt '((nil . nil) + (CRLF . "\r\n") + (CR . "\r") + (dos . "\r\n") + (mac . "\r")))) + ) + (defun mime-charset-to-coding-system (charset) (if (stringp charset) (setq charset (intern (downcase charset))) @@ -46,25 +54,40 @@ default-mime-charset 'us-ascii)) -(defun encode-mime-charset-region (start end charset) +(defun encode-mime-charset-region (start end charset &optional lbt) "Encode the text between START and END as MIME CHARSET." - ) + (let ((newline (lbt-to-string lbt))) + (if newline + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (while (search-forward "\n" nil t) + (replace-match newline)) + ))) + )) (defun decode-mime-charset-region (start end charset &optional lbt) "Decode the text between START and END as MIME CHARSET." - (cond ((eq lbt 'CRLF) - (save-excursion - (save-restriction - (narrow-to-region start end) - (goto-char (point-min)) - (while (search-forward "\r\n" nil t) - (replace-match "\n")) - )) - ))) - -(defun encode-mime-charset-string (string charset) + (let ((newline (lbt-to-string lbt))) + (if newline + (save-excursion + (save-restriction + (narrow-to-region start end) + (goto-char (point-min)) + (while (search-forward newline nil t) + (replace-match "\n")) + ))) + )) + +(defun encode-mime-charset-string (string charset &optional lbt) "Encode the STRING as MIME CHARSET." - string) + (if lbt + (with-temp-buffer + (insert string) + (encode-mime-charset-region (point-min)(point-max) charset lbt) + (buffer-string)) + string)) (defun decode-mime-charset-string (string charset &optional lbt) "Decode the STRING as MIME CHARSET."