aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKatsumi Yamaoka2010-10-28 06:37:35 +0000
committerKatsumi Yamaoka2010-10-28 06:37:35 +0000
commita87ee50bb9e0471765aadba771d44465edc39464 (patch)
tree97d5906ce0a680971bdf55ea1a11f008eabe2d1c
parentf41f19b0d215b9764e79ec368a224499c577e6e0 (diff)
downloademacs-a87ee50bb9e0471765aadba771d44465edc39464.tar.gz
emacs-a87ee50bb9e0471765aadba771d44465edc39464.zip
gnus-art.el: Improve MIME part functions.
gnus-art.el (gnus-article-jump-to-part): Error on no part; fix prompt. (gnus-mime-copy-part): Check coding system, not charset. (gnus-mime-view-part-externally): Never remove part. (gnus-mime-view-part-internally): Don't remove part here. (gnus-article-part-wrapper): Make sure MIME tag is visible. (gnus-article-goto-part): Go to displayed or preferred subpart if it is multipart/alternative. mm-decode.el (mm-display-part): Take optional arg `force'.
-rw-r--r--lisp/gnus/ChangeLog12
-rw-r--r--lisp/gnus/gnus-art.el65
-rw-r--r--lisp/gnus/mm-decode.el5
3 files changed, 64 insertions, 18 deletions
diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog
index f4dde8b660b..15664e87aa6 100644
--- a/lisp/gnus/ChangeLog
+++ b/lisp/gnus/ChangeLog
@@ -1,3 +1,15 @@
12010-10-28 Katsumi Yamaoka <yamaoka@jpl.org>
2
3 * gnus-art.el (gnus-article-jump-to-part): Error on no part; fix prompt.
4 (gnus-mime-copy-part): Check coding system, not charset.
5 (gnus-mime-view-part-externally): Never remove part.
6 (gnus-mime-view-part-internally): Don't remove part here.
7 (gnus-article-part-wrapper): Make sure MIME tag is visible.
8 (gnus-article-goto-part): Go to displayed or preferred subpart if it is
9 multipart/alternative.
10
11 * mm-decode.el (mm-display-part): Take optional arg `force'.
12
12010-10-26 Julien Danjou <julien@danjou.info> 132010-10-26 Julien Danjou <julien@danjou.info>
2 14
3 * gnus-group.el (gnus-group-default-list-level): Add this function to 15 * gnus-group.el (gnus-group-default-list-level): Add this function to
diff --git a/lisp/gnus/gnus-art.el b/lisp/gnus/gnus-art.el
index 530e72ff5ea..b4b16797ad7 100644
--- a/lisp/gnus/gnus-art.el
+++ b/lisp/gnus/gnus-art.el
@@ -4811,11 +4811,17 @@ General format specifiers can also be used. See Info node
4811(defun gnus-article-jump-to-part (n) 4811(defun gnus-article-jump-to-part (n)
4812 "Jump to MIME part N." 4812 "Jump to MIME part N."
4813 (interactive "P") 4813 (interactive "P")
4814 (pop-to-buffer gnus-article-buffer) 4814 (let ((parts (with-current-buffer gnus-article-buffer
4815 ;; FIXME: why is it necessary? 4815 (length gnus-article-mime-handle-alist))))
4816 (sit-for 0) 4816 (when (zerop parts)
4817 (let ((parts (length gnus-article-mime-handle-alist))) 4817 (error "No such part"))
4818 (or n (setq n (read-number (format "Jump to part (2..%s): " parts)))) 4818 (pop-to-buffer gnus-article-buffer)
4819 ;; FIXME: why is it necessary?
4820 (sit-for 0)
4821 (or n
4822 (setq n (if (= parts 1)
4823 1
4824 (read-number (format "Jump to part (1..%s): " parts)))))
4819 (unless (and (integerp n) (<= n parts) (>= n 1)) 4825 (unless (and (integerp n) (<= n parts) (>= n 1))
4820 (setq n 4826 (setq n
4821 (progn 4827 (progn
@@ -5115,7 +5121,7 @@ are decompressed."
5115 (if (or coding-system 5121 (if (or coding-system
5116 (and charset 5122 (and charset
5117 (setq coding-system (mm-charset-to-coding-system charset)) 5123 (setq coding-system (mm-charset-to-coding-system charset))
5118 (not (eq charset 'ascii)))) 5124 (not (eq coding-system 'ascii))))
5119 (progn 5125 (progn
5120 (mm-enable-multibyte) 5126 (mm-enable-multibyte)
5121 (insert (mm-decode-coding-string contents coding-system)) 5127 (insert (mm-decode-coding-string contents coding-system))
@@ -5290,9 +5296,7 @@ specified charset."
5290 (gnus-mime-view-part-as-type 5296 (gnus-mime-view-part-as-type
5291 nil (lambda (type) (stringp (mailcap-mime-info type)))) 5297 nil (lambda (type) (stringp (mailcap-mime-info type))))
5292 (when handle 5298 (when handle
5293 (if (mm-handle-undisplayer handle) 5299 (mm-display-part handle nil t)))))
5294 (mm-remove-part handle)
5295 (mm-display-part handle))))))
5296 5300
5297(defun gnus-mime-view-part-internally (&optional handle) 5301(defun gnus-mime-view-part-internally (&optional handle)
5298 "View the MIME part under point with an internal viewer. 5302 "View the MIME part under point with an internal viewer.
@@ -5311,9 +5315,7 @@ If no internal viewer is available, use an external viewer."
5311 (gnus-mime-view-part-as-type 5315 (gnus-mime-view-part-as-type
5312 nil (lambda (type) (mm-inlinable-p handle type))) 5316 nil (lambda (type) (mm-inlinable-p handle type)))
5313 (when handle 5317 (when handle
5314 (if (mm-handle-undisplayer handle) 5318 (gnus-bind-safe-url-regexp (mm-display-part handle))))))
5315 (mm-remove-part handle)
5316 (gnus-bind-safe-url-regexp (mm-display-part handle)))))))
5317 5319
5318(defun gnus-mime-action-on-part (&optional action) 5320(defun gnus-mime-action-on-part (&optional action)
5319 "Do something with the MIME attachment at \(point\)." 5321 "Do something with the MIME attachment at \(point\)."
@@ -5376,6 +5378,10 @@ If INTERACTIVE, call FUNCTION interactivly."
5376 (when (gnus-article-goto-part n) 5378 (when (gnus-article-goto-part n)
5377 ;; We point the cursor and the arrow at the MIME button 5379 ;; We point the cursor and the arrow at the MIME button
5378 ;; when the `function' prompt the user for something. 5380 ;; when the `function' prompt the user for something.
5381 (unless (and (pos-visible-in-window-p)
5382 (> (count-lines (point) (window-end))
5383 (/ (1- (window-height)) 3)))
5384 (recenter (/ (1- (window-height)) 3)))
5379 (let ((cursor-in-non-selected-windows t) 5385 (let ((cursor-in-non-selected-windows t)
5380 (overlay-arrow-string "=>") 5386 (overlay-arrow-string "=>")
5381 (overlay-arrow-position (point-marker))) 5387 (overlay-arrow-position (point-marker)))
@@ -5387,11 +5393,10 @@ If INTERACTIVE, call FUNCTION interactivly."
5387 (funcall function)) 5393 (funcall function))
5388 (interactive 5394 (interactive
5389 (call-interactively 5395 (call-interactively
5390 function 5396 function (get-text-property (point) 'gnus-data)))
5391 (cdr (assq n gnus-article-mime-handle-alist))))
5392 (t 5397 (t
5393 (funcall function 5398 (funcall function
5394 (cdr (assq n gnus-article-mime-handle-alist))))) 5399 (get-text-property (point) 'gnus-data))))
5395 (set-marker overlay-arrow-position nil) 5400 (set-marker overlay-arrow-position nil)
5396 (unless gnus-auto-select-part 5401 (unless gnus-auto-select-part
5397 (gnus-select-frame-set-input-focus frame) 5402 (gnus-select-frame-set-input-focus frame)
@@ -5556,7 +5561,35 @@ all parts."
5556 5561
5557(defun gnus-article-goto-part (n) 5562(defun gnus-article-goto-part (n)
5558 "Go to MIME part N." 5563 "Go to MIME part N."
5559 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n))) 5564 (let ((start (text-property-any (point-min) (point-max) 'gnus-part n))
5565 part handle end next handles)
5566 (when start
5567 (goto-char start)
5568 (if (setq handle (get-text-property start 'gnus-data))
5569 start
5570 ;; Go to the displayed subpart, assuming this is multipart/alternative.
5571 (setq part start
5572 end (point-at-eol))
5573 (while (and (not handle)
5574 part
5575 (< part end)
5576 (setq next (text-property-not-all part end
5577 'gnus-data nil)))
5578 (setq part next
5579 handle (get-text-property part 'gnus-data))
5580 (push (cons handle part) handles)
5581 (unless (mm-handle-displayed-p handle)
5582 (setq handle nil
5583 part (text-property-any part end 'gnus-data nil))))
5584 (unless handle
5585 ;; No subpart is displayed, so we find preferred one.
5586 (setq part
5587 (cdr (assq (mm-preferred-alternative
5588 (nreverse (mapcar 'car handles)))
5589 handles))))
5590 (if part
5591 (goto-char (1+ part))
5592 start)))))
5560 5593
5561(defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed) 5594(defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5562 (let ((gnus-tmp-name 5595 (let ((gnus-tmp-name
diff --git a/lisp/gnus/mm-decode.el b/lisp/gnus/mm-decode.el
index d1fd493a37d..531206c538e 100644
--- a/lisp/gnus/mm-decode.el
+++ b/lisp/gnus/mm-decode.el
@@ -696,13 +696,14 @@ Postpone undisplaying of viewers for types in
696(autoload 'mailcap-parse-mailcaps "mailcap") 696(autoload 'mailcap-parse-mailcaps "mailcap")
697(autoload 'mailcap-mime-info "mailcap") 697(autoload 'mailcap-mime-info "mailcap")
698 698
699(defun mm-display-part (handle &optional no-default) 699(defun mm-display-part (handle &optional no-default force)
700 "Display the MIME part represented by HANDLE. 700 "Display the MIME part represented by HANDLE.
701Returns nil if the part is removed; inline if displayed inline; 701Returns nil if the part is removed; inline if displayed inline;
702external if displayed external." 702external if displayed external."
703 (save-excursion 703 (save-excursion
704 (mailcap-parse-mailcaps) 704 (mailcap-parse-mailcaps)
705 (if (mm-handle-displayed-p handle) 705 (if (and (not force)
706 (mm-handle-displayed-p handle))
706 (mm-remove-part handle) 707 (mm-remove-part handle)
707 (let* ((ehandle (if (equal (mm-handle-media-type handle) 708 (let* ((ehandle (if (equal (mm-handle-media-type handle)
708 "message/external-body") 709 "message/external-body")