(mm-string-to-multibyte contents)))
(goto-char b)))))
+(defun gnus-mime-strip-charset-parameters (handle)
+ "Strip charset parameters from HANDLE."
+ (if (stringp (car handle))
+ (mapc #'gnus-mime-strip-charset-parameters (cdr handle))
+ (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
+ "message/external-body")
+ (progn
+ (unless (mm-handle-cache handle)
+ (mm-extern-cache-contents handle))
+ (mm-handle-cache handle))
+ handle)))
+ (charset (assq 'charset (cdr type))))
+ (when charset
+ (delq charset type)))))
+
(defun gnus-mime-view-part-as-charset (&optional handle arg)
"Insert the MIME part under point into the current buffer using the
specified charset."
(let ((handle (or handle (get-text-property (point) 'gnus-data)))
(fun (get-text-property (point) 'gnus-callback))
(gnus-newsgroup-ignored-charsets 'gnus-all)
- gnus-newsgroup-charset type charset)
+ gnus-newsgroup-charset form preferred parts)
(when handle
(if (mm-handle-undisplayer handle)
(mm-remove-part handle))
(setq gnus-newsgroup-charset
(or (cdr (assq arg gnus-summary-show-article-charset-alist))
(mm-read-coding-system "Charset: ")))
- ;; Strip the charset parameter from `handle'.
- (setq type (mm-handle-type
- (if (equal (mm-handle-media-type handle)
- "message/external-body")
- (progn
- (unless (mm-handle-cache handle)
- (mm-extern-cache-contents handle))
- (mm-handle-cache handle))
- handle))
- charset (assq 'charset (cdr type)))
- (delq charset type)
+ (gnus-mime-strip-charset-parameters handle)
+ (when (and (consp (setq form (cdr-safe fun)))
+ (setq form (ignore-errors
+ (assq 'gnus-mime-display-alternative form)))
+ (setq preferred (caddr form))
+ (progn
+ (when (eq (car preferred) 'quote)
+ (setq preferred (cadr preferred)))
+ (not (equal preferred
+ (get-text-property (point) 'gnus-data))))
+ (setq parts (get-text-property (point) 'gnus-part))
+ (setq parts (cdr (assq parts
+ gnus-article-mime-handle-alist)))
+ (equal (mm-handle-media-type parts) "multipart/alternative")
+ (setq parts (reverse (cdr parts))))
+ (setcar (cddr form)
+ (list 'quote (or (cadr (member preferred parts))
+ (car parts)))))
(funcall fun handle)))))
(defun gnus-mime-view-part-externally (&optional handle)
(funcall (cdr action-pair)))))
(defun gnus-article-part-wrapper (n function)
- (save-current-buffer
- (set-buffer gnus-article-buffer)
- (when (> n (length gnus-article-mime-handle-alist))
- (error "No such part"))
- (gnus-article-goto-part n)
- (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
- (funcall function handle))))
+ (let ((window (get-buffer-window gnus-article-buffer 'visible))
+ frame)
+ (when window
+ ;; It is necessary to select the article window so that
+ ;; `gnus-article-goto-part' may really move the point.
+ (setq frame (selected-frame))
+ (gnus-select-frame-set-input-focus (window-frame window))
+ (unwind-protect
+ (save-window-excursion
+ (select-window window)
+ (when (> n (length gnus-article-mime-handle-alist))
+ (error "No such part"))
+ (gnus-article-goto-part n)
+ (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
+ (funcall function handle)))
+ (gnus-select-frame-set-input-focus frame)))))
(defun gnus-article-pipe-part (n)
"Pipe MIME part N, which is the numerical prefix."
(mm-setup-w3m)
(let ((text (mm-get-part handle))
(b (point))
- (charset (mail-content-type-get (mm-handle-type handle) 'charset)))
+ (charset (or (mail-content-type-get (mm-handle-type handle) 'charset)
+ mail-parse-charset)))
(save-excursion
(insert (if charset (mm-decode-string text charset) text))
(save-restriction
"Render a text/html part using w3m."
(if (mm-w3m-standalone-supports-m17n-p)
(let ((source (mm-get-part handle))
- (charset (mail-content-type-get (mm-handle-type handle) 'charset))
+ (charset (or (mail-content-type-get (mm-handle-type handle)
+ 'charset)
+ (symbol-name mail-parse-charset)))
cs)
(unless (and charset
(setq cs (mm-charset-to-coding-system charset))
(defun mm-inline-render-with-function (handle func &rest args)
(let ((source (mm-get-part handle))
- (charset (mail-content-type-get (mm-handle-type handle) 'charset)))
+ (charset (or (mail-content-type-get (mm-handle-type handle) 'charset)
+ mail-parse-charset)))
(mm-insert-inline
handle
(mm-with-multibyte-buffer