tm 6.70
[elisp/tm.git] / doc / tm-view_en.texi
1 \input texinfo.tex
2 @c{-*-tm manual-*-}
3 @setfilename tm-view_en.info
4 @settitle{tm-view manual}
5
6 @titlepage
7 @title tm-view Manual (English Version)
8 @author by MORIOKA Tomohiko
9 @code{$Id: tm-view_en.texi,v 3.0 1995/08/01 18:49:44 morioka Exp $}
10 @end titlepage
11
12
13 @node Top, Mechanism, (dir), (dir)
14 @comment  node-name,  next,  previous,  up
15 @chapter{tm-view}
16 @cindex{tm-view}
17
18 The tm-view is a general MIME viewer running on GNU Emacs.
19
20 tm-view provides the major-mode called @code{mime/viewer-mode} to read
21 MIME message for MUA. MUA implementer can use it to add MIME function.
22
23
24
25 @menu
26 * Mechanism::      Mechanism of mime/viewer-mode.
27 * How to run::     How to run mime/viewer-mode.
28 * How to use::     Commands of mime/viewer-mode.
29 * Preview Buffer:: Screen design of preview buffer.
30 * Decoding::       Mechanism of decoding operations for contents.
31
32 Preview buffer
33 * Preview Buffer:: Screen design of preview buffer.
34 * content-subject::
35 * content-header::
36 * content-body::
37 * content-separator::
38
39 Decoding
40 * Decoding:: Mechanism of decoding operations for contents.
41 * decoding-condition:: Setting of content decoding condition.
42 * Format of method value:: Format of method value part.
43 * Example of decoding-condition:: Examples of decoding-condition.
44
45 Indexes
46 * Concept Index::
47 * Command Index::
48 * Variable Index::
49 @end menu
50
51
52 @node Mechanism, How to run, Top, Top
53 @comment  node-name,  next,  previous,  up
54 @chapter{Mechanism}
55 @cindex{Mechanism}
56
57 tm-view managements two buffers, one is for raw message called
58 @strong{article buffer}, another one is to preview for user called
59 @strong{preview buffer}.
60
61 When called @code{mime/viewer-mode}, tm-view analyzes article buffer,
62 and sets its result to the variable @code{mime::article/content-info}.
63
64 After that, tm-view create a preview buffer corresponded to the
65 article buffer. As this time, tm-view modifies header and body of each
66 contents of the message. It is done by definition for Content-Types.
67
68 On the preview buffer created by tm-view, user can manipulate a
69 message to decode, such as run external vewer, extract files, or
70 print.
71
72 Notice: In this document, I call @strong{content-type} as
73 content-type/subtype of Content-Type field.
74
75
76 @node How to run, How to use, Mechanism, Top
77 @comment  node-name,  next,  previous,  up
78 @chapter{How to run mime/viewer-mode}
79 @cindex{How to run mime/viewer-mode}
80
81 @deffn{Command} mime/viewer-mode &optional mother ctl encoding
82
83 Parse current-buffer as a MIME message, and create preview buffer to
84 display to user, then enter @code{mime/viewer-mode}.
85
86 @var{mother} is used to specify original article buffer. It may be
87 useful when an article buffer is assembled from message/partial.
88
89 @var{ctl} is used to specify Content-Type field information. Its
90 format is output format of @code{mime/Content-Type}. When @var{ctl} is 
91 specified, tm-view uses it instead of Content-Type field of the
92 article buffer.
93
94 @var{encoding} is used to specify field-body of
95 Content-Transfer-Encoding field. When is is specified, tm-view uses it
96 instead of Content-Type field of the article buffer.
97 @end deffn
98
99
100 @node How to use, Preview Buffer, How to run, Top
101 @comment  node-name,  next,  previous,  up
102 @chapter{Commands of mime/viewer-mode}
103 @cindex{Commands of mime/viewer-mode}
104
105 @code{mime/viewer-mode} has following functions:
106
107 @table @kbd 
108 @item u
109         goes to the upper content (returns to the Summary mode if the
110         cursor is sitting on the top content (*1))
111 @item p
112         goes to the previous content
113 @item n
114         goes to the next content
115 @item @key{SPC}
116         scrolls up
117 @item @key{M-SPC}
118         scrolls down
119 @item @key{DEL}
120         scrolls down
121 @item @key{RET}
122         goes to the next line
123 @item @key{M-RET}
124         goes to the previous line
125 @item v
126         playbacks a content            (*2)
127 @item e
128         extracts a file from a content (*2)
129 @item C-c C-p
130         prints a content               (*2)
131 @end table
132
133 @b{[Notice]}
134 @enumerate
135 @item
136 Not return to the Summary mode unless tm-view has been setup using
137 tm-mh-e, tm-gnus, tm-rmail etc.
138
139 @item
140 Actual playback/extract/print will be performed by a method.
141 @end enumerate
142
143
144 @node Preview Buffer, content-subject, how-to-use, Top
145 @comment  node-name,  next,  previous,  up
146 @chapter{Screen design of preview buffer}
147 @cindex{Screen design of preview buffer}
148
149 In preview buffer, following are displayed for each content:
150
151 @example
152         [content-subject]
153         (content-header)
154         
155         (content-body)
156         (content-separator)
157 @end example
158
159 You can change design or stop to display if you specify for each
160 content-types.
161
162 Example:
163
164 @example
165 From: MORIOKA Tomohiko <morioka@@jaist.ac.jp>
166 Newsgroups: zxr.comp.emacs.tm-english
167 Subject: tm6.63.tar.gz
168 Date: Mon, 26 Jun 1995 17:39:50 JST
169 Organization: Chamonix, JAIST, Tatsunokuchi, Ishikawa, Japan
170 Reply-To: tm-eng@@chamonix.jaist.ac.jp
171 To: tm-eng@@chamonix.jaist.ac.jp
172 In-Reply-To: Your message of "Sun, 25 Jun 1995 23:20:49 MST"
173 X-Mua: mh-e 4.1 + tm 6.63 / Mule 2.2 (WAKAMURASAKI) PL02
174 X-Mime-Composer: mime.el + tiny-mime 5.12
175 X-Ml-Count: 32
176
177 [1  (text/plain)]
178   I put tm6.63.tar.gz in ftp.jaist.ac.jp.
179
180   In this version, tm-view uses new MIME encoding/decoding engine
181 ``mel (MIME encoding library''. This library has internal/external
182 encoding/decoding engine. If data is smaller than a limit, tm-view
183 uses internal decoder, otherwise external decoder.
184
185 [2 tm6.63.tar.gz ([anon-ftp] ftp.jaist.ac.jp:/pub/GNU/elisp/mime/alpha)]
186
187 [3  (text/plain)]
188 ----
189 MORIOKA, Tomohiko <morioka@@jaist.ac.jp>
190 @end example
191
192
193 @menu
194 * content-subject::
195 * content-header::
196 * content-body::
197 * content-separator::
198 @end menu
199
200
201 @node content-subject, content-header, Preview Buffer, Preview Buffer
202 @comment  node-name,  next,  previous,  up
203 @section{content-subject}
204 @cindex{content-subject}
205
206 content-subject is a part to display abstract for the content. It is
207 placed in top of content.
208
209 In default, it is displayed following design:
210
211 @example
212         [1.3 test (text/plain)]
213 @end example
214
215 First number field represents position of a content in the message. It
216 is called `content-number'. It can be considered as the chapter number
217 in the message.
218
219 Second string part represents title. It is created by following:
220
221 @itemize
222 @item name paramater or x-name parameter in Content-Type field
223 @item Content-Description field or Subject field
224 @item filename of uuencode
225 @end itemize
226
227 If they are not exists, space is displayed.
228
229 Third parenthesis part represents content-type/subtype of the
230 content. If it is non-MIME part, @code{nil} is displayed.
231
232 Content-subject is used like icon when content-header and content-body
233 are hidden. For example,
234
235 @example
236         [2  (image/gif)]
237 @end example
238
239 if you press `v' key, GIF image is displayed.
240
241
242 @defvr{Variable} mime-viewer/content-subject-omitting-Content-Type-list
243
244 List of content-type. If content-type of a content is a member of this 
245 list, its content-subject is not displayed.
246
247 This variable is referenced by function
248 @code{mime-viewer/default-content-subject-function}.
249 @end defvr
250
251
252 @deffn{Function} mime-viewer/default-content-subject-function cnum cinfo ctype params subj
253
254 Default value of the variable
255 @code{mime-viewer/content-subject-function}.
256 It refers variable
257 @code{mime-viewer/content-subject-omitting-Content-Type-list}.
258 @end deffn
259
260
261 @defvar mime-viewer/content-subject-function cnum cinfo ctype params subj
262
263 Variable to specify content-subject display function. Default value is
264 the function @code{mime-viewer/default-content-subject-function}.
265 @end defvar
266
267
268 @node content-header, content-body, content-subject, Preview Buffer
269 @comment  node-name,  next,  previous,  up
270 @section{content-header}
271 @cindex{content-header}
272
273 A content header shows the header portion of a content in the preview
274 buffer.
275
276 When the function @code{mime-viewer/header-visible-p} returns @code{t}
277 for content-number of a content, content-header is displayed. This
278 judge function returns @code{t} when a content is root or content-type
279 of its parent is a member of the variable
280 @code{mime-viewer/childrens-header-showing-Content-Type-list}.
281
282 If you want to change this condition, please redefine it.
283
284 When content-header is displayed, content-header are formated by
285 content-header-filter. Content-header-filter is searched from variable 
286 @code{mime-viewer/content-header-filter-alist}. Its key is major-mode
287 of the article buffer. If not found, function
288 @code{mime-viewer/default-content-header-filter} is called.
289
290
291 @defvar mime-viewer/childrens-header-showing-Content-Type-list
292
293 List of content-type. If content-type of parent of a content is a
294 member of this variable, its content-header is displayed.
295 Default value is "message/rfc822".
296
297 This variable is referred by the function
298 @code{mime-viewer/header-visible-p}.
299 @end defvar
300
301
302 @deffn{Function} mime-viewer/header-visible-p cnum cinfo &optional ctype
303
304 Returns @code{t} if a content is displayed.
305
306 @var{cnum} is content-number. @var{cinfo} is content-info. If you know 
307 content-type, you can specify by @var{ctype}.
308 @end deffn
309
310
311 @defvar mime-viewer/content-header-filter-alist
312
313 Association-list whose key is major-mode of a article buffer, value is
314 content-header-filter.
315 @end defvar
316
317
318 @deffn{Function} mime-viewer/default-content-header-filter
319
320 It is called when content-header-filter is not found in variable
321 @code{mime-viewer/content-header-filter-alist}.
322 @end deffn
323
324
325 @node content-body, content-separator, content-header, Preview Buffer
326 @comment  node-name,  next,  previous,  up
327 @section{content-body}
328 @cindex{content-body}
329
330 Content-body represents content of the message. tm-view does not
331 display raw content body. For example, if a content has binary, it is
332 hidden. If a content has richtext, it is formated. Namely content body
333 is hidden or formated.
334
335 Function @code{mime-viewer/body-visible-p} is a judge function whether
336 content-body of a content is displayed. If it returns @code{nil},
337 content-body is hidden. In default, it returns non-@code{nil} when
338 content-type of a content is a member of variable
339 @code{mime-viewer/default-showing-Content-Type-list}.
340
341 When content-body of a content is displayed, content-body is formated
342 by content-filter. Content-filter is searched from variable
343 @code{mime-viewer/content-filter-alist}. At this time, major-mode of
344 the article buffer is used as the key.
345
346 If it is not found, function @code{mime-viewer/default-content-filter}
347 is called.
348
349
350 @defvar mime-viewer/default-showing-Content-Type-list
351
352 List of content-type. If content-type of a content is a member of this 
353 variable, its body is displayed.
354 @end defvar
355
356
357 @deffn{Function} mime-viewer/body-visible-p cnum cinfo &optional ctype
358
359 Return non-@code{nil}, if content-type of a content is displayed.
360 @var{cnum} is content-number of a content. @var{cinfo} is content-info
361 of the message. If you know content-type of a content, you can specify
362 it as argument @var{ctype}.
363 @end deffn
364
365
366 @defvar mime-viewer/content-filter-alist
367
368 Association-list whose key is major-mode of a article buffer, value is
369 content-filter.
370 @end defvar
371
372
373 @deffn{Function} mime-viewer/default-content-filter cnum cinfo ctype params subj
374
375 It is called when content-body of a content should be displayed and
376 content-filter is not found in
377 @code{mime-viewer/content-filter-alist}.
378
379 In default, it does nothing.
380 @end deffn
381
382
383 @node content-separator, Decoding, content-body, Preview Buffer
384 @comment  node-name,  next,  previous,  up
385 @section{content-separator}
386 @cindex{content-separator}
387
388 Content-separator is displayed to represent boundary of contents.
389
390 Content-separator is displayed by function
391 @code{mime-viewer/default-content-separator}. In default, it displays
392 line-break when content-header and content-body are not displayed.
393
394 If you want to change this condition, please redefine this function.
395
396
397 @deffn{Function} mime-viewer/default-content-separator cnum cinfo ctype params subj
398
399 Display content-separator. @var{cnum} is content-number of a
400 content. @var{cinfo} is content-info of the message. @var{ctype} is
401 content-type of a content. @var{params} is Content-Type field
402 parameters of a content. @var{subj} is subject.
403
404 In default, it displays line-break when content-header and
405 content-body are not displayed.
406 @end deffn
407
408
409 @node Decoding, decoding-condition, Preview Buffer, Top
410 @comment  node-name,  next,  previous,  up
411 @chapter{Decoding}
412 @cindex{Decoding}
413
414 In @code{mime/viewer-mode}, you can do play (@key{v}), extract
415 (@key{e}), or print (@key{C-c C-p}) for each content. These operations
416 are called ``decoding operation(s) (for a content)''. And kind of
417 decoding operations are called @strong{decoding-mode}.
418
419 When decoding operation is driven, tm-view calls a procedure matched
420 for the condition, such as content-type. This procedure is called
421 @strong{method}.
422
423 There are two kinds of method. One is Emacs Lisp function, called
424 @strong{internal method}. Another one is external program, called
425 @strong{external method}.
426
427 Internal method operates in Emacs, so it can do carefully.
428
429 External method is called as asynchronous process, so Emacs does not
430 wait while method is running. So it is good for big data, such as
431 audio, image or video.
432
433 @menu
434 * decoding-condition:: Setting of content decoding condition.
435 * Format of method value:: Format of method value part.
436 * Example of decoding-condition:: Examples of decoding-condition.
437 @end menu
438
439
440 @node decoding-condition, Format of method value, Decoding, Decoding
441 @comment  node-name,  next,  previous,  up
442 @section{Setting of content decoding condition}
443 @cindex{Setting of content decoding condition}
444
445 When decoding operation is driven, tm-view calls a method matched for
446 the condition searched from the variable
447 @code{mime/content-decoding-condition}.
448
449 Variable @code{mime/content-decoding-condition} is defined as a list
450 with the following syntax:
451
452 @lisp
453         (condition1 condition2 ...)
454 @end lisp
455
456 Each condition are association-list with the following syntax:
457
458 @lisp
459         ((field-type_1 . value_1)
460          (field-type_2 . value_2)
461          ...)
462 @end lisp
463
464 For example, if you want to call the external method named tm-plain to
465 decode every text/plain type content, you can define the condition
466 like
467
468 @lisp
469         ((type . "text/plain")
470          (method "tm-plain" nil 'file 'type 'encoding 'mode 'name))
471 @end lisp
472
473 As you notice, now you can define the arguments to pass to a external
474 method.  Refer to \ref{sec:method-arguments} section for more
475 explanation.
476
477 This condition definition will match all contents whose types are
478 text/plain. Here is an another example:
479
480 @lisp
481         ((type . "text/plain")
482          (method "tm-plain" nil 'file 'type 'encoding 'mode 'name)
483          (mode . "play"))
484 @end lisp
485
486 This will match the content whose type is text/plain and the mode is
487 play.
488
489 @lisp
490         ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file)
491          (mode . "play"))
492 @end lisp
493
494 This will match all contents which have a mode of play.
495
496 The conditions defined in a mime/content-decoding-condition variable
497 are examined from top to bottom.  The first matching condition becomes
498 valid and the method specified in that condition definition will be
499 executed.
500
501
502 @node Format of method value, Example of decoding-condition, decoding-condition, Decoding
503 @comment  node-name,  next,  previous,  up
504 @section{Format of method value part}
505 @cindex{Format of method value part}
506
507 You can specify the method field of the decoding-condition definition
508 in two different ways,
509
510 @lisp
511         (method . SYMBOL)
512 @end lisp
513
514 or
515
516 @lisp
517         (method  STRING  FLAG  ARGUMENT1  ARGUMENT2  ...)
518 @end lisp
519
520 can be accepted.
521
522 When a symbol is specified in the method field, a function whose name
523 is SYMBOL will be called as an internal method.
524
525 When a list is specified in the method field, it will be called as an
526 external method.
527
528 The list below shows the meaning of the parameters when the external
529 method is specified in the method field.
530
531 @table @samp
532 @item STRING
533         name of an external method
534 @item FLAG
535         If @code{t}, both the content header and the content body are
536         passed to an external method. if nil, only the content body is
537         passed to an external method.
538 @item ARGUMENTs
539         list of arguments passed to an external method
540 @end table
541
542 An argument passed to an external method can be in one of the
543 following formats:
544
545 @table @samp
546 @item STRING
547         string itself
548 @item 'SYMBOL
549         value gotten using SYMBOL as a key (see below)
550 @item 'STRING
551         value gotten using STRING as a key (see below)
552 @end table
553
554 'SYMBOL can be one of the following:
555
556 @table @samp
557 @item 'file
558         name of a file holding the original content
559 @item 'type
560         content-type/sub-type of Content-Type field
561 @item 'encoding
562         field body of Content-Transfer-Encoding field
563 @item 'mode
564         decoding-mode
565 @item 'name
566         name of a file created by decode operation
567 @end table
568
569 'STRING is used to search a parameter of the Content-Type field whose
570 name matches with it, and pass the value of that parameter to the
571 external method.
572
573
574 @node Example of decoding-condition, Concept Index, Format of method value, Decoding
575 @comment  node-name,  next,  previous,  up
576 @section{Examples of decoding-condition}
577 @cindex{Examples of decoding-condition}
578
579 The default definition of a mime/content-decoding-condition variable
580 is shown below.
581
582 @lisp
583 (defvar mime/content-decoding-condition
584   '(((type . "text/plain")
585      (method "tm-plain" nil 'file 'type 'encoding 'mode 'name))
586     ((type . "text/x-latex")
587      (method "tm-latex" nil 'file 'type 'encoding 'mode 'name))
588     ((type . "audio/basic")
589      (method "tm-au"    nil 'file 'type 'encoding 'mode 'name))
590     ((type . "image/gif")
591      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
592     ((type . "image/jpeg")
593      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
594     ((type . "image/tiff")
595      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
596     ((type . "image/x-tiff")
597      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
598     ((type . "image/x-xbm")
599      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
600     ((type . "image/x-pic")
601      (method "tm-image" nil 'file 'type 'encoding 'mode 'name))
602     ((type . "video/mpeg")`
603      (method "tm-mpeg"  nil 'file 'type 'encoding 'mode 'name))
604     ((type . "application/octet-stream")
605      (method "tm-file"  nil 'file 'type 'encoding 'mode 'name))
606     ((type . "message/partial")
607      (method . mime/decode-message/partial-region))
608     ((method "metamail" t
609              "-m" "tm" "-x" "-d" "-z" "-e" 'file)(mode . "play"))
610     ))
611 @end lisp
612
613 For example, if you want to use metamail to decode any contents,
614
615 @lisp
616 (setq mime/content-decoding-condition
617       '(
618         ((method "metamail" t "-m" "tm" "-x" "-d" "-z" "-e" 'file))
619        ))
620 @end lisp
621
622 will work.
623
624 A mime/content-decoding-condition variable provides you of very flexible
625 way to define the conditions of decoding.  It can be simple if you only
626 need the a few decoding methods, while it can be very complicated if you
627 want to use the separate decoding method for each type/mode combination.
628
629
630 Following function may be useful to set decoding-condition. It is a
631 function of tl-atype.el.
632
633
634 @deffn{Function} set-atype symbol alist
635
636 Add condition @var{alist} to symbol @var{symbol}.
637
638 Example:
639
640 @lisp
641 (set-atype 'mime/content-decoding-condition
642            '((type . "message/external-body")
643              ("access-type" . "anon-ftp")
644              (method . mime/decode-message/external-ftp)
645              ))
646 @end lisp
647 @end deffn
648
649
650 @node Concept Index, Command Index, Decoding, Top
651 @unnumbered Concept Index
652
653 @printindex cp
654
655
656 @node Command Index, Variable Index, Concept Index, Top
657 @unnumbered Command and Function Index
658
659 @printindex fn
660
661
662 @node Variable Index,  , Command Index, Top
663 @unnumbered Variable Index
664
665 @printindex vr
666
667 @bye