home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / docs / texinfo / texi.6 < prev    next >
Encoding:
GNU Info File  |  1993-09-04  |  48.7 KB  |  1,452 lines

  1. This is Info file texi.info, produced by Makeinfo-1.55 from the input
  2. file texi.tex.
  3.  
  4.    This file documents Texinfo, a documentation system that uses a
  5. single source file to produce both on-line information and a printed
  6. manual.
  7.  
  8.    Copyright (C) 1988, 1990, 1991, 1992, 1993 Free Software Foundation,
  9. Inc.
  10.  
  11.    This is the second edition of the Texinfo documentation,
  12. and is consistent with version 2 of `texinfo.tex'.
  13.  
  14.    Permission is granted to make and distribute verbatim copies of this
  15. manual provided the copyright notice and this permission notice are
  16. preserved on all copies.
  17.  
  18.    Permission is granted to copy and distribute modified versions of
  19. this manual under the conditions for verbatim copying, provided that
  20. the entire resulting derived work is distributed under the terms of a
  21. permission notice identical to this one.
  22.  
  23.    Permission is granted to copy and distribute translations of this
  24. manual into another language, under the above conditions for modified
  25. versions, except that this permission notice may be stated in a
  26. translation approved by the Free Software Foundation.
  27.  
  28. 
  29. File: texi,  Node: Inserting Braces,  Next: Controlling Spacing,  Prev: Inserting An Atsign,  Up: Braces Atsigns Periods
  30.  
  31. Inserting `{' and `}'with @{ and @}
  32. -----------------------------------
  33.  
  34.    `@{' stands for a single `{' in either printed or Info output.
  35.  
  36.    `@}' stands for a single `}' in either printed or Info output.
  37.  
  38.    Do not put braces after either an `@{' or an `@}' command.
  39.  
  40. 
  41. File: texi,  Node: Controlling Spacing,  Prev: Inserting Braces,  Up: Braces Atsigns Periods
  42.  
  43. Spacing After Colons and Periods
  44. --------------------------------
  45.  
  46.    Use the `@:' command after a period, question mark, exclamation
  47. mark, or colon that should not be followed by extra space.  For
  48. example, use `@:' after periods that end abbreviations which are not at
  49. the ends of sentences.  `@:' has no effect on the Info file output.
  50.  
  51.    For example,
  52.  
  53.      The s.o.p.@: has three parts ...
  54.      The s.o.p. has three parts ...
  55.  
  56. produces
  57.  
  58.      The s.o.p. has three parts ...
  59.      The s.o.p. has three parts ...
  60.  
  61. `@:' has no effect on the Info output.  (`s.o.p' is an acronym for
  62. "Standard Operating Procedure".)
  63.  
  64.    Use `@.' instead of a period at the end of a sentence that ends with
  65. a single capital letter.  Otherwise, TeX will think the letter is an
  66. abbreviation and will not insert the correct end-of-sentence spacing.
  67. Here is an example:
  68.  
  69.      Give it to M.I.B. and to M.E.W@.  Also, give it to R.J.C@.
  70.      Give it to M.I.B. and to M.E.W.  Also, give it to R.J.C.
  71.  
  72. produces
  73.  
  74.      Give it to M.I.B. and to M.E.W.  Also, give it to R.J.C.
  75.      Give it to M.I.B. and to M.E.W.  Also, give it to R.J.C.
  76.  
  77.    In the Info file output, `@.' is equivalent to a simple `.'.
  78.  
  79.    The meanings of `@:' and `@.' in Texinfo are designed to work well
  80. with the Emacs sentence motion commands.  This made it necessary for
  81. them to be incompatible with some other formatting systems that use
  82. @-commands.
  83.  
  84.    Do not put braces after either an `@:' or an `@.' command.
  85.  
  86. 
  87. File: texi,  Node: dmn,  Next: Dots Bullets,  Prev: Braces Atsigns Periods,  Up: Insertions
  88.  
  89. `@dmn'{DIMENSION}: Format a Dimension
  90. =====================================
  91.  
  92.    At times, you may want to write `12pt' or `8.5in' with little or no
  93. space between the number and the abbreviation for the dimension.  You
  94. can use the `@dmn' command to do this.  On seeing the command, TeX
  95. inserts just enough space for proper typesetting; the Info formatting
  96. commands insert no space at all, since the Info file does not require
  97. it.
  98.  
  99.    To use the `@dmn' command, write the number and then follow it
  100. immediately, with no intervening space, by `@dmn', and then by the
  101. dimension within braces.
  102.  
  103. For example,
  104.  
  105.      A4 paper is 8.27@dmn{in} wide.
  106.  
  107. produces
  108.  
  109.      A4 paper is 8.27in wide.
  110.  
  111.    Not everyone uses this style.  Instead of writing `8.27@dmn{in}' in
  112. the Texinfo file, you may write `8.27 in.' or `8.27 inches'.  (In these
  113. cases, the formatters may insert a line break between the number and the
  114. dimension.  Also, if you write a period after an abbreviation within a
  115. sentence, you should write `@:' after the period to prevent TeX from
  116. inserting extra whitespace.  *Note Spacing After Colons and Periods:
  117. Controlling Spacing.)
  118.  
  119. 
  120. File: texi,  Node: Dots Bullets,  Next: TeX and copyright,  Prev: dmn,  Up: Insertions
  121.  
  122. Inserting Ellipsis, Dots, and Bullets
  123. =====================================
  124.  
  125.    An "ellipsis" (a line of dots) is not typeset as a string of
  126. periods, so a special command is used for ellipsis in Texinfo.  The
  127. `@bullet' command is special, too.  Each of these commands is followed
  128. by a pair of braces, `{}', without any whitespace between the name of
  129. the command and the braces.  (You need to use braces with these
  130. commands because you can use them next to other text; without the
  131. braces, the formatters would be confused.  *Note @-Command Syntax:
  132. Command Syntax, for further information.)
  133.  
  134. * Menu:
  135.  
  136. * dots::                        How to insert dots ...
  137. * bullet::                      How to insert a bullet.
  138.  
  139. 
  140. File: texi,  Node: dots,  Next: bullet,  Up: Dots Bullets
  141.  
  142. `@dots'{}
  143. ---------
  144.  
  145.    Use the `@dots{}' command to generate an ellipsis, which is three
  146. dots in a row, appropriately spaced, like this: `...'.  Do not simply
  147. write three periods in the input file; that would work for the Info
  148. file output, but would produce the wrong amount of space between the
  149. periods in the printed manual.
  150.  
  151. 
  152. File: texi,  Node: bullet,  Prev: dots,  Up: Dots Bullets
  153.  
  154. `@bullet'{}
  155. -----------
  156.  
  157.    Use the `@bullet{}' command to generate a large round dot, or the
  158. closest possible thing to one.  In Info, an asterisk is used.
  159.  
  160.    Here is a bullet: *
  161.  
  162.    When you use `@bullet' in `@itemize', you do not need to type the
  163. braces, because `@itemize' supplies them.  *Note itemize::.
  164.  
  165. 
  166. File: texi,  Node: TeX and copyright,  Next: minus,  Prev: Dots Bullets,  Up: Insertions
  167.  
  168. Inserting TeX and the Copyright Symbol
  169. ======================================
  170.  
  171.    The logo `TeX' is typeset in a special fashion and it needs an
  172. @-command.  The copyright symbol, `(C)', is also special.  Each of
  173. these commands is followed by a pair of braces, `{}', without any
  174. whitespace between the name of the command and the braces.
  175.  
  176. * Menu:
  177.  
  178. * tex::                         How to insert the TeX logo.
  179. * copyright symbol::            How to use `@copyright'{}.
  180.  
  181. 
  182. File: texi,  Node: tex,  Next: copyright symbol,  Up: TeX and copyright
  183.  
  184. `@TeX'{}
  185. --------
  186.  
  187.    Use the `@TeX{}' command to generate `TeX'.  In a printed manual,
  188. this is a special logo that is different from three ordinary letters.
  189. In Info, it just looks like `TeX'.  The `@TeX{}' command is unique
  190. among Texinfo commands in that the T and the X are in upper case.
  191.  
  192. 
  193. File: texi,  Node: copyright symbol,  Prev: tex,  Up: TeX and copyright
  194.  
  195. `@copyright'{}
  196. --------------
  197.  
  198.    Use the `@copyright{}' command to generate `(C)'.  In a printed
  199. manual, this is a `c' inside a circle, and in Info, this is `(C)'.
  200.  
  201. 
  202. File: texi,  Node: minus,  Prev: TeX and copyright,  Up: Insertions
  203.  
  204. `@minus'{}: Inserting a Minus Sign
  205. ==================================
  206.  
  207.    Use the `@minus{}' command to generate a minus sign.  In a
  208. fixed-width font, this is a single hyphen, but in a proportional font,
  209. the symbol is the customary length for a minus sign--a little longer
  210. than a hyphen.
  211.  
  212.    You can compare the two forms:
  213.  
  214.      `-' is a minus sign generated with `@minus{}',
  215.      
  216.      `-' is a hyphen generated with the character `-'.
  217.  
  218. In the fixed-width font used by Info, `@minus{}' is the same as a
  219. hyphen.
  220.  
  221.    You should not use `@minus{}' inside `@code' or `@example' because
  222. the width distinction is not made in the fixed-width font they use.
  223.  
  224.    When you use `@minus' to specify the mark beginning each entry in an
  225. itemized list, you do not need to type the braces (*note itemize::.).
  226.  
  227. 
  228. File: texi,  Node: Glyphs,  Next: Breaks,  Prev: Insertions,  Up: Top
  229.  
  230. Glyphs for Examples
  231. *******************
  232.  
  233.    In Texinfo, code is often illustrated in examples that are delimited
  234. by `@example' and `@end example', or by `@lisp' and `@end lisp'.  In
  235. such examples, you can indicate the results of evaluation or an
  236. expansion using `=>' or `==>'.  Likewise, there are commands to insert
  237. glyphs to indicate printed output, error messages, equivalence of
  238. expressions, and the location of point.
  239.  
  240.    The glyph-insertion commands do not need to be used within an
  241. example, but most often they are.  Every  glyph-insertion command is
  242. followed by a pair of left- and right-hand braces.
  243.  
  244. * Menu:
  245.  
  246. * Glyphs Summary::
  247. * result::                      How to show the result of expression.
  248. * expansion::                   How to indicate an expansion.
  249. * Print Glyph::                 How to indicate printed output.
  250. * Error Glyph::                 How to indicate an error message.
  251. * Equivalence::                 How to indicate equivalence.
  252. * Point Glyph::                 How to indicate the location of point.
  253.  
  254. 
  255. File: texi,  Node: Glyphs Summary,  Next: result,  Up: Glyphs
  256.  
  257. Glyphs Summary
  258. ==============
  259.  
  260.    Here are the different glyph commands:
  261.  
  262. =>
  263.      `@result{}' points to the result of an expression.
  264.  
  265. ==>
  266.      `@expansion{}' shows the results of a macro expansion.
  267.  
  268. -|
  269.      `@print{}' indicates printed output.
  270.  
  271. error-->
  272.      `@error{}' indicates that the following text is an error message.
  273.  
  274. ==
  275.      `@equiv{}' indicates the exact equivalence of two forms.
  276.  
  277. -!-
  278.      `@point{}' shows the location of point.
  279.  
  280. 
  281. File: texi,  Node: result,  Next: expansion,  Prev: Glyphs Summary,  Up: Glyphs
  282.  
  283. =>: Indicating Evaluation
  284. =========================
  285.  
  286.    Use the `@result{}' command to indicate the result of evaluating an
  287. expression.
  288.  
  289.    The `@result{}' command is displayed as `=>' in Info and as a double
  290. stemmed arrow in the printed output.
  291.  
  292.    Thus, the following,
  293.  
  294.      (cdr '(1 2 3))
  295.           => (2 3)
  296.  
  297. may be read as "`(cdr '(1 2 3))' evaluates to `(2 3)'".
  298.  
  299. 
  300. File: texi,  Node: expansion,  Next: Print Glyph,  Prev: result,  Up: Glyphs
  301.  
  302. ==>: Indicating an Expansion
  303. ============================
  304.  
  305.    When an expression is a macro call, it expands into a new expression.
  306. You can indicate the result of the expansion with the `@expansion{}'
  307. command.
  308.  
  309.    The `@expansion{}' command is displayed as `==>' in Info and as a
  310. long arrow with a flat base in the printed output.
  311.  
  312.    For example, the following
  313.  
  314.      @lisp
  315.      (third '(a b c))
  316.           @expansion{} (car (cdr (cdr '(a b c))))
  317.           @result{} c
  318.      @end lisp
  319.  
  320. produces
  321.  
  322.      (third '(a b c))
  323.           ==> (car (cdr (cdr '(a b c))))
  324.           => c
  325.  
  326. which may be read as:
  327.  
  328.      `(third '(a b c))' expands to `(car (cdr (cdr '(a b c))))'; the
  329.      result of evaluating the expression is `c'.
  330.  
  331. Often, as in this case, an example looks better if the `@expansion{}'
  332. and `@result{}' commands are indented five spaces.
  333.  
  334. 
  335. File: texi,  Node: Print Glyph,  Next: Error Glyph,  Prev: expansion,  Up: Glyphs
  336.  
  337. -|: Indicating Printed Output
  338. =============================
  339.  
  340.    Sometimes an expression will print output during its execution.  You
  341. can indicate the printed output with the `@print{}' command.
  342.  
  343.    The `@print{}' command is displayed as `-|' in Info and similarly,
  344. as a horizontal dash butting against a vertical bar, in the printed
  345. output.
  346.  
  347.    In the following example, the printed text is indicated with `-|',
  348. and the value of the expression follows on the last line.
  349.  
  350.      (progn (print 'foo) (print 'bar))
  351.           -| foo
  352.           -| bar
  353.           => bar
  354.  
  355. In a Texinfo source file, this example is written as follows:
  356.  
  357.      @lisp
  358.      (progn (print 'foo) (print 'bar))
  359.           @print{} foo
  360.           @print{} bar
  361.           @result{} bar
  362.      @end lisp
  363.  
  364. 
  365. File: texi,  Node: Error Glyph,  Next: Equivalence,  Prev: Print Glyph,  Up: Glyphs
  366.  
  367. error-->: Indicating an Error Message
  368. =====================================
  369.  
  370.    A piece of code may cause an error when you evaluate it.  You can
  371. designate the error message with the `@error{}' command.
  372.  
  373.    The `@error{}' command is displayed as `error-->' in Info and as the
  374. word `error' in a box in the printed output.
  375.  
  376.    Thus,
  377.  
  378.      @lisp
  379.      (+ 23 'x)
  380.      @error{} Wrong type argument: integer-or-marker-p, x
  381.      @end lisp
  382.  
  383. produces
  384.  
  385.      (+ 23 'x)
  386.      error--> Wrong type argument: integer-or-marker-p, x
  387.  
  388. This indicates that the following error message is printed when you
  389. evaluate the expression:
  390.  
  391.      Wrong type argument: integer-or-marker-p, x
  392.  
  393.    Note that `error-->' itself is not part of the error message.
  394.  
  395. 
  396. File: texi,  Node: Equivalence,  Next: Point Glyph,  Prev: Error Glyph,  Up: Glyphs
  397.  
  398. ==: Indicating Equivalence
  399. ==========================
  400.  
  401.    Sometimes two expressions produce identical results.  You can
  402. indicate the exact equivalence of two forms with the `@equiv{}' command.
  403.  
  404.    The `@equiv{}' command is displayed as `==' in Info and as a three
  405. parallel horizontal lines in the printed output.
  406.  
  407.    Thus,
  408.  
  409.      @lisp
  410.      (make-sparse-keymap) @equiv{} (list 'keymap)
  411.      @end lisp
  412.  
  413. produces
  414.  
  415.      (make-sparse-keymap) == (list 'keymap)
  416.  
  417. This indicates that evaluating `(make-sparse-keymap)' produces
  418. identical results to evaluating `(list 'keymap)'.
  419.  
  420. 
  421. File: texi,  Node: Point Glyph,  Prev: Equivalence,  Up: Glyphs
  422.  
  423. Indicating Point in a Buffer
  424. ============================
  425.  
  426.    Sometimes you need to show an example of text in an Emacs buffer.  In
  427. such examples, the convention is to include the entire contents of the
  428. buffer in question between two lines of dashes containing the buffer
  429. name.
  430.  
  431.    You can use the `@point{}' command to show the location of point in
  432. the text in the buffer.  (The symbol for point, of course, is not part
  433. of the text in the buffer; it indicates the place *between* two
  434. characters where point is located.)
  435.  
  436.    The `@point{}' command is displayed as `-!-' in Info and as a small
  437. five pointed star in the printed output.
  438.  
  439.    The following example shows the contents of buffer `foo' before and
  440. after evaluating a Lisp command to insert the word `changed'.
  441.  
  442.      ---------- Buffer: foo ----------
  443.      This is the -!-contents of foo.
  444.      ---------- Buffer: foo ----------
  445.  
  446.      (insert "changed ")
  447.           => nil
  448.      ---------- Buffer: foo ----------
  449.      This is the changed -!-contents of foo.
  450.      ---------- Buffer: foo ----------
  451.  
  452.    In a Texinfo source file, the example is written like this:
  453.  
  454.      @example
  455.      ---------- Buffer: foo ----------
  456.      This is the @point{}contents of foo.
  457.      ---------- Buffer: foo ----------
  458.      
  459.      (insert "changed ")
  460.           @result{} nil
  461.      ---------- Buffer: foo ----------
  462.      This is the changed @point{}contents of foo.
  463.      ---------- Buffer: foo ----------
  464.      @end example
  465.  
  466. 
  467. File: texi,  Node: Breaks,  Next: Definition Commands,  Prev: Glyphs,  Up: Top
  468.  
  469. Making and Preventing Breaks
  470. ****************************
  471.  
  472.    Usually, a Texinfo file is processed both by TeX and by one of the
  473. Info formatting commands.  Line, paragraph, or page breaks sometimes
  474. occur in the `wrong' place in one or other form of output.  You must
  475. ensure that text looks right both in the printed manual and in the Info
  476. file.
  477.  
  478.    For example, in a printed manual, page breaks may occur awkwardly in
  479. the middle of an example; to prevent this, you can hold text together
  480. using a grouping command that keeps the text from being split across
  481. two pages.  Conversely, you may want to force a page break where none
  482. would occur normally.  Fortunately, problems like these do not often
  483. arise.  When they do, use the break, break prevention, or pagination
  484. commands.
  485.  
  486. * Menu:
  487.  
  488. * Break Commands::              Cause and prevent splits.
  489. * Line Breaks::                 How to force a single line to use two lines.
  490. * w::                           How to prevent unwanted line breaks.
  491. * sp::                          How to insert blank lines.
  492. * page::                        How to force the start of a new page.
  493. * group::                       How to prevent unwanted page breaks.
  494. * need::                        Another way to prevent unwanted page breaks.
  495.  
  496. 
  497. File: texi,  Node: Break Commands,  Next: Line Breaks,  Up: Breaks
  498.  
  499. The Break Commands
  500. ==================
  501.  
  502.    The break commands create line and paragraph breaks:
  503.  
  504. `@*'
  505.      Force a line break.
  506.  
  507. `@sp N'
  508.      Skip N blank lines.
  509.  
  510.    The line-break-prevention command holds text together all on one
  511. line:
  512.  
  513. `@w{TEXT}'
  514.      Prevent TEXT from being split and hyphenated across two lines.
  515.  
  516.    The pagination commands apply only to printed output, since Info
  517. files do not have pages.
  518.  
  519. `@page'
  520.      Start a new page in the printed manual.
  521.  
  522. `@group'
  523.      Hold text together that must appear on one printed page.
  524.  
  525. `@need MILS'
  526.      Start a new printed page if not enough space on this one.
  527.  
  528. 
  529. File: texi,  Node: Line Breaks,  Next: w,  Prev: Break Commands,  Up: Breaks
  530.  
  531. `@*': Generate Line Breaks
  532. ==========================
  533.  
  534.    The `@*' command forces a line break in both the printed manual and
  535. in Info.
  536.  
  537.    For example,
  538.  
  539.      This line @* is broken @*in two places.
  540.  
  541. produces
  542.  
  543.      This line
  544.       is broken
  545.      in two places.
  546.  
  547. (Note that the space after the first `@*' command is faithfully carried
  548. down to the next line.)
  549.  
  550.    The `@*' command is often used in a file's copyright page:
  551.  
  552.      This is edition 2.0 of the Texinfo documentation,@*
  553.      and is for ...
  554.  
  555. In this case, the `@*' command keeps TeX from stretching the line
  556. across the whole page in an ugly manner.
  557.  
  558.      *Please note:* Do not write braces after an `@*' command; they are
  559.      not needed.
  560.  
  561.      Do not write an `@refill' command at the end of a paragraph
  562.      containing an `@*' command; it will cause the paragraph to be
  563.      refilled after the line break occurs, negating the effect of the
  564.      line break.
  565.  
  566. 
  567. File: texi,  Node: w,  Next: sp,  Prev: Line Breaks,  Up: Breaks
  568.  
  569. `@w'{TEXT}: Prevent Line Breaks
  570. ===============================
  571.  
  572.    `@w{TEXT}' outputs TEXT and prohibits line breaks within TEXT.
  573.  
  574.    You can use the `@w' command to prevent TeX from automatically
  575. hyphenating a long name or phrase that accidentally falls near the end
  576. of a line.
  577.  
  578.      You can copy GNU software from @w{@file{prep.ai.mit.edu}}.
  579.  
  580. produces
  581.  
  582.      You can copy GNU software from `prep.ai.mit.edu'.
  583.  
  584.    In the Texinfo file, you must write the `@w' command and its
  585. argument (all the affected text) all on one line.
  586.  
  587.      *Caution:* Do not write an `@refill' command at the end of a
  588.      paragraph containing an `@w' command; it will cause the paragraph
  589.      to be refilled and may thereby negate the effect of the `@w'
  590.      command.
  591.  
  592. 
  593. File: texi,  Node: sp,  Next: page,  Prev: w,  Up: Breaks
  594.  
  595. `@sp' N: Insert Blank Lines
  596. ===========================
  597.  
  598.    A line beginning with and containing only `@sp N' generates N blank
  599. lines of space in both the printed manual and the Info file.  `@sp'
  600. also forces a paragraph break.  For example,
  601.  
  602.      @sp 2
  603.  
  604. generates two blank lines.
  605.  
  606.    The `@sp' command is most often used in the title page.
  607.  
  608. 
  609. File: texi,  Node: page,  Next: group,  Prev: sp,  Up: Breaks
  610.  
  611. `@page': Start a New Page
  612. =========================
  613.  
  614.    A line containing only `@page' starts a new page in a printed
  615. manual.  The command has no effect on Info files since they are not
  616. paginated.  An `@page' command is often used in the `@titlepage'
  617. section of a Texinfo file to start the copyright page.
  618.  
  619. 
  620. File: texi,  Node: group,  Next: need,  Prev: page,  Up: Breaks
  621.  
  622. `@group': Prevent Page Breaks
  623. =============================
  624.  
  625.    The `@group' command (on a line by itself) is used inside an
  626. `@example' or similar construct to begin an unsplittable vertical
  627. group, which will appear entirely on one page in the printed output.
  628. The group is terminated by a line containing only `@end group'.  These
  629. two lines produce no output of their own, and in the Info file output
  630. they have no effect at all.
  631.  
  632.    Although `@group' would make sense conceptually in a wide variety of
  633. contexts, its current implementation works reliably only within
  634. `@example' and variants, and within `@display', `@format', `@flushleft'
  635. and `@flushright'.  *Note Quotations and Examples::.  (What all these
  636. commands have in common is that each line of input produces a line of
  637. output.)  In other contexts, `@group' can cause anomalous vertical
  638. spacing.
  639.  
  640.    This formatting requirement means that you should write:
  641.  
  642.      @example
  643.      @group
  644.      ...
  645.      @end group
  646.      @end example
  647.  
  648. with the `@group' and `@end group' commands inside the `@example' and
  649. `@end example' commands.
  650.  
  651.    The `@group' command is most often used to hold an example together
  652. on one page.  In this Texinfo manual, more than 100 examples contain
  653. text that is enclosed between `@group' and `@end group'.
  654.  
  655.    If you forget to end a group, you may get strange and unfathomable
  656. error messages when you run TeX.  This is because TeX keeps trying to
  657. put the rest of the Texinfo file onto the one page and does not start
  658. to generate error messages until it has processed considerable text.
  659. It is a good rule of thumb to look for a missing `@end group' if you
  660. get incomprehensible error messages in TeX.
  661.  
  662. 
  663. File: texi,  Node: need,  Prev: group,  Up: Breaks
  664.  
  665. `@need MILS': Prevent Page Breaks
  666. =================================
  667.  
  668.    A line containing only `@need N' starts a new page in a printed
  669. manual if fewer than N mils (thousandths of an inch) remain on the
  670. current page.  Do not use braces around the argument N.  The `@need'
  671. command has no effect on Info files since they are not paginated.
  672.  
  673.    This paragraph is preceded by an `@need' command that tells TeX to
  674. start a new page if fewer than 800 mils (eight-tenths inch) remain on
  675. the page.  It looks like this:
  676.  
  677.      @need 800
  678.      This paragraph is preceded by ...
  679.  
  680.    The `@need' command is useful for preventing orphans (single lines
  681. at the bottoms of printed pages).
  682.  
  683. 
  684. File: texi,  Node: Definition Commands,  Next: Footnotes,  Prev: Breaks,  Up: Top
  685.  
  686. Definition Commands
  687. *******************
  688.  
  689.    The `@deffn' command and the other "definition commands" enable you
  690. to describe functions, variables, macros, commands, user options,
  691. special forms and other such artifacts in a uniform format.
  692.  
  693.    In the Info file, a definition causes the entity
  694. category--`Function', `Variable', or whatever--to appear at the
  695. beginning of the first line of the definition, followed by the entity's
  696. name and arguments.  In the printed manual, the command causes TeX to
  697. print the entity's name and its arguments on the left margin and print
  698. the category next to the right margin.  In both output formats, the
  699. body of the definition is indented.  Also, the name of the entity is
  700. entered into the appropriate index: `@deffn' enters the name into the
  701. index of functions, `@defvr' enters it into the index of variables, and
  702. so on.
  703.  
  704.    A manual need not and should not contain more than one definition for
  705. a given name.  An appendix containing a summary should use `@table'
  706. rather than the definition commands.
  707.  
  708. * Menu:
  709.  
  710. * Def Cmd Template::            How to structure a description using a
  711.                                   definition command.
  712. * Optional Arguments::          How to handle optional and repeated arguments.
  713. * deffnx::                      How to group two or more `first' lines.
  714. * Def Cmds in Detail::          All the definition commands.
  715. * Def Cmd Conventions::         Conventions for writing definitions.
  716. * Sample Function Definition::
  717.  
  718. 
  719. File: texi,  Node: Def Cmd Template,  Next: Optional Arguments,  Up: Definition Commands
  720.  
  721. The Template for a Definition
  722. =============================
  723.  
  724.    The `@deffn' command is used for definitions of entities that
  725. resemble functions.  To write a definition using the `@deffn' command,
  726. write the `@deffn' command at the beginning of a line and follow it on
  727. the same line by the category of the entity, the name of the entity
  728. itself, and its arguments (if any).  Then write the body of the
  729. definition on succeeding lines.  (You may embed examples in the body.)
  730. Finally, end the definition with an `@end deffn' command written on a
  731. line of its own.  (The other definition commands follow the same
  732. format.)
  733.  
  734.    The template for a definition looks like this:
  735.  
  736.      @deffn CATEGORY NAME ARGUMENTS...
  737.      BODY-OF-DEFINITION
  738.      @end deffn
  739.  
  740. For example,
  741.  
  742.      @deffn Command forward-word count
  743.      This command moves point forward @var{count} words
  744.      (or backward if @var{count} is negative). ...
  745.      @end deffn
  746.  
  747. produces
  748.  
  749.       - Command: forward-word COUNT
  750.           This function moves point forward COUNT words (or backward if
  751.           COUNT is negative). ...
  752.  
  753.    Capitalize the category name like a title.  If the name of the
  754. category contains spaces, as in the phrase `Interactive Command', write
  755. braces around it.  For example:
  756.  
  757.      @deffn {Interactive Command} isearch-forward
  758.      ...
  759.      @end deffn
  760.  
  761. Otherwise, the second word will be mistaken for the name of the entity.
  762.  
  763.    Some of the definition commands are more general than others.  The
  764. `@deffn' command, for example, is the general definition command for
  765. functions and the like--for entities that may take arguments.  When you
  766. use this command, you specify the category to which the entity belongs.
  767. The `@deffn' command possesses three predefined, specialized
  768. variations, `@defun', `@defmac', and `@defspec', that specify the
  769. category for you: "Function", "Macro", and "Special Form" respectively.
  770. The `@defvr' command also is accompanied by several predefined,
  771. specialized variations for describing particular kinds of variables.
  772.  
  773.    The template for a specialized definition, such as `@defun', is
  774. similar to the template for a generalized definition, except that you
  775. do not need to specify the category:
  776.  
  777.      @defun NAME ARGUMENTS...
  778.      BODY-OF-DEFINITION
  779.      @end defun
  780.  
  781. Thus,
  782.  
  783.      @defun buffer-end flag
  784.      This function returns @code{(point-min)} if @var{flag}
  785.      is less than 1, @code{(point-max)} otherwise.
  786.      ...
  787.      @end defun
  788.  
  789. produces
  790.  
  791.       - Function: buffer-end FLAG
  792.           This function returns `(point-min)' if FLAG is less than 1,
  793.           `(point-max)' otherwise.  ...
  794.  
  795. *Note Sample Function Definition: Sample Function Definition, for a
  796. more detailed example of a function definition, including the use of
  797. `@example' inside the definition.
  798.  
  799.    The other specialized commands work like `@defun'.
  800.  
  801. 
  802. File: texi,  Node: Optional Arguments,  Next: deffnx,  Prev: Def Cmd Template,  Up: Definition Commands
  803.  
  804. Optional and Repeated Arguments
  805. ===============================
  806.  
  807.    Some entities take optional or repeated arguments, which may be
  808. specified by a distinctive glyph that uses square brackets and
  809. ellipses.  For example, a special form often breaks its argument list
  810. into separate arguments in more complicated ways than a straightforward
  811. function.
  812.  
  813.    An argument enclosed within square brackets is optional.  Thus,
  814. [OPTIONAL-ARG] means that OPTIONAL-ARG is optional.  An argument
  815. followed by an ellipsis is optional and may be repeated more than once.
  816. Thus, REPEATED-ARGS... stands for zero or more arguments.  Parentheses
  817. are used when several arguments are grouped into additional levels of
  818. list structure in Lisp.
  819.  
  820.    Here is the `@defspec' line of an example of an imaginary special
  821. form:
  822.  
  823.       - Special Form: foobar (VAR [FROM TO [INC]]) BODY...
  824.  
  825. In this example, the arguments FROM and TO are optional, but must both
  826. be present or both absent.  If they are present, INC may optionally be
  827. specified as well.  These arguments are grouped with the argument VAR
  828. into a list, to distinguish them from BODY, which includes all
  829. remaining elements of the form.
  830.  
  831.    In a Texinfo source file, this `@defspec' line is written like this
  832. (except it would not be split over two lines, as it is in this example).
  833.  
  834.      @defspec foobar (@var{var} [@var{from} @var{to}
  835.           [@var{inc}]]) @var{body}@dots{}
  836.  
  837. The function is listed in the Command and Variable Index under `foobar'.
  838.  
  839. 
  840. File: texi,  Node: deffnx,  Next: Def Cmds in Detail,  Prev: Optional Arguments,  Up: Definition Commands
  841.  
  842. Two or More `First' Lines
  843. =========================
  844.  
  845.    To create two or more `first' or header lines for a definition,
  846. follow the first `@deffn' line by a line beginning with `@deffnx'.  The
  847. `@deffnx' command works exactly like `@deffn' except that it does not
  848. generate extra vertical white space between it and the preceding line.
  849.  
  850.    For example,
  851.  
  852.      @deffn {Interactive Command} isearch-forward
  853.      @deffnx {Interactive Command} isearch-backward
  854.      These two search commands are similar except ...
  855.      @end deffn
  856.  
  857. produces
  858.  
  859.  - Interactive Command: isearch-forward
  860.  - Interactive Command: isearch-backward
  861.      These two search commands are similar except ...
  862.  
  863.    Each of the other definition commands has an `x' form: `@defunx',
  864. `@defvrx', `@deftypefunx', etc.
  865.  
  866.    The `x' forms work just like `@itemx'; see *Note `@itemx': itemx.
  867.  
  868. 
  869. File: texi,  Node: Def Cmds in Detail,  Next: Def Cmd Conventions,  Prev: deffnx,  Up: Definition Commands
  870.  
  871. The Definition Commands
  872. =======================
  873.  
  874.    Texinfo provides more than a dozen definition commands, all of which
  875. are described in this section.
  876.  
  877.    The definition commands automatically enter the name of the entity in
  878. the appropriate index: for example, `@deffn', `@defun', and `@defmac'
  879. enter function names in the index of functions; `@defvr' and `@defvar'
  880. enter variable names in the index of variables.
  881.  
  882.    Although the examples that follow mostly illustrate Lisp, the
  883. commands can be used for other programming languages.
  884.  
  885. * Menu:
  886.  
  887. * Functions Commands::          Commands for functions and similar entities.
  888. * Variables Commands::          Commands for variables and similar entities.
  889. * Typed Functions::             Commands for functions in typed languages.
  890. * Typed Variables::             Commands for variables in typed languages.
  891. * Abstract Objects::            Commands for object-oriented programming.
  892. * Data Types::                  The definition command for data types.
  893.  
  894. 
  895. File: texi,  Node: Functions Commands,  Next: Variables Commands,  Up: Def Cmds in Detail
  896.  
  897. Functions and Similar Entities
  898. ------------------------------
  899.  
  900.    This section describes the commands for describing functions and
  901. similar entities:
  902.  
  903. `@deffn CATEGORY NAME ARGUMENTS...'
  904.      The `@deffn' command is the general definition command for
  905.      functions, interactive commands, and similar entities that may take
  906.      arguments.  You must choose a term to describe the category of
  907.      entity being defined; for example, "Function" could be used if the
  908.      entity is a function.  The `@deffn' command is written at the
  909.      beginning of a line and is followed on the same line by the
  910.      category of entity being described, the name of this particular
  911.      entity, and its arguments, if any.  Terminate the definition with
  912.      `@end deffn' on a line of its own.
  913.  
  914.      For example, here is a definition:
  915.  
  916.           @deffn Command forward-char nchars
  917.           Move point forward @var{nchars} characters.
  918.           @end deffn
  919.  
  920.      This shows a rather terse definition for a "command" named
  921.      `forward-char' with one argument, NCHARS.
  922.  
  923.      `@deffn' prints argument names such as NCHARS in italics or upper
  924.      case, as if `@var' had been used, because we think of these names
  925.      as metasyntactic variables--they stand for the actual argument
  926.      values.  Within the text of the description, write an argument name
  927.      explicitly with `@var' to refer to the value of the argument.  In
  928.      the example above, we used `@var{nchars}' in this way.
  929.  
  930.      The template for `@deffn' is:
  931.  
  932.           @deffn CATEGORY NAME ARGUMENTS...
  933.           BODY-OF-DEFINITION
  934.           @end deffn
  935.  
  936. `@defun NAME ARGUMENTS...'
  937.      The `@defun' command is the definition command for functions.
  938.      `@defun' is equivalent to `@deffn Function ...'.
  939.  
  940.      For example,
  941.  
  942.           @defun set symbol new-value
  943.           Change the value of the symbol @var{symbol}
  944.           to @var{new-value}.
  945.           @end defun
  946.  
  947.      shows a rather terse definition for a function `set' whose
  948.      arguments are SYMBOL and NEW-VALUE.  The argument names on the
  949.      `@defun' line automatically appear in italics or upper case as if
  950.      they were enclosed in `@var'.  Terminate the definition with `@end
  951.      defun' on a line of its own.
  952.  
  953.      The template is:
  954.  
  955.           @defun FUNCTION-NAME ARGUMENTS...
  956.           BODY-OF-DEFINITION
  957.           @end defun
  958.  
  959.      `@defun' creates an entry in the index of functions.
  960.  
  961. `@defmac NAME ARGUMENTS...'
  962.      The `@defmac' command is the definition command for macros.
  963.      `@defmac' is equivalent to `@deffn Macro ...' and works like
  964.      `@defun'.
  965.  
  966. `@defspec NAME ARGUMENTS...'
  967.      The `@defspec' command is the definition command for special
  968.      forms.  (In Lisp, a special form is an entity much like a
  969.      function.) `@defspec' is equivalent to `@deffn {Special Form} ...'
  970.      and works like `@defun'.
  971.  
  972. 
  973. File: texi,  Node: Variables Commands,  Next: Typed Functions,  Prev: Functions Commands,  Up: Def Cmds in Detail
  974.  
  975. Variables and Similar Entities
  976. ------------------------------
  977.  
  978.    Here are the commands for defining variables and similar entities:
  979.  
  980. `@defvr CATEGORY NAME'
  981.      The `@defvr' command is a general definition command for something
  982.      like a variable--an entity that records a value.  You must choose
  983.      a term to describe the category of entity being defined; for
  984.      example, "Variable" could be used if the entity is a variable.
  985.      Write the `@defvr' command at the beginning of a line and followed
  986.      it on the same line by the category of the entity and the name of
  987.      the entity.
  988.  
  989.      Capitalize the category name like a title.  If the name of the
  990.      category contains spaces, as in the name `User Option', write
  991.      braces around it.  Otherwise, the second word will be mistaken for
  992.      the name of the entity, for example:
  993.  
  994.           @defvr {User Option} fill-column
  995.           This buffer-local variable specifies
  996.           the maximum width of filled lines.
  997.           ...
  998.           @end defvr
  999.  
  1000.      Terminate the definition with `@end defvr' on a line of its own.
  1001.  
  1002.      The template is:
  1003.  
  1004.           @defvr CATEGORY NAME
  1005.           BODY-OF-DEFINITION
  1006.           @end defvr
  1007.  
  1008.      `@defvr' creates an entry in the index of variables for NAME.
  1009.  
  1010. `@defvar NAME'
  1011.      The `@defvar' command is the definition command for variables.
  1012.      `@defvar' is equivalent to `@defvr Variable ...'.
  1013.  
  1014.      For example:
  1015.  
  1016.           @defvar kill-ring
  1017.           ...
  1018.           @end defvar
  1019.  
  1020.      The template is:
  1021.  
  1022.           @defvar NAME
  1023.           BODY-OF-DEFINITION
  1024.           @end defvar
  1025.  
  1026.      `@defvar' creates an entry in the index of variables for NAME.
  1027.  
  1028. `@defopt NAME'
  1029.      The `@defopt' command is the definition command for user options.
  1030.      `@defopt' is equivalent to `@defvr {User Option} ...' and works
  1031.      like `@defvar'.
  1032.  
  1033. 
  1034. File: texi,  Node: Typed Functions,  Next: Typed Variables,  Prev: Variables Commands,  Up: Def Cmds in Detail
  1035.  
  1036. Functions in Typed Languages
  1037. ----------------------------
  1038.  
  1039.    The `@deftypefn' command and its variations are for describing
  1040. functions in C or any other language in which you must declare types of
  1041. variables and functions.
  1042.  
  1043. `@deftypefn CATEGORY DATA-TYPE NAME ARGUMENTS...'
  1044.      The `@deftypefn' command is the general definition command for
  1045.      functions and similar entities that may take arguments and that are
  1046.      typed.  The `@deftypefn' command is written at the beginning of a
  1047.      line and is followed on the same line by the category of entity
  1048.      being described, the type of the returned value, the name of this
  1049.      particular entity, and its arguments, if any.
  1050.  
  1051.      For example,
  1052.  
  1053.           @deftypefn {Library Function} int foobar
  1054.              (int @var{foo}, float @var{bar})
  1055.           ...
  1056.           @end deftypefn
  1057.  
  1058.      (where the text before the "...", shown above as two lines, would
  1059.      actually be a single line in a real Texinfo file) produces the
  1060.      following in Info:
  1061.  
  1062.           -- Library Function: int foobar (int FOO, float BAR)
  1063.           ...
  1064.  
  1065.      This means that `foobar' is a "library function" that returns an
  1066.      `int', and its arguments are FOO (an `int') and BAR (a `float').
  1067.  
  1068.      The argument names that you write in `@deftypefn' are not subject
  1069.      to an implicit `@var'--since the actual names of the arguments in
  1070.      `@deftypefn' are typically scattered among data type names and
  1071.      keywords, Texinfo cannot find them without help.  Instead, you
  1072.      must write `@var' explicitly around the argument names.  In the
  1073.      example above, the argument names are `foo' and `bar'.
  1074.  
  1075.      The template for `@deftypefn' is:
  1076.  
  1077.           @deftypefn CATEGORY DATA-TYPE NAME ARGUMENTS ...
  1078.           BODY-OF-DESCRIPTION
  1079.           @end deftypefn
  1080.  
  1081.      Note that if the CATEGORY or DATA TYPE is more than one word then
  1082.      it must be enclosed in braces to make it a single argument.
  1083.  
  1084.      If you are describing a procedure in a language that has packages,
  1085.      such as Ada, you might consider using `@deftypefn' in a manner
  1086.      somewhat contrary to the convention described in the preceding
  1087.      paragraphs.
  1088.  
  1089.      For example:
  1090.  
  1091.           @deftypefn stacks private push
  1092.                   (@var{s}:in out stack;
  1093.                   @var{n}:in integer)
  1094.           ...
  1095.           @end deftypefn
  1096.  
  1097.      (The `@deftypefn' arguments are shown split into three lines, but
  1098.      would be a single line in a real Texinfo file.)
  1099.  
  1100.      In this instance, the procedure is classified as belonging to the
  1101.      package `stacks' rather than classified as a `procedure' and its
  1102.      data type is described as `private'.  (The name of the procedure
  1103.      is `push', and its arguments are S and N.)
  1104.  
  1105.      `@deftypefn' creates an entry in the index of functions for NAME.
  1106.  
  1107. `@deftypefun DATA-TYPE NAME ARGUMENTS...'
  1108.      The `@deftypefun' command is the specialized definition command
  1109.      for functions in typed languages.  The command is equivalent to
  1110.      `@deftypefn Function ...'.
  1111.  
  1112.      Thus,
  1113.  
  1114.           @deftypefun int foobar (int @var{foo}, float @var{bar})
  1115.           ...
  1116.           @end deftypefun
  1117.  
  1118.      produces the following in Info:
  1119.  
  1120.           -- Function: int foobar (int FOO, float BAR)
  1121.           ...
  1122.  
  1123.      The template is:
  1124.  
  1125.           @deftypefun TYPE NAME ARGUMENTS...
  1126.           BODY-OF-DESCRIPTION
  1127.           @end deftypefun
  1128.  
  1129.      `@deftypefun' creates an entry in the index of functions for NAME.
  1130.  
  1131. 
  1132. File: texi,  Node: Typed Variables,  Next: Abstract Objects,  Prev: Typed Functions,  Up: Def Cmds in Detail
  1133.  
  1134. Variables in Typed Languages
  1135. ----------------------------
  1136.  
  1137.    Variables in typed languages are handled in a manner similar to
  1138. functions in typed languages.  *Note Typed Functions::.  The general
  1139. definition command `@deftypevr' corresponds to `@deftypefn' and the
  1140. specialized definition command `@deftypevar' corresponds to
  1141. `@deftypefun'.
  1142.  
  1143. `@deftypevr CATEGORY DATA-TYPE NAME'
  1144.      The `@deftypevr' command is the general definition command for
  1145.      something like a variable in a typed language--an entity that
  1146.      records a value.  You must choose a term to describe the category
  1147.      of the entity being defined; for example, "Variable" could be used
  1148.      if the entity is a variable.
  1149.  
  1150.      The `@deftypevr' command is written at the beginning of a line and
  1151.      is followed on the same line by the category of the entity being
  1152.      described, the data type, and the name of this particular entity.
  1153.  
  1154.      For example:
  1155.  
  1156.           @deftypevr {Global Flag} int enable
  1157.           ...
  1158.           @end deftypevr
  1159.  
  1160.      produces the following in Info:
  1161.  
  1162.           -- Global Flag: int enable
  1163.           ...
  1164.  
  1165.      The template is:
  1166.  
  1167.           @deftypevr CATEGORY DATA-TYPE NAME
  1168.           BODY-OF-DESCRIPTION
  1169.           @end deftypevr
  1170.  
  1171.      `@deftypevr' creates an entry in the index of variables for NAME.
  1172.  
  1173. `@deftypevar DATA-TYPE NAME'
  1174.      The `@deftypevar' command is the specialized definition command
  1175.      for variables in typed languages.  `@deftypevar' is equivalent to
  1176.      `@deftypevr Variable ...'.
  1177.  
  1178.      For example:
  1179.  
  1180.           @deftypevar int fubar
  1181.           ...
  1182.           @end deftypevar
  1183.  
  1184.      produces the following in Info:
  1185.  
  1186.           -- Variable: int fubar
  1187.           ...
  1188.  
  1189.      The template is:
  1190.  
  1191.           @deftypevar DATA-TYPE NAME
  1192.           BODY-OF-DESCRIPTION
  1193.           @end deftypevar
  1194.  
  1195.      `@deftypevar' creates an entry in the index of variables for NAME.
  1196.  
  1197. 
  1198. File: texi,  Node: Abstract Objects,  Next: Data Types,  Prev: Typed Variables,  Up: Def Cmds in Detail
  1199.  
  1200. Object-Oriented Programming
  1201. ---------------------------
  1202.  
  1203.    Here are the commands for formatting descriptions about abstract
  1204. objects, such as are used in object-oriented programming.  A class is a
  1205. defined type of abstract object.  An instance of a class is a
  1206. particular object that has the type of the class.  An instance variable
  1207. is a variable that belongs to the class but for which each instance has
  1208. its own value.
  1209.  
  1210.    In a definition, if the name of a class is truly a name defined in
  1211. the programming system for a class, then you should write an `@code'
  1212. around it.  Otherwise, it is printed in the usual text font.
  1213.  
  1214. `@defcv CATEGORY CLASS NAME'
  1215.      The `@defcv' command is the general definition command for
  1216.      variables associated with classes in object-oriented programming.
  1217.      The `@defcv' command is followed by three arguments: the category
  1218.      of thing being defined, the class to which it belongs, and its
  1219.      name.  Thus,
  1220.  
  1221.           @defcv {Class Option} Window border-pattern
  1222.           ...
  1223.           @end defcv
  1224.  
  1225.      illustrates how you would write the first line of a definition of
  1226.      the `border-pattern' class option of the class `Window'.
  1227.  
  1228.      The template is
  1229.  
  1230.           @defcv CATEGORY CLASS NAME
  1231.           ...
  1232.           @end defcv
  1233.  
  1234.      `@defcv' creates an entry in the index of variables.
  1235.  
  1236. `@defivar CLASS NAME'
  1237.      The `@defivar' command is the definition command for instance
  1238.      variables in object-oriented programming.  `@defivar' is
  1239.      equivalent to `@defcv {Instance Variable} ...'
  1240.  
  1241.      The template is:
  1242.  
  1243.           @defivar CLASS INSTANCE-VARIABLE-NAME
  1244.           BODY-OF-DEFINITION
  1245.           @end defivar
  1246.  
  1247.      `@defivar' creates an entry in the index of variables.
  1248.  
  1249. `@defop CATEGORY CLASS NAME ARGUMENTS...'
  1250.      The `@defop' command is the general definition command for
  1251.      entities that may resemble methods in object-oriented programming.
  1252.      These entities take arguments, as functions do, but are associated
  1253.      with particular classes of objects.
  1254.  
  1255.      For example, some systems have constructs called "wrappers" that
  1256.      are associated with classes as methods are, but that act more like
  1257.      macros than like functions.  You could use `@defop Wrapper' to
  1258.      describe one of these.
  1259.  
  1260.      Sometimes it is useful to distinguish methods and "operations".
  1261.      You can think of an operation as the specification for a method.
  1262.      Thus, a window system might specify that all window classes have a
  1263.      method named `expose'; we would say that this window system
  1264.      defines an `expose' operation on windows in general.  Typically,
  1265.      the operation has a name and also specifies the pattern of
  1266.      arguments; all methods that implement the operation must accept
  1267.      the same arguments, since applications that use the operation do
  1268.      so without knowing which method will implement it.
  1269.  
  1270.      Often it makes more sense to document operations than methods.  For
  1271.      example, window application developers need to know about the
  1272.      `expose' operation, but need not be concerned with whether a given
  1273.      class of windows has its own method to implement this operation.
  1274.      To describe this operation, you would write:
  1275.  
  1276.           @defop Operation windows expose
  1277.  
  1278.      The `@defop' command is written at the beginning of a line and is
  1279.      followed on the same line by the overall name of the category of
  1280.      operation, the name of the class of the operation, the name of the
  1281.      operation, and its arguments, if any.
  1282.  
  1283.      The template is:
  1284.  
  1285.           @defop CATEGORY CLASS NAME ARGUMENTS...
  1286.           BODY-OF-DEFINITION
  1287.           @end defop
  1288.  
  1289.      `@defop' creates an entry, such as ``expose' on `windows'', in the
  1290.      index of functions.
  1291.  
  1292. `@defmethod CLASS NAME ARGUMENTS...'
  1293.      The `@defmethod' command is the definition command for methods in
  1294.      object-oriented programming.  A method is a kind of function that
  1295.      implements an operation for a particular class of objects and its
  1296.      subclasses.  In the Lisp Machine, methods actually were functions,
  1297.      but they were usually defined with `defmethod'.
  1298.  
  1299.      `@defmethod' is equivalent to `@defop Method ...'.  The command is
  1300.      written at the beginning of a line and is followed by the name of
  1301.      the class of the method, the name of the method, and its
  1302.      arguments, if any.
  1303.  
  1304.      For example,
  1305.  
  1306.           @defmethod `bar-class' bar-method argument
  1307.           ...
  1308.           @end defmethod
  1309.  
  1310.      illustrates the definition for a method called `bar-method' of the
  1311.      class `bar-class'.  The method takes an argument.
  1312.  
  1313.      The template is:
  1314.  
  1315.           @defmethod CLASS METHOD-NAME ARGUMENTS...
  1316.           BODY-OF-DEFINITION
  1317.           @end defmethod
  1318.  
  1319.      `@defmethod' creates an entry in the index of functions, such as
  1320.      ``bar-method' on `bar-class''.
  1321.  
  1322. 
  1323. File: texi,  Node: Data Types,  Prev: Abstract Objects,  Up: Def Cmds in Detail
  1324.  
  1325. Data Types
  1326. ----------
  1327.  
  1328.    Here is the command for data types:
  1329.  
  1330. `@deftp CATEGORY NAME ATTRIBUTES...'
  1331.      The `@deftp' command is the generic definition command for data
  1332.      types.  The command is written at the beginning of a line and is
  1333.      followed on the same line by the category, by the name of the type
  1334.      (which is a word like `int' or `float'), and then by names of
  1335.      attributes of objects of that type.  Thus, you could use this
  1336.      command for describing `int' or `float', in which case you could
  1337.      use `data type' as the category.  (A data type is a category of
  1338.      certain objects for purposes of deciding which operations can be
  1339.      performed on them.)
  1340.  
  1341.      In Lisp, for example,  "pair" names a particular data type, and an
  1342.      object of that type has two slots called the CAR and the CDR.
  1343.      Here is how you would write the first line of a definition of
  1344.      `pair'.
  1345.  
  1346.           @deftp {Data type} pair car cdr
  1347.           ...
  1348.           @end deftp
  1349.  
  1350.      The template is:
  1351.  
  1352.           @deftp CATEGORY NAME-OF-TYPE ATTRIBUTES...
  1353.           BODY-OF-DEFINITION
  1354.           @end deftp
  1355.  
  1356.      `@deftp' creates an entry in the index of data types.
  1357.  
  1358. 
  1359. File: texi,  Node: Def Cmd Conventions,  Next: Sample Function Definition,  Prev: Def Cmds in Detail,  Up: Definition Commands
  1360.  
  1361. Conventions for Writing Definitions
  1362. ===================================
  1363.  
  1364.    When you write a definition using `@deffn', `@defun', or one of the
  1365. other definition commands, please take care to use arguments that
  1366. indicate the meaning, as with the COUNT argument to the `forward-word'
  1367. function.  Also, if the name of an argument contains the name of a
  1368. type, such as INTEGER, take care that the argument actually is of that
  1369. type.
  1370.  
  1371. 
  1372. File: texi,  Node: Sample Function Definition,  Prev: Def Cmd Conventions,  Up: Definition Commands
  1373.  
  1374. A Sample Function Definition
  1375. ============================
  1376.  
  1377.    A function definition uses the `@defun' and `@end defun' commands.
  1378. The name of the function follows immediately after the `@defun' command
  1379. and it is followed, on the same line, by the parameter list.
  1380.  
  1381.    Here is a definition from `The GNU Emacs Lisp Reference Manual'.
  1382. (*Note Calling Functions: (elisp)Calling Functions.)
  1383.  
  1384.       - Function: apply FUNCTION &rest ARGUMENTS
  1385.           `apply' calls FUNCTION with ARGUMENTS, just like `funcall'
  1386.           but with one difference: the last of ARGUMENTS is a list of
  1387.           arguments to give to FUNCTION, rather than a single argument.
  1388.           We also say that this list is "appended" to the other
  1389.           arguments.
  1390.  
  1391.           `apply' returns the result of calling FUNCTION.  As with
  1392.           `funcall', FUNCTION must either be a Lisp function or a
  1393.           primitive function; special forms and macros do not make
  1394.           sense in `apply'.
  1395.  
  1396.                (setq f 'list)
  1397.                     => list
  1398.                (apply f 'x 'y 'z)
  1399.                error--> Wrong type argument: listp, z
  1400.                (apply '+ 1 2 '(3 4))
  1401.                     => 10
  1402.                (apply '+ '(1 2 3 4))
  1403.                     => 10
  1404.                
  1405.                (apply 'append '((a b c) nil (x y z) nil))
  1406.                     => (a b c x y z)
  1407.  
  1408.           An interesting example of using `apply' is found in the
  1409.           description of `mapcar'.
  1410.  
  1411.    In the Texinfo source file, this example looks like this:
  1412.  
  1413.      @defun apply function &rest arguments
  1414.      
  1415.      @code{apply} calls @var{function} with
  1416.      @var{arguments}, just like @code{funcall} but with one
  1417.      difference: the last of @var{arguments} is a list of
  1418.      arguments to give to @var{function}, rather than a single
  1419.      argument.  We also say that this list is @dfn{appended}
  1420.      to the other arguments.
  1421.      
  1422.      @code{apply} returns the result of calling
  1423.      @var{function}.  As with @code{funcall},
  1424.      @var{function} must either be a Lisp function or a
  1425.      primitive function; special forms and macros do not make
  1426.      sense in @code{apply}.
  1427.      
  1428.      @example
  1429.      (setq f 'list)
  1430.           @result{} list
  1431.      (apply f 'x 'y 'z)
  1432.      @error{} Wrong type argument: listp, z
  1433.      (apply '+ 1 2 '(3 4))
  1434.           @result{} 10
  1435.      (apply '+ '(1 2 3 4))
  1436.           @result{} 10
  1437.      
  1438.      (apply 'append '((a b c) nil (x y z) nil))
  1439.           @result{} (a b c x y z)
  1440.      @end example
  1441.      
  1442.      An interesting example of using @code{apply} is found
  1443.      in the description of @code{mapcar}.@refill
  1444.      @end defun
  1445.  
  1446. In this manual, this function is listed in the Command and Variable
  1447. Index under `apply'.
  1448.  
  1449.    Ordinary variables and user options are described using a format like
  1450. that for functions except that variables do not take arguments.
  1451.  
  1452.