0

In wanderlust, if an attachment has an image/* content type, the image will be properly displayed in the message buffer. For example ...

Content-Type: image/jpeg; name="foobar.jpg"

However, some emails arrive with their attachment's content type set to application/octet-stream, even though the attachment is an image, and wanderlust will not display these images in the message buffer. For example ...

Content-Type: application/octet-stream; name="foobar.jpg"

Is there any way to configure wanderlust so that it uses the name attribute to determine that an octet stream represents an image, so it can be displayed in the message buffer?

  • Have a look at all of the references to (ctree-set-calist-strictly ...) – lawlist Aug 5 '17 at 20:35
  • Thank you. As far as I can tell, ctree-set-calist-strictly seems to ignore the name="..." attribute in Content-Type. Actually, the entire MIME parsing system under semi seems to ignore that attribute ... unless I'm missing something. – HippoMan Aug 5 '17 at 21:16
  • While I have not played with your specific fact pattern, I have set up PDF to be displayed as images after being converted to PNG and I had to remove or comment out (ctree-set-calist-strictly 'mime-preview-condition '((body . visible) (body-presentation-method . mime-display-text/plain))) After commenting out that section, I was able to use (ctree-set-calist-strictly 'mime-preview-condition '((type . application) (subtype . pdf) (body . visible) (body-presentation-method . mime-display-image) (image-format . pdf))) Perhaps the same section of code that I commented out also affects you? – lawlist Aug 5 '17 at 21:54
  • Actually, in looking through the semi/mime-*.el stuff, I realized that I could do what I want by modifying the mime-entity-situation function. Your pointing me to ctree-set-calist-strictly got me onto the right track, so thank you! – HippoMan Aug 5 '17 at 22:13
0

I managed to do it by hacking mime-entity-situation, as follows ...

(defun my-mime-imagetype (fname)
  (let (imtype
        mime-info
        subtype)
    (when (stringp fname)
      (setq mime-info (mime-find-file-type fname))
      (and (string-equal (car mime-info) "image")
           (setq subtype (car (cdr mime-info)))
           (setq imtype (intern subtype))))
    imtype))

(defun my-mime-entity-situation (oldfunc &rest args)
  (let* ((result   (apply oldfunc args))
         (filename (cdr (assq 'filename result)))
         (type     (cdr (assq 'type     result)))
         (subtype  (cdr (assq 'subtype  result)))
         imtype)
    (when (and (eq type    'application)
               (eq subtype 'octet-stream)
               (setq imtype (my-mime-imagetype filename)))
      (setf (alist-get 'type    result) 'image)
      (setf (alist-get 'subtype result) imtype))
    result))
(advice-add 'mime-entity-situation :around #'my-mime-entity-situation)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.