Gnus development mailing list
 help / color / mirror / Atom feed
* [Patch] Improved mm-display-part for application/octet-stream
@ 2006-01-19  8:27 Geoff Kuenning
  2006-01-19 19:54 ` Reiner Steib
  0 siblings, 1 reply; 2+ messages in thread
From: Geoff Kuenning @ 2006-01-19  8:27 UTC (permalink / raw)


I am constantly frustrated by correspondents with broken mailers who
send me attachments that are identified as application/octet-stream,
even though they have a specific type (90% of the time it's .doc;
another 9% is .pdf) that should be identified as such.

Since I can't do the right thing and fix the broken mailers, I did the
next best thing: I revised mm-display-part to pick out the proper type
based on the file extension.  The revised version is below.  The first
"when" clause is new; everthing else is the same.  If people like the
idea, I'd like to see it get into the main tree (how do I make that
happen?).

(defun mm-display-part (handle &optional no-default)
  "Display the MIME part represented by HANDLE.
Returns nil if the part is removed; inline if displayed inline;
external if displayed external."
  (save-excursion
    (mailcap-parse-mailcaps)
    (if (mm-handle-displayed-p handle)
	(mm-remove-part handle)
      (let* ((type (mm-handle-media-type handle))
	     (method (mailcap-mime-info type)))
	(when (and
               (not method)
               (equal type "application/octet-stream"))
	  (let* ((filename (cdr (assoc 'name (nth 1 handle))))
		(start (string-match "\\.[^.]*$" filename)))
	    (when start
	      (setq type
		    (mailcap-extension-to-mime (substring filename start)))
	      (setq method (mailcap-mime-info type))
	      )))
	(if (mm-inlined-p handle)
	    (progn
	      (forward-line 1)
	      (mm-display-inline handle)
	      'inline)
	  (when (or method
		    (not no-default))
	    (if (and (not method)
		     (equal "text" (car (split-string type))))
		(progn
		  (forward-line 1)
		  (mm-insert-inline handle (mm-get-part handle))
		  'inline)
	      (mm-display-external
	       handle (or method 'mailcap-save-binary-file)))))))))

-- 
    Geoff Kuenning   geoff@cs.hmc.edu   http://www.cs.hmc.edu/~geoff/

If at first you succeed, try to hide your astonishment.
	-- Harry F. Banks



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

* Re: [Patch] Improved mm-display-part for application/octet-stream
  2006-01-19  8:27 [Patch] Improved mm-display-part for application/octet-stream Geoff Kuenning
@ 2006-01-19 19:54 ` Reiner Steib
  0 siblings, 0 replies; 2+ messages in thread
From: Reiner Steib @ 2006-01-19 19:54 UTC (permalink / raw)


On Thu, Jan 19 2006, Geoff Kuenning wrote:

> I am constantly frustrated by correspondents with broken mailers who
> send me attachments that are identified as application/octet-stream,
> even though they have a specific type (90% of the time it's .doc;
> another 9% is .pdf) that should be identified as such.

In <http://thread.gmane.org/gmane.emacs.devel/46385>, Stefan Monnier
addressed the same or similar problems.  But his patch (against the
stable branch = Gnus 5.11 in Emacs CVS) doesn't apply in the current
development sources and I didn't have time to resolve it manually yet.

> Since I can't do the right thing and fix the broken mailers, I did the
> next best thing: I revised mm-display-part to pick out the proper type
> based on the file extension.  The revised version is below.  The first
> "when" clause is new; everthing else is the same.

A unified (or context) diff would be nicer.

> If people like the idea, I'd like to see it get into the main tree
> (how do I make that happen?).

Maybe you could investigate if Stefan's patch fits your needs?
I don't know if it works for your Gnus version (5.9), though.

Bye, Reiner.
-- 
       ,,,
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/




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

end of thread, other threads:[~2006-01-19 19:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-19  8:27 [Patch] Improved mm-display-part for application/octet-stream Geoff Kuenning
2006-01-19 19:54 ` Reiner Steib

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