Gnus development mailing list
 help / color / mirror / Atom feed
From: Rupert Swarbrick <rswarbrick@googlemail.com>
To: Greg Troxel <gdt@work.lexort.com>
Cc: ding@gnus.org
Subject: Re: Auto-overriding *.pdf application/octet-stream MIME type?
Date: Mon, 03 Nov 2008 18:13:43 +0000	[thread overview]
Message-ID: <87d4hcwuco.fsf@gmail.com> (raw)
In-Reply-To: <smu3ai9ug2h.fsf@linuxpal.mit.edu> (Greg Troxel's message of "Mon, 03 Nov 2008 07:52:54 -0500")

[-- Attachment #1: Type: text/plain, Size: 1959 bytes --]

Greg Troxel <gdt@work.lexort.com> writes:

>   From: Simon Josefsson <simon@josefsson.org>
>
>   What do people think about a variable that can be used to auto-override
>   MIME types based on filename extensions?  I get a lot of *.pdf marked as
>   application/octet-stream and selecting 'View as Type' feels dull.
>
> I have been annoyed by dealing with messages that come with wrong mime
> types and definitely second the notion that support would be nice.
>
>   Something like this:
>
>   (setq mm-content-type-mapping
>         '(("application/octet-stream" "*.pdf" "application/pdf")))
>
>   The cells would be of the form (INCOMING-TYPE EXTENSION MAPPED-TYPE),
>   and either of INCOMING-TYPE or EXTENSION can be nil to match anything.
>
> That looks good to me.  I would have at first left out the first item,
> but on reflection I think that almost all miscoded objects are labeled
> application/octet-stream.  This lets one have the narrowest effective
> configuration.

May I suggest that a list of 3 elements is as above, but one can leave
out the first to match all incoming MIME types?

So

  ("application/octet-stream" "*.pdf" "application/pdf")

would be as above and

  ("*.pdf" "application/pdf")

would match more - anything called blah.pdf would be relabelled
application/pdf no matter what MIME type it had.

But I'd suggest that both the first and the second values were treated
as regexes. Then I can say things like

  (".*xml.*" ".*" "application/xml")

(that was off the top of my head. There are probably better
examples). Also, maybe one should allow some magic, so that "*.pdf" gets
turned into ".*\.pdf" for newish users not to get bitten. Maybe rewrite
anything of the form

  ^\*\.\(.*\)$

to

  ^.*\.\\1$

Or maybe strip off the "*" bit and don't require the ^,$?

Anyway, I suspect this problem (of regexes vs shell globs) has been
given a canonical solution somewhere else in the emacs code-base. Does
anyone know?

Rupert

[-- Attachment #2: Type: application/pgp-signature, Size: 314 bytes --]

  reply	other threads:[~2008-11-03 18:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-03 11:31 Simon Josefsson
2008-11-03 12:52 ` Greg Troxel
2008-11-03 18:13   ` Rupert Swarbrick [this message]
2008-11-03 17:12 ` Ted Zlatanov
2008-11-06  0:41 ` Russ Allbery

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=87d4hcwuco.fsf@gmail.com \
    --to=rswarbrick@googlemail.com \
    --cc=ding@gnus.org \
    --cc=gdt@work.lexort.com \
    /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).