Gnus development mailing list
 help / color / mirror / Atom feed
* Suggestion: tell `gnus-part-display-hook'-functions whether header/body
@ 2001-04-01 19:58 Christoph Conrad
  2001-04-01 21:25 ` Kai Großjohann
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Conrad @ 2001-04-01 19:58 UTC (permalink / raw)


Hi,

******* Motivation

I wanted to add a function which washes message/news which of
content-type "text/html". I saw that a function
`gnus-article-wash-html' (on "W h" in summary) does this and the
manual states that it

    Treat HTML (`gnus-article-wash-html'). Note that the this is
    USUALLY DONE AUTOMATICALLY by Gnus if the message in question has
    a `Content-Type' header that says that this type has been done.

(emphasizing by me)

But:

1) It uses w3. This is too slow for me (P133), i wanted to use lynx as
   with multipart messages (displaying the html part)
2) It doesn't work for me (any hint?)

******* Solution

So i searched around and found that `gnus-part-display-hook' seems to
be ideal for that task, cause the manual mentions:

    You can, of course, write your own functions to be called from
    `gnus-part-display-hook'. The functions are called narrowed to the
    part, and you can do anything you like, pretty much.

******* Problem

But one problem remains:

The functions in `gnus-part-display-hook' are called TWICE.

call chain:

gnus-article-prepare-display -> gnus-display-mime-function
(gnus-display-mime) ->gnus-treat-article (1x body, 1x header)

But there's no guaranted mechanism to distinguish whether we are
called with the article narrowd to the body or to the headers.

There are some possibilities:

Body part when:

;;      (let* ( (buffer-read-only nil)
;;              (ct  (message-fetch-field "content-type"))
;;              (ctg (gnus-fetch-field    "content-type")) )
;;        ;; ct is nil when in body part
;;        (when (and (null ct)
;;                   ctg
;;                   (string-match "^text/html" ctg))

or

;;      (let* ( (buffer-read-only nil)
;;              (content-type (gnus-fetch-field "content-type")) )
;;        ;; condition == 'head when in head / nil in body
;;        (when (and (null condition)
;;                   content-type
;;                   (string-match "^text/html" content-type))

The second "solution" relies on variables which are defined from the
function calling the functions in `gnus-part-display-hook'.

******* Question

So i ask for defining a guranteed way of knowing whether in header or
body when called in `gnus-part-display-hook'. A good way could to not
run the hook with `run-hooks' but with `run-hook-with-args' and to
deliver one arg (a list) saying whether we are in header or body part.
I see, this would break compatibility.

Another solution could be to define a variable which is guaranteed to
be defined when in functions in `gnus-part-display-hook'.

The best way would be to extend the built-in mechanism for
"gnus-treat-*"-variables for userdefined functions. (see node
"Customizing Articles" in gnus manual).

Best regards,
cu, -cc-
-- 
=> GNU Emacs Webring @ <http://www.gnusoftware.com/WebRing/> <=
Look Ma, this man can twist his fingers as if they were made of rubber,
isn't that amazing? -- Not really, he's been using emacs for years...!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Suggestion: tell `gnus-part-display-hook'-functions whether header/body
  2001-04-01 19:58 Suggestion: tell `gnus-part-display-hook'-functions whether header/body Christoph Conrad
@ 2001-04-01 21:25 ` Kai Großjohann
  2001-04-02 21:16   ` Christoph Conrad
  0 siblings, 1 reply; 4+ messages in thread
From: Kai Großjohann @ 2001-04-01 21:25 UTC (permalink / raw)
  Cc: ding

Maybe the best way to achieve what you want is to frob
mailcap-mime-data to point to your own function, no?

kai
-- 
Be indiscrete.  Do it continuously.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Suggestion: tell `gnus-part-display-hook'-functions whether header/body
  2001-04-01 21:25 ` Kai Großjohann
@ 2001-04-02 21:16   ` Christoph Conrad
  2001-04-03  7:14     ` Kai Großjohann
  0 siblings, 1 reply; 4+ messages in thread
From: Christoph Conrad @ 2001-04-02 21:16 UTC (permalink / raw)
  Cc: ding

    > Maybe the best way to achieve what you want is to frob
    > mailcap-mime-data to point to your own function, no?

I tried

(mailcap-add-mailcap-entry
 "text"
 "html"
 '((viewer . cc-treat-html)
   (type   . "text/html")))

but the routine didn't get called. I tested with

(mailcap-mime-info "text/html")

that it the associated mime method is my function.

I had a looked where `mailcap-mime-info' is used: in "mm-decode.el". I
verified that the routines using `mailcap-mime-info' are not called in
my case; there is only one message body with content-type "text/html".

Mhmmm... did i misunderstand something??

Best regards,
cu, -cc-
-- 
=> GNU Emacs Webring @ <http://www.gnusoftware.com/WebRing/> <=
Look Ma, this man can twist his fingers as if they were made of rubber,
isn't that amazing? -- Not really, he's been using emacs for years...!


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Suggestion: tell `gnus-part-display-hook'-functions whether header/body
  2001-04-02 21:16   ` Christoph Conrad
@ 2001-04-03  7:14     ` Kai Großjohann
  0 siblings, 0 replies; 4+ messages in thread
From: Kai Großjohann @ 2001-04-03  7:14 UTC (permalink / raw)
  Cc: ding

On 02 Apr 2001, Christoph Conrad wrote:

> I had a looked where `mailcap-mime-info' is used: in
> "mm-decode.el". I verified that the routines using
> `mailcap-mime-info' are not called in my case; there is only one
> message body with content-type "text/html".

That's strange.  How can this happen?

kai
-- 
Be indiscrete.  Do it continuously.


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-04-03  7:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-04-01 19:58 Suggestion: tell `gnus-part-display-hook'-functions whether header/body Christoph Conrad
2001-04-01 21:25 ` Kai Großjohann
2001-04-02 21:16   ` Christoph Conrad
2001-04-03  7:14     ` Kai Großjohann

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