From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/61581 Path: news.gmane.org!not-for-mail From: Hynek Schlawack Newsgroups: gmane.emacs.gnus.general Subject: Viewing HTML-mails with external browsers - proposed code Date: Sun, 18 Dec 2005 22:49:43 +0100 Message-ID: <874q56xeh4@ularx.de> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: sea.gmane.org 1134942610 31770 80.91.229.2 (18 Dec 2005 21:50:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 18 Dec 2005 21:50:10 +0000 (UTC) Original-X-From: ding-owner+m10113@lists.math.uh.edu Sun Dec 18 22:50:06 2005 Return-path: Original-Received: from malifon.math.uh.edu ([129.7.128.13]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Eo6Pb-0000fD-OK for ding-account@gmane.org; Sun, 18 Dec 2005 22:49:48 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.math.uh.edu ident=lists) by malifon.math.uh.edu with smtp (Exim 3.20 #1) id 1Eo6PW-0007b0-00; Sun, 18 Dec 2005 15:49:42 -0600 Original-Received: from nas01.math.uh.edu ([129.7.128.39]) by malifon.math.uh.edu with esmtp (Exim 3.20 #1) id 1Eo6Ok-0007av-00 for ding@lists.math.uh.edu; Sun, 18 Dec 2005 15:48:54 -0600 Original-Received: from quimby.gnus.org ([80.91.224.244]) by nas01.math.uh.edu with esmtp (Exim 4.52) id 1Eo6Oh-0000AE-9o for ding@lists.math.uh.edu; Sun, 18 Dec 2005 15:48:54 -0600 Original-Received: from relay1.mail.vrmd.de ([81.28.232.18]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1Eo6Og-0004S8-00 for ; Sun, 18 Dec 2005 22:48:50 +0100 Original-Received: from [84.189.78.56] (helo=squirrel.hn.org) by vm8.bln2.vrmd.de with asmtp (Exim 4.41) id 1Eo6Og-0004sP-EL for ding@gnus.org; Sun, 18 Dec 2005 22:48:50 +0100 Original-Received: by squirrel.hn.org (Postfix, from userid 1000) id B673150D7796; Sun, 18 Dec 2005 22:49:43 +0100 (CET) Original-To: ding@gnus.org X-URL: http://www.ularx.de/ X-PGP-Key-FingerPrint: 9630 3D11 CBB3 2776 D143 7EFB DA15 A045 7505 8F70 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAAAAAByaaZbAAAACXBIWXMAAABIAAAASABGyWs+ AAACG0lEQVRIx62W4ZGEMAiFLWOroh6KoAW6oCBLufCAhKjnzs0c9+NW5csjBNDj/KMd/wLYqSrC rPYVUCX6dBN6AUz582DE9gvw6J5CD8CLewjZDmToFPaIWAO4whVRmDBN24ijLT/cVa1M/Eo8uzyZ BCyusHq56zQwhRgAXtHYxSq+SQCAvzz5F+BEShwZETtgD7aiAqAD0Am8EBWUK7xsoUsEIN+BkgiA ByD3M7gCu8K5HTHsniZpewigDMXAyFgWyHxQ5+BpxQ2/Lfl4EDiwvg7KPDZNImsV/JYhUPdoEV5L No7ETyHlieDnQCh6vGAccAX39BThdASGiALg0CZHB0EAlCOnmQ+YZkh1HRi5Qqxcqcw0agLSzHW8 vEUzhC33FiHJ3hViUNAu4SvHRV8o6w9ArBUHnXWQsBMzVNQrR8eFuCztbI3Iq9ahO5BDQCmJlZD6 H32SbcoFnNd0NAvF2HMbM5F7rYcXMC90DTJKZZEszt0/ImK7AVHQsWe17LP0H39zthp9aG1O6ryi 80Uqd3N6m5dha7ltBxVq+Qcw/L3nrkjV4dpxhjSA0RPohtXYzR2h9ReKd1AnZtVmbOi1FpJvwtuj hsc2vufIowZsRKvbbQpvwCgm90S2aO4jKtR9+2sxX1lGIVI7qerBdRdYL0XFoXJ7tSWdE+/xxc5r BMUArFHFy+ny6XDKJaShItsXxxWAEvoa00hunyc/yE4HHXmSQMIAAAAASUVORK5CYII= User-Agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux) X-Relay-User: mailout@ularx.de X-Spam-Score: -2.6 (--) Precedence: bulk Original-Sender: ding-owner@lists.math.uh.edu Xref: news.gmane.org gmane.emacs.gnus.general:61581 Archived-At: --=-=-= Hi, first of all: Gmane hates me. It really does. Or it hates my code. Well, HTML-mails are really a plague but...this is just about reading...I hope the mailinglist software shows more mercy. I guess this mail will arrive in a few days again but I can't be sure, so please apologize this double-post in advance. ;) 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. 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. -hs --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=hs-show-html-mail.el ;;; hs-show-html-mail.el --- View HTML-parts in a graphical browser. ;; Copyright (C) 2005 Hynek Schlawack ;; Author: Hynek Schlawack ;; Version: $Id: hs-show-html-mail.el 12 2005-12-15 15:44:30Z hynek $ ;; Keywords: mail news ;; This file is NOT part of GNU Emacs. ;; This file is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; This file is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, ;; Boston, MA 02111-1307, USA. ;;; Commentary: ;; Scans the actual article in Gnus for HTML-parts and shows them using ;; browse-url. ;;; Code: (defun hs-show-html-list (LIST) "View all HTML-parts from 'LIST'. Recurse into multiparts." (let ((showed)) ;; Find and show the html-parts. (dolist (elt LIST) ;; If HTML, show it (cond ((and (listp elt) (bufferp (car elt)) (string-match "text/html" (car (mm-handle-type elt)))) (let ((tmp (format "%s-%s.html" (make-temp-name "/tmp/gnus-html-") (user-login-name)))) (mm-save-part-to-file elt tmp) (browse-url tmp) (setq showed t))) ;; If multipart, recurse ((and (listp elt) (stringp (car elt)) (string-match "multipart/" (substring (car elt) 0 10)) (setq showed (or showed (hs-show-html-list elt))))))) showed)) (defun hs-show-html-mail () "View HTML-parts of the current Gnus-Article in a graphical browser." (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!")) (gnus-summary-show-article)))) (provide 'hs-show-html-mail) ;;; hs-show-html-mail.el ends here --=-=-=--