From: morioka Date: Sat, 24 Oct 1998 11:09:30 +0000 (+0000) Subject: (mime-insert-header-from-buffer): New function. X-Git-Tag: flim-1_11_2~39 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=096b3304d2986da99200d7d52997d7acfc92dded;p=elisp%2Fflim.git (mime-insert-header-from-buffer): New function. (insert-header): Use `mime-insert-header-from-buffer'. --- diff --git a/mmgeneric.el b/mmgeneric.el index e6062e9..6d67b99 100644 --- a/mmgeneric.el +++ b/mmgeneric.el @@ -144,44 +144,50 @@ ) t))) +(defun mime-insert-header-from-buffer (buffer start end + &optional invisible-fields + visible-fields) + (let ((the-buf (current-buffer)) + f-b p f-e field-name len field field-body) + (save-excursion + (set-buffer buffer) + (save-restriction + (narrow-to-region start end) + (goto-char start) + (while (re-search-forward std11-field-head-regexp nil t) + (setq f-b (match-beginning 0) + p (match-end 0) + field-name (buffer-substring f-b p) + len (string-width field-name) + f-e (std11-field-end)) + (when (mime-visible-field-p field-name + visible-fields invisible-fields) + (setq field (intern + (capitalize (buffer-substring f-b (1- p)))) + field-body (buffer-substring p f-e)) + (with-current-buffer the-buf + (insert field-name) + (insert + (if (memq field eword-decode-ignored-field-list) + ;; Don't decode + field-body + (if (memq field eword-decode-structured-field-list) + ;; Decode as structured field + (eword-decode-and-fold-structured-field field-body len) + ;; Decode as unstructured field + (eword-decode-unstructured-field-body field-body len) + ))) + (insert "\n") + ))))))) + (mm-define-method insert-header ((entity generic) &optional invisible-fields visible-fields) - (save-restriction - (narrow-to-region (point)(point)) - (let ((the-buf (current-buffer)) - (src-buf (mime-entity-buffer entity)) - (h-end (mime-entity-header-end-internal entity)) - beg p end field-name len field field-body) - (save-excursion - (set-buffer src-buf) - (goto-char (mime-entity-header-start-internal entity)) - (save-restriction - (narrow-to-region (point) h-end) - (while (re-search-forward std11-field-head-regexp nil t) - (setq beg (match-beginning 0) - p (match-end 0) - field-name (buffer-substring beg p) - len (string-width field-name) - end (std11-field-end)) - (when (mime-visible-field-p field-name - visible-fields invisible-fields) - (setq field (intern - (capitalize (buffer-substring beg (1- p)))) - field-body (buffer-substring p end)) - (with-current-buffer the-buf - (insert field-name) - (insert - (if (memq field eword-decode-ignored-field-list) - ;; Don't decode - field-body - (if (memq field eword-decode-structured-field-list) - ;; Decode as structured field - (eword-decode-and-fold-structured-field field-body len) - ;; Decode as unstructured field - (eword-decode-unstructured-field-body field-body len) - ))) - (insert "\n") - )))))))) + (mime-insert-header-from-buffer + (mime-entity-buffer entity) + (mime-entity-header-start-internal entity) + (mime-entity-header-end-internal entity) + invisible-fields visible-fields) + ) (mm-define-method insert-text-content ((entity generic)) (insert