Gnus development mailing list
 help / color / mirror / Atom feed
* Auto-overriding *.pdf application/octet-stream MIME type?
@ 2008-11-03 11:31 Simon Josefsson
  2008-11-03 12:52 ` Greg Troxel
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Josefsson @ 2008-11-03 11:31 UTC (permalink / raw)
  To: ding

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.

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.

I've seen the mm-tweak-* variables, but they are 1) not customizable,
and 2) not easy to use to achieve the common *.pdf to application/pdf
mapping.  At least as far as I could tell?

/Simon



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

* Re: Auto-overriding *.pdf application/octet-stream MIME type?
  2008-11-03 11:31 Auto-overriding *.pdf application/octet-stream MIME type? Simon Josefsson
@ 2008-11-03 12:52 ` Greg Troxel
  2008-11-03 18:13   ` Rupert Swarbrick
  2008-11-03 17:12 ` Ted Zlatanov
  2008-11-06  0:41 ` Russ Allbery
  2 siblings, 1 reply; 5+ messages in thread
From: Greg Troxel @ 2008-11-03 12:52 UTC (permalink / raw)
  To: ding

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

  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.

Is the extension field going to be a regexp, glob, or string?  Probably
it should be a regex for an extension, with an implied ".*\." before it.

Besides .pdf, .doc, .ppt and .xls labeled as application/octet-stream,
the other problem I have is getting patches labeled as
application/octet-stream.  I tend to call them text/plain, but I think
there is application/x-patch.  Fixing this would seem to require having
a "body test", basically running file on the part, and this seems harder
and dangerous.  I'm not suggesting that all problems be solved at once -
I see no downside to your proposal.

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

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

* Re: Auto-overriding *.pdf application/octet-stream MIME type?
  2008-11-03 11:31 Auto-overriding *.pdf application/octet-stream MIME type? Simon Josefsson
  2008-11-03 12:52 ` Greg Troxel
@ 2008-11-03 17:12 ` Ted Zlatanov
  2008-11-06  0:41 ` Russ Allbery
  2 siblings, 0 replies; 5+ messages in thread
From: Ted Zlatanov @ 2008-11-03 17:12 UTC (permalink / raw)
  To: ding

On Mon, 03 Nov 2008 12:31:13 +0100 Simon Josefsson <simon@josefsson.org> wrote: 

SJ> What do people think about a variable that can be used to auto-override
SJ> MIME types based on filename extensions?  I get a lot of *.pdf marked as
SJ> application/octet-stream and selecting 'View as Type' feels dull.

I usually just hit `e' to view them externally.

Ted




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

* Re: Auto-overriding *.pdf application/octet-stream MIME type?
  2008-11-03 12:52 ` Greg Troxel
@ 2008-11-03 18:13   ` Rupert Swarbrick
  0 siblings, 0 replies; 5+ messages in thread
From: Rupert Swarbrick @ 2008-11-03 18:13 UTC (permalink / raw)
  To: Greg Troxel; +Cc: ding

[-- 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 --]

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

* Re: Auto-overriding *.pdf application/octet-stream MIME type?
  2008-11-03 11:31 Auto-overriding *.pdf application/octet-stream MIME type? Simon Josefsson
  2008-11-03 12:52 ` Greg Troxel
  2008-11-03 17:12 ` Ted Zlatanov
@ 2008-11-06  0:41 ` Russ Allbery
  2 siblings, 0 replies; 5+ messages in thread
From: Russ Allbery @ 2008-11-06  0:41 UTC (permalink / raw)
  To: ding

Simon Josefsson <simon@josefsson.org> writes:

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

This might not be a great idea, but this feels like it might be something
that could be done with a wash.  That introduces all the existing
infrastructure for picking which washes you want to apply.  The wash could
fix the MIME types of all attachments with application/octet-stream MIME
types based on the extensions.

-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>



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

end of thread, other threads:[~2008-11-06  0:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-03 11:31 Auto-overriding *.pdf application/octet-stream MIME type? Simon Josefsson
2008-11-03 12:52 ` Greg Troxel
2008-11-03 18:13   ` Rupert Swarbrick
2008-11-03 17:12 ` Ted Zlatanov
2008-11-06  0:41 ` Russ Allbery

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