(eww-convert-widgets): Fix last patch.
[gnus] / lisp / mm-decode.el
index 812ee73..971c26e 100644 (file)
@@ -29,8 +29,7 @@
 
 (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")
@@ -813,6 +812,8 @@ external if displayed external."
 
 (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."
@@ -1803,11 +1804,12 @@ If RECURSIVE, search recursively."
             (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 ()
@@ -1815,6 +1817,23 @@ If RECURSIVE, search recursively."
            (delete-region ,(point-min-marker)
                           ,(point-max-marker))))))))
 
+(defvar shr-map)
+
+(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)
@@ -1825,7 +1844,7 @@ If RECURSIVE, search recursively."
 (provide 'mm-decode)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
 
 ;;; mm-decode.el ends here