From: morioka Date: Thu, 25 Sep 1997 12:58:09 +0000 (+0000) Subject: (eword-find-field-encoding-method): New inline function. X-Git-Tag: semi-0_115~13 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6b00b9cea8d68831dd89eccf73c9c1a9485329cc;p=elisp%2Fsemi.git (eword-find-field-encoding-method): New inline function. (eword-encode-header): Use it. --- diff --git a/eword-encode.el b/eword-encode.el index 0739c85..7025eba 100644 --- a/eword-encode.el +++ b/eword-encode.el @@ -3,7 +3,7 @@ ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. ;; Author: MORIOKA Tomohiko -;; Version: $Revision: 0.30 $ +;; Version: $Revision: 0.31 $ ;; Keywords: encoded-word, MIME, multilingual, header, mail, news ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces). @@ -36,7 +36,7 @@ ;;; (defconst eword-encode-RCS-ID - "$Id: eword-encode.el,v 0.30 1997-07-13 19:30:26 morioka Exp $") + "$Id: eword-encode.el,v 0.31 1997-09-25 12:58:09 morioka Exp $") (defconst eword-encode-version (get-version-string eword-encode-RCS-ID)) @@ -584,6 +584,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. @@ -600,33 +615,22 @@ 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