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

Re: Counfounding MIME



At Wed, 27 Oct 2010 11:28:40 -0400,
David Abrahams wrote:
> 
> 
> Hi all,
> 
> I'm hoping someone can explain to me how to get MIME working more
> smoothly in WL.  It almost never seems to do what I want, and I don't
> know how to get back to the state where it does.  For example, right
> now I'm looking at this:
>
> […]
>
> I know I was seeing inline images in messages a few days ago; now I
> can't get these to display.  When I try to "view" them (`v'), it just
> asks me if I want to save them to a file.  My .mailcap contains:
> 
>   */*; /usr/bin/open %s
>   text/html; sh -c "mv %s %s.html && /usr/bin/open %s.html"
> 
> which theoretically should cause them to be opened with the default
> program for their file type on my Mac (right?), but that isn't having
> any effect.

The messages might have Content-Disposition: attachment, in which case
I think that WL is doing the right thing by not displaying them. You
might try C-c C-v C-c on the mime “button”, which toggles visibility.

A few other comments: image/jpg is wrong; the mimetype is
image/jpeg. Adding an image/jpg mimetype to mailcap might help, if
there is not one.

Maybe I am missing something, but I think that the lines in mailcap
that matter are the image/jpg lines.

Finally, sometimes C-u v helps; it ignores
mime-acting-situation-example-list.

> Another problem is that WL is constantly asking me what encoding I
> want to use for attachments that I'm sending, and I don't know what
> the best answers are.  Gnus never used to bother me with questions
> about encoding.  
> 
> In all, I'm left with the impression that WL supplies lots of powerful
> low-level tools for handling MIME, but doesn't assemble them, by
> default, into a reasonably-usable whole.  I would be happy to propose
> some default configuration if I knew how to make any of this stuff
> work more intuitively, but I don't.

WL does come with good tools to guess a file’s mime type, encoding,
etc. but it does prompt when used interactively. I like this myself,
but it seems it could be a config parameter. Try the following:

(defvar mime-edit-insert-interactive-is-verbose t
        "Ask detailed questions when inserting mime files.")

(setq mime-edit-insert-interactive-is-verbose nil)

(defun mime-edit-insert-file (file &optional verbose)
  "Insert a message from a file."
  (interactive "fInsert file as MIME message: \nP")
  (let*  ((guess (mime-find-file-type file))
	  (type (nth 0 guess))
	  (subtype (nth 1 guess))
	  (parameters (nth 2 guess))
	  (encoding (nth 3 guess))
	  (disposition-type (nth 4 guess))
	  (disposition-params (nth 5 guess))
	  )
    (if (or verbose 
            (and mime-edit-insert-interactive-is-verbose
                 (interactive-p)))
	(setq type (mime-prompt-for-type type)
	      subtype (mime-prompt-for-subtype type subtype)
	      encoding (mime-prompt-for-encoding encoding)))
    (if (or (consp parameters) (stringp disposition-type))
	(let ((rest parameters) cell attribute value)
	  (setq parameters "")
	  (while rest
	    (setq cell (car rest))
	    (setq attribute (car cell))
	    (setq value (cdr cell))
	    (if (eq value 'file)
		(setq value (std11-wrap-as-quoted-string
			     (file-name-nondirectory file)))
	      )
	    (setq parameters (concat parameters "; " attribute "=" value))
	    (setq rest (cdr rest))
	    )
	  (if disposition-type
	      (progn
		(setq parameters
		      (concat parameters "\n"
			      "Content-Disposition: " disposition-type))
		(setq rest disposition-params)
		(while rest
		  (setq cell (car rest))
		  (setq attribute (car cell))
		  (setq value (cdr cell))
		  (if (eq value 'file)
		      (setq value (std11-wrap-as-quoted-string
				   (file-name-nondirectory file)))
		    )
		  (setq parameters
			(concat parameters "; " attribute "=" value))
		  (setq rest (cdr rest))
		  )
		))
	  ))
    (mime-edit-insert-tag type subtype parameters)
    (mime-edit-insert-binary-file file encoding)
    ))

best, Erik