# HG changeset patch # User Miles Bader # Date 1176984533 0 # Node ID 56cc03f5f68c210456fdf8966bea4160f3adf458 # Parent 2ec04a50669a76ee34563f9a106ea22cd05c9a53 Merge from gnus--rel--5.10 Patches applied: * gnus--rel--5.10 (patch 216) - Update from CVS 2007-04-19 Katsumi Yamaoka * lisp/gnus/gnus-art.el (gnus-mime-strip-charset-parameters): New function. (gnus-mime-view-part-as-charset): Use it; redisplay subpart currently displayed of multipart/alternative part if it is invoked from summary buffer. (gnus-article-part-wrapper): Select article window. * lisp/gnus/mm-view.el (mm-inline-text-html-render-with-w3m) (mm-inline-text-html-render-with-w3m-standalone) (mm-inline-render-with-function): Use mail-parse-charset by default. Revision: emacs@sv.gnu.org/emacs--devo--0--patch-706 diff -r 2ec04a50669a -r 56cc03f5f68c lisp/gnus/ChangeLog --- a/lisp/gnus/ChangeLog Thu Apr 19 08:41:05 2007 +0000 +++ b/lisp/gnus/ChangeLog Thu Apr 19 12:08:53 2007 +0000 @@ -1,3 +1,15 @@ +2007-04-19 Katsumi Yamaoka + + * gnus-art.el (gnus-mime-strip-charset-parameters): New function. + (gnus-mime-view-part-as-charset): Use it; redisplay subpart currently + displayed of multipart/alternative part if it is invoked from summary + buffer. + (gnus-article-part-wrapper): Select article window. + + * mm-view.el (mm-inline-text-html-render-with-w3m) + (mm-inline-text-html-render-with-w3m-standalone) + (mm-inline-render-with-function): Use mail-parse-charset by default. + 2007-04-10 Katsumi Yamaoka * gnus-msg.el (gnus-inews-yank-articles): Use diff -r 2ec04a50669a -r 56cc03f5f68c lisp/gnus/gnus-art.el --- a/lisp/gnus/gnus-art.el Thu Apr 19 08:41:05 2007 +0000 +++ b/lisp/gnus/gnus-art.el Thu Apr 19 12:08:53 2007 +0000 @@ -4606,6 +4606,21 @@ (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." @@ -4614,7 +4629,7 @@ (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)) @@ -4622,17 +4637,24 @@ (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) @@ -4688,13 +4710,22 @@ (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." diff -r 2ec04a50669a -r 56cc03f5f68c lisp/gnus/mm-view.el --- a/lisp/gnus/mm-view.el Thu Apr 19 08:41:05 2007 +0000 +++ b/lisp/gnus/mm-view.el Thu Apr 19 12:08:53 2007 +0000 @@ -238,7 +238,8 @@ (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 @@ -302,7 +303,9 @@ "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)) @@ -368,7 +371,8 @@ (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