From: yamaoka Date: Thu, 24 Jan 2002 06:59:15 +0000 (+0000) Subject: Synch with Oort Gnus (this change has no effect on T-gnus :-). X-Git-Tag: t-gnus-6_15_6-01-quimby~109 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=cd7f0a21e22c97a5095791b276de6b18645a5d1b;p=elisp%2Fgnus.git- Synch with Oort Gnus (this change has no effect on T-gnus :-). --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c806e69..da43d57 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,24 @@ +2002-01-24 Katsumi Yamaoka + + * lpath.el: Fbind `w3m-region'; bind `w3m-mode-map'. + + * mm-decode.el (mm-inline-text-html-renderer): New user option. + (mm-inline-media-tests): Test whether the value of + `mm-inline-text-html-renderer' is a function for text/html. + + * mm-view.el (mm-inline-text-html-render-with-w3): New function + separated from `mm-inline-text'. + (mm-w3m-minor-mode): New variable. + (mm-w3m-setup): New variable. + (mm-setup-w3m): New function. + (mm-inline-text-html-render-with-w3m): New function. + (mm-inline-text): Funcall `mm-inline-text-html-renderer' for + text/html. + +2002-01-23 Paul Jarc + + * lpath.el: fbind make-symbolic-link and unix-sync for nnmaildir. + 2002-01-23 Katsumi Yamaoka * gnus-xmas.el (gnus-xmas-redefine): Quote `gnus-completing-read' diff --git a/lisp/lpath.el b/lisp/lpath.el index 604739d..d53a322 100644 --- a/lisp/lpath.el +++ b/lisp/lpath.el @@ -21,6 +21,7 @@ find-coding-systems-string image-size image-type-available-p insert-image image-type-from-file-header + make-symbolic-link make-temp-file message-xmas-redefine mail-aliases-setup mm-copy-tree mule-write-region-no-coding-system put-image @@ -35,9 +36,11 @@ sc-cite-regexp set-font-family set-font-size temp-directory string-as-multibyte tool-bar-add-item tool-bar-add-item-from-menu + unix-sync url-view-url vcard-pretty-print url-insert-file-contents w3-coding-system-for-mime-charset w3-prepare-buffer w3-region + w3m-region widget-make-intangible x-defined-colors)) (maybe-bind '(adaptive-fill-first-line-regexp @@ -54,7 +57,8 @@ url-current-mime-headers w3-meta-charset-content-type-regexp rmail-enable-mime-composing rmail-insert-mime-forwarded-message-function - w3-meta-content-type-charset-regexp)) + w3-meta-content-type-charset-regexp + w3m-mode-map)) (if (featurep 'xemacs) (progn diff --git a/lisp/mm-decode.el b/lisp/mm-decode.el index 7c85b3d..6447fa3 100644 --- a/lisp/mm-decode.el +++ b/lisp/mm-decode.el @@ -95,6 +95,20 @@ `(list ,buffer ,type ,encoding ,undisplayer ,disposition ,description ,cache ,id)) +(defcustom mm-inline-text-html-renderer + (cond ((locate-library "w3") + 'mm-inline-text-html-render-with-w3) + ((locate-library "w3m") + 'mm-inline-text-html-render-with-w3m)) + "Function used for rendering HTML contents. The function will be +called with a MIME handle as the argument. There are two pre-defined +functions: `mm-inline-text-html-render-with-w3', which uses Emacs/w3; +and `mm-inline-text-html-render-with-w3m', which uses emacs-w3m." + :type '(radio (function-item mm-inline-text-html-render-with-w3) + (function-item mm-inline-text-html-render-with-w3m) + (function)) + :group 'mime-display) + (defcustom mm-inline-media-tests '(("image/jpeg" mm-inline-image @@ -147,7 +161,7 @@ ("text/html" mm-inline-text (lambda (handle) - (locate-library "w3"))) + (gnus-functionp mm-inline-text-html-renderer))) ("text/x-vcard" mm-inline-text (lambda (handle) diff --git a/lisp/mm-view.el b/lisp/mm-view.el index 192b94f..26f68a0 100644 --- a/lisp/mm-view.el +++ b/lisp/mm-view.el @@ -81,81 +81,118 @@ (require 'url-vars) (setq mm-w3-setup t))) +(defun mm-inline-text-html-render-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))))))))) + +(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-render-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))))))))) + (funcall mm-inline-text-html-renderer handle)) ((equal type "x-vcard") (mm-insert-inline handle diff --git a/texi/ChangeLog b/texi/ChangeLog index 88c22d7..b1cd1f8 100644 --- a/texi/ChangeLog +++ b/texi/ChangeLog @@ -1,3 +1,8 @@ +2002-01-24 Katsumi Yamaoka + + * emacs-mime.texi (Customization): Added documentation for + `mm-inline-text-html-renderer'. + 2002-01-23 Katsumi Yamaoka * gnus.texi (Article Washing): Add URL about w3m. diff --git a/texi/emacs-mime.texi b/texi/emacs-mime.texi index 0c043ba..c6fb02b 100644 --- a/texi/emacs-mime.texi +++ b/texi/emacs-mime.texi @@ -241,7 +241,7 @@ at the beginning of the narrowed buffer. @item mail-header-narrow-to-field @findex mail-header-narrow-to-field Narrow the buffer to the header under point. Understands continuation -headers. +headers. @item mail-header-fold-field @findex mail-header-fold-field @@ -647,7 +647,7 @@ Take a year number and say whether it's a leap year. @item time-to-day-in-year Take a time and return the day number within the year that the time is -in. +in. @end table @@ -1001,9 +1001,19 @@ Prompt for a mailcap method to use to view the part. @table @code +@item mm-inline-text-html-renderer +@findex mm-inline-text-html-render-with-w3 +@findex mm-inline-text-html-render-with-w3m +This function will be used to convert the HTML to the text. There are +two pre-defined functions: @code{mm-inline-text-html-render-with-w3}, +which uses Emacs/w3; and @code{mm-inline-text-html-render-with-w3m}, +which uses emacs-w3m (see @uref{http://emacs-w3m.namazu.org/} for more +information about emacs-w3m). The function will be called with a MIME +handle as the argument. + @item mm-inline-media-tests This is an alist where the key is a @sc{mime} type, the second element -is a function to display the part @dfn{inline} (i.e., inside Emacs), and +is a function to display the part @dfn{inline} (i.e., inside Emacs), and the third element is a form to be @code{eval}ed to say whether the part can be displayed inline. @@ -1023,7 +1033,7 @@ be displayed automatically. @item mm-attachment-override-types Some @sc{mime} agents create parts that have a content-disposition of -@samp{attachment}. This variable allows overriding that disposition and +@samp{attachment}. This variable allows overriding that disposition and displaying the part inline. (Note that the disposition is only overridden if we are able to, and want to, display the part inline.) @@ -1082,7 +1092,7 @@ Here's an example viewer for displaying @code{text/enriched} inline: @end lisp We see that the function takes a @sc{mime} handle as its parameter. It -then goes to a temporary buffer, inserts the text of the part, does some +then goes to a temporary buffer, inserts the text of the part, does some work on the text, stores the result, goes back to the buffer it was called from and inserts the result. @@ -1381,7 +1391,7 @@ given by @code{mail-parse-charset} (a symbol) is used. (Never set this variable directly, though. If you want to change the default charset, please consult the documentation of the package which you use to process @sc{mime} messages. -@xref{Various Message Variables, , Various Message Variables, message, +@xref{Various Message Variables, , Various Message Variables, message, Message Manual}, for example.) If there are only ASCII characters, the @sc{mime} charset US-ASCII is used, of course.