<<< Date Index >>>     <<< Thread Index >>>

Re: 4b5326d8d2ee breaks viewing of text/html with needsterminal



Hi,

* Christian Ebert wrote:
>
> Am I overlooking something?

No, the fix shouldn't affect the attachment menu.

> imho, I (like the reporter I have $implicit_autoview set) solved
> the problem described in #3246 with according text/* entries at
> the end of my mailcap file -- with the advantage that this
> fallback was customizable (CRLF conversion etc.)

> I don't really understand the rationale behind this patch. It
> doesn't feel like an improvement.

The problem this patch tries to solve is that it's IMHO overkill to have 
to go and learn mailcap syntax just to make your mailer display _text_ 
by default. I think mutt should be useable for starters with -nF 
/dev/null and there it's ugly to be greated with text/foo is 
unsupported. Yes, it tells you to go to the attachment menu, but there 
it'll simply dump the text (if no mailcap entry is present)... so why 
not dump it in the first place without a mailcap entry?

Of course, you'll need to dig into mailcap et al if you don't like the 
output your mailer gives you, but something simple as text should just 
be displayed, I'd say.

> So, how can I make the above mailcap entry work again? Could
> someone adjust my perspective?

Can you please try the attached patch? It tries to limit the impact of 
the change to the pager only. My tests keep working and your example 
works for me with, too.

Rocco
diff --git a/attach.c b/attach.c
--- a/attach.c
+++ b/attach.c
@@ -385,7 +385,7 @@ int mutt_is_autoview (BODY *b, const cha
   mutt_check_lookup_list (b, _type, sizeof(_type));
   type = _type;
 
-  if (mutt_needs_mailcap (b))
+  if (mutt_needs_mailcap (b, 1))
   {
     if (option (OPTIMPLICITAUTOVIEW))
       return 1;
@@ -428,7 +428,7 @@ int mutt_view_attachment (FILE *fp, BODY
       !crypt_valid_passphrase(a->hdr->security))
     return (rc);
   use_mailcap = (flag == M_MAILCAP ||
-               (flag == M_REGULAR && mutt_needs_mailcap (a)));
+               (flag == M_REGULAR && mutt_needs_mailcap (a, 0)));
   snprintf (type, sizeof (type), "%s/%s", TYPE (a), a->subtype);
   
   if (use_mailcap)
diff --git a/muttlib.c b/muttlib.c
--- a/muttlib.c
+++ b/muttlib.c
@@ -617,13 +617,16 @@ void mutt_delete_parameter (const char *
 }
 
 /* returns 1 if Mutt can't display this type of data, 0 otherwise */
-int mutt_needs_mailcap (BODY *m)
+int mutt_needs_mailcap (BODY *m, int is_pager)
 {
   switch (m->type)
   {
     case TYPETEXT:
-      /* we can display any text, overridable by auto_view */
-      return 0;
+
+      if (is_pager || !ascii_strcasecmp ("plain", m->subtype) ||
+         !ascii_strcasecmp ("rfc822-headers", m->subtype) ||
+         !ascii_strcasecmp ("enriched", m->subtype))
+       return 0;
       break;
 
     case TYPEAPPLICATION:
diff --git a/protos.h b/protos.h
--- a/protos.h
+++ b/protos.h
@@ -328,7 +328,7 @@ int mutt_match_rx_list (const char *, RX
 int mutt_match_spam_list (const char *, SPAM_LIST *, char *, int);
 int mutt_messages_in_thread (CONTEXT *, HEADER *, int);
 int mutt_multi_choice (char *prompt, char *letters);
-int mutt_needs_mailcap (BODY *);
+int mutt_needs_mailcap (BODY *, int);
 int mutt_num_postponed (int);
 int mutt_parse_bind (BUFFER *, BUFFER *, unsigned long, BUFFER *);
 int mutt_parse_exec (BUFFER *, BUFFER *, unsigned long, BUFFER *);
diff --git a/send.c b/send.c
--- a/send.c
+++ b/send.c
@@ -1460,7 +1460,7 @@ ci_send_message (int flags,               /* send mod
         query_quadoption (OPT_FORWEDIT, _("Edit forwarded message?")) == 
M_YES))
     {
       /* If the this isn't a text message, look for a mailcap edit command */
-      if (mutt_needs_mailcap (msg->content))
+      if (mutt_needs_mailcap (msg->content, 1))
       {
        if (!mutt_edit_attachment (msg->content))
           goto cleanup;