Announcements and discussions for Gnus, the GNU Emacs Usenet newsreader
 help / color / mirror / Atom feed
* Re: how to see text/plain in multipart messages
       [not found]   ` <ygd3cki7eaf.fsf@angmar.retis>
@ 2003-04-21 17:05     ` tmstaedt
  0 siblings, 0 replies; only message in thread
From: tmstaedt @ 2003-04-21 17:05 UTC (permalink / raw)


Hey, Pietro,

The following turned to be very useful for me. Uses lynx to display all the
html stuff.

thomas


From: Jesper Petersen <jesperp**Delete**@nork.auc.dk>
Newsgroups: gnu.emacs.gnus
Subject: Re: gnus handling of html based email
Date: 14 Aug 2001 11:14:14 +0200
Organization: SunSITE.dk - Supporting Opensource Software
Lines: 69
Message-ID: <87bslj80m1.fsf@l198a1.nork.auc.dk>
References: <m3ofpj9th9.fsf@gryphon.myth.atl.mediaone.net>
NNTP-Posting-Host: l198a1.nork.auc.dk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: sunsite.dk 997780236 15007 192.168.65.114 (14 Aug 2001 09:10:36 GMT)
X-Complaints-To: news@sunsite.dk
NNTP-Posting-Date: Tue, 14 Aug 2001 09:10:36 +0000 (UTC)
X-Authenticated: <anon>@<local>
User-Agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7



 Chuck> I use gnus 5.8 as my mail reader with the nnmh backend.  I am
 Chuck> looking for a way to have it render html based email as text
 Chuck> with an embedded url reference rhather that what it is doing
 Chuck> for me now which is displaying it with w3 immediately.

I use the following that I've found on the net, see if it does what
you want:

;****************************************************************
;; Alternatives to rendering HTML-mails/articles by w3?
;; From: Mark Thomas <mthomas@jprc.com>
;; I did this a few of months ago and I have been very happy with the
;; almost instantaneous display of html content.

(defun remassoc (elt list)
  (let ((result '()))
    (mapcar (lambda (e) (unless (and (consp e)
     (equal elt (car e)))
  (setq result (cons e result))))
    list)
    (nreverse result)))

  (setq
   ;; prefer to show plain text over markup for multipart/alternative
   mm-discouraged-alternatives (append mm-discouraged-alternatives
                                       '("text/html"
                                         "text/richtext"
                                         ))

   ;; use lynx -dump to view inline HTML
   mm-inline-media-tests (cons '("text/html"
                                 my:gnus-html2text
                                 (lambda (handle)
                                   (fboundp 'my:gnus-html2text)))
                               (remassoc "text/html"
                               mm-inline-media-tests))
   )

  ;; function to call to handle text/html attachments
  (defun my:gnus-html2text (handle)
    (let (text)
      (with-temp-buffer
        (mm-insert-part handle)
        (save-window-excursion
  (my:html2text-region (point-min) (point-max))
  (setq text (buffer-string))))
      (mm-insert-inline handle text)))

(defun my:html2text-region (min max)
  "Replace the HTML region from MIN to MAX with lynx --dump."
  (interactive "r")
  (let ( (file (concat (make-temp-name "/tmp/") ".html")) )
    (unwind-protect
        (progn
          (write-region min max file)
          (delete-region min max)
          (insert (shell-command-to-string
                   (concat "/usr/bin/lynx "
                           "/usr/bin/lynx -dump "
                           (shell-quote-argument
                            (expand-file-name file))))))
      (delete-file file))))
;****************************************************************

Jesper

--
Remove **Delete** from my email-address when replying by mail.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-04-21 17:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <ygd65pfhnrk.fsf@angmar.retis>
     [not found] ` <uader69l6.fsf@hschmi22.userfqdn.rz-online.de>
     [not found]   ` <ygd3cki7eaf.fsf@angmar.retis>
2003-04-21 17:05     ` how to see text/plain in multipart messages tmstaedt

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).