*** empty log message ***
[elisp/semi.git] / eword-encode.el
index ddfa8c9..997c6e3 100644 (file)
@@ -3,7 +3,7 @@
 ;; Copyright (C) 1995,1996,1997 Free Software Foundation, Inc.
 
 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
-;; Version: $Revision: 0.4 $
+;; Version: $Revision: 0.10 $
 ;; Keywords: encoded-word, MIME, multilingual, header, mail, news
 
 ;; This file is part of SEMI (SEMI is Emacs MIME Interfaces).
 (require 'mel)
 (require 'std11)
 (require 'mime-def)
-(require 'tl-list)
+(require 'cl)
+
+(defsubst find-non-ascii-charset-string (string)
+  "Return a list of charsets in the STRING except ascii."
+  (delq 'ascii (find-charset-string string))
+  )
 
 
 ;;; @ version
 ;;;
 
 (defconst eword-encode-RCS-ID
-  "$Id: eword-encode.el,v 0.4 1997-02-22 17:04:26 morioka Exp $")
+  "$Id: eword-encode.el,v 0.10 1997-02-27 08:42:17 tmorioka Exp $")
 (defconst eword-encode-version (get-version-string eword-encode-RCS-ID))
 
 
@@ -63,7 +68,7 @@ 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-message-header'.")
+when Subject field is encoded by `eword-encode-header'.")
 
 (defvar eword-charset-encoding-alist
   '((us-ascii          . nil)
@@ -526,12 +531,15 @@ when Subject field is encoded by `eword-encode-message-header'.")
        (car (tm-eword::encode-string 0 str))
        )))
 
-(defun mime/exist-encoded-word-in-subject ()
+(defun eword-in-subject-p ()
   (let ((str (std11-field-body "Subject")))
-    (if (and str (string-match mime/encoded-word-regexp str))
+    (if (and str (string-match eword-encoded-word-regexp str))
        str)))
 
-(defun eword-encode-message-header (&optional code-conversion)
+(defun eword-encode-header (&optional code-conversion)
+  "Encode header fields to network representation, such as MIME encoded-word.
+
+It refer variable `eword-field-encoding-method-alist'."
   (interactive "*")
   (save-excursion
     (save-restriction
@@ -544,14 +552,14 @@ when Subject field is encoded by `eword-encode-message-header'.")
          (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 (ASSOC (downcase field-name)
-                                    eword-field-encoding-method-alist
-                                    :test (function
-                                           (lambda (str1 str2)
-                                             (and (stringp str2)
-                                                  (string= str1
-                                                           (downcase str2))
-                                                  ))))
+              (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
@@ -575,7 +583,7 @@ when Subject field is encoded by `eword-encode-message-header'.")
          ))
       (and eword-generate-X-Nsubject
           (or (std11-field-body "X-Nsubject")
-              (let ((str (mime/exist-encoded-word-in-subject)))
+              (let ((str (eword-in-subject-p)))
                 (if str
                     (progn
                       (setq str
@@ -585,16 +593,14 @@ when Subject field is encoded by `eword-encode-message-header'.")
                           (setq str
                                 (encode-mime-charset-string
                                  str
-                                 (or (cdr (ASSOC
-                                           "x-nsubject"
-                                           eword-field-encoding-method-alist
-                                           :test
+                                 (or (cdr (assoc-if
                                            (function
-                                            (lambda (str1 str2)
-                                              (and (stringp str2)
-                                                   (string= str1
+                                            (lambda (str)
+                                              (and (stringp str)
+                                                   (string= "x-nsubject"
                                                             (downcase str2))
-                                                   )))))
+                                                   )))
+                                           eword-field-encoding-method-alist))
                                      'iso-2022-jp-2)))
                         )
                       (insert (concat "\nX-Nsubject: " str))