From: Reiner Steib <reinersteib+gmane@imap.cc>
Subject: Re: Viewing HTML-mails with external browsers - proposed code
Date: Thu, 19 Jan 2006 20:35:13 +0100 [thread overview]
Message-ID: <v9irsg2eq6.fsf@marauder.physik.uni-ulm.de> (raw)
In-Reply-To: <874q56xeh4@ularx.de>
On Sun, Dec 18 2005, Hynek Schlawack wrote:
> Anyway: As I started to get more and more Mails (mostly newsletters etc)
> that make sense only if readen with an graphical browser like Firefox, I
> was wondering whether there's some easy way to display them in Gnus? As
> I haven't found anything, I wrote a little elisp to solve this. It's
> kindof my first lisp ever, so please be tolerant. ;) Nevertheless it
> actually works; even with recursevly hidden HTML-parts.
JFTR: It failed with "Mail doesn't contain a HTML-part!" on the
following forwarded message:
| <* mixed> Fwd: RE: Termine
| <1 text>
| <2 rfc822>
| <2.* alternative> RE: Termine
| <2.1 text>
| <2.2 html>
> I'm sending the code attached, maybe everyone has something like that in
> his .gnus, then please nevermind. I'd be happy about some feedback or
> even inclusion though.
I think (when your assignment is completed), we should add both
functions to `gnus-art.el' and add a key binding (suggestions?) and
menu entries in `gnus-sum.el'.
As requested, some comments/suggestions on the code:
> (defun hs-show-html-list (LIST)
Rename to, say `gnus-article-browse-html-parts'. Other suggestions?
Instead of LIST, you should write list (in lowercase).
> "View all HTML-parts from 'LIST'.
"View all \"text/html\" parts from LIST.
(Only here in the doc string it must be uppercase.)
> Recurse into multiparts."
>
> (let ((showed))
Maybe "done" instead of "showed"?
> ;; Find and show the html-parts.
> (dolist (elt LIST)
> ;; If HTML, show it
> (cond ((and (listp elt)
Maybe rename "elt" to "handle"?
Basically you have:
(cond ((and a b c)
(do-something))
((and a s d (do-other-things))))
Maybe it would be more clear to write it as follows. But it could be
just a matter of taste.
(when a
(cond ((and b c)
(do-something))
((and s d)
(do-other-things))
> (bufferp (car elt))
Isn't (car elt) the same as (mm-handle-buffer elt)?
> (string-match "text/html" (car (mm-handle-type elt))))
> (let ((tmp (format "%s-%s.html"
Maybe "file" instead of "tmp"?
> (make-temp-name "/tmp/gnus-html-")
> (user-login-name))))
(mm-make-temp-file (expand-file-name "mm" mm-tmp-directory) nil ".html")
Maybe even (convert-standard-filename (mm-make-temp-file ...)) like
in `browse-url-of-buffer' is required?
> (mm-save-part-to-file elt tmp)
> (browse-url tmp)
It would be nice to remove the tmp file after proceeding to the next
article or leaving the summary buffer (maybe similar to
`mm-remove-part'). But it might depend on the browser and the user if
this is desired. Or it could be removed here:
(when (gnus-y-or-n-p "Remove temp file? ") (delete-file tmp))
> (setq showed t)))
> ;; If multipart, recurse
> ((and (listp elt)
> (stringp (car elt))
> (string-match "multipart/" (substring (car elt) 0 10))
(string-match "^multipart/" (car elt))
> (setq showed (or showed (hs-show-html-list elt)))))))
> showed))
>
> (defun hs-show-html-mail ()
(defun gnus-article-browse-html-article
Other suggestions?
> "View HTML-parts of the current Gnus-Article in a graphical browser."
"View \"text/html\" parts of the current article with a WWW browser."
See `C-h f browse-url RET'.
> (interactive)
>
> (save-window-excursion
> ;; Open raw article and select the buffer
> (gnus-summary-show-article t)
> (gnus-summary-select-article-buffer)
> (let ((parts (mm-dissect-buffer t t)))
>
> ;; If singlepart, enforce a list.
> (when (and (bufferp (car parts))
> (stringp (car (mm-handle-type parts))))
> (setq parts (list parts)))
>
> ;; Process the list
> (unless (hs-show-html-list parts)
> (message "Mail doesn't contain a HTML-part!"))
Either (gnus-message 3 ...) or even (gnus-error ...) should be used
here, I think.
> (gnus-summary-show-article))))
Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
next prev parent reply other threads:[~2006-01-19 19:35 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-12-18 21:49 Hynek Schlawack
2006-01-13 13:42 ` Hynek Schlawack
2006-01-13 15:57 ` Reiner Steib
2006-01-13 17:13 ` Hynek Schlawack
2006-01-19 19:35 ` Reiner Steib [this message]
2006-01-22 12:40 ` Hynek Schlawack
2006-01-25 14:44 ` Reiner Steib
2006-01-25 16:29 ` Hynek Schlawack
2006-01-25 17:41 ` Reiner Steib
2006-01-31 12:38 ` Hynek Schlawack
2006-02-10 18:15 ` Reiner Steib
2006-02-13 0:06 ` Katsumi Yamaoka
2006-02-13 14:53 ` Reiner Steib
2006-02-13 15:24 ` Hynek Schlawack
2006-02-13 15:37 ` Hynek Schlawack
2006-02-13 22:16 ` Reiner Steib
2006-02-14 0:11 ` Katsumi Yamaoka
2006-02-14 11:50 ` Katsumi Yamaoka
2006-02-15 8:39 ` mm-make-temp-file (was Re: Viewing HTML-mails with external browsers - proposed code) Katsumi Yamaoka
2006-02-14 20:08 ` Viewing HTML-mails with external browsers - proposed code Hynek Schlawack
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=v9irsg2eq6.fsf@marauder.physik.uni-ulm.de \
--to=reinersteib+gmane@imap.cc \
--cc=Reiner.Steib@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).