;;; mm-decode.el --- Functions for decoding MIME things
-;; Copyright (C) 1998-2012 Free Software Foundation, Inc.
+;; Copyright (C) 1998-2013 Free Software Foundation, Inc.
;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
(require 'mail-parse)
(require 'mm-bodies)
-(eval-when-compile (require 'cl)
- (require 'term))
+(eval-when-compile (require 'cl))
(autoload 'gnus-map-function "gnus-util")
(autoload 'gnus-replace-in-string "gnus-util")
(declare-function gnus-configure-windows "gnus-win" (setting &optional force))
(defvar mailcap-mime-extensions) ; mailcap-mime-info autoloads
+(declare-function term-mode "term" ())
+(declare-function term-char-mode "term" ())
(defun mm-display-external (handle method)
"Display HANDLE using METHOD."
(when filename
(setq filename (gnus-map-function mm-file-name-rewrite-functions
(file-name-nondirectory filename))))
- (setq file
- (read-file-name
- (or prompt
- (format "Save MIME part to (default %s): "
- (or filename "")))
- (or mm-default-directory default-directory)
- (expand-file-name (or filename "")
- (or mm-default-directory default-directory))))
+ (while
+ (progn
+ (setq file
+ (read-file-name
+ (or prompt
+ (format "Save MIME part to (default %s): "
+ (or filename "")))
+ (or mm-default-directory default-directory)
+ (expand-file-name (or filename "")
+ (or mm-default-directory default-directory))))
+ (cond ((or (not file) (equal file ""))
+ (message "Please enter a file name")
+ t)
+ ((and (file-directory-p file)
+ (not filename))
+ (message "Please enter a non-directory file name")
+ t)
+ (t nil)))
+ (sit-for 2)
+ (discard-input))
(if (file-directory-p file)
(setq file (expand-file-name filename file))
(setq file (expand-file-name
(insert (prog1
(if (and charset
(setq charset
- (mm-charset-to-coding-system charset))
+ (mm-charset-to-coding-system charset
+ nil t))
(not (eq charset 'ascii)))
(mm-decode-coding-string (buffer-string) charset)
(mm-string-as-multibyte (buffer-string)))
(replace-match (char-to-string char))))
;; Remove "soft hyphens".
(goto-char (point-min))
- (while (search-forward "" nil t)
+ (while (search-forward "Â" nil t)
(replace-match "" t t))
(libxml-parse-html-region (point-min) (point-max))))
(unless (bobp)
(insert "\n"))
+ (mm-convert-shr-links)
(mm-handle-set-undisplayer
handle
`(lambda ()
(delete-region ,(point-min-marker)
,(point-max-marker))))))))
+(defvar shr-map)
+
+(autoload 'widget-convert-button "wid-edit")
+
+(defun mm-convert-shr-links ()
+ (let ((start (point-min))
+ end)
+ (while (and start
+ (< start (point-max)))
+ (when (setq start (text-property-not-all start (point-max) 'shr-url nil))
+ (setq end (next-single-property-change start 'shr-url nil (point-max)))
+ (widget-convert-button
+ 'url-link start end
+ :help-echo (get-text-property start 'help-echo)
+ :keymap shr-map
+ (get-text-property start 'shr-url))
+ (put-text-property start end 'local-map nil)
+ (setq start end)))))
+
(defun mm-handle-filename (handle)
"Return filename of HANDLE if any."
(or (mail-content-type-get (mm-handle-type handle)
(provide 'mm-decode)
+;; Local Variables:
+;; coding: utf-8
+;; End:
+
;;; mm-decode.el ends here