Hi Yeechang,

Note VM development has moved to https://gitlab.com/emacs-vm/vm/

While we haven't put out an new version, a lot of changes and fixes
have been made in the git repo.  Please consider upgrade.  Requires
emacs 28 or newer.

I have the below configuration and the display button in
  xHTML (UTF-8): <no suggested filename>, HTML                   [display]

I have to toggle the display to get this; I keep meaning to figure out how
to change it to not need a toggle only for HTML.

(if window-system
    (progn
      (setq vm-mime-external-content-types-alist
            '(("video/mpeg"             "open")
              ("video"                  "open")
              ("application/postscript" "open")
              ("application/pdf"        "open")
              ("text/html"              "open")
              ("image/jpeg"             "open")
              ("image/jpg"              "open")
              ("image/png"              "open")
              ("image/tiff"             "open")
              ("image/gif"              "open")
              
("application/vnd.openxmlformats-officedocument.presentationml.presentation" 
"open")
              
("application/vnd.openxmlformats-officedocument.wordprocessingml.document" 
"open")
              ("application/msword"     "open")
              ("application/ics"        "open")
              ("text/calendar"          "open")
              ))
      (setq vm-mime-external-content-type-exceptions
            '("video/mpeg"
              "video"
              "text/html"))
      ))


Yeechang Lee <[email protected]> writes:
> You wrote:
> > Is there a way to configure VM to run this function only when I click 
> > mouse-2 on an HTML button?
> 
> The below isn't an answer to your question. However, it is how I make HTML 
> messages visible in a browser. (The "Seems really hacky" comment sums up the 
> whole thing, really, but it has worked for me for years. I am on 8.2.0b.)
> 
> ----
> 
> (defun my-vm-view-html-in-browser ()
>   "In VM, view HTML message in external browser.
> 
> TODO: Better handle message with HTML within attached message."
>   (interactive)
>   (when (vm-current-message)
>     ;; Does message have HTML?
>     (let ((result)
>         (vm-current-message-layout (prin1-to-string (vm-mm-layout 
> (vm-current-message)))))
>                                       ; Seems really hacky
>       (if (string-match-p "text/html" vm-current-message-layout)
>         (progn ; Yes, HTML is present.
>                                       ; Store window arrangement
>           (vm-save-window-configuration 'my-vm-view-html-in-browser)
>           (when (boundp 'vm-mime-decoded)
>             (unless (string-equal "buttons" vm-mime-decoded)
>               (vm-decode-mime-message 'buttons)
>               (unless (string-equal "buttons" vm-mime-decoded)
>                 (vm-decode-mime-message 'buttons)))) ; Second time
>                                                      ; guarantees
>                                                      ; button
>                                                      ; display from
>                                                      ; undecoded
>                                                      ; message
>           (vm-beginning-of-message)
>           (if (re-search-forward "^HTML (" nil 0)
>               (progn
>                 (setq result "Showing HTML message in external browser...")
>                 (vm-inform 5 result)
>                 (vm-mime-reader-map-display-using-external-viewer)
>                 (setq result "Showing HTML message in external browser... 
> done."))
>                                       ; Seach for HTML attachment failed.
>             (setq result "No HTML found in message")
>                                       ; Attached message present
>                                       ; (might be the only fail
>                                       ; case)
>             (when (string-match-p "message/" vm-current-message-layout)
>               (setq result (concat result ". Check attached message"))))
>           (vm-decode-mime-message 'undecoded) ; Why is this necessary?
>           (vm-decode-mime-message 'decoded)
>                                       ; Restore window arrangement
>           (vm-apply-window-configuration 'my-vm-view-html-in-browser))
>       (setq result "No HTML found in message")) ; No HTML.
> 
>       (if (string-prefix-p "No HTML found" result)
>         (error (vm-inform 5 result))
>       ;; Below hopefully no longer needed with
>       ;; vm-mime-delete-viewer-processes nil
>       ;;      (vm-inform 5 result))
>       ;; (when (string-equal "Showing HTML message in external browser." 
> result)
>       ;;      (sleep-for .25))))) ; Force wait to ensure openremote isn't 
> interrupted
>               (vm-inform 5 result)))))
> 
> ; Bound to "H" key
> (define-key vm-mode-map [remap vm-folders-summarize] 
> 'my-vm-view-html-in-browser)
> 

Reply via email to