From 6b554e88693084621601261ea4d863684f01e34a Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Thu, 19 Apr 2007 12:08:53 +0000 Subject: [PATCH] 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 --- lisp/gnus/ChangeLog | 12 ++++++++ lisp/gnus/gnus-art.el | 69 +++++++++++++++++++++++++++++++------------ lisp/gnus/mm-view.el | 10 +++++-- 3 files changed, 69 insertions(+), 22 deletions(-) diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 8f094dd6537..b02dc6c2f8e 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -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 --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el index 552f3a68f49..6ae52b5eedd 100644 --- a/lisp/gnus/gnus-art.el +++ b/lisp/gnus/gnus-art.el @@ -4606,6 +4606,21 @@ are decompressed." (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 @@ 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)) @@ -4622,17 +4637,24 @@ specified charset." (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 @@ If no internal viewer is available, use an external viewer." (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 --git a/lisp/gnus/mm-view.el b/lisp/gnus/mm-view.el index 14d480fe7df..888c814bf24 100644 --- a/lisp/gnus/mm-view.el +++ b/lisp/gnus/mm-view.el @@ -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 -- 2.39.2