Gnus development mailing list
 help / color / mirror / Atom feed
* emacs-w3m
@ 2002-01-24  2:38 Katsumi Yamaoka
  2002-01-24  2:51 ` emacs-w3m Daniel Pittman
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Katsumi Yamaoka @ 2002-01-24  2:38 UTC (permalink / raw)
  Cc: emacs-w3m

[-- Attachment #1: Type: text/plain, Size: 1564 bytes --]

Hi,

Emacs-w3m is yet another web browser for Emacsen.  It is light
and fast for rendering html contents, because it uses the
external command w3m.  Emacs-w3m can also show images inline
under XEmacs or Emacs 21+.  Why don't we use emacs-w3m for
converting text/html parts on Gnus?  I wish to install the
attached patch to Gnus CVS by myself.  Do you have any
objections?

If you are interested in emacs-w3m, visit the following web
site:

  http://emacs-w3m.namazu.org/

Note that you have to install both the lisp package emacs-w3m
and the external command w3m to make your Emacs web browser,
and some programs (e.g. gifsicle, ImageMagick, etc.) will help
you.  See the documentations for details.


2002-01-24  Katsumi Yamaoka  <yamaoka@jpl.org>

	* mm-decode.el (mm-inline-text-use-emacs-w3m): New user option.
	(mm-inline-media-tests): Check for w3m instead of w3 if
	`mm-inline-text-use-emacs-w3m' is non-nil.

	* mm-view.el (mm-inline-text-html-with-w3): New function separated
	from `mm-inline-text'.
	(w3m-region, w3m-mode-map): Bind them when compiling.
	(mm-w3m-minor-mode): New variable.
	(mm-w3m-setup): New variable.
	(mm-setup-w3m): New function.
	(mm-inline-text-html-with-w3m): New function.
	(mm-inline-text): Use `mm-inline-text-html-with-w3m' or
	`mm-inline-text-html-with-w3' to convert html part.


The original code which uses `defadvice' was posted in the news:

  From: greg@visiontech-dml.com
  Newsgroups: gnu.emacs.help
  Subject: Re: w3m-mode and images
  Date: 19 Jul 2001 10:59:19 +0300
  Message-ID: <2fasnftcpt4.fsf@broadcom.com>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: w3m.patch --]
[-- Type: text/x-patch, Size: 7226 bytes --]

--- mm-decode.el~	Tue Jan 22 21:54:08 2002
+++ mm-decode.el	Thu Jan 24 02:36:27 2002
@@ -95,6 +95,11 @@
   `(list ,buffer ,type ,encoding ,undisplayer
 	 ,disposition ,description ,cache ,id))
 
+(defcustom mm-inline-text-use-emacs-w3m nil
+  "If non-nil, use emacs-w3m to show html parts.  Otherwise, use emacs-w3."
+  :type 'boolean
+  :group 'mime-display)
+
 (defcustom mm-inline-media-tests
   '(("image/jpeg"
      mm-inline-image
@@ -147,7 +152,9 @@
     ("text/html"
      mm-inline-text
      (lambda (handle)
-       (locate-library "w3")))
+       (if mm-inline-text-use-emacs-w3m
+	   (locate-library "w3m")
+	 (locate-library "w3"))))
     ("text/x-vcard"
      mm-inline-text
      (lambda (handle)
--- mm-view.el~	Mon Jan 14 22:01:28 2002
+++ mm-view.el	Thu Jan 24 02:36:27 2002
@@ -81,81 +81,124 @@
     (require 'url-vars)
     (setq mm-w3-setup t)))
 
+(defun mm-inline-text-html-with-w3 (handle)
+  (mm-setup-w3)
+  (let ((text (mm-get-part handle))
+	(b (point))
+	(url-standalone-mode t)
+	(w3-honor-stylesheets nil)
+	(w3-delay-image-loads t)
+	(url-current-object
+	 (url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
+	(width (window-width))
+	(charset (mail-content-type-get
+		  (mm-handle-type handle) 'charset)))
+    (save-excursion
+      (insert text)
+      (save-restriction
+	(narrow-to-region b (point))
+	(goto-char (point-min))
+	(if (or (and (boundp 'w3-meta-content-type-charset-regexp)
+		     (re-search-forward
+		      w3-meta-content-type-charset-regexp nil t))
+		(and (boundp 'w3-meta-charset-content-type-regexp)
+		     (re-search-forward
+		      w3-meta-charset-content-type-regexp nil t)))
+	    (setq charset
+		  (or (let ((bsubstr (buffer-substring-no-properties
+				      (match-beginning 2)
+				      (match-end 2))))
+			(if (fboundp 'w3-coding-system-for-mime-charset)
+			    (w3-coding-system-for-mime-charset bsubstr)
+			  (mm-charset-to-coding-system bsubstr)))
+		      charset)))
+	(delete-region (point-min) (point-max))
+	(insert (mm-decode-string text charset))
+	(save-window-excursion
+	  (save-restriction
+	    (let ((w3-strict-width width)
+		  ;; Don't let w3 set the global version of
+		  ;; this variable.
+		  (fill-column fill-column)
+		  (w3-honor-stylesheets nil)
+		  (w3-delay-image-loads t)
+		  (url-standalone-mode t))
+	      (condition-case var
+		  (w3-region (point-min) (point-max))
+		(error
+		 (delete-region (point-min) (point-max))
+		 (let ((b (point))
+		       (charset (mail-content-type-get
+				 (mm-handle-type handle) 'charset)))
+		   (if (or (eq charset 'gnus-decoded)
+			   (eq mail-parse-charset 'gnus-decoded))
+		       (save-restriction
+			 (narrow-to-region (point) (point))
+			 (mm-insert-part handle)
+			 (goto-char (point-max)))
+		     (insert (mm-decode-string (mm-get-part handle)
+					       charset))))
+		 (message
+		  "Error while rendering html; showing as text/plain"))))))
+	(mm-handle-set-undisplayer
+	 handle
+	 `(lambda ()
+	    (let (buffer-read-only)
+	      (if (functionp 'remove-specifier)
+		  (mapcar (lambda (prop)
+			    (remove-specifier
+			     (face-property 'default prop)
+			     (current-buffer)))
+			  '(background background-pixmap foreground)))
+	      (delete-region ,(point-min-marker)
+			     ,(point-max-marker)))))))))
+
+(eval-when-compile
+  (autoload 'w3m-region "w3m")
+  (defvar w3m-mode-map))
+
+(defvar mm-w3m-minor-mode nil)
+(make-variable-buffer-local 'mm-w3m-minor-mode)
+(defvar mm-w3m-setup nil)
+(defun mm-setup-w3m ()
+  (unless mm-w3m-setup
+    (require 'w3m)
+    (gnus-add-minor-mode 'mm-w3m-minor-mode " w3m" w3m-mode-map)
+    (setq mm-w3m-setup t)))
+
+(defun mm-inline-text-html-with-w3m (handle)
+  (mm-setup-w3m)
+  (let ((text (mm-get-part handle))
+	(b (point)))
+    (save-excursion
+      (insert text)
+      (save-restriction
+	(narrow-to-region b (point))
+	(goto-char (point-min))
+	(w3m-region (point-min) (point-max))
+	(setq mm-w3m-minor-mode t))
+      (mm-handle-set-undisplayer
+       handle
+       `(lambda ()
+	  (let (buffer-read-only)
+	    (setq mm-w3m-minor-mode nil)
+	    (if (functionp 'remove-specifier)
+		(mapcar (lambda (prop)
+			  (remove-specifier
+			   (face-property 'default prop)
+			   (current-buffer)))
+			'(background background-pixmap foreground)))
+	    (delete-region ,(point-min-marker)
+			   ,(point-max-marker))))))))
+
 (defun mm-inline-text (handle)
   (let ((type (mm-handle-media-subtype handle))
-	text buffer-read-only)
+	buffer-read-only)
     (cond
      ((equal type "html")
-      (mm-setup-w3)
-      (setq text (mm-get-part handle))
-      (let ((b (point))
-	    (url-standalone-mode t)
-	    (w3-honor-stylesheets nil)
-	    (w3-delay-image-loads t)
-	    (url-current-object
-	     (url-generic-parse-url (format "cid:%s" (mm-handle-id handle))))
-	    (width (window-width))
-	    (charset (mail-content-type-get
-		      (mm-handle-type handle) 'charset)))
-	(save-excursion
-	  (insert text)
-	  (save-restriction
-	    (narrow-to-region b (point))
-	    (goto-char (point-min))
-	    (if (or (and (boundp 'w3-meta-content-type-charset-regexp)
-			 (re-search-forward
-			  w3-meta-content-type-charset-regexp nil t))
-		    (and (boundp 'w3-meta-charset-content-type-regexp)
-			 (re-search-forward
-			  w3-meta-charset-content-type-regexp nil t)))
-		(setq charset
-		      (or (let ((bsubstr (buffer-substring-no-properties
-					  (match-beginning 2)
-					  (match-end 2))))
-			    (if (fboundp 'w3-coding-system-for-mime-charset)
-				(w3-coding-system-for-mime-charset bsubstr)
-			      (mm-charset-to-coding-system bsubstr)))
-			  charset)))
-	    (delete-region (point-min) (point-max))
-	    (insert (mm-decode-string text charset))
-	    (save-window-excursion
-	      (save-restriction
-		(let ((w3-strict-width width)
-		      ;; Don't let w3 set the global version of
-		      ;; this variable.
-		      (fill-column fill-column)
-		      (w3-honor-stylesheets nil)
-		      (w3-delay-image-loads t)
-		      (url-standalone-mode t))
-		  (condition-case var
-		      (w3-region (point-min) (point-max))
-		    (error
-		     (delete-region (point-min) (point-max))
-		     (let ((b (point))
-			   (charset (mail-content-type-get
-				     (mm-handle-type handle) 'charset)))
-		       (if (or (eq charset 'gnus-decoded)
-			       (eq mail-parse-charset 'gnus-decoded))
-			   (save-restriction
-			     (narrow-to-region (point) (point))
-			     (mm-insert-part handle)
-			     (goto-char (point-max)))
-			 (insert (mm-decode-string (mm-get-part handle)
-						   charset))))
-		     (message
-		      "Error while rendering html; showing as text/plain"))))))
-	    (mm-handle-set-undisplayer
-	     handle
-	     `(lambda ()
-		(let (buffer-read-only)
-		  (if (functionp 'remove-specifier)
-		      (mapcar (lambda (prop)
-				(remove-specifier
-				 (face-property 'default prop)
-				 (current-buffer)))
-			      '(background background-pixmap foreground)))
-		  (delete-region ,(point-min-marker)
-				 ,(point-max-marker)))))))))
+      (if mm-inline-text-use-emacs-w3m
+	  (mm-inline-text-html-with-w3m handle)
+	(mm-inline-text-html-with-w3 handle)))
      ((equal type "x-vcard")
       (mm-insert-inline
        handle

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2002-02-12 19:27 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-24  2:38 emacs-w3m Katsumi Yamaoka
2002-01-24  2:51 ` emacs-w3m Daniel Pittman
2002-01-24  3:26   ` emacs-w3m Katsumi Yamaoka
2002-01-24  6:11     ` emacs-w3m Katsumi Yamaoka
2002-01-25 13:29       ` emacs-w3m Niels Olof Bouvin
2002-01-25 18:15         ` emacs-w3m Josh Huber
2002-01-26  2:40           ` emacs-w3m Jinhyok Heo
2002-01-26  3:07           ` emacs-w3m ShengHuo ZHU
2002-01-24 13:37     ` emacs-w3m Per Abrahamsen
2002-01-24 11:28 ` emacs-w3m Jinhyok Heo
2002-01-25  1:28   ` emacs-w3m Katsumi Yamaoka
2002-01-25  2:34     ` emacs-w3m Katsumi Yamaoka
2002-01-25  3:05       ` emacs-w3m Jinhyok Heo
2002-01-25  2:41     ` emacs-w3m Jinhyok Heo
2002-01-24 22:19 ` emacs-w3m Florian Weimer
2002-01-24 22:49   ` emacs-w3m François Pinard
2002-01-26 22:36     ` emacs-w3m Steinar Bang
2002-01-28  2:36       ` emacs-w3m Patric Mueller
2002-01-28 11:32       ` emacs-w3m Katsumi Yamaoka
2002-01-31 15:48         ` emacs-w3m Dirk Meyer
2002-02-01  8:09           ` emacs-w3m Katsumi Yamaoka
2002-02-06 13:29             ` emacs-w3m Dirk Meyer
2002-02-12 18:45     ` emacs-w3m Florian Weimer
2002-02-12 19:27       ` emacs-w3m François Pinard
2002-01-24 23:10   ` emacs-w3m Katsumi Yamaoka
2002-01-27  1:33 ` emacs-w3m Raja R Harinath
2002-01-28  1:30   ` emacs-w3m Katsumi Yamaoka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).