Function: rmail-mime-set-bulk-data

rmail-mime-set-bulk-data is a byte-compiled function defined in rmailmm.el.gz.

Signature

(rmail-mime-set-bulk-data ENTITY)

Documentation

Setup the information about the attachment object for MIME-entity ENTITY.

The value is non-nil if and only if the attachment object should be shown directly.

Source Code

;; Defined in /usr/src/emacs/lisp/mail/rmailmm.el.gz
(defun rmail-mime-set-bulk-data (entity)
  "Setup the information about the attachment object for MIME-entity ENTITY.
The value is non-nil if and only if the attachment object should be shown
directly."
  (let ((content-type (car (rmail-mime-entity-type entity)))
	(size (cdr (assq 'size (cdr (rmail-mime-entity-disposition entity)))))
	(bulk-data (aref (rmail-mime-entity-tagline entity) 1))
	(body (rmail-mime-entity-body entity))
	type to-show)
    (cond (size
	   (setq size (string-to-number size)))
	  ((stringp (aref body 0))
	   (setq size (length (aref body 0))))
	  (t
	   ;; Rough estimation of the size.
	   (let ((encoding (rmail-mime-entity-transfer-encoding entity)))
	     (setq size (- (aref body 1) (aref body 0)))
	     (cond ((string= encoding "base64")
                    ;; https://en.wikipedia.org/wiki/Base64#MIME
		    (setq size (* size 0.73)))
		   ((string= encoding "quoted-printable")
                    ;; Assume most of the text is ASCII...
		    (setq size (/ (* size 5) 7)))))))

    (cond
     ((string-match "text/html" content-type)
      (setq type 'html))
     ((string-match "text/" content-type)
      (setq type 'text))
     ((string-match "image/\\(.*\\)" content-type)
      (setq type (image-supported-file-p
		  (concat "." (match-string 1 content-type))))
      (when (and type
                 rmail-mime-show-images
                 (not (eq rmail-mime-show-images 'button))
                 (or (not (numberp rmail-mime-show-images))
		     (< size rmail-mime-show-images)))
	(setq to-show t))))
    (setcar bulk-data size)
    (setcdr bulk-data type)
    to-show))