[Date Prev][Date Next][Thread Prev][][Date Index][Thread Index]

Re: w3m doesn't display messages with text/html mime-type properly



Hi,

>>>>> In [emacs-w3m : No.04830]
>>>>>	Katsumi Yamaoka <yamaoka@jpl.org> wrote:

> Though the patch has aleady been installed in the emacs-w3m CVS,
> it is bogus!  I'll fix it ASAP.

The new patch for the emacs-w3m v1.3.3 release is attached at
the end of this message.  I've tested it with the following
advice as well:

(defadvice w3m-safe-view-this-url (around use-browser-function activate)
  "Use browser function."
  (let ((url (w3m-anchor)))
    (cond (url
	   (browse-url url))
	  ((w3m-image)
	   (if (w3m-display-graphic-p)
	       (w3m-toggle-inline-image)

Well, only the w3m-view-url-with-external-browser command is
provided to use the browse-url feature.  I think we should
improve emacs-w3m in order to be able to use the external
browser here and there, though it may not be easy.

The attached patch is still only imitation of the widget,
however I learned how it can be used in the future emacs-w3m.
--- w3m.el~	2002-10-25 05:55:02 +0000
+++ w3m.el	2003-05-06 08:15:03 +0000
@@ -128,11 +128,13 @@
   (autoload 'w3m-cookie "w3m-cookie")
   (autoload 'w3m-about-cookie "w3m-cookie")
   (autoload 'w3m-cookie-shutdown "w3m-cookie" nil t)
-  (autoload 'report-emacs-w3m-bug "w3m-bug" nil t))
+  (autoload 'report-emacs-w3m-bug "w3m-bug" nil t)
+  (autoload 'widget-forward "wid-edit" nil t))
 
 ;; Avoid byte-compile warnings.
 (eval-when-compile
-  (autoload 'rfc2368-parse-mailto-url "rfc2368"))
+  (autoload 'rfc2368-parse-mailto-url "rfc2368")
+  (autoload 'widget-convert-button "wid-edit"))
 
 (defconst emacs-w3m-version "1.3.3"
   "Version number of this package.")
@@ -318,6 +320,13 @@
   :group 'w3m
   :type 'boolean)
 
+(defcustom w3m-imitate-widget-button '(eq major-mode 'gnus-article-mode)
+  "*If non-nil, imitate the widget button on link (anchor) buttons.
+It is useful for moving about in a Gnus article buffer using TAB key.
+It can also be any Lisp form that should return a boolean value."
+  :group 'w3m
+  :type 'sexp)
+
 (defcustom w3m-treat-image-size (and (member "image" w3m-compile-options) t)
   "*Non-nil means to let the w3m HTML rendering be conscious of image size.
 `w3m-pixels-per-character' is used for the `-ppc' argument of the w3m command.
@@ -2140,6 +2149,14 @@
     (apply (function concat)
 	   (nreverse (cons (substring str start) buf)))))
 
+(defun w3m-imitate-widget-button ()
+  "Return a boolean value corresponding to the variable of the same name."
+  (if (listp w3m-imitate-widget-button)
+      (condition-case nil
+	  (eval w3m-imitate-widget-button)
+	(error nil))
+    (and w3m-imitate-widget-button t)))
+
 (defun w3m-fontify-anchors ()
   "Fontify anchor tags in this buffer which contains half-dumped data."
   (let ((help (w3m-make-help-echo w3m-href-anchor))
@@ -2186,6 +2203,15 @@
 					   'w3m-anchor-sequence hseq
 					   'help-echo help
 					   'balloon-help balloon))
+	    (when (w3m-imitate-widget-button)
+	      (require 'wid-edit)
+	      (let ((widget-button-face (if (w3m-arrived-p href)
+					    'w3m-arrived-anchor-face
+					  'w3m-anchor-face))
+		    (widget-mouse-face 'highlight))
+		(widget-convert-button 'default start end
+				       :button-keymap nil
+				       :help-echo href)))
 	    (when name
 	      (w3m-add-text-properties start (point-max)
 				       (list 'w3m-name-anchor
@@ -4501,10 +4527,12 @@
       (w3m-previous-anchor (- arg))
     (while (> arg 0)
       (unless (w3m-goto-next-anchor)
-	;; search from the beginning of the buffer
 	(setq w3m-goto-anchor-hist nil)
-	(goto-char (point-min))
-	(w3m-goto-next-anchor))
+	(if (w3m-imitate-widget-button)
+	    (widget-forward 1)
+	  ;; search from the beginning of the buffer
+	  (goto-char (point-min))
+	  (w3m-goto-next-anchor)))
       (setq arg (1- arg))
       (if (member (w3m-anchor-sequence) w3m-goto-anchor-hist)
 	  (setq arg (1+ arg))
@@ -4547,10 +4575,12 @@
       (w3m-next-anchor (- arg))
     (while (> arg 0)
       (unless (w3m-goto-previous-anchor)
-	;; search from the end of the buffer
 	(setq w3m-goto-anchor-hist nil)
-	(goto-char (point-max))
-	(w3m-goto-previous-anchor))
+	(if (w3m-imitate-widget-button)
+	    (widget-forward -1)
+	  ;; search from the end of the buffer
+	  (goto-char (point-max))
+	  (w3m-goto-previous-anchor)))
       (setq arg (1- arg))
       (if (member (w3m-anchor-sequence) w3m-goto-anchor-hist)
 	  (setq arg (1+ arg))
@@ -6866,6 +6896,10 @@
       (substitute-key-definition (car pair)
 				 (or (cdr pair) (car pair))
 				 keymap w3m-mode-map))
+    (unless (featurep 'xemacs)
+      ;; Inhibit the `widget-button-click' command when
+      ;; `w3m-imitate-widget-button' is activated.
+      (define-key keymap [down-mouse-2] 'undefined))
     keymap))
 
 (defvar w3m-minor-mode-map (w3m-make-minor-mode-keymap)