missing link in the view buffer

225 views
Skip to first unread message

Emilio Torres Manzanera

unread,
May 11, 2012, 6:17:02 AM5/11/12
to mu-discuss
Hello,

I have received this message with a link in the text , but this link
does not appear in the view buffer.
Any solution?
Thanks,
Emilio

mu4e - mu for emacs version 0.9.8.4

(*mu4e-view*)

Plugin html is pending approval on
Grupo_de_Interés_Local_de_Barcelona_-
GIL_Barcelona_o_RUGBCN.

See all the pending plugins in the plugin_approval_page.


(*mu4-raw-view*):

Plugin html is pending approval on <a href="http://www.r-es.org/Grupo
+de+Inter%C3%A9s+Local+de+Barcelona+-+GIL+Barcelona+o+RUGBCN" class=""
data-type="wiki page" data-object="Grupo de Interés Local de Barcelona
- GIL Barcelona o RUGBCN">Grupo de Interés Local de Barcelona - GIL
Barcelona o RUGBCN</a>.<br />
<br />
See all the pending plugins in the <a href='http://www.r-es.org/tiki-
plugins.php'>plugin approval page</a>.<br />
<br />
<br />
<b>Plugin body:</b><br />
<iframe src="https://www.google.com/calendar/embed?src=rugbcn
%40gmail.com&amp;ctz=Atlantic/Canary" frameborder="0" width="510"
height="600" marginheight="0" marginwidth="0"></iframe><br />

Dirk-Jan C. Binnema

unread,
May 11, 2012, 2:28:07 PM5/11/12
to mu-di...@googlegroups.com
Hi Emilio,

Emilio Torres Manzanera <tor...@uniovi.es> writes:

> Hello,
>
> I have received this message with a link in the text , but this link
> does not appear in the view buffer.
> Any solution?
> Thanks,
> Emilio
>
> mu4e - mu for emacs version 0.9.8.4
>
> (*mu4e-view*)
>
> Plugin html is pending approval on
> Grupo_de_Interés_Local_de_Barcelona_-
> GIL_Barcelona_o_RUGBCN.
>
> See all the pending plugins in the plugin_approval_page.

When showing html messages, mu4e does html->text conversion; either in
emacs or using some external program; see the variable
`mu4e-html2text-command'.

If that conversion does not preserve the link as something that can be
recognized as an url, there is not much we can do, unfortunately...

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl
pgp: D09C E664 897D 7D39 5047 A178 E96A C7A1 017D DA3C

Emilio Torres Manzanera

unread,
May 11, 2012, 4:58:53 PM5/11/12
to mu-discuss
Hi Dirk,

you are right, I am using
(setq mu4e-html2text-command "html2text -utf8 -width 72")
and it seems that the conversion eats the link.

Would you please implement an option to toggle the view between plain
format and html format? For instance, pressing key 'v' converts the
body of the mail into a browser buffer (browse-url-of-buffer or
similar function)

Is it possible?
Thanks in advance.
Emilio



On May 11, 8:28 pm, Dirk-Jan C. Binnema <d...@djcbsoftware.nl> wrote:
> Hi Emilio,
>
> Emilio Torres Manzanera <tor...@uniovi.es> writes:
>
>
>
>
>
>
>
>
>
> > Hello,
>
> > I have received this message with a link in the text , but this link
> > does not appear in the view buffer.
> > Any solution?
> > Thanks,
> > Emilio
>
> > mu4e - mu for emacs version 0.9.8.4
>
> > (*mu4e-view*)
>
> > Plugin html is pending approval on
> > Grupo_de_Interés_Local_de_Barcelona_-
> > GIL_Barcelona_o_RUGBCN.
>
> > See all the pending plugins in the plugin_approval_page.
>
> When showing html messages, mu4e does html->text conversion; either in
> emacs or using some external program; see the variable
> `mu4e-html2text-command'.
>
> If that conversion does not preserve the link as something that can be
> recognized as an url, there is not much we can do, unfortunately...
>
> Best wishes,
> Dirk.
>
> --
> Dirk-Jan C. Binnema                  Helsinki, Finland
> e:d...@djcbsoftware.nl           w:www.djcbsoftware.nl

Dirk-Jan C. Binnema

unread,
May 12, 2012, 5:04:19 AM5/12/12
to mu-di...@googlegroups.com
Hi,

Emilio Torres Manzanera <tor...@uniovi.es> writes:

> Hi Dirk,
>
> you are right, I am using
> (setq mu4e-html2text-command "html2text -utf8 -width 72")
> and it seems that the conversion eats the link.
>
> Would you please implement an option to toggle the view between plain
> format and html format? For instance, pressing key 'v' converts the
> body of the mail into a browser buffer (browse-url-of-buffer or
> similar function)

You can use the actions system for this; below, a bit hackish way using
'mu extract' to view a message in an external web browser:

---
(defun mu4e-action-view-in-browser (msg)
"Hack to view the html part for MSG in a web browser."
(let* ((shellpath (shell-quote-argument (mu4e-msg-field msg :path)))
(partnum
(shell-command-to-string
(format "%s extract %s | grep 'text/html' | awk '{print $1}'"
mu4e-mu-binary shellpath))))
(unless (> (length partnum) 0)
(error "No html part for this message"))
(call-process-shell-command
(format "cd %s; %s extract %s --parts=%s --overwrite --play"
(shell-quote-argument temporary-file-directory)
mu4e-mu-binary shellpath (substring partnum 0 -1)))))

(add-to-list 'mu4e-view-actions
'("View in browser" ?v mu4e-action-view-in-browser) t)
---

Now, 'a v' in the view should do the trick. If you want to view things
inside emacs (e.g, using w3m), I guess you could adapt the latter part
of the function. *Left as an exercise for the reader*

I have some ideas about making this less hacky; stay tuned.

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Emilio Torres Manzanera

unread,
May 13, 2012, 4:50:49 PM5/13/12
to mu-discuss
It is a fantastic solution! It works very nice. Thanks!
I provide a quick and less elaborate function that does a similar
result.

(defun mu4e-view-in-browser ()
"View the body of the message in a web browser."
(interactive)
(let (msg txt html)
(setq msg (mu4e-message-at-point t))
(setq txt (plist-get msg :body-txt))
(setq html (plist-get msg :body-html))
(with-temp-buffer
(when (> (length html) 0)
(insert html))
(when (> (length txt) 0)
(insert txt))
(browse-url-of-buffer))))
> e:d...@djcbsoftware.nl           w:www.djcbsoftware.nl

Tamas Papp

unread,
May 16, 2012, 3:03:33 AM5/16/12
to mu-di...@googlegroups.com
Hi Emilio and Dirk,

Emilio Torres Manzanera <tor...@uniovi.es> writes:

> It is a fantastic solution! It works very nice. Thanks!
> I provide a quick and less elaborate function that does a similar
> result.
>
> (defun mu4e-view-in-browser ()
> "View the body of the message in a web browser."
> (interactive)
> (let (msg txt html)
> (setq msg (mu4e-message-at-point t))
> (setq txt (plist-get msg :body-txt))
> (setq html (plist-get msg :body-html))
> (with-temp-buffer
> (when (> (length html) 0)
> (insert html))
> (when (> (length txt) 0)
> (insert txt))
> (browse-url-of-buffer))))

I tried both scripts and they work fine, but Firefox renders the file as
plain text, not HTML. I found a workaround (Force HTML bookmarklet [1])
but I was wondering if there is a solution that would automatically
achieve this --- eg save the temporary file with a html extension.

Best,

Tamas

[1] http://www.howtocreate.co.uk/bookmarklets.html

Dirk-Jan C. Binnema

unread,
May 16, 2012, 10:20:11 AM5/16/12
to mu-di...@googlegroups.com
Hi Tamas,

Tamas Papp <tkp...@gmail.com> writes:

> Hi Emilio and Dirk,

<snip>

> I tried both scripts and they work fine, but Firefox renders the file as
> plain text, not HTML. I found a workaround (Force HTML bookmarklet [1])
> but I was wondering if there is a solution that would automatically
> achieve this --- eg save the temporary file with a html extension.

Did you try? Something like should work:

--
(defun mu4e-action-view-in-browser-2 (msg)
"View the body of the message in a web browser."
(let ((html (mu4e-msg-field msg :body-html))
(tmpfile (format "%s/%d.html" temporary-file-directory (random))))
(unless html (error "No html part for this message"))
(with-temp-file tmpfile
(insert
"<html>"
"<head><meta http-equiv=\"content-type\""
"content=\"text/html;charset=UTF-8\">"
html))
(browse-url (concat "file://" tmpfile))))

(add-to-list 'mu4e-view-actions
'("Browser" ?B mu4e-action-view-in-browser-2) t)
--

Best wishes,
Dirk.

--
Dirk-Jan C. Binnema Helsinki, Finland
e:dj...@djcbsoftware.nl w:www.djcbsoftware.nl

Tamas Papp

unread,
May 18, 2012, 4:08:49 AM5/18/12
to mu-di...@googlegroups.com
Hi Dirk,

Dirk-Jan C. Binnema <dj...@djcbsoftware.nl> writes:

> Tamas Papp <tkp...@gmail.com> writes:

>> I tried both scripts and they work fine, but Firefox renders the file as
>> plain text, not HTML. I found a workaround (Force HTML bookmarklet [1])
>> but I was wondering if there is a solution that would automatically
>> achieve this --- eg save the temporary file with a html extension.
>
> Did you try? Something like should work:

Sorry, I did try, but I still know very little about programming in
Emacs. Could you, by any chance, recommend a good book/tutorial? I
already know CL, I just need to learn to find my way around the the DSL
that is Emacs.

> (defun mu4e-action-view-in-browser-2 (msg)
> "View the body of the message in a web browser."
> (let ((html (mu4e-msg-field msg :body-html))
> (tmpfile (format "%s/%d.html" temporary-file-directory (random))))
> (unless html (error "No html part for this message"))
> (with-temp-file tmpfile
> (insert
> "<html>"
> "<head><meta http-equiv=\"content-type\""
> "content=\"text/html;charset=UTF-8\">"
> html))
> (browse-url (concat "file://" tmpfile))))
>
> (add-to-list 'mu4e-view-actions
> '("Browser" ?B mu4e-action-view-in-browser-2) t)

This works fine, thanks!

Best,

Tamas
Reply all
Reply to author
Forward
0 new messages