+ (let ((number (wl-summary-pop-message (wl-summary-message-number))))
+ (unless number
+ (error "Empty message ring"))
+ (wl-summary-jump-to-msg number)
+ (when wl-summary-buffer-disp-msg
+ (let (wl-summary-buffer-message-ring)
+ (wl-summary-redisplay)))))
+
+(defun wl-summary-goto-last-displayed-msg (&optional arg)
+ "Jump to last displayed message."
+ (interactive "P")
+ (cond
+ ((eq last-command 'wl-summary-pop-to-last-message)
+ (setq this-command 'wl-summary-pop-to-last-message)
+ (wl-summary-pop-to-last-message))
+ (arg
+ (setq this-command 'wl-summary-pop-to-last-message)
+ (wl-summary-pop-to-last-message))
+ (t
+ (let ((current (wl-summary-message-number))
+ (number (wl-summary-pop-message)))
+ (if number
+ (progn
+ (wl-summary-jump-to-msg number)
+ (if wl-summary-buffer-disp-msg
+ (wl-summary-redisplay)
+ (wl-summary-push-message current)))
+ (message "No last message."))))))
+
+(defun wl-summary-message-display-type ()
+ (when (and wl-summary-buffer-disp-msg
+ (buffer-live-p wl-message-buffer)
+ wl-summary-buffer-current-msg
+ (wl-summary-message-number)
+ (= (wl-summary-message-number) wl-summary-buffer-current-msg))
+ (wl-message-buffer-display-type wl-message-buffer)))
+
+(defun wl-summary-buffer-display-mime-mode ()
+ (or (wl-message-display-type-property (wl-summary-message-display-type)
+ :mime)
+ wl-summary-buffer-display-mime-mode))
+
+(defun wl-summary-buffer-display-header-mode ()
+ (or (wl-message-display-type-property (wl-summary-message-display-type)
+ :header)
+ wl-summary-buffer-display-header-mode))
+
+(defun wl-summary-toggle-mime (&optional arg)
+ "Toggle MIME decoding.
+If ARG is non-nil, ask coding-system to display the message in the current
+MIME analysis mode.
+
+If ARG is numeric number, decode message as following:
+1: Enable MIME analysis.
+2: Enable MIME analysis only for headers.
+3: Disable MIME analysis."
+ (interactive "P")
+ (let ((mime-mode (wl-summary-buffer-display-mime-mode))
+ (elmo-mime-display-as-is-coding-system
+ elmo-mime-display-as-is-coding-system))
+ (if (and (consp arg) (> (prefix-numeric-value arg) 4))
+ (progn
+ (setq wl-summary-buffer-display-mime-mode mime-mode)
+ (wl-summary-update-modeline))
+ (cond
+ ((numberp arg)
+ (setq mime-mode (case arg
+ (1 'mime)
+ (2 'header-only)
+ (3 'as-is)
+;;; (4 'decode-only)
+ (5 'no-merge))))
+ (arg
+ ;; Specify coding-system (doesn't change the MIME mode).
+ (setq elmo-mime-display-as-is-coding-system
+ (if (and arg
+ (not (wl-message-mime-analysis-p
+ (wl-summary-message-display-type))))
+ (or (read-coding-system "Coding system: ")
+ elmo-mime-display-as-is-coding-system)
+ elmo-mime-display-as-is-coding-system)))
+ (t
+ ;; Change the MIME mode.
+ (setq mime-mode (or (cadr (memq mime-mode
+ wl-summary-display-mime-mode-list))
+ (car wl-summary-display-mime-mode-list)))))
+ (wl-summary-redisplay-internal nil nil arg mime-mode))
+ (message "MIME decoding: %s%s"
+ (upcase (symbol-name mime-mode))
+ (if (and (not (eq mime-mode 'mime))
+ (not (eq elmo-mime-display-as-is-coding-system
+ wl-cs-autoconv)))
+ (concat " ("
+ (symbol-name elmo-mime-display-as-is-coding-system)
+ ")")
+ ""))))