| mu4e & xwidget / webkit | djcb | 23/01/16 07:38 | Hi all,
Hope you've all recovered from the festivities surrounding the mu 0.9.16 release :-). Of course, things don't stop there. If you're using emacs' development version - ie. the latest from the 'emacs-25' branch, you may have noticed the merging of the xwidget-branch, which is allows for embedding various gtk+ widgets inside emacs, and it includes a webkit widget as an example of that. Now, how hard would it be for mu4e to use that? Not very hard, it seems; see the below snippet, which is just a small variation on `mu4e-action-view-in-browser`. If you add it to your configuration, typing `a x` in the message view allows you to view messages in their full html-glory inside emacs (see attached screenshot). This is a bit crude - ultimately, a better solution would be to use a mu4e-specific email widget, such as the one in toys/mug. That would require a bit of work still. But regardless, I've found it quite useful, and a good alternative for `mu4e-view-action-view-in-browser`. --8<---------------cut here---------------start------------->8--- ;; works only for emacs with xwidget support (defun my-mu4e-action-view-with-xwidget (msg) "View the body of the message inside xwidget-webkit." (unless (fboundp 'xwidget-webkit-browse-url) (mu4e-error "No xwidget support available")) (let* ((html (mu4e-message-field msg :body-html)) (txt (mu4e-message-field msg :body-txt)) (tmpfile (format "%s%x.html" temporary-file-directory (random t)))) (unless (or html txt) (mu4e-error "No body part for this message")) (with-temp-buffer ;; simplistic -- but note that it's only an example... (insert (or html (concat "<pre>" txt "</pre>"))) (write-file tmpfile) (xwidget-webkit-browse-url (concat "file://" tmpfile) t)))) (add-to-list 'mu4e-view-actions '("xViewXWidget" . my-mu4e-action-view-with-xwidget) t) --8<---------------cut here---------------end--------------->8--- Kind regards, Dirk. |
| Re: mu4e & xwidget / webkit | Nicolas Richard | 25/01/16 05:36 | Hi,
Thanks for the snippet ! I have a build without xwidget support, but I do have a function xwidget-webkit-browse-url nevertheless. The error is : Debugger entered--Lisp error: (void-function make-xwidget) make-xwidget(1 1 webkit-osr "*xwidget-webkit*<2>" 1000 1000 nil) xwidget-insert(1 webkit-osr "*xwidget-webkit*<2>" 1000 1000) xwidget-webkit-new-session("file:///tmp/24d164f71e1f136.html") xwidget-webkit-browse-url("file:///tmp/24d164f71e1f136.html" t) thus testing for make-xwidget might work better. -- Nicolas |
| Re: mu4e & xwidget / webkit | djcb | 25/01/16 11:48 | This seems like a little niggle in xwidget itself; I guess testing
for some xwidget implementation detail is not the way to go. Anyway, xwidget is /really/ new, so there will be changes... Kind regards, Dirk. -- Dirk-Jan C. Binnema Helsinki, Finland e:d...@djcbsoftware.nl w:www.djcbsoftware.nl pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C |
| Re: mu4e & xwidget / webkit | Peter Tran-Jørgensen | 20/10/16 07:04 | Thanks for this. When using the configuration above xwidget leaves a lot of buffers around C-x C-b. *% *xwidget webkit... 30 xwidget-webkit *% *xwidget webkit... 30 xwidget-webkit *% *xwidget-webkit* 30 xwidget-webkit *% *xwidget-webkit... 30 xwidget-webkit .. Is there a clever way to make sure they get killed after viewing the message? Thanks in advance! |
| Re: mu4e & xwidget / webkit | Peter Tran-Jørgensen | 20/10/16 07:53 | I should mention that I'm experiencing the same when I use (add-to-list 'mu4e-view-actions '("xViewXWidget" . mu4e-action-view-with-xwidget) t) |
| Re: mu4e & xwidget / webkit | djcb | 22/10/16 10:43 | mu4e writes a temp file, and then hands it off to xwidget; so you can use whatever xwidget supports for that, including changing the key bindings. (DOn't have an xwidget-enabled emacs handy, but I'm sure you can figure it out :-) |