Re: problems reading mail with mime parts

Greg Bognar <[email protected]> Thu, 21 Nov 2019 18:31:10 -0500
Newsgroups gmane.mail.wanderlust.general
Message-ID <8736egvmbl.wl-greg.bognar__22954.4031478994$1574379134$gmane$org@startmail.com>
The relevant bits of my setup (using use-package):

(use-package mime-play
  :config ;https://www.emacswiki.org/emacs/WlFaq#toc42
  (setq mime-play-find-every-situations nil
        mime-play-delete-file-immediately nil))

(use-package mime-view
  :init
  (add-hook 'wl-summary-mode-hook
            (lambda ()
              (local-set-key "\C-c\C-o" 'wl-summary-view-html)))
  :config (setq mime-view-text/html-previewer 'shr
                mime-situation-examples-file (concat user-cache-directory "mime")
                ;https://www.emacswiki.org/emacs/WlFaq#toc42
                mime-view-mailcap-files (concat user-cache-directory "mailcap"))
  
  ;; Functions
  ;; Reading HTML mail
  (defun wl-summary-view-html ()
    (interactive)
    (save-excursion
      (wl-message-select-buffer wl-message-buffer)
      (let ((done nil)
            (mime-preview-over-to-next-method-alist
             `((wl-original-message-mode . (lambda ()
                                             (setq done t)))))
            type subtype)
        (while (not done)
          (setq type (cdr (assq 'type (get-text-property (point) 'mime-view-situation))))
          (setq subtype (cdr (assq 'subtype (get-text-property (point) 'mime-view-situation))))
          (if (and (eq type 'text)
                   (eq subtype 'html))
              (progn
                (setq done t)
                (mime-preview-play-current-entity))
            (mime-preview-move-to-next))))))

  ;; Suggested by Erik Hetzner (https://www.emacswiki.org/emacs/WlFaq#toc43)
  (defun mime-preview-extract-current-entity (&optional ignore-examples)
    "Extract current entity into file (maybe).
It decodes current entity to call internal or external method as
\"extract\" mode.  The method is selected from variable
`mime-acting-condition'."
    (interactive "P")
    (cl-letf (((symbol-function #'mime-play-entity)
               (lambda (entity &optional situation ignored-method)
                 (mime-save-content entity situation))))
      (mime-preview-play-current-entity ignore-examples "extract"))))

(use-package shr
  :config (setq shr-max-image-proportion 0.7
                shr-use-colors nil
                shr-use-fonts nil))

(use-package mime-shr
  :after (shr)
  :config (setq mime-shr-blocked-images nil))

That displays all html mail, whether pure or attachment, with shr (or external
browser).  You need to set

(defconst user-cache-directory "~/.cache/emacs/")
(make-directory user-cache-directory t)

but that is just my personal preference.

For the contents of the "mailcap" file, see https://www.emacswiki.org/emacs/WlFaq#toc42.

-------------------------------------------------------------------------------
On Thu 21 Nov 2019 at 08:15 John Covici wrote:
> 
> One additional note, now if the buffer is pure html, not a mime
> attachment, I am getting the html coding and shr is not invoked -- is
> there a way to get that to work?
> 
> Thanks.
> 
> On Thu, 21 Nov 2019 03:36:06 -0500,
> John Covici wrote:
> > 
> > Well, I finally have gotten things working, one problem was that even
> > though I have libxml2, emacs was not compiled with it, but I did not
> > know that until I tried to do shr-render-region and it said that.  So,
> > I compiled emacs and deleted some experiments in mime-previewer-alist
> > and now things are working.
> > 
> > Thanks guys for all your help.
> > 
> > On Thu, 21 Nov 2019 00:33:47 -0500,
> > Herbert J. Skuhra wrote:
> > > 
> > > On Wed, 20 Nov 2019 21:29:56 +0100, "Herbert J. Skuhra" wrote:
> > > 
> > > > Install libxml2 and try again. If you are building from source you
> > > > have to recompile Emacs. If emacs-w3m is not installed/enabled shr
> > > > (wrongly called eww in my previous e-mail) will be used to render
> > > > html.
> > > 
> > > If your Emacs already supports shr/eww you can try:
> > > 
> > > (setq mime-view-text/html-previewer 'shr)
> > > 
> > > I guess you can remove w3 support in Wanderlust by modifying
> > > mime-view-text/html-previewer-alist.
> > > 
> > > --
> > > Herbert
> > > 
> > 
> > -- 
> > Your life is like a penny.  You're going to lose it.  The question is:
> > How do
> > you spend it?
> > 
> >          John Covici wb2una
> >          [email protected]
> > 
> 
> -- 
> Your life is like a penny.  You're going to lose it.  The question is:
> How do
> you spend it?
> 
>          John Covici wb2una
>          [email protected]
>