[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Displaying MIME parts internally/externally in Gnus

From: Reiner Steib
Subject: Re: Displaying MIME parts internally/externally in Gnus
Date: Fri, 02 Dec 2005 17:27:01 +0100
User-agent: Gnus/5.110004 (No Gnus v0.4) Emacs/22.0.50 (gnu/linux)

On Mon, Nov 21 2005, Stefan Monnier wrote:

| To: address@hidden, address@hidden

Probably you meant address@hidden

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

I don't see how you use the predicate `PRED'.

Your patch may conflict with the one I've installed in the trunk to
improve `gnus-mime-view-part-as-type' (see below[1] and

Does you patch address a similar scenario?  (Sorry, I didn't have time
to check it myself.)

Bye, Reiner.

2005-10-13  Reiner Steib  <address@hidden>
        * gnus-art.el (gnus-mime-view-part-as-type-internal): Try to fetch
        `filename' from Content-Disposition if Content-Type doesn't
        provide `name'.
        (gnus-mime-view-part-as-type): Set default instead of

--8<---------------cut here---------------start------------->8---
--- gnus-art.el 12 Oct 2005 12:50:14 -0000      7.129
+++ gnus-art.el 13 Oct 2005 13:26:03 -0000      7.130
@@ -4317,9 +4317,12 @@
 (defun gnus-mime-view-part-as-type-internal ()
-  (let* ((name (mail-content-type-get
-               (mm-handle-type (get-text-property (point) 'gnus-data))
-               'name))
+  (let* ((handle (get-text-property (point) 'gnus-data))
+        (name (or
+               ;; Content-Type: foo/bar; name=...
+               (mail-content-type-get (mm-handle-type handle) 'name)
+               ;; Content-Disposition: attachment; filename=...
+               (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
         (def-type (and name (mm-default-file-encoding name))))
     (and def-type (cons def-type 0))))
@@ -4327,11 +4330,14 @@
   "Choose a MIME media type, and view the part as such."
   (unless mime-type
-    (setq mime-type (completing-read
-                    "View as MIME type: "
-                    (mapcar #'list (mailcap-mime-types))
-                    nil nil
-                    (gnus-mime-view-part-as-type-internal))))
+    (setq mime-type
+         (let ((default (gnus-mime-view-part-as-type-internal)))
+           (completing-read
+            (format "View as MIME type (default %s): "
+                    (car default))
+            (mapcar #'list (mailcap-mime-types))
+            nil nil nil nil
+            (car default)))))
   (let ((handle (get-text-property (point) 'gnus-data)))
     (when handle
--8<---------------cut here---------------end--------------->8---
      (o o)
---ooO-(_)-Ooo---  |  PGP key available  |  http://rsteib.home.pages.de/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]