From: tomo Date: Thu, 2 Mar 2000 10:50:09 +0000 (+0000) Subject: (mime-visible-field-p): Moved from mmbuffer.el. X-Git-Tag: chao-1_14_0-1~21 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=c11722f67c755026823e7bd8a68ae1bb7425a703;p=elisp%2Fflim.git (mime-visible-field-p): Moved from mmbuffer.el. (mime-insert-header-from-buffer): Moved from mmbuffer.el. --- diff --git a/mmgeneric.el b/mmgeneric.el index 02dcfd2..034ed23 100644 --- a/mmgeneric.el +++ b/mmgeneric.el @@ -119,6 +119,66 @@ def-body)) +;;; @ header filter +;;; + +;; [tomo] We should think about specification of better filtering +;; mechanism. Please discuss in the emacs-mime mailing lists. + +(defun mime-visible-field-p (field-name visible-fields invisible-fields) + (or (catch 'found + (while visible-fields + (let ((regexp (car visible-fields))) + (if (string-match regexp field-name) + (throw 'found t) + )) + (setq visible-fields (cdr visible-fields)) + )) + (catch 'found + (while invisible-fields + (let ((regexp (car invisible-fields))) + (if (string-match regexp field-name) + (throw 'found nil) + )) + (setq invisible-fields (cdr invisible-fields)) + ) + t))) + +(defun mime-insert-header-from-buffer (buffer start end + &optional invisible-fields + visible-fields) + (let ((the-buf (current-buffer)) + (mode-obj (mime-find-field-presentation-method 'wide)) + field-decoder + 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) + field-decoder (inline (mime-find-field-decoder-internal + field mode-obj))) + (with-current-buffer the-buf + (insert field-name) + (insert (if field-decoder + (funcall field-decoder field-body len) + ;; Don't decode + field-body)) + (insert "\n") + ))))))) + + ;;; @ end ;;;