X-Git-Url: http://git.chise.org/gitweb/?p=elisp%2Fgnus.git-;a=blobdiff_plain;f=texi%2Femacs-mime.texi;h=08cd7fae15a51834eb6b9418af9b50f3f9c96442;hp=93e1d6ed42d0d245d5d9ef834263a30620a213c2;hb=c8b25eebe2bfccd8b707d8c9e8ffa0d88d4a20af;hpb=625b891fc07e1e5fc5f2658176b6c0e3cb244ee0 diff --git a/texi/emacs-mime.texi b/texi/emacs-mime.texi index 93e1d6e..08cd7fa 100644 --- a/texi/emacs-mime.texi +++ b/texi/emacs-mime.texi @@ -746,6 +746,7 @@ returned as a result of this analysis. * Handles:: Handle manipulations. * Display:: Displaying handles. * Customization:: Variables that affect display. +* New Viewers:: How to write your own viewers. @end menu @@ -902,6 +903,34 @@ their size. @end table +@node New Viewers +@section New Viewers + +Here's an example viewer for displaying @code{text/enriched} inline: + +@lisp +(defun mm-display-enriched-inline (handle) + (let (text) + (with-temp-buffer + (mm-insert-part handle) + (save-window-excursion + (enriched-decode (point-min) (point-max)) + (setq text (buffer-string)))) + (mm-insert-inline handle text))) +@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 +work on the text, stores the result, goes back to the buffer it was +called from and inserts the result. + +The two important helper functions here are @code{mm-insert-part} and +@code{mm-insert-inline}. The first function inserts the text of the +handle in the current buffer. It handles charset and/or content +transfer decoding. The second function just inserts whatever text you +tell it to insert, but it also sets things up so that the text can be +``undisplayed' in a convenient manner. + @node Composing @chapter Composing