X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tm-ew-d.el;h=0eabbea40b228caf4c78c0bb868fd77c445307d8;hb=c084f9643a142f73a9589954cd3615ffadc9de09;hp=32327701c150397e4c1d573b58d66b3752d2ef4e;hpb=f23312823073375ef7443064a48f3175063bb7b3;p=elisp%2Ftm.git diff --git a/tm-ew-d.el b/tm-ew-d.el index 3232770..0eabbea 100644 --- a/tm-ew-d.el +++ b/tm-ew-d.el @@ -10,7 +10,7 @@ ;;; MORIOKA Tomohiko ;;; Maintainer: MORIOKA Tomohiko ;;; Created: 1993/6/3 (1995/10/3 obsolete tiny-mime.el) -;;; Version: $Revision: 7.10 $ +;;; Version: $Revision: 7.18 $ ;;; Keywords: mail, news, MIME, RFC 1522, multilingual, encoded-word ;;; ;;; This file is part of tm (Tools for MIME). @@ -41,7 +41,7 @@ ;;; (defconst tm-ew-d/RCS-ID - "$Id: tm-ew-d.el,v 7.10 1996/04/19 08:24:15 morioka Exp $") + "$Id: tm-ew-d.el,v 7.18 1996/08/07 15:50:44 morioka Exp $") (defconst mime/eword-decoder-version (get-version-string tm-ew-d/RCS-ID)) @@ -65,7 +65,7 @@ ;;; @ for string ;;; -(defun mime-eword/decode-string (str) +(defun mime-eword/decode-string (str &optional unfolding) (setq str (rfc822/unfolding-string str)) (let ((dest "")(ew nil) beg end) @@ -81,9 +81,11 @@ (setq dest (concat dest (substring str 0 beg))) ) ) - (setq dest (concat dest - (mime/decode-encoded-word (substring str beg end)) - )) + (setq dest + (concat dest + (mime/decode-encoded-word + (substring str beg end) unfolding) + )) (setq str (substring str end)) (setq ew t) ) @@ -94,7 +96,7 @@ ;;; @ for region ;;; -(defun mime-eword/decode-region (beg end &optional unfolding) +(defun mime-eword/decode-region (beg end &optional unfolding must-unfold) (interactive "*r") (save-excursion (save-restriction @@ -111,12 +113,11 @@ (goto-char (point-min)) (let (charset encoding text) (while (re-search-forward mime/encoded-word-regexp nil t) - (insert (mime/decode-encoded-word + (insert (mime/decode-encoded-word (prog1 (buffer-substring (match-beginning 0) (match-end 0)) (delete-region (match-beginning 0) (match-end 0)) - ) - )) + ) must-unfold)) )) ))) @@ -154,12 +155,11 @@ ;;; @ encoded-word decoder ;;; -(defun mime/decode-encoded-word (word) +(defun mime/decode-encoded-word (word &optional unfolding) (or (if (string-match mime/encoded-word-regexp word) (let ((charset - (upcase - (substring word (match-beginning 1) (match-end 1)) - )) + (substring word (match-beginning 1) (match-end 1)) + ) (encoding (upcase (substring word (match-beginning 2) (match-end 2)) @@ -167,7 +167,7 @@ (text (substring word (match-beginning 3) (match-end 3)) )) - (mime/decode-encoded-text charset encoding text) + (mime/decode-encoded-text charset encoding text unfolding) )) word)) @@ -175,17 +175,21 @@ ;;; @ encoded-text decoder ;;; -(defun mime/decode-encoded-text (charset encoding str) +(defun mime/decode-encoded-text (charset encoding str &optional unfolding) (let ((dest - (cond ((string= "B" encoding) + (cond ((string-equal "B" encoding) (base64-decode-string str)) - ((string= "Q" encoding) + ((string-equal "Q" encoding) (q-encoding-decode-string str)) (t (message "unknown encoding %s" encoding) nil)))) (if dest - (mime/convert-string-to-emacs dest charset) - ))) + (progn + (setq dest (decode-mime-charset-string dest charset)) + (if unfolding + (rfc822/unfolding-string dest) + dest) + )))) ;;; @ end