From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Displaying MIME parts internally/externally in Gnus Date: Fri, 02 Dec 2005 10:11:56 -0500 Message-ID: <8764q7lenq.fsf-monnier+emacs@gnu.org> References: <87irum4tka.fsf-monnier+emacs@gnu.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1133543890 14192 80.91.229.2 (2 Dec 2005 17:18:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 2 Dec 2005 17:18:10 +0000 (UTC) Cc: gnus@gnus.org, bugs@gnus.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Dec 02 18:18:07 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EiEVA-0008Qk-4E for ged-emacs-devel@m.gmane.org; Fri, 02 Dec 2005 18:15:16 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EiEV9-0000IP-Bt for ged-emacs-devel@m.gmane.org; Fri, 02 Dec 2005 12:15:15 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EiCZz-000813-Hz for emacs-devel@gnu.org; Fri, 02 Dec 2005 10:12:08 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EiCZv-0007zk-Bo for emacs-devel@gnu.org; Fri, 02 Dec 2005 10:12:05 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EiCZt-0007zX-7y for emacs-devel@gnu.org; Fri, 02 Dec 2005 10:12:01 -0500 Original-Received: from [209.226.175.188] (helo=tomts25-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EiCZs-0006vX-8u for emacs-devel@gnu.org; Fri, 02 Dec 2005 10:12:00 -0500 Original-Received: from alfajor ([67.71.25.91]) by tomts25-srv.bellnexxia.net (InterMail vM.5.01.06.10 201-253-122-130-110-20040306) with ESMTP id <20051202151156.OMZZ28424.tomts25-srv.bellnexxia.net@alfajor>; Fri, 2 Dec 2005 10:11:56 -0500 Original-Received: by alfajor (Postfix, from userid 1000) id BB6B3D75F1; Fri, 2 Dec 2005 10:11:56 -0500 (EST) Original-To: emacs-devel@gnu.org In-Reply-To: <87irum4tka.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Sun, 20 Nov 2005 21:42:07 -0500") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-Originating-IP: [0] X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:46890 Archived-At: I haven't heard the slightest comment about this. Hello? Is anybody there? Stefan >>>>> "Stefan" == Stefan Monnier writes: > Many attachments come with poor content-type description, in which case Gnus > typically doesn't know what to do with it. When doing "view externally", > such attachments are actually saved. I don't know about you, but I don't > consider "saving" as a sort of "viewing" activity. If I had wanted to save > the attachment I'd have used something more like, say, the "Save" > command instead, don't you think? > Similar problems happen for "view internally". So I suggest the patch below > which tries harder to show the attachment internally or externally: if the > content-type can't be displayed as requested, it asks the user what kind of > content-type to use instead. > A minor variant of it has been mildly tested (and only on Emacs-CVS), and > it's based on a very shallow understanding of the code, so it's probably > not perfect. > If there's no objection I'll install it, otherwise please tell me what's > wrong with it. > Stefan > --- gnus-art.el 23 oct 2005 22:29:41 -0400 1.98 > +++ gnus-art.el 20 nov 2005 21:33:17 -0500 > @@ -4276,14 +4276,16 @@ > (def-type (and name (mm-default-file-encoding name)))) > (and def-type (cons def-type 0)))) > -(defun gnus-mime-view-part-as-type (&optional mime-type) > - "Choose a MIME media type, and view the part as such." > +(defun gnus-mime-view-part-as-type (&optional mime-type pred) > + "Choose a MIME media type, and view the part as such. > +If non-nil, PRED is a predicate to use during completion to limit the > +available media-types." > (interactive) > (unless mime-type > (setq mime-type (completing-read > "View as MIME type: " > (mapcar #'list (mailcap-mime-types)) > - nil nil > + pred nil > (gnus-mime-view-part-as-type-internal)))) > (gnus-article-check-buffer) > (let ((handle (get-text-property (point) 'gnus-data))) > @@ -4450,12 +4452,18 @@ > (mm-inlined-types nil) > (mail-parse-charset gnus-newsgroup-charset) > (mail-parse-ignored-charsets > - (save-excursion (set-buffer gnus-summary-buffer) > - gnus-newsgroup-ignored-charsets))) > + (with-current-buffer gnus-summary-buffer > + gnus-newsgroup-ignored-charsets)) > + (type (mm-handle-media-type handle)) > + (method (mailcap-mime-info type)) > + (mm-enable-external t)) > + (if (not (stringp method)) > + (gnus-mime-view-part-as-type > + nil (lambda (type) (stringp (mailcap-mime-info type)))) > (when handle > (if (mm-handle-undisplayer handle) > (mm-remove-part handle) > - (mm-display-part handle))))) > + (mm-display-part handle)))))) > (defun gnus-mime-view-part-internally (&optional handle) > "View the MIME part under point with an internal viewer. > @@ -4467,13 +4475,16 @@ > (mm-inline-large-images t) > (mail-parse-charset gnus-newsgroup-charset) > (mail-parse-ignored-charsets > - (save-excursion (set-buffer gnus-summary-buffer) > + (with-current-buffer gnus-summary-buffer > gnus-newsgroup-ignored-charsets)) > (inhibit-read-only t)) > + (if (not (mm-inlinable-p handle)) > + (gnus-mime-view-part-as-type > + nil (lambda (type) (mm-inlinable-p handle type))) > (when handle > (if (mm-handle-undisplayer handle) > (mm-remove-part handle) > - (mm-display-part handle))))) > + (mm-display-part handle)))))) > (defun gnus-mime-action-on-part (&optional action) > "Do something with the MIME attachment at \(point\)."