From c0a7f5b74cbae0cffe6742de410d03e2645605dc Mon Sep 17 00:00:00 2001 From: akr Date: Mon, 19 Oct 1998 11:06:49 +0000 Subject: [PATCH] * eword-decode.el (eword-decode-field): New function. (eword-decode-header): Use `eword-decode-field'. * mime.el (mime-read-field): Use `eword-decode-field'. * mmgeneric.el (insert-header): Use `eword-decode-field'. --- ChangeLog | 9 +++++++++ eword-decode.el | 58 +++++++++++++++++++++++++++++++++++-------------------- mime.el | 8 +------- mmgeneric.el | 27 +++++--------------------- 4 files changed, 52 insertions(+), 50 deletions(-) diff --git a/ChangeLog b/ChangeLog index b0696e7..78a0111 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +1998-10-19 Tanaka Akira + + * eword-decode.el (eword-decode-field): New function. + (eword-decode-header): Use `eword-decode-field'. + + * mime.el (mime-read-field): Use `eword-decode-field'. + + * mmgeneric.el (insert-header): Use `eword-decode-field'. + 1998-10-18 MORIOKA Tomohiko * FLIM: Version 1.11.0 (Yamadagawa) was released. diff --git a/eword-decode.el b/eword-decode.el index 2414a7a..4342af5 100644 --- a/eword-decode.el +++ b/eword-decode.el @@ -289,6 +289,39 @@ Each field name must be symbol." :group 'eword-decode :type '(repeat symbol)) +(defun eword-decode-field (field-name field-body &optional unfolded max-column) + "If FIELD-NAME is in `eword-decode-ignored-field-list', +return FIELD-BODY itself. + +If FIELD-NAME is in `eword-decode-structured-field-list', +FIELD-BODY is interpreted as structured field, +decode MIME encoded-words and return it. + +Otherwise, FIELD-BODY is interpreted as unstructured field, +decode MIME encoded-words and return it. + +Anyway, non-encoded-word part is decoded with `default-mime-charset'. + +If FIELD-BODY is already unfolded, UNFOLDED should be non-nil. + +If MAX-COLUMN is nil, FIELD-BODY is unfolded. +Otherwise, FIELD-BODY is folded with with MAX-COLUMN +(or `fill-column' if MAX-COLUMN is not integer.)" + (cond + ((memq field-name eword-decode-ignored-field-list) + field-body) + ((memq field-name eword-decode-structured-field-list) + (if (null max-column) + (eword-decode-and-fold-structured-field + field-body + (1+ (string-width (symbol-name field-name))) + (if (integerp max-column) max-column fill-column)) + (eword-decode-and-unfold-structured-field field-body))) + (t + (eword-decode-unstructured-field-body + field-body + (1+ (string-width (symbol-name field-name))))))) + (defun eword-decode-header (&optional code-conversion separator) "Decode MIME encoded-words in header fields. If CODE-CONVERSION is nil, it decodes only encoded-words. If it is @@ -315,27 +348,10 @@ If SEPARATOR is not nil, it is used as header separator." len (string-width field-name) field-name (intern (capitalize field-name)) end (std11-field-end)) - (cond ((memq field-name eword-decode-ignored-field-list) - ;; Don't decode - ) - ((memq field-name eword-decode-structured-field-list) - ;; Decode as structured field - (let ((body (buffer-substring p end)) - (default-mime-charset default-charset)) - (delete-region p end) - (insert (eword-decode-and-fold-structured-field - body (1+ len))) - )) - (t - ;; Decode as unstructured field - (save-restriction - (narrow-to-region beg (1+ end)) - (decode-mime-charset-region p end default-charset) - (goto-char p) - (if (re-search-forward eword-encoded-word-regexp - nil t) - (eword-decode-region beg (point-max) 'unfold)) - ))))) + (let ((body (buffer-substring p end)) + (default-mime-charset default-charset)) + (delete-region p end) + (insert (eword-decode-field field-name body nil t))))) (eword-decode-region (point-min) (point-max) t) ))))) diff --git a/mime.el b/mime.el index 293b3e7..57fe2e2 100644 --- a/mime.el +++ b/mime.el @@ -276,14 +276,8 @@ If MESSAGE is specified, it is regarded as root entity." (setq field (std11-parse-address (eword-lexical-analyze field-body))) ) - ((memq field-name eword-decode-ignored-field-list) - (setq field field-body)) - ((memq field-name eword-decode-structured-field-list) - (setq field (eword-decode-structured-field-body - field-body))) (t - (setq field (eword-decode-unstructured-field-body - field-body)) + (setq field (eword-decode-field field-name field-body)) )) (mime-entity-set-parsed-header-internal entity (put-alist field-name field header)) diff --git a/mmgeneric.el b/mmgeneric.el index 634c80a..100516b 100644 --- a/mmgeneric.el +++ b/mmgeneric.el @@ -170,28 +170,11 @@ (set-buffer the-buf) (insert field-name) (insert ":") - (cond ((memq field eword-decode-ignored-field-list) - ;; Don't decode - (insert-buffer-substring src-buf p end) - ) - ((memq field eword-decode-structured-field-list) - ;; Decode as structured field - (let ((body (save-excursion - (set-buffer src-buf) - (buffer-substring p end) - ))) - (insert (eword-decode-and-fold-structured-field - body (1+ len))) - )) - (t - ;; Decode as unstructured field - (let ((body (save-excursion - (set-buffer src-buf) - (buffer-substring p end) - ))) - (insert (eword-decode-unstructured-field-body - body (1+ len))) - ))) + (insert + (eword-decode-field field + (with-current-buffer src-buf + (buffer-substring p end)) + nil t)) (insert "\n") )))))))) -- 1.7.10.4