Gnus development mailing list
 help / color / mirror / Atom feed
From: Christoph Conrad <christoph.conrad@gmx.de>
Subject: Suggestion: tell `gnus-part-display-hook'-functions whether header/body
Date: 01 Apr 2001 21:58:47 +0200	[thread overview]
Message-ID: <m3ae60flki.fsf@gmx.de> (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...!


             reply	other threads:[~2001-04-01 19:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-04-01 19:58 Christoph Conrad [this message]
2001-04-01 21:25 ` Kai Großjohann
2001-04-02 21:16   ` Christoph Conrad
2001-04-03  7:14     ` Kai Großjohann

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=m3ae60flki.fsf@gmx.de \
    --to=christoph.conrad@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).