Gnus development mailing list
 help / color / mirror / Atom feed
* Bug in "View as type"?
@ 2005-10-11 21:04 Reiner Steib
  2005-10-11 23:04 ` Adam Sjøgren
  0 siblings, 1 reply; 5+ messages in thread
From: Reiner Steib @ 2005-10-11 21:04 UTC (permalink / raw)


Hi,

if I understand the code correctly, `gnus-mime-view-part-as-type'
(bound to `t' on MIME buttons) is supposed to offer the type by
calling `mm-default-file-encoding' in
`gnus-mime-view-part-as-type-internal'.  I.e. when the content type is
application/octet-stream and the file is in fact image/whatever or
application/pdf (some broken mailers do), the user should be offered
as more reasonable default.

But in fact this doesn't work (at least for me):

(get-text-property (point) 'gnus-data)
=> (#<buffer  *mm*<7>> ("application/octet-stream") base64 nil
    ("attachment" (filename . "cookies.txt")) nil nil nil)

(mm-handle-type ...)
=> ("application/octet-stream")

(mail-content-type-get ... 'name)
=> nil


The following seems to do better.  

The only use of `gnus-mime-view-part-as-type-internal' is in
`gnus-mime-view-part-as-type'.  Or can anyone imaging a situation
where the current implementation is preferable?

Do we have some shortcut for this?

  (cdr (assq 'name (cdr (mm-handle-disposition handle))))

--8<---------------cut here---------------start------------->8---
--- gnus-art.el	27 Sep 2005 17:50:05 +0200	7.128
+++ gnus-art.el	11 Oct 2005 22:59:23 +0200	
@@ -4317,9 +4317,9 @@
 
 (defun gnus-mime-view-part-as-type-internal ()
   (gnus-article-check-buffer)
-  (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 (cdr (assq 'name (cdr (mm-handle-disposition handle))))
+		   (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
 	 (def-type (and name (mm-default-file-encoding name))))
     (and def-type (cons def-type 0))))
 
@@ -4328,10 +4328,12 @@
   (interactive)
   (unless mime-type
     (setq mime-type (completing-read
-		     "View as MIME type: "
+		     (format "View as MIME type (default %s): "
+			     (car (gnus-mime-view-part-as-type-internal)))
 		     (mapcar #'list (mailcap-mime-types))
 		     nil nil
-		     (gnus-mime-view-part-as-type-internal))))
+		     nil nil
+		     (car (gnus-mime-view-part-as-type-internal)))))
   (gnus-article-check-buffer)
   (let ((handle (get-text-property (point) 'gnus-data)))
     (when handle
--8<---------------cut here---------------end--------------->8---


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




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

end of thread, other threads:[~2005-10-12 15:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 21:04 Bug in "View as type"? Reiner Steib
2005-10-11 23:04 ` Adam Sjøgren
2005-10-12 12:31   ` Reiner Steib
2005-10-12 13:22     ` Adam Sjøgren
2005-10-12 15:43       ` 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).