X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=eword-encode.el;h=6dbbea373e486656c67b1a9952d529371b901b29;hb=0c115c3068d06f197bf3cb99aad53c3a948a15a0;hp=bbd2c0fba0338c16dd8a29215da0fe45eb522610;hpb=23c6092a1274e38b4e7466a3e5a3e09f099f4309;p=elisp%2Fsemi.git diff --git a/eword-encode.el b/eword-encode.el index bbd2c0f..6dbbea3 100644 --- a/eword-encode.el +++ b/eword-encode.el @@ -1,12 +1,11 @@ ;;; eword-encode.el --- RFC 2047 based encoded-word encoder for GNU Emacs -;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. +;; Copyright (C) 1995,1996,1997,1998 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko -;; Version: $Revision: 0.29 $ ;; Keywords: encoded-word, MIME, multilingual, header, mail, news -;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). +;; This file is part of SEMI (Spadework for Emacs MIME Interfaces). ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as @@ -36,7 +35,7 @@ ;;; (defconst eword-encode-RCS-ID - "$Id: eword-encode.el,v 0.29 1997-07-13 18:15:32 morioka Exp $") + "$Id: eword-encode.el,v 1.1 1998-03-12 19:10:12 morioka Exp $") (defconst eword-encode-version (get-version-string eword-encode-RCS-ID)) @@ -63,10 +62,6 @@ network-code. If method is nil, this field will not be encoded.") -(defvar eword-generate-X-Nsubject nil - "*If it is not nil, X-Nsubject field is generated -when Subject field is encoded by `eword-encode-header'.") - (defvar eword-charset-encoding-alist '((us-ascii . nil) (iso-8859-1 . "Q") @@ -494,7 +489,10 @@ MODE is allows `text', `comment', `phrase' or nil. Default value is ) (append dest - (list (list (concat "<" (std11-addr-to-string route) ">") nil nil)) + (eword-addr-seq-to-rwl + (append '((specials . "<")) + route + '((specials . ">")))) )))) (defun eword-addr-spec-to-rwl (addr-spec) @@ -560,7 +558,8 @@ encoded-word. ASCII token is not encoded." resent-reply-to resent-from resent-sender to resent-to cc resent-cc - bcc resent-bcc dcc) + bcc resent-bcc dcc + mime-version) ) (car (tm-eword::encode-address-list (+ (length field-name) 2) field-body)) @@ -581,6 +580,21 @@ encoded-word. ASCII token is not encoded." (if (and str (string-match eword-encoded-word-regexp str)) str))) +(defsubst eword-find-field-encoding-method (field-name) + (setq field-name (downcase field-name)) + (let ((alist eword-field-encoding-method-alist)) + (catch 'found + (while alist + (let* ((pair (car alist)) + (str (car pair))) + (if (and (stringp str) + (string= field-name (downcase str))) + (throw 'found (cdr pair)) + )) + (setq alist (cdr alist))) + (cdr (assq t eword-field-encoding-method-alist)) + ))) + (defun eword-encode-header (&optional code-conversion) "Encode header fields to network representation, such as MIME encoded-word. @@ -597,59 +611,24 @@ It refer variable `eword-field-encoding-method-alist'." (setq field-name (buffer-substring beg (1- (match-end 0)))) (setq end (std11-field-end)) (and (find-non-ascii-charset-region beg end) - (let ((ret (or (let ((fname (downcase field-name))) - (assoc-if - (function - (lambda (str) - (and (stringp str) - (string= fname (downcase str)) - ))) - eword-field-encoding-method-alist)) - (assq t eword-field-encoding-method-alist) - ))) - (if ret - (let ((method (cdr ret))) - (cond ((eq method 'mime) - (let ((field - (buffer-substring-no-properties beg end) - )) - (delete-region beg end) - (insert (eword-encode-field field)) - )) - (code-conversion - (let ((cs - (or (mime-charset-to-coding-system - method) - default-cs))) - (encode-coding-region beg end cs) - ))) - )) + (let ((method (eword-find-field-encoding-method + (downcase field-name)))) + (cond ((eq method 'mime) + (let ((field + (buffer-substring-no-properties beg end) + )) + (delete-region beg end) + (insert (eword-encode-field field)) + )) + (code-conversion + (let ((cs + (or (mime-charset-to-coding-system + method) + default-cs))) + (encode-coding-region beg end cs) + ))) )) )) - (and eword-generate-X-Nsubject - (or (std11-field-body "X-Nsubject") - (let ((str (eword-in-subject-p))) - (if str - (progn - (setq str - (eword-decode-string - (std11-unfold-string str))) - (if code-conversion - (setq str - (encode-mime-charset-string - str - (or (cdr (assoc-if - (function - (lambda (str) - (and (stringp str) - (string= "x-nsubject" - (downcase str)) - ))) - eword-field-encoding-method-alist)) - 'iso-2022-jp-2))) - ) - (insert (concat "\nX-Nsubject: " str)) - ))))) ))) (defun eword-encode-string (str &optional column mode)