texinfo-2.15/0000755000175000017500000000000013751600005010350 5ustar ggtexinfo-2.15/ChangeLog0000644000175000017500000003745612415566425012156 0ustar ggWed Jun 10 15:26:18 1992 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-append-refill): Refill properly when lines begin with within-paragraph @-commands. Tue Jun 9 12:28:11 1992 Robert J. Chassell (bob at grackle) * texinfmt.el: Add `texinfo-deffn-formatting-property' and `texinfo-defun-indexing-property' to @deffn commands. Mon Jun 8 11:52:01 1992 Robert J. Chassell (bob at grackle) * texnfo-upd.el: Replace `(mark-whole-buffer)' with `(push-mark (point-max) t) (goto-char (point-min))' to avoid `Mark set' messages. Fri Jun 5 15:15:16 1992 Robert J. Chassell (bob@kropotkin.gnu.ai.mit.edu) * texnfo-upd.el (texinfo-check-for-node-name): Offer section title as prompt. (texinfo-copy-next-section-title): Copy title correctly. Thu May 28 20:34:17 1992 Robert J. Chassell (bob@hill.gnu.ai.mit.edu) * texinfmt.el: @vtable defined, parallel to @ftable, for variables. (texinfo-append-refill): set case-fold-search nil so @TeX is not confused with @tex. Thu May 14 21:14:25 1992 Noah Friedman (friedman@nutrimat.gnu.ai.mit.edu) * fixfonts: Enclosed most variable references with "" to prevent potential globbing and other weirdness. Eliminated uses of ${var-value}, which unfortunately isn't portable. * texi2dvi: rewritten from scratch. Sat Apr 18 23:46:25 1992 Charles Hannum (mycroft@hal.gnu.ai.mit.edu) * fixfonts: Re-evaluate prefix and libdir if inherited (to resolve variable references from make). (texlibdir): Don't add '/tex', since it's already there. Fri Apr 10 14:51:23 1992 Noah Friedman (friedman@hill.gnu.ai.mit.edu) * fixfonts: set prefix and libdir only if they are not already defined (i.e. not inherited from the environment). Changed default path for libdir to be consistent with Makefile. Thu Mar 26 21:36:41 1992 Robert J. Chassell (bob@kropotkin.gnu.ai.mit.edu) * makeinfo.el: Rename temp buffer from *Makeinfo* back to *compilation* so `next-error' works; unfortunately, *compilation* is written into the code as the name `next-error' needs. Rename `makeinfo-recenter-makeinfo-buffer' back to `makeinfo-recenter-makeinfo-buffer' Tue Mar 3 13:17:42 1992 Robert J. Chassell (bob at grackle) * texnfo-upd.el (texinfo-insert-master-menu-list): Insert a master menu only after `Top' node and before next node. (texinfo-copy-menu): Error message if menu empty. Mon Feb 24 15:47:49 1992 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-format-region): Make sure region ends in a newline. (texinfo-itemize-item): Recognize all non-whitespace on same line as @item command. Wed Feb 12 10:50:51 1992 Robert J. Chassell (bob at grackle) * texinfo2.texi: Rewrite @enumerate section to explain new features, rewrite miscellaneous paragraphs for clarity. * makeinfo.el: Rename temp buffer as *Makeinfo*. Rename `makeinfo-recenter-compilation-buffer'. (makeinfo-buffer): Offer to save buffer if it is modified. (makeinfo-compile): Do not offer to save other buffers. (makeinfo-compilation-sentinel): Switch to Info file. Tue Feb 4 13:07:39 1992 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-print-index): Format so that node names in the index are lined up. Mon Feb 3 09:08:14 1992 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-itemize-item): Format entry when text is on the same line as @item command. Also, handle @-commands. (texinfo-format-region, texinfo-format-buffer-1): Set fill column to local value of Texinfo buffer. * texnfo-upd.el (texinfo-pointer-name): Find only those section commands that are accompanied by `@node' lines. Fri Jan 17 00:05:17 1992 Robert J. Chassell (bob at kropotki) * texinfo2.texi: Updated TeX ordering information. Tue Jan 14 16:10:16 1992 Robert J. Chassell (bob at grackle) * texnfo-upd.el: Ensure that no commands depend on the value of case-fold-search. Fri Jan 10 15:13:55 1992 Robert J. Chassell (bob at kropotkin) * texinfmt.el (texinfo-append-refill): Replace use of unsupported function `looking-at-backward' with `re-search-backward'. Mon Dec 16 15:01:36 1991 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-append-refill): New function appends @refill to all appropriate paragraphs so you no longer need to append @refill command yourself. (texinfo-format-region, texinfo-format-buffer-1, texinfo-format-include): Call `texinfo-append-refill'. Mon Dec 2 10:26:57 1991 Robert J. Chassell (bob at grackle) * texinfo2.texi: Replace `+' long-option introductory char with `--'. Tue Nov 26 10:21:04 1991 Robert J. Chassell (bob at grackle) * texnfo-upd.el (texinfo-section-types-regexp): `@subtitle' no longer treated as subsection. Sat Nov 16 08:27:42 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) * fixfonts: New file, from Karl Berry. * Makefile (install): Run fixfonts to fix lcircle10. Thu Nov 14 22:32:02 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) * Makefile: Change $(make), which is nowhere defined, to $(MAKE), which most makes predefine. Thu Nov 14 22:11:25 1991 Richard Stallman (rms at mole.gnu.ai.mit.edu) * Makefile (install): New target. Installs lcircle10.tfm. (all, info, makeinfo, texindex, TAGS, *clean): New trivial targets. Tue Nov 12 16:13:24 1991 Robert J. Chassell (bob at grackle) * texinfmt.el: Create @end smalllisp. Mon Nov 11 16:50:13 1991 Robert J. Chassell (bob at grackle) * texinfo.el (texinfo-environment-regexp): Add all other block enclosing Texinfo commands. Sun Nov 10 12:00:06 1991 Karl Berry (karl at hayley) * texinfo.tex (\doprintindex): only \read if the file existed; \closein the test stream in all cases. (\initial, \entry): do not \outer, so that \read does not get an error if the index exists. Thu Nov 7 10:23:51 1991 Robert J. Chassell (bob at grackle) * texinfo.el (texinfo-insert-@end): Attempt to insert correct end command statement, eg, @end table. Fails with nested lists. (texinfo-insert-*): Accept prefix arg to surround following N words with braces for command. Tue Nov 5 08:29:13 1991 Robert J. Chassell (bob at grackle) * texinfo.tex (@thischaptername): Provide default value for when @chapter not defined. Sat Nov 2 17:59:02 1991 Karl Berry (karl at hayley) * texinfo.tex (\itemizezzz): do \begingroup here, since \itemizey can't any longer. Fri Nov 1 16:10:59 1991 Robert J. Chassell (bob at kropotki) * texinfo2.texi: Document @set, @ifset, @clear, @ifclear. Fri Nov 1 01:12:42 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) * Move texindex to C subdirectory. * Makefile: Include COPYING and ChangeLog files in distribution. Thu Oct 31 21:31:41 1991 Robert J. Chassell (bob at kropotki) * texinfmt.el (texinfo-clear): Clear flag even if flag not previously set. Tue Oct 29 12:17:41 1991 Robert J. Chassell (bob at grackle) * texinfo.tex: @paragraphindent defined as a no op. Fri Oct 25 15:19:47 1991 Karl Berry (karl at hayley) * texinfo.tex (\enumerate): allow any lowercase letter, uppercase letter, or number as argument; initialize \itemno and begin the environment's group here. (\itemizey): don't initialize \itemno here. (\numericenumerate, \startenumeration): new macro. Wed Oct 23 11:15:58 1991 Robert J. Chassell (bob at grackle) * texinfo.el (texinfo-mode): page-delimiter now finds top node as well as chapters. Tue Oct 22 11:46:12 1991 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-do-flushright): Test whether a line is too long for the flush right command (line length must be less than the value of fill column). * texnfo-tex.el (texinfo-tex-buffer): Prompt for original file even if point moved to *texinfo-tex-shell*. texinfo-tex-original-file: variable to hold file name. Wed Oct 16 08:32:05 1991 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-format-center): Expand string before centering so @-commands not included. Thu Oct 10 22:01:47 1991 Robert J. Chassell (bob at kropotki) * texnfo-tex.el (texinfo-show-tex-print-queue): Do not kill a running process; do start a process none exists. Thu Sep 26 21:58:47 1991 Robert J. Chassell (bob at kropotki) * texinfo2.texi: Suggest writing version and edition numbers in title page and Top node summary. * texi2dvi: Misc. bugs fixed. * texinfo.el: Remove extraneous references to TeX. Thu Sep 19 20:45:29 1991 Robert J. Chassell (bob at kropotki) * texinfmt.el: add @cartouche as a noop (makes box with rounded corners in TeX) * texinfo2.texi: add @cartouche doc Tue Sep 10 20:44:57 1991 Robert J. Chassell (bob at grackle) * texnfo-upd.el (texinfo-make-one-menu): Copy node-name correctly for message. Thu Aug 29 17:54:07 1991 Robert J. Chassell (bob at kropotki) * texnfo-tex.el (texinfo-quit-tex-job): Do not set mark. * Makefile, Makefile-for-dist, README: Revise to include configure file for makeinfo and info. Wed Aug 21 10:36:21 1991 Robert J. Chassell (bob at grackle) * texnfo-upd.el: (texinfo-copy-menu-title): Copy title as it should rather than node line. Wed Aug 7 11:16:52 1991 Robert J. Chassell (bob at grackle) * texinfo2.texi: Minor textual corrections; update new features. Mon Aug 5 15:27:12 1991 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-format-convert): Changed regexp that looks for three hyphens in a row to find those between word constituent characters, as now, for Oxford Univ. style dashes and also between spaces, for Cambridge Univ. Press style dashes. * texnfo-tex.el (texinfo-tex-start-shell): Runs "/bin/sh" so `explicit-shell-file-name' is not set globally. * texnfo-upd.el: Rewrite messages. (texinfo-find-higher-level-node): Stop search at limit. (texinfo-copy-menu-title): Rewrite to handle outer include files. (texinfo-multi-file-update): Update all nodes properly; rewrite doc string and interactive. Sat Aug 3 10:46:13 1991 Robert J. Chassell (bob at grackle) * texnfo-upd.el (texinfo-all-menus-update): Fixed typo that caused the function to create a master menu when it shouldn't. * texinfo.el (texinfo-mode): Make `indent-tabs-mode' a local variable and set to nil to prevent TABs troubles with TeX. Wed Jul 31 11:07:08 1991 Robert J. Chassell (bob at grackle) * texnfo-tex.el (texinfo-quit-tex-job): New function: quit currently running TeX job, by sending an `x' to it. (texinfo-tex-shell-sentinel): New function to restart texinfo-tex-shell after it is killed. (texinfo-kill-tex-job): Rewrite to use kill-process rather than quit-process; uses `texinfo-tex-shell-sentinel' to restart texinfo-tex-shell after it is killed. (texinfo-tex-region, texinfo-tex-buffer): Replace texinfo-kill-tex-job with quit-process. * texinfo.el (texinfo-define-common-keys): Add keybinding for texinfo-quit-tex-job * texinfo2.texi: Describe texinfo-quit-tex-job; add new index entries. Thu Jul 18 11:01:51 1991 Robert J. Chassell (bob at grackle) * texinfmt.el (texinfo-enumerate, texinfo-enumerate-item, texinfo-itemize, texinfo-table, texinfo-ftable): Revised @enumerate, @itemize, @table, and @ftable to take an optional argument. @enumerate may take a number or lower or uppercase letter and start marking list with that number or letter. If no arg provided, @enumerate behaves as before, starting list with 1. If no arg provided, @itemize inserts @bullet, @table uses @asis, @ftable uses @code. Wed Jul 10 15:15:03 1991 Robert J. Chassell (bob at grackle) * texinfmt.el: New commands @set, @clear, @ifset...@end ifset, and @ifclear...@end ifclear. Definition functions rewritten to make them easier to maintain. Wed Jul 3 19:37:04 1991 Robert J. Chassell (bob at kropotki) * texinfmt.el (texinfo-format-deftypefn-index): Remove reference to data-type to make consistent with texinfo.tex and makeinfo. texinfo.el: Fix page-delimiter and texinfo-chapter-level-regexp variables. Thu Jun 27 18:35:36 1991 Robert J. Chassell (bob at nutrimat) * texinfmt.el: Add @dmn as `texinfo-format-noop'. texinfo2.texi: Document @dmn. texinfmt.el (texinfo{,-end}-{eleterate,ecapitate} renamed {alphaenumerate, capsenumerate}. Fri Jun 14 12:46:32 1991 Robert J. Chassell (bob at churchy.gnu.ai.mit.edu) * texinfmt.el (texinfo-format-defun-1): @defivar prints name correctly. Fri Jun 7 17:21:38 1991 Roland McGrath (roland@geech.gnu.ai.mit.edu) * texinfmt.el (texinfo{,-end}-{eleterate,ecapitate}, texinfo-{eleterate,ecapitate}-item): New fns for @eleterate and @ecapitate constructs. Thu Jun 6 21:38:33 1991 Robert J. Chassell (bob at churchy.gnu.ai.mit.edu) * texinfo2.texi: Add index entries; fix typo; document use of page commands to move by chapter, etc. * texinfo.el (texinfo-mode): Set page delimiter to 'texinfo-chapter-level-regexp' so that page commands work by chapter or equivalent. * texinfmt.el (texinfo-format-defun-1): @defop prints name correctly. (batch-texinfo-format): replace unsupported 'buffer-disable-undo' with 'buffer-flush-undo' Thu May 30 17:59:07 1991 Robert J. Chassell (bob at kropotki) * texinfo2.texi: Fix two typos. Fri Apr 5 15:17:17 1991 Robert J. Chassell (bob at wookumz.gnu.ai.mit.edu) * makeinfo.el (makeinfo-compilation-sentinel): Check for existance of makeinfo-temp-file to avoid harmless error message. texinfo2.texi: Minor typos fixed. Thu Mar 28 19:13:24 1991 Robert J. Chassell (bob at pogo.gnu.ai.mit.edu) * texi2dvi: Revised. texinfo2.texi: Minor typos fixed. Makefile, Makefile-for-texinfo2: include texindex.c. Thu Mar 21 19:19:49 1991 Robert J. Chassell (bob at wookumz.gnu.ai.mit.edu) * Makefile: copy 18.57 version of info.el and informat.el, which work on version 18 machines. Mon Mar 11 12:35:51 1991 Robert J. Chassell (bob at grackle) * texinfmt.el: (@footnotestyle): New command to set footnotestyle. (@paragraphindent): New command to set indentation. (texinfo-format-refill): Add indentation feature so as to indent paragraph or leave indentation asis before refilling according to value set by @paragraphindent command. (texinfo-format-region): Insert header, if any, into Info buffer. (texinfo-format-separate-node, texinfo-format-end-node): Run texinfo-format-scan on footnote text only once. (texinfo-format-scan): Shorten `---' to `--'. * texinfo.el: Define key for `texinfo-master-menu'; define start and end of header expressions. * texnfo-upd.el (texinfo-all-menus-update): Update pre-existing master menu, if there is one. * texnfo-tex.el: Move definitions for start and end of header to texinfo.el, Local Variables: left-margin: 8 End: texinfo-2.15/COPYING0000644000175000017500000004307612415566420011425 0ustar gg GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. texinfo-2.15/New-features0000644000175000017500000002176412415566443012667 0ustar ggTexinfo 2 ********* The second edition of the Texinfo manual is now released in a package with the second version of the various Texinfo support files, including `texinfo.el', `texnfo-upd.el', and `makeinfo.c'. The new manual is considerably larger than the previous one. The Texinfo 2 package is temporary; after a period of testing, the new documentation and software will be merged into the Emacs distribution. Here is a brief description of the new Texinfo mode commands and the newly described @-commands: New Texinfo Mode Commands ========================= Texinfo mode provides commands and features especially designed for working with Texinfo files. More than 20 new commands have been added, including commands for automatically creating and updating nodes and menus, a tedious task when done by hand. The keybindings are intended to be somewhat mnemonic. Update everything ----------------- The `texinfo-master-menu' command is the primary command: C-c C-u m Create or update a master menu. With an argument, first create or update all nodes and regular menus. Update Pointers --------------- Create or update `Next', `Previous', and `Up' node pointers. C-c C-u C-n Update a node. C-c C-u C-e Update every node in the buffer. Update Menus ------------ Create or update menus. C-c C-u C-m Make or update a menu. C-c C-u C-a Make or update all the menus in a buffer; with an argument, first update all the nodes. Format for Info --------------- Provide keybindings both for the Info formatting commands that are written in Emacs Lisp and for `makeinfo' which is written in C. Use the Emacs lisp `texinfo-format...' commands: C-c C-e C-r Format the region. C-c C-e C-b Format the buffer. Use `makeinfo': C-c C-m C-r Format the region. C-c C-m C-b Format the buffer. C-c C-m C-l Recenter the `makeinfo' output buffer. C-c C-m C-k Kill the `makeinfo' formatting job. Typeset and Print ----------------- Typeset and print Texinfo documents from within Emacs. C-c C-t C-r Run TeX on the region. C-c C-t C-b Run TeX on the buffer. C-c C-t C-i Run `texindex'. C-c C-t C-p Print the DVI file. C-c C-t C-q Show the print queue. C-c C-t C-d Delete a job from the print queue. C-c C-t C-k Kill the current TeX formatting job. C-c C-t C-x Quit a currently stopped TeX formatting job. C-c C-t C-l Recenter the output buffer. Other Updating Commands ----------------------- The `other updating commands' do not have standard keybindings because they are less frequently used. M-x texinfo-insert-node-lines Insert missing node lines using section titles as node names. M-x texinfo-multiple-files-update Update a multi-file document. M-x texinfo-indent-menu-description Indent descriptions in menus. M-x texinfo-sequential-update-node Insert node pointers in strict sequence. Newly Described Texinfo @-Commands ================================== The second edition of the Texinfo manual describes more than 50 commands that were not described in the first edition. A third or so of these commands existed in Texinfo but were not documented in the manual; the others are new. Here is a listing, with brief descriptions of them: Commands for creating your own index and for merging two indices: `@defindex INDEX-NAME' Define a new index and its indexing command. Print entries in a roman font. Also, the `@defcodeindex' command, which prints entries in an `@code' font. `@synindex FROM-INDEX INTO-INDEX' Merge the index named in the first argument into the index named in the second argument. Sets FROM-INDEX in the same (roman) font as INTO-INDEX. Also, the `@syncodeindex' command, which prints the entries from the first index in `@code' font. Many commands to help you describe functions, variables, macros, commands, user options, special forms and other such artifacts in a uniform format. `@deffn CATEGORY NAME ARGUMENTS...' Format a description for functions, interactive commands, and similar entities that may take arguments. Takes as arguments the category of entity being described, the name of this particular entity, and its arguments, if any. `@defvr, @defop, ...' 15 other related commands. Special symbols to indicate the results of evaluation or an expansion, printed output, an error message, equivalence of expressions, and the location of point. `@equiv{}' Indicate the exact equivalence of two forms; special glyph: `=='. `@error{}' Indicate that the following text is an error message: `error-->'. `@expansion{}' Indicate the result of a macro expansion; special glyph: `==>'. `@point{}' Indicate the position of point; special glyph: `-!-'. `@print{}' Indicate printed output; special glyph: `-|'. `@result{}' Indicate the result of an expression; special glyph: `=>'. Commands to customize headings: `@headings ON-OFF-SINGLE-DOUBLE' Turn headings on or off, or specify single-sided or double-sided headings for printing. `@evenfooting [LEFT] @| [CENTER] @| [RIGHT]' Specify footings for even-numbered (left-hand) pages. Not relevant to Info. `@evenheading, @everyheading, @oddheading, ...' Five other related commands. `@thischapter' In a heading or footing, stands for the number and name of the current chapter, in the format `Chapter 1: First Chapter'. `@thischaptername, @thisfile, @thistitle, @thispage' Related commands. Commands for formatting text: `@cartouche' Draw rounded box surrounding text (not in Info). `@enumerate OPTIONAL-ARG' Enumerate a list with letters or numbers. `@exdent LINE-OF-TEXT' Remove any indentation a line might have. `@flushleft' Left justify every line but leave the right end ragged. Leave font as is. `@flushright' Right justify every line but leave the left end ragged. Leave font as is. `@format' Like `@example' or `@display', but do not narrow the margins or select the fixed-width font. `@ftable FORMATTING-COMMAND' `@vtable FORMATTING-COMMAND' Begin a two-column table, using `@item' for each entry. `@ftable' automatically enters each of the items in the first column into the index of functions and `@vtable' enters them into the index of variables. The commands are the same as `@table', except for indexing. `@lisp' Indent text, do not fill, select fixed-width font. `@smallexample' Indent text, do not fill, select fixed-width font. In `@smallbook' format, print text in a smaller font than with the `@example' environment. Also, the `@smalllisp' command. Commands for formatting if a flag is set or cleared: `@set FLAG' Set FLAG, causing the Texinfo formatting commands to format text between subsequent pairs of `@ifset FLAG' and `@end ifset' commands. `@ifset FLAG ... @end ifset' If FLAG is set, the Texinfo formatting commands format text between `@ifset FLAG' and the following `@end ifset' command. `@clear FLAG' Unset FLAG, preventing the Texinfo formatting commands from formatting text between subsequent pairs of `@ifset FLAG' and `@end ifset' commands. `@ifclear FLAG ... @end ifclear' If FLAG is unset, the Texinfo formatting commands format text between `@ifclear FLAG' and the following `@end ifclear' command. Produce unnumbered headings that do not appear in a table of contents: `@heading TITLE' Print an unnumbered section-like heading in the text, but not in the table of contents of a printed manual. `@chapheading, @majorheading' `@subheading, @subsubheading' Related commands. Font commands: `@r{TEXT}' Print TEXT in roman font. No effect in Info. `@sc{TEXT}' Set TEXT in the printed output in THE SMALL CAPS FONT and set text in the Info file in uppercase letters. Miscellaneous: `@author AUTHOR' Typeset author's name flushleft and underline it. `@finalout' Prevent TeX from printing large black warning rectangles beside over-wide lines. `@footnotestyle STYLE' Specify footnote style, end or separate. `@dmn{DIMENSION}' Format a dimension. `@minus{}' Generate a minus sign. `@paragraphindent INDENT' Specify paragraph indentation, asis or a number. `@ref{NODE-NAME, [ENTRY], [TOPIC], [INFO-FILE], [MANUAL]}' Make a reference. In the printed manual, the reference does not start with a `See'. `@title TITLE' Alternative format for a title page. In the printed manual, set a title flush to the left-hand side of the page in a larger than normal font and underline it with a black rule. Also, `@subtitle' command. `@subtitle SUBTITLE' Subtitle in the alternative title page format. `@today{}' Insert the current date. texinfo-2.15/fixfonts0000644000175000017500000000447112415566464012161 0ustar gg#!/bin/sh # Make links named `lcircle10' for all TFM and GF/PK files, if no # lcircle10's already exist. # Don't override definition of prefix and/or libdir if they are # already defined in the environment. if [ ! "${prefix}" ]; then prefix=/usr/local else # prefix may contain references to other variables, thanks to make. eval prefix="${prefix}" fi if [ ! "${libdir}" ]; then libdir="${prefix}/lib/tex" else # libdir may contain references to other variables, thanks to make. eval libdir="${libdir}" fi texlibdir="${libdir}" texfontdir="${texlibdir}/fonts" # Directories for the different font formats, in case they're not all # stored in one place. textfmdir="${texfontdir}" texpkdir="${texfontdir}" texgfdir="${texfontdir}" if [ ! "${TMPDIR}" ]; then TMPDIR="/tmp" fi tempfile="${TMPDIR}/circ$$" tempfile2="${TMPDIR}/circ2$$" # Find all the fonts with names that include `circle'. cd "${texfontdir}" find . -name '*circle*' -print > "${tempfile}" # If they have lcircle10.tfm, assume everything is there, and quit. if grep -s lcircle10.tfm "${tempfile}" then echo "Found lcircle10.tfm." rm -f "${tempfile}" exit 0 fi # No TFM file for lcircle. Make a link to circle10.tfm if it exists, # and then make a link to the bitmap files. if grep circle10.tfm "${tempfile}" > "${tempfile2}" then # We found circle10.tfm. Continue below. true else # No circle10.tfm. Give up. echo "I can't find any circle fonts in ${texfontdir}." echo "If it isn't installed somewhere else, you need" echo "to get the Metafont sources from somewhere, e.g.," echo "labrea.stanford.edu:pub/tex/latex/circle10.mf," echo "and run Metafont on them." rm -f ${tempfile} exit 1 fi # We have circle10.tfm. (If we have it more than once, take the first # one.) Make the link. ln `head -1 "${tempfile2}"` "${textfmdir}/lcircle10.tfm" echo "Linked to `head -1 ${tempfile2}`." # Now make a link for the PK files, if any. grep 'circle10.*pk' "${tempfile}" > "${tempfile2}" cd "${texpkdir}" for f in `cat ${tempfile2}` do ln "$f" `dirname "$f"`/l`basename "$f"` echo "Linked to $f." done # And finally for the GF files. grep 'circle10.*gf' "${tempfile}" > "${tempfile2}" cd "${texgfdir}" for f in `cat "${tempfile2}"` do ln "$f" `dirname "$f"`/l`basename "$f"` echo "Linked to $f." done rm -f "${tempfile}" "${tempfile2}" # eof texinfo-2.15/C/0000755000175000017500000000000013751600005010532 5ustar ggtexinfo-2.15/C/getopt1.c0000644000175000017500000000673212415566127012305 0ustar gg/* Getopt for GNU. Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifdef LIBC /* For when compiled as part of the GNU C library. */ #include #endif #include "getopt.h" #ifndef __STDC__ #define const #endif #if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) || defined (LIBC) #include #else /* STDC_HEADERS or __GNU_LIBRARY__ */ char *getenv (); #endif /* STDC_HEADERS or __GNU_LIBRARY__ */ #if !defined (NULL) #define NULL 0 #endif int getopt_long (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 0); } /* Like getopt_long, but '-' as well as '--' can indicate a long option. If an option that starts with '-' (not '--') doesn't match a long option, but does match a short option, it is parsed as a short option instead. */ int getopt_long_only (argc, argv, options, long_options, opt_index) int argc; char *const *argv; const char *options; const struct option *long_options; int *opt_index; { return _getopt_internal (argc, argv, options, long_options, opt_index, 1); } #ifdef TEST #include int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; int option_index = 0; static struct option long_options[] = { {"add", 1, 0, 0}, {"append", 0, 0, 0}, {"delete", 1, 0, 0}, {"verbose", 0, 0, 0}, {"create", 0, 0, 0}, {"file", 1, 0, 0}, {0, 0, 0, 0} }; c = getopt_long (argc, argv, "abc:d:0123456789", long_options, &option_index); if (c == EOF) break; switch (c) { case 0: printf ("option %s", long_options[option_index].name); if (optarg) printf (" with arg %s", optarg); printf ("\n"); break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case 'd': printf ("option d with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ texinfo-2.15/C/Makefile.in0000644000175000017500000000643312415566071012617 0ustar gg# Makefile for the info sources... -*- text -*- # Copyright (C) 1990, 1991 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. SHELL = /bin/sh #### Start of system configuration section. #### srcdir = @srcdir@ VPATH = @srcdir@ CC = @CC@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ # Things you might add to DEFS: # -DSTDC_HEADERS If you have ANSI C headers and libraries. # -DHAVE_UNISTD_H If you have unistd.h. # -DUSG If you have System V/ANSI C string and # memory functions and headers. # -DUSGr3 If you need to include sys/stream.h and sys/ptem.h # to get the screen size from the kernel. DEFS = @DEFS@ CFLAGS = -g LDFLAGS = -g LIBS = @LIBS@ # Colon-separated list of directories in which to look for info files. DEFAULT_INFOPATH = .:$(infodir):/usr/gnu/info:/usr/local/emacs/info:/usr/local/lib/emacs/info # Command used to print out a text file. The filename follows this command. INFO_PRINT_COMMAND = lpr prefix = /usr/local exec_prefix = $(prefix) # Where installed binaries go. bindir = $(exec_prefix)/bin # Where info files go. infodir = $(prefix)/info # Where manual pages go, and their extension (not including `.'). mandir = $(prefix)/man/man1 manext = 1 #### End of system configuration section. #### PATHSPEC = -DDEFAULT_INFOPATH='"$(DEFAULT_INFOPATH)"' PRINTSPEC = -DINFO_PRINT_COMMAND='"$(INFO_PRINT_COMMAND)"' INFO_FLAGS = $(PATHSPEC) $(PRINTSPEC) SOURCES = info.c makeinfo.c texindex.c getopt.c getopt1.c OBJECTS = info.o makeinfo.o texindex.o getopt.o getopt1.o HEADERS = getopt.h SUPPORT = Makefile.in configure THINGS_TO_TAR = $(SOURCES) $(HEADERS) $(SUPPORT) PROGS = info makeinfo texindex all: $(PROGS) .c.o: $(CC) -c $(CFLAGS) $(CPPFLAGS) $(DEFS) $< info: info.o getopt.o getopt1.o $(CC) $(LDFLAGS) -o $@ info.o getopt.o getopt1.o -ltermcap $(LIBS) info.o: info.c $(CC) -c $(CFLAGS) $(INFO_FLAGS) $info.c< makeinfo: makeinfo.o getopt.o getopt1.o $(CC) $(LDFLAGS) -o $@ makeinfo.o getopt.o getopt1.o $(LIBS) makeinfo.o: makeinfo.c $(CC) -c $(CFLAGS) $(MAKEINFO_FLAGS) $makeinfo.c< texindex: texindex.o getopt.o getopt1.o $(CC) $(LDFLAGS) -o $@ texindex.o getopt.o getopt1.o $(LIBS) info.o makeinfo.o texindex.o getopt1.o: getopt.h install: all for f in $(PROGS); do $(INSTALL_PROGRAM) $$f $(bindir)/$$f; done TAGS: $(SOURCES) etags $(SOURCES) clean: rm -f $(PROGS) $(OBJECTS) mostlyclean: clean distclean: clean rm -f Makefile config.status realclean: distclean rm -f TAGS dist: $(THINGS_TO_TAR) rm -rf info-dist mkdir info-dist (cd info-dist; for i in $(THINGS_TO_TAR); do ln -s ../$$i .; done) tar chzf info.tar.Z info-dist rm -rf info-dist # Prevent GNU make v3 from overflowing arg limit on SysV. .NOEXPORT: texinfo-2.15/C/texindex.c0000644000175000017500000011534612415566143012552 0ustar gg/* Prepare TeX index dribble output into an actual index. Version 1.45 Copyright (C) 1987, 1991 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "getopt.h" #if defined (STDC_HEADERS) # include # include # if !defined (bzero) # define bzero(p, n) memset((p), '\0', (n)) # endif /* !bzero */ #else /* !STDC_HEADERS */ extern int errno; char *getenv (), *malloc (), *realloc (); void bzero (); #endif /* !STDC_HEADERS */ #if defined (HAVE_UNISTD_H) # include #else /* !HAVE_UNISTD_H */ long lseek (); #endif /* !HAVE_UNISTD_H */ char *mktemp (); #if defined (VMS) # if !defined (VAX11C) # define noshare # endif /* !VAX11C */ # include extern noshare int sys_nerr; extern noshare char *sys_errlist[]; # include # define EXIT_SUCCESS ((1 << 28) | 1) # define EXIT_FATAL ((1 << 28) | 4) # define unlink delete #else /* !VMS */ extern int sys_nerr; extern char *sys_errlist[]; # if defined (USG) # include # include # endif /* USG */ # if defined (_AIX) || !defined (_POSIX_VERSION) # include # else /* !AIX && _POSIX_VERSION */ # if !defined (USG) # include # endif /* !USG */ # endif /* !_AIX && _POSIX_VERSION */ # define EXIT_SUCCESS 0 # define EXIT_FATAL 1 #endif /* !VMS */ #if !defined (SEEK_SET) # define SEEK_SET 0 # define SEEK_CUR 1 # define SEEK_END 2 #endif /* !SEEK_SET */ /* When sorting in core, this structure describes one line and the position and length of its first keyfield. */ struct lineinfo { char *text; /* The actual text of the line. */ union { char *text; /* The start of the key (for textual comparison). */ long number; /* The numeric value (for numeric comparison). */ } key; long keylen; /* Length of KEY field. */ }; /* This structure describes a field to use as a sort key. */ struct keyfield { int startwords; /* Number of words to skip. */ int startchars; /* Number of additional chars to skip. */ int endwords; /* Number of words to ignore at end. */ int endchars; /* Ditto for characters of last word. */ char ignore_blanks; /* Non-zero means ignore spaces and tabs. */ char fold_case; /* Non-zero means case doesn't matter. */ char reverse; /* Non-zero means compare in reverse order. */ char numeric; /* Non-zeros means field is ASCII numeric. */ char positional; /* Sort according to file position. */ char braced; /* Count balanced-braced groupings as fields. */ }; /* Vector of keyfields to use. */ struct keyfield keyfields[3]; /* Number of keyfields stored in that vector. */ int num_keyfields = 3; /* Vector of input file names, terminated with a null pointer. */ char **infiles; /* Vector of corresponding output file names, or NULL, meaning default it (add an `s' to the end). */ char **outfiles; /* Length of `infiles'. */ int num_infiles; /* Pointer to the array of pointers to lines being sorted. */ char **linearray; /* The allocated length of `linearray'. */ long nlines; /* Directory to use for temporary files. On Unix, it ends with a slash. */ char *tempdir; /* Start of filename to use for temporary files. */ char *tempbase; /* Number of last temporary file. */ int tempcount; /* Number of last temporary file already deleted. Temporary files are deleted by `flush_tempfiles' in order of creation. */ int last_deleted_tempcount; /* During in-core sort, this points to the base of the data block which contains all the lines of data. */ char *text_base; /* Additional command switches .*/ /* Nonzero means do not delete tempfiles -- for debugging. */ int keep_tempfiles; /* The name this program was run with. */ char *program_name; /* Forward declarations of functions in this file. */ void decode_command (); void sort_in_core (); void sort_offline (); char **parsefile (); char *find_field (); char *find_pos (); long find_value (); char *find_braced_pos (); char *find_braced_end (); void writelines (); int compare_field (); int compare_full (); long readline (); int merge_files (); int merge_direct (); void pfatal_with_name (); void fatal (); void error (); void *xmalloc (), *xrealloc (); char *concat (); char *maketempname (); void flush_tempfiles (); char *tempcopy (); #define MAX_IN_CORE_SORT 500000 void main (argc, argv) int argc; char **argv; { int i; tempcount = 0; last_deleted_tempcount = 0; program_name = argv[0]; /* Describe the kind of sorting to do. */ /* The first keyfield uses the first braced field and folds case. */ keyfields[0].braced = 1; keyfields[0].fold_case = 1; keyfields[0].endwords = -1; keyfields[0].endchars = -1; /* The second keyfield uses the second braced field, numerically. */ keyfields[1].braced = 1; keyfields[1].numeric = 1; keyfields[1].startwords = 1; keyfields[1].endwords = -1; keyfields[1].endchars = -1; /* The third keyfield (which is ignored while discarding duplicates) compares the whole line. */ keyfields[2].endwords = -1; keyfields[2].endchars = -1; decode_command (argc, argv); tempbase = mktemp (concat ("txiXXXXXX", "", "")); /* Process input files completely, one by one. */ for (i = 0; i < num_infiles; i++) { int desc; long ptr; char *outfile; desc = open (infiles[i], O_RDONLY, 0); if (desc < 0) pfatal_with_name (infiles[i]); lseek (desc, 0L, SEEK_END); ptr = lseek (desc, 0L, SEEK_CUR); close (desc); outfile = outfiles[i]; if (!outfile) { outfile = concat (infiles[i], "s", ""); } if (ptr < MAX_IN_CORE_SORT) /* Sort a small amount of data. */ sort_in_core (infiles[i], ptr, outfile); else sort_offline (infiles[i], ptr, outfile); } flush_tempfiles (tempcount); exit (EXIT_SUCCESS); } void usage () { fprintf (stderr, "\ Usage: %s [-k] infile [-o outfile] ...\n", program_name); exit (1); } /* Decode the command line arguments to set the parameter variables and set up the vector of keyfields and the vector of input files. */ void decode_command (argc, argv) int argc; char **argv; { int optc; char **ip; char **op; /* Store default values into parameter variables. */ tempdir = getenv ("TMPDIR"); #ifdef VMS if (tempdir == NULL) tempdir = "sys$scratch:"; #else if (tempdir == NULL) tempdir = "/tmp/"; else tempdir = concat (tempdir, "/", ""); #endif keep_tempfiles = 0; /* Allocate ARGC input files, which must be enough. */ infiles = (char **) xmalloc (argc * sizeof (char *)); outfiles = (char **) xmalloc (argc * sizeof (char *)); ip = infiles; op = outfiles; while ((optc = getopt (argc, argv, "-ko:")) != EOF) { switch (optc) { case 1: /* Non-option filename. */ *ip++ = optarg; *op++ = NULL; break; case 'k': keep_tempfiles = 1; break; case 'o': if (op > outfiles) *(op - 1) = optarg; break; default: usage (); } } /* Record number of keyfields and terminate list of filenames. */ num_infiles = ip - infiles; *ip = 0; if (num_infiles == 0) usage (); } /* Return a name for a temporary file. */ char * maketempname (count) int count; { char tempsuffix[10]; sprintf (tempsuffix, "%d", count); return concat (tempdir, tempbase, tempsuffix); } /* Delete all temporary files up to TO_COUNT. */ void flush_tempfiles (to_count) int to_count; { if (keep_tempfiles) return; while (last_deleted_tempcount < to_count) unlink (maketempname (++last_deleted_tempcount)); } /* Copy the input file open on IDESC into a temporary file and return the temporary file name. */ #define BUFSIZE 1024 char * tempcopy (idesc) int idesc; { char *outfile = maketempname (++tempcount); int odesc; char buffer[BUFSIZE]; odesc = open (outfile, O_WRONLY | O_CREAT, 0666); if (odesc < 0) pfatal_with_name (outfile); while (1) { int nread = read (idesc, buffer, BUFSIZE); write (odesc, buffer, nread); if (!nread) break; } close (odesc); return outfile; } /* Compare LINE1 and LINE2 according to the specified set of keyfields. */ int compare_full (line1, line2) char **line1, **line2; { int i; /* Compare using the first keyfield; if that does not distinguish the lines, try the second keyfield; and so on. */ for (i = 0; i < num_keyfields; i++) { long length1, length2; char *start1 = find_field (&keyfields[i], *line1, &length1); char *start2 = find_field (&keyfields[i], *line2, &length2); int tem = compare_field (&keyfields[i], start1, length1, *line1 - text_base, start2, length2, *line2 - text_base); if (tem) { if (keyfields[i].reverse) return -tem; return tem; } } return 0; /* Lines match exactly. */ } /* Compare LINE1 and LINE2, described by structures in which the first keyfield is identified in advance. For positional sorting, assumes that the order of the lines in core reflects their nominal order. */ int compare_prepared (line1, line2) struct lineinfo *line1, *line2; { int i; int tem; char *text1, *text2; /* Compare using the first keyfield, which has been found for us already. */ if (keyfields->positional) { if (line1->text - text_base > line2->text - text_base) tem = 1; else tem = -1; } else if (keyfields->numeric) tem = line1->key.number - line2->key.number; else tem = compare_field (keyfields, line1->key.text, line1->keylen, 0, line2->key.text, line2->keylen, 0); if (tem) { if (keyfields->reverse) return -tem; return tem; } text1 = line1->text; text2 = line2->text; /* Compare using the second keyfield; if that does not distinguish the lines, try the third keyfield; and so on. */ for (i = 1; i < num_keyfields; i++) { long length1, length2; char *start1 = find_field (&keyfields[i], text1, &length1); char *start2 = find_field (&keyfields[i], text2, &length2); int tem = compare_field (&keyfields[i], start1, length1, text1 - text_base, start2, length2, text2 - text_base); if (tem) { if (keyfields[i].reverse) return -tem; return tem; } } return 0; /* Lines match exactly. */ } /* Like compare_full but more general. You can pass any strings, and you can say how many keyfields to use. POS1 and POS2 should indicate the nominal positional ordering of the two lines in the input. */ int compare_general (str1, str2, pos1, pos2, use_keyfields) char *str1, *str2; long pos1, pos2; int use_keyfields; { int i; /* Compare using the first keyfield; if that does not distinguish the lines, try the second keyfield; and so on. */ for (i = 0; i < use_keyfields; i++) { long length1, length2; char *start1 = find_field (&keyfields[i], str1, &length1); char *start2 = find_field (&keyfields[i], str2, &length2); int tem = compare_field (&keyfields[i], start1, length1, pos1, start2, length2, pos2); if (tem) { if (keyfields[i].reverse) return -tem; return tem; } } return 0; /* Lines match exactly. */ } /* Find the start and length of a field in STR according to KEYFIELD. A pointer to the starting character is returned, and the length is stored into the int that LENGTHPTR points to. */ char * find_field (keyfield, str, lengthptr) struct keyfield *keyfield; char *str; long *lengthptr; { char *start; char *end; char *(*fun) (); if (keyfield->braced) fun = find_braced_pos; else fun = find_pos; start = (*fun) (str, keyfield->startwords, keyfield->startchars, keyfield->ignore_blanks); if (keyfield->endwords < 0) { if (keyfield->braced) end = find_braced_end (start); else { end = start; while (*end && *end != '\n') end++; } } else { end = (*fun) (str, keyfield->endwords, keyfield->endchars, 0); if (end - str < start - str) end = start; } *lengthptr = end - start; return start; } /* Return a pointer to a specified place within STR, skipping (from the beginning) WORDS words and then CHARS chars. If IGNORE_BLANKS is nonzero, we skip all blanks after finding the specified word. */ char * find_pos (str, words, chars, ignore_blanks) char *str; int words, chars; int ignore_blanks; { int i; char *p = str; for (i = 0; i < words; i++) { char c; /* Find next bunch of nonblanks and skip them. */ while ((c = *p) == ' ' || c == '\t') p++; while ((c = *p) && c != '\n' && !(c == ' ' || c == '\t')) p++; if (!*p || *p == '\n') return p; } while (*p == ' ' || *p == '\t') p++; for (i = 0; i < chars; i++) { if (!*p || *p == '\n') break; p++; } return p; } /* Like find_pos but assumes that each field is surrounded by braces and that braces within fields are balanced. */ char * find_braced_pos (str, words, chars, ignore_blanks) char *str; int words, chars; int ignore_blanks; { int i; int bracelevel; char *p = str; char c; for (i = 0; i < words; i++) { bracelevel = 1; while ((c = *p++) != '{' && c != '\n' && c) /* Do nothing. */ ; if (c != '{') return p - 1; while (bracelevel) { c = *p++; if (c == '{') bracelevel++; if (c == '}') bracelevel--; if (c == 0 || c == '\n') return p - 1; } } while ((c = *p++) != '{' && c != '\n' && c) /* Do nothing. */ ; if (c != '{') return p - 1; if (ignore_blanks) while ((c = *p) == ' ' || c == '\t') p++; for (i = 0; i < chars; i++) { if (!*p || *p == '\n') break; p++; } return p; } /* Find the end of the balanced-brace field which starts at STR. The position returned is just before the closing brace. */ char * find_braced_end (str) char *str; { int bracelevel; char *p = str; char c; bracelevel = 1; while (bracelevel) { c = *p++; if (c == '{') bracelevel++; if (c == '}') bracelevel--; if (c == 0 || c == '\n') return p - 1; } return p - 1; } long find_value (start, length) char *start; long length; { while (length != 0L) { if (isdigit (*start)) return atol (start); length--; start++; } return 0l; } /* Vector used to translate characters for comparison. This is how we make all alphanumerics follow all else, and ignore case in the first sorting. */ int char_order[256]; void init_char_order () { int i; for (i = 1; i < 256; i++) char_order[i] = i; for (i = '0'; i <= '9'; i++) char_order[i] += 512; for (i = 'a'; i <= 'z'; i++) { char_order[i] = 512 + i; char_order[i + 'A' - 'a'] = 512 + i; } } /* Compare two fields (each specified as a start pointer and a character count) according to KEYFIELD. The sign of the value reports the relation between the fields. */ int compare_field (keyfield, start1, length1, pos1, start2, length2, pos2) struct keyfield *keyfield; char *start1; long length1; long pos1; char *start2; long length2; long pos2; { if (keyfields->positional) { if (pos1 > pos2) return 1; else return -1; } if (keyfield->numeric) { long value = find_value (start1, length1) - find_value (start2, length2); if (value > 0) return 1; if (value < 0) return -1; return 0; } else { char *p1 = start1; char *p2 = start2; char *e1 = start1 + length1; char *e2 = start2 + length2; while (1) { int c1, c2; if (p1 == e1) c1 = 0; else c1 = *p1++; if (p2 == e2) c2 = 0; else c2 = *p2++; if (char_order[c1] != char_order[c2]) return char_order[c1] - char_order[c2]; if (!c1) break; } /* Strings are equal except possibly for case. */ p1 = start1; p2 = start2; while (1) { int c1, c2; if (p1 == e1) c1 = 0; else c1 = *p1++; if (p2 == e2) c2 = 0; else c2 = *p2++; if (c1 != c2) /* Reverse sign here so upper case comes out last. */ return c2 - c1; if (!c1) break; } return 0; } } /* A `struct linebuffer' is a structure which holds a line of text. `readline' reads a line from a stream into a linebuffer and works regardless of the length of the line. */ struct linebuffer { long size; char *buffer; }; /* Initialize LINEBUFFER for use. */ void initbuffer (linebuffer) struct linebuffer *linebuffer; { linebuffer->size = 200; linebuffer->buffer = (char *) xmalloc (200); } /* Read a line of text from STREAM into LINEBUFFER. Return the length of the line. */ long readline (linebuffer, stream) struct linebuffer *linebuffer; FILE *stream; { char *buffer = linebuffer->buffer; char *p = linebuffer->buffer; char *end = p + linebuffer->size; while (1) { int c = getc (stream); if (p == end) { buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); p += buffer - linebuffer->buffer; end += buffer - linebuffer->buffer; linebuffer->buffer = buffer; } if (c < 0 || c == '\n') { *p = 0; break; } *p++ = c; } return p - buffer; } /* Sort an input file too big to sort in core. */ void sort_offline (infile, nfiles, total, outfile) char *infile; int nfiles; long total; char *outfile; { /* More than enough. */ int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); FILE *istream = fopen (infile, "r"); int i; struct linebuffer lb; long linelength; int failure = 0; initbuffer (&lb); /* Read in one line of input data. */ linelength = readline (&lb, istream); if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') { error ("%s: not a texinfo index file", infile); return; } /* Split up the input into `ntemps' temporary files, or maybe fewer, and put the new files' names into `tempfiles' */ for (i = 0; i < ntemps; i++) { char *outname = maketempname (++tempcount); FILE *ostream = fopen (outname, "w"); long tempsize = 0; if (!ostream) pfatal_with_name (outname); tempfiles[i] = outname; /* Copy lines into this temp file as long as it does not make file "too big" or until there are no more lines. */ while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) { tempsize += linelength + 1; fputs (lb.buffer, ostream); putc ('\n', ostream); /* Read another line of input data. */ linelength = readline (&lb, istream); if (!linelength && feof (istream)) break; if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') { error ("%s: not a texinfo index file", infile); failure = 1; goto fail; } } fclose (ostream); if (feof (istream)) break; } free (lb.buffer); fail: /* Record number of temp files we actually needed. */ ntemps = i; /* Sort each tempfile into another tempfile. Delete the first set of tempfiles and put the names of the second into `tempfiles'. */ for (i = 0; i < ntemps; i++) { char *newtemp = maketempname (++tempcount); sort_in_core (&tempfiles[i], MAX_IN_CORE_SORT, newtemp); if (!keep_tempfiles) unlink (tempfiles[i]); tempfiles[i] = newtemp; } if (failure) return; /* Merge the tempfiles together and indexify. */ merge_files (tempfiles, ntemps, outfile); } /* Sort INFILE, whose size is TOTAL, assuming that is small enough to be done in-core, then indexify it and send the output to OUTFILE (or to stdout). */ void sort_in_core (infile, total, outfile) char *infile; long total; char *outfile; { char **nextline; char *data = (char *) xmalloc (total + 1); char *file_data; long file_size; int i; FILE *ostream = stdout; struct lineinfo *lineinfo; /* Read the contents of the file into the moby array `data'. */ int desc = open (infile, O_RDONLY, 0); if (desc < 0) fatal ("failure reopening %s", infile); for (file_size = 0;;) { i = read (desc, data + file_size, total - file_size); if (i <= 0) break; file_size += i; } file_data = data; data[file_size] = 0; close (desc); if (file_size > 0 && data[0] != '\\' && data[0] != '@') { error ("%s: not a texinfo index file", infile); return; } init_char_order (); /* Sort routines want to know this address. */ text_base = data; /* Create the array of pointers to lines, with a default size frequently enough. */ nlines = total / 50; if (!nlines) nlines = 2; linearray = (char **) xmalloc (nlines * sizeof (char *)); /* `nextline' points to the next free slot in this array. `nlines' is the allocated size. */ nextline = linearray; /* Parse the input file's data, and make entries for the lines. */ nextline = parsefile (infile, nextline, file_data, file_size); if (nextline == 0) { error ("%s: not a texinfo index file", infile); return; } /* Sort the lines. */ /* If we have enough space, find the first keyfield of each line in advance. Make a `struct lineinfo' for each line, which records the keyfield as well as the line, and sort them. */ lineinfo = (struct lineinfo *) malloc ((nextline - linearray) * sizeof (struct lineinfo)); if (lineinfo) { struct lineinfo *lp; char **p; for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) { lp->text = *p; lp->key.text = find_field (keyfields, *p, &lp->keylen); if (keyfields->numeric) lp->key.number = find_value (lp->key.text, lp->keylen); } qsort (lineinfo, nextline - linearray, sizeof (struct lineinfo), compare_prepared); for (lp = lineinfo, p = linearray; p != nextline; lp++, p++) *p = lp->text; free (lineinfo); } else qsort (linearray, nextline - linearray, sizeof (char *), compare_full); /* Open the output file. */ if (outfile) { ostream = fopen (outfile, "w"); if (!ostream) pfatal_with_name (outfile); } writelines (linearray, nextline - linearray, ostream); if (outfile) fclose (ostream); free (linearray); free (data); } /* Parse an input string in core into lines. DATA is the input string, and SIZE is its length. Data goes in LINEARRAY starting at NEXTLINE. The value returned is the first entry in LINEARRAY still unused. Value 0 means input file contents are invalid. */ char ** parsefile (filename, nextline, data, size) char *filename; char **nextline; char *data; long size; { char *p, *end; char **line = nextline; p = data; end = p + size; *end = 0; while (p != end) { if (p[0] != '\\' && p[0] != '@') return 0; *line = p; while (*p && *p != '\n') p++; if (p != end) p++; line++; if (line == linearray + nlines) { char **old = linearray; linearray = (char **) xrealloc (linearray, sizeof (char *) * (nlines *= 4)); line += linearray - old; } } return line; } /* Indexification is a filter applied to the sorted lines as they are being written to the output file. Multiple entries for the same name, with different page numbers, get combined into a single entry with multiple page numbers. The first braced field, which is used for sorting, is discarded. However, its first character is examined, folded to lower case, and if it is different from that in the previous line fed to us a \initial line is written with one argument, the new initial. If an entry has four braced fields, then the second and third constitute primary and secondary names. In this case, each change of primary name generates a \primary line which contains only the primary name, and in between these are \secondary lines which contain just a secondary name and page numbers. */ /* The last primary name we wrote a \primary entry for. If only one level of indexing is being done, this is the last name seen. */ char *lastprimary; /* Length of storage allocated for lastprimary. */ int lastprimarylength; /* Similar, for the secondary name. */ char *lastsecondary; int lastsecondarylength; /* Zero if we are not in the middle of writing an entry. One if we have written the beginning of an entry but have not yet written any page numbers into it. Greater than one if we have written the beginning of an entry plus at least one page number. */ int pending; /* The initial (for sorting purposes) of the last primary entry written. When this changes, a \initial {c} line is written */ char *lastinitial; int lastinitiallength; /* When we need a string of length 1 for the value of lastinitial, store it here. */ char lastinitial1[2]; /* Initialize static storage for writing an index. */ void init_index () { pending = 0; lastinitial = lastinitial1; lastinitial1[0] = 0; lastinitial1[1] = 0; lastinitiallength = 0; lastprimarylength = 100; lastprimary = (char *) xmalloc (lastprimarylength + 1); bzero (lastprimary, lastprimarylength + 1); lastsecondarylength = 100; lastsecondary = (char *) xmalloc (lastsecondarylength + 1); bzero (lastsecondary, lastsecondarylength + 1); } /* Indexify. Merge entries for the same name, insert headers for each initial character, etc. */ void indexify (line, ostream) char *line; FILE *ostream; { char *primary, *secondary, *pagenumber; int primarylength, secondarylength = 0, pagelength; int nosecondary; int initiallength; char *initial; char initial1[2]; register char *p; /* First, analyze the parts of the entry fed to us this time. */ p = find_braced_pos (line, 0, 0, 0); if (*p == '{') { initial = p; /* Get length of inner pair of braces starting at `p', including that inner pair of braces. */ initiallength = find_braced_end (p + 1) + 1 - p; } else { initial = initial1; initial1[0] = *p; initial1[1] = 0; initiallength = 1; if (initial1[0] >= 'a' && initial1[0] <= 'z') initial1[0] -= 040; } pagenumber = find_braced_pos (line, 1, 0, 0); pagelength = find_braced_end (pagenumber) - pagenumber; if (pagelength == 0) abort (); primary = find_braced_pos (line, 2, 0, 0); primarylength = find_braced_end (primary) - primary; secondary = find_braced_pos (line, 3, 0, 0); nosecondary = !*secondary; if (!nosecondary) secondarylength = find_braced_end (secondary) - secondary; /* If the primary is different from before, make a new primary entry. */ if (strncmp (primary, lastprimary, primarylength)) { /* Close off current secondary entry first, if one is open. */ if (pending) { fputs ("}\n", ostream); pending = 0; } /* If this primary has a different initial, include an entry for the initial. */ if (initiallength != lastinitiallength || strncmp (initial, lastinitial, initiallength)) { fprintf (ostream, "\\initial {"); fwrite (initial, 1, initiallength, ostream); fprintf (ostream, "}\n", initial); if (initial == initial1) { lastinitial = lastinitial1; *lastinitial1 = *initial1; } else { lastinitial = initial; } lastinitiallength = initiallength; } /* Make the entry for the primary. */ if (nosecondary) fputs ("\\entry {", ostream); else fputs ("\\primary {", ostream); fwrite (primary, primarylength, 1, ostream); if (nosecondary) { fputs ("}{", ostream); pending = 1; } else fputs ("}\n", ostream); /* Record name of most recent primary. */ if (lastprimarylength < primarylength) { lastprimarylength = primarylength + 100; lastprimary = (char *) xrealloc (lastprimary, 1 + lastprimarylength); } strncpy (lastprimary, primary, primarylength); lastprimary[primarylength] = 0; /* There is no current secondary within this primary, now. */ lastsecondary[0] = 0; } /* Should not have an entry with no subtopic following one with a subtopic. */ if (nosecondary && *lastsecondary) error ("entry %s follows an entry with a secondary name", line); /* Start a new secondary entry if necessary. */ if (!nosecondary && strncmp (secondary, lastsecondary, secondarylength)) { if (pending) { fputs ("}\n", ostream); pending = 0; } /* Write the entry for the secondary. */ fputs ("\\secondary {", ostream); fwrite (secondary, secondarylength, 1, ostream); fputs ("}{", ostream); pending = 1; /* Record name of most recent secondary. */ if (lastsecondarylength < secondarylength) { lastsecondarylength = secondarylength + 100; lastsecondary = (char *) xrealloc (lastsecondary, 1 + lastsecondarylength); } strncpy (lastsecondary, secondary, secondarylength); lastsecondary[secondarylength] = 0; } /* Here to add one more page number to the current entry. */ if (pending++ != 1) fputs (", ", ostream); /* Punctuate first, if this is not the first. */ fwrite (pagenumber, pagelength, 1, ostream); } /* Close out any unfinished output entry. */ void finish_index (ostream) FILE *ostream; { if (pending) fputs ("}\n", ostream); free (lastprimary); free (lastsecondary); } /* Copy the lines in the sorted order. Each line is copied out of the input file it was found in. */ void writelines (linearray, nlines, ostream) char **linearray; int nlines; FILE *ostream; { char **stop_line = linearray + nlines; char **next_line; init_index (); /* Output the text of the lines, and free the buffer space. */ for (next_line = linearray; next_line != stop_line; next_line++) { /* If -u was specified, output the line only if distinct from previous one. */ if (next_line == linearray /* Compare previous line with this one, using only the explicitly specd keyfields. */ || compare_general (*(next_line - 1), *next_line, 0L, 0L, num_keyfields - 1)) { char *p = *next_line; char c; while ((c = *p++) && c != '\n') /* Do nothing. */ ; *(p - 1) = 0; indexify (*next_line, ostream); } } finish_index (ostream); } /* Assume (and optionally verify) that each input file is sorted; merge them and output the result. Returns nonzero if any input file fails to be sorted. This is the high-level interface that can handle an unlimited number of files. */ #define MAX_DIRECT_MERGE 10 int merge_files (infiles, nfiles, outfile) char **infiles; int nfiles; char *outfile; { char **tempfiles; int ntemps; int i; int value = 0; int start_tempcount = tempcount; if (nfiles <= MAX_DIRECT_MERGE) return merge_direct (infiles, nfiles, outfile); /* Merge groups of MAX_DIRECT_MERGE input files at a time, making a temporary file to hold each group's result. */ ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); for (i = 0; i < ntemps; i++) { int nf = MAX_DIRECT_MERGE; if (i + 1 == ntemps) nf = nfiles - i * MAX_DIRECT_MERGE; tempfiles[i] = maketempname (++tempcount); value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); } /* All temporary files that existed before are no longer needed since their contents have been merged into our new tempfiles. So delete them. */ flush_tempfiles (start_tempcount); /* Now merge the temporary files we created. */ merge_files (tempfiles, ntemps, outfile); free (tempfiles); return value; } /* Assume (and optionally verify) that each input file is sorted; merge them and output the result. Returns nonzero if any input file fails to be sorted. This version of merging will not work if the number of input files gets too high. Higher level functions use it only with a bounded number of input files. */ int merge_direct (infiles, nfiles, outfile) char **infiles; int nfiles; char *outfile; { struct linebuffer *lb1, *lb2; struct linebuffer **thisline, **prevline; FILE **streams; int i; int nleft; int lossage = 0; int *file_lossage; struct linebuffer *prev_out = 0; FILE *ostream = stdout; if (outfile) { ostream = fopen (outfile, "w"); } if (!ostream) pfatal_with_name (outfile); init_index (); if (nfiles == 0) { if (outfile) fclose (ostream); return 0; } /* For each file, make two line buffers. Also, for each file, there is an element of `thisline' which points at any time to one of the file's two buffers, and an element of `prevline' which points to the other buffer. `thisline' is supposed to point to the next available line from the file, while `prevline' holds the last file line used, which is remembered so that we can verify that the file is properly sorted. */ /* lb1 and lb2 contain one buffer each per file. */ lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); /* thisline[i] points to the linebuffer holding the next available line in file i, or is zero if there are no lines left in that file. */ thisline = (struct linebuffer **) xmalloc (nfiles * sizeof (struct linebuffer *)); /* prevline[i] points to the linebuffer holding the last used line from file i. This is just for verifying that file i is properly sorted. */ prevline = (struct linebuffer **) xmalloc (nfiles * sizeof (struct linebuffer *)); /* streams[i] holds the input stream for file i. */ streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); /* file_lossage[i] is nonzero if we already know file i is not properly sorted. */ file_lossage = (int *) xmalloc (nfiles * sizeof (int)); /* Allocate and initialize all that storage. */ for (i = 0; i < nfiles; i++) { initbuffer (&lb1[i]); initbuffer (&lb2[i]); thisline[i] = &lb1[i]; prevline[i] = &lb2[i]; file_lossage[i] = 0; streams[i] = fopen (infiles[i], "r"); if (!streams[i]) pfatal_with_name (infiles[i]); readline (thisline[i], streams[i]); } /* Keep count of number of files not at eof. */ nleft = nfiles; while (nleft) { struct linebuffer *best = 0; struct linebuffer *exch; int bestfile = -1; int i; /* Look at the next avail line of each file; choose the least one. */ for (i = 0; i < nfiles; i++) { if (thisline[i] && (!best || 0 < compare_general (best->buffer, thisline[i]->buffer, (long) bestfile, (long) i, num_keyfields))) { best = thisline[i]; bestfile = i; } } /* Output that line, unless it matches the previous one and we don't want duplicates. */ if (!(prev_out && !compare_general (prev_out->buffer, best->buffer, 0L, 1L, num_keyfields - 1))) indexify (best->buffer, ostream); prev_out = best; /* Now make the line the previous of its file, and fetch a new line from that file. */ exch = prevline[bestfile]; prevline[bestfile] = thisline[bestfile]; thisline[bestfile] = exch; while (1) { /* If the file has no more, mark it empty. */ if (feof (streams[bestfile])) { thisline[bestfile] = 0; /* Update the number of files still not empty. */ nleft--; break; } readline (thisline[bestfile], streams[bestfile]); if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) break; } } finish_index (ostream); /* Free all storage and close all input streams. */ for (i = 0; i < nfiles; i++) { fclose (streams[i]); free (lb1[i].buffer); free (lb2[i].buffer); } free (file_lossage); free (lb1); free (lb2); free (thisline); free (prevline); free (streams); if (outfile) fclose (ostream); return lossage; } /* Print error message and exit. */ void fatal (s1, s2) char *s1, *s2; { error (s1, s2); exit (EXIT_FATAL); } /* Print error message. S1 is printf control string, S2 is arg for it. */ void error (s1, s2) char *s1, *s2; { printf ("%s: ", program_name); printf (s1, s2); printf ("\n"); } void perror_with_name (name) char *name; { char *s; if (errno < sys_nerr) s = concat ("", sys_errlist[errno], " for %s"); else s = "cannot open %s"; error (s, name); } void pfatal_with_name (name) char *name; { char *s; if (errno < sys_nerr) s = concat ("", sys_errlist[errno], " for %s"); else s = "cannot open %s"; fatal (s, name); } /* Return a newly-allocated string whose contents concatenate those of S1, S2, S3. */ char * concat (s1, s2, s3) char *s1, *s2, *s3; { int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); char *result = (char *) xmalloc (len1 + len2 + len3 + 1); strcpy (result, s1); strcpy (result + len1, s2); strcpy (result + len1 + len2, s3); *(result + len1 + len2 + len3) = 0; return result; } /* Just like malloc, but kills the program in case of fatal error. */ void * xmalloc (nbytes) int nbytes; { void *temp = (void *) malloc (nbytes); if (nbytes && temp == (void *)NULL) memory_error ("xmalloc", nbytes); return (temp); } /* Like realloc (), but barfs if there isn't enough memory. */ void * xrealloc (pointer, nbytes) void *pointer; int nbytes; { void *temp; if (!pointer) temp = (void *)xmalloc (nbytes); else temp = (void *)realloc (pointer, nbytes); if (nbytes && !temp) memory_error ("xrealloc", nbytes); return (temp); } memory_error (callers_name, bytes_wanted) char *callers_name; int bytes_wanted; { char printable_string[80]; sprintf (printable_string, "Virtual memory exhausted in %s ()! Needed %d bytes.", callers_name, bytes_wanted); error (printable_string); abort (); } #ifndef STDC_HEADERS void bzero (b, length) register char *b; register int length; { #ifdef VMS short zero = 0; long max_str = 65535; while (length > max_str) { (void) LIB$MOVC5 (&zero, &zero, &zero, &max_str, b); length -= max_str; b += max_str; } (void) LIB$MOVC5 (&zero, &zero, &zero, &length, b); #else while (length-- > 0) *b++ = 0; #endif /* not VMS */ } #endif /* not STDC_HEADERS */ texinfo-2.15/C/ChangeLog0000644000175000017500000004301112415565560012317 0ustar ggSun Jun 7 10:24:37 1992 Brian Fox (bfox@cubit) * info.c: New version 1.44. * makeinfo.c: New version 1.47 * info.c:(main) If the user speficied the info file to use, and it wasn't found, then exit immediately. * makeinfo.texinfo: Updated documentation to include all of the long options. Other minor cosmetic changes. Sat May 30 11:52:26 1992 Brian Fox (bfox@cubit) * info.c (show_version_info) New function displays version information. New long option "--version" causes this function to be called, and then Info to exit. Wed May 27 09:52:22 1992 Brian Fox (bfox@cubit) * info.c (dump_current_node) If the output filename is "-", then dump to stdout. Sun May 24 11:30:20 1992 Brian Fox (bfox@cubit) * makeinfo.c (begin_insertion, end_insertion) Do not close paragraphs if producing a file with --no-headers. * makeinfo.c (begin_insertion) Indentation of multiple paragraphs appearing within an @enumerate is only done if the #define INDENT_PARAGRAPHS_IN_TABLE is set (not the default). This makes @enumerate paragraph indentation identical to @table and friends. Sat May 23 19:44:43 1992 Brian Fox (bfox@cubit) * makeinfo.c: New version 1.46. Changed `@set' to accept an equal sign followed by a value to allow set variables to have values. New command `@value{FOO}' inserts the value of the variable FOO. @set accepts quoted values of the form: @set FOO="this is a list". @ifclear and @ifset now count the conditionals encountered while searching for their respective ends. Command line arguments "-Dfoo" and "-Ubar" set and clear foo and bar. Thu Apr 23 14:44:30 1992 Brian Fox (bfox@cubit) * makeinfo.c: New version 1.45. * makeinfo.c (cm_center): Add fudge_factor to centering calculation to give more pleasing results. Call cm_noindent () before inserting any text. * makeinfo.c (cm_exdent): Execute the line so that @var{} and friends will work correctly. * makeinfo.c (cm_node): When defaulting the next node, make sure that the reference type is `menu'. Wed Apr 22 00:27:52 1992 David J. MacKenzie (djm@churchy.gnu.ai.mit.edu) * makeinfo.c: Indent #pragma. Wed Apr 8 23:11:51 1992 Charles Hannum (mycroft@hal.gnu.ai.mit.edu) * makeinfo.c (usage): Terminate lines in string correctly. Mon Mar 9 23:38:57 1992 David J. MacKenzie (djm@wookumz.gnu.ai.mit.edu) * info.c, makeinfo.c: Document long options as starting with `--', not `+'. Sat Feb 22 02:15:00 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: (begin_insertion) @group does absolutely nothing when found inside of an @example. * texindex.c: New version 1.45 has cleanups, should compile under VMS quietly. Thu Feb 20 16:21:54 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (cm_center) Inhibit output flushing to prevent the executed line from disappearing before its length can be calculated. * makeinfo.c (inhibit_output_flushing, uninhibit_output_flushing) Turn off and on actual disk writing. * makeinfo.c: New version 1.44. Mon Feb 17 17:52:55 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (get_file_info_in_path, extract_colon_unit, find_and_load_file) Two new functions, and modify find_and_load_file () to use get_file_info_in_path (). You can now supply multiple `-I' flags to makeinfo in order to specify directories which should be searched to find files included with @include. Sat Feb 8 00:06:17 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (usage): Update the help message. * Makefile.in: Hack kludge to get -traditional into the CFLAGS. I hate auto-configure, and worse, where does it get off deciding for me that I want to use a specific compiler simply because I have a file called gcc in my PATH? * makeinfo.c (new functions): New functions cm_macro, cm_unmacro, add_macro, execute_macro, delete_macro () all implement new @macro construct. This is conditionally compiled with #define HAVE_MACROS. Fri Feb 7 18:27:45 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (cm_center): Center the line *after* "executing" it. * info.c: Remove "true", "false", and "boolean", replacing them with 1, 0, and int. Tue Jan 21 01:18:25 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (cm_titlefont) New function does nothing special but makes life easier. Fri Jan 10 16:43:04 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (cm_code) Increment/decrement in_fixed_width_font while processing the text inside of an @code (includes @samp, @file). Wed Jan 8 02:52:33 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: (close_insertion_paragraph) New function gets called to close certain types of insertions. This includes @format, @example, etc. New variable line_already_broken describes the state of the output file to close/start_paragraph (). Tue Jan 7 02:24:10 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: (cm_node) Get and remember sectioning commands even for those nodes which are not currently defaulting. Such nodes can contain menus whose nodes are defaulted, and we need to know the sectioning level of the node containing the menu. * makeinfo.c: Removed definitions for "true", "false", and the typedef for "boolean". Changed all code accordingly. Added defines for BRACE_ARGS and NO_BRACE_ARGS to increase readability of the CommandTable. * makeinfo.c (begin_insertion) Do not inhibit_paragraph_indentation for @table and friends. Mon Jan 6 11:52:36 1992 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (convert) WHoops! Remove surrounding whitespace from OUTPUT_FILENAME before using. * makeinfo.c: (end_insertion) If an @end INSERTION is followed by a blank line, then start a new paragraph there, otherwise close the current one without a blank line. * makeinfo.c: (main, convert) Add code to support -o FILE (+output FILE) option. The output filename generated from this option overrides the filename appearing in the @setfilename command. Mon Dec 23 23:46:42 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) * texindex.c: Change POSIX ifdefs to HAVE_UNISTD_H and _POSIX_VERSION. Wed Dec 18 04:26:02 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (end_insertion) Close paragraphs removing last inserted newline which comes from @end INSERTION. * makeinfo.c (start_paragraph) Do not unconditionally set the output column from the desired indentation; use an interim value instead and keep in mind that some indentation may have already been done. Fri Dec 6 01:25:09 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) * texindex.c: Conditionalize on _AIX (which is predefined) instead of AIX, just like makeinfo does. Sat Nov 23 22:43:05 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: (cm_vtable) New command @vtable is just like @ftable, but adds an entry to the variable index instead of the function index. Thu Nov 21 00:12:51 1991 Brian Fox (bfox at gnuwest.fsf.org) * info.c: #define S_ISREG macro if not defined, and use the definition. Wed Nov 20 01:07:57 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: (flush_output) Turn off meta bit on sentence enders that were ignored. Fri Nov 1 01:09:43 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) * Makefile.in: Add texindex. * texindex.c: Add more #ifdefs, for VMS and USG. (usage): New function. (decode_command): Call it if given invalid option or no files. Use getopt. Sat Sep 21 17:02:42 1991 Info Maintainer (info at gnuwest.fsf.org) * makeinfo.c: New command @deftypemethod added. * makeinfo.c: (cm_cartouche) New function which is ignored in makeinfo. * makeinfo.c: (cm_br) If we skip a newline then increment line_number. * makeinfo.c: (reader_loop) ignore the whitespace on lines which appear blank. * index_add_arg (), close_paragraph (); Call ignore_blank_line () to tell the reader that the previous line disappeared from the input stream. New function ignore_blank_line (). Tue Sep 3 22:38:18 1991 Info Maintainer (info at gnuwest.fsf.org) * makeinfo.c: (cm_footnotestyle, cm_paragraphindent) Fix bogus call to get_rest_of_line (). Tue Jun 11 00:34:12 1991 Brian Fox (bfox at gnuwest.fsf.org) * info.c: Fixed SIGWINCH display bugs. Windows can now be resized at will. Mon Jun 10 11:25:01 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c New function cm_math () does nothing but accepts arguments. * makeinfo.c (flush_output) only change the 8th bit for space, tab, or newline. This protects ISO character sets. * info.c: opsys_filename (); Return only the names of regular files, not directories or block special devices. * makeinfo.c (add_char) Fixed bug in filling which could cause 78 character lines to be filled incorrectly when fill_column was 79. Tue Jun 4 13:34:57 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: Add @paragraphindent and @footnotesytle as interactive commands to change default paragraph indentation and footnote style. Thu Jan 31 10:55:34 1991 Brian Fox (bfox at gnuwest.fsf.org) * @cite now produces `...' instead of ``...''. Tue Jan 29 16:47:01 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: add flushleft, and flushright. (cm_xref): all calls to add_word_args () are now calls to execute_string () so that @code{@@bullet} produces the correct output. The call to normalize_node_name () from get_xref_token () is removed, since xref now calls execute string. (end_insertion) now sets last_char_was_newline so that no extra indentation can appear on the following text line. Sun Jan 27 22:32:45 1991 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (args_from_string): Hack tokenization to consider a command followed immediately by braces to be a single token (including the braces and contents of same). Thu Jun 28 15:01:51 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c, info.c, Makefile: Change SYSV to USG. Wed Jun 27 12:22:12 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: new function cm_today () produces the date in the output document. Wed May 30 13:00:09 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c (cm_xref) If arguments 4 or 5 are present, then we use argument 2 as the node name, unless it is empty, in which case we use argument one. See how easy this is to use? * makeinfo.c (many index functions) Handle code indices by inserting @code{} around the index entry item when it is being printed. Keep track of which type of index was used to insert this item into the index. * makeinfo.c (reader_loop) Paired single quotes turn into double quote (outside of fixed-width font insertions. Multiple dashes don't shrink down to double dashes inside of fixed-width font insertions. Sun May 27 11:23:27 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c Merge in VMS changes. Adds single change to find_and_load (), and mimics some things that SYSV needs for headers. Mon May 21 11:39:43 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c Added @smallbook. Thu Apr 26 05:01:04 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c: Output newline before tag table leader. @sp X doesn't close paragraph anymore, it just acts as if you personally typed in X newlines. Mon Apr 16 02:26:11 1990 Brian Fox (bfox at gnuwest.fsf.org) * makeinfo.c Fixed splitting to output the final node in a separate subfile if outputting it in the current subfile would make the subfile too large. Sun Jan 14 10:34:42 1990 Brian Fox (bfox at sbphy.ucsb.edu) * makeinfo.c: new function normalize_node_name () gets called from get_node_token (), get_xref_token (), glean_node_from_menu (). It allows (by hacking) @@ in the name of a node. This leaves @Top undefined as to what action to take: that is to say that @@Top and @Top are identical node names. * makeinfo.c:begin_insertion (). Made @example and friends sensitive to newlines so that pending_indent wouldn't build up. This fixed bug of extra indentation if @example was followed immediately by a blank line, instead of text. Mon Dec 11 11:47:28 1989 Brian Fox (bfox at rice-chex) * Changed cons_string to savestring everywhere. * Added info.tar.Z as a target to the Makefile. Mon Dec 11 00:28:14 1989 David J. MacKenzie (djm at rice-chex) * Merge modification history comments from info.c and makeinfo.c into the ChangeLog. * makeinfo.c (main): Use getopt_long. (usage): Describe new option syntax, adding descriptions of the verbose and paragraph-indent options. * Makefile: Add rules to link makeinfo with getopt. Sun Dec 10 01:26:34 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) * Makefile: Move default info directory path definition from info.c and shorten it, since it will now be changed appropriately for each site. Rearrange rules to put those that are likely to be changed locally at the beginning. Define SHELL, don't define DOC (wasn't used). (dist): New rule to make info.tar and info.tar.Z. info.c (get_terminal_info): Use fgets instead of gets. Flush output before reading. (info_signal_handler): Don't declare extra unused args. (help_possible_completions): Don't return a value; never used. (help_use_info): Ditto. (main): Add missing arg to call of get_node. (toploop): Ditto. (build_notes): Move misplaced ')'. Global: Added some casts to function calls. Commented out some unused code. Sat Dec 9 18:44:33 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) * info.c: Move some function decl's outside of function bodies. Include getopt.h. (main): Use getopt_long. Fix error in use of printf. Add /usr/local/emacs/info to the default directory path so it works at the AI lab. (usage): Rename from explain. Update message. (eat_argument): Function removed. * Makefile: Add rules for linking info with getopt. Rename DOT_OHS macro to OBJECTS. Tue Nov 7 17:48:31 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) * makeinfo.c (CommandTable): Define `@ ' and `@RET'. Mon Nov 6 08:15:20 1989 Brian Fox (bfox at rice-chex) * makeinfo.c: Added defaulting Next, Prev, and Up pointers in a @node command without arguments. Revamped validation to be more robust. Added new validation rules (see comment at validat_file). * Changed Makefile to include ChangeLog and default-nodes.texinfo in info.tar.Z. Sun Nov 5 02:27:35 1989 Richard Stallman (rms at sugar-bombs.ai.mit.edu) * makeinfo.c (convert): Split even if errors. Tue Aug 22 14:51:11 1989 Robert J. Chassell (bob at hobbes.ai.mit.edu) * makeinfo.c (defun_internal): Line that begin with an asterisk are mistook for menu entries by info; so, replaced `* ' prior to function, variable, etc. definitions with ` * '. ... Aug .. ........ 1989 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: Added the @def... commands. Added the -pi flag for paragraph_start_indent. Wed Jul 6 ........ 1989 Brian Fox (bfox at rice-chex.ai.mit.edu) * info.c: Indirect tags are not assumed to point close to the node. Instead, they point to where the node would have been, had the the file never been split. Thus, the header of a split file is compensated for, by dynamically figuring out how long it is every time we read in a file. Mon Jun 12 19:48:58 1989 Robert J. Chassell (bob at rice-chex.ai.mit.edu) * makeinfo.c: @result, @expansion, @print, @error, @point, @equiv added ... Jun .. ........ 1989 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: Make sure that the NEXT node has a PREV that points to it. * makeinfo.c: Added @result, @expansion, @equiv, @print, @error and @point. Tue May 2 23:41:37 1989 Randall Smith (randy at rice-chex.ai.mit.edu) * makeinfo.c (find_index): Fixed comparison to be versus -1. Fri Apr 7 14:24:27 1989 Randall Smith (randy at rice-chex.ai.mit.edu) * makeinfo.c: Installed new version from bfox. * makeinfo.c (get_until): Fixed typo; == should have been =. ... Apr .. ........ 1989 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: Added validation of Up fields. They now have to have a menu item which points to them in the indicated node. Thu Feb 25 10:22:00 1989 Brian Fox (bfox at rice-chex.ai.mit.edu) * info.c: Made info_directory_paths try to get its value from the environment variable INFO_DIRECTORY_PATHS. Added cons_string in an attempt to get rid of the brain-damage (read brian-damage) I originally wrote in here. Death to static limits! ... Oct .. ........ 1988 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: Allowed user defined commands. In the specific, allowed the the user to make his/her own indices. We define the default ones. Fri Oct 9 13:03:00 1988 Brian Fox (bfox at rice-chex.ai.mit.edu) * info.c: Virgin release 1.0. * info.c: Made the completer not use static size variables. Also made the completer more generic. Maybe this will be of some use someday. Changed file_error to incorporate code suggestions from Roland McGrath. Changed idiot error messages. We still need some canonical location for the initial Info directory path. ... Jul .. ........ 1988 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: added code to handle un-closed braces at the start of a node, un-finished insertions at the start of a node, and outputting the `header' at the start of each info split sub-file. * makeinfo.c: Made split_file NOT update the tags table to reflect the changes in the output files. This means the reader has also changed. ... Jun .. ........ 1988 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: fixed filling to do the right thing at sentence ends. stopped automatically removing filename extensions on output split files. ... Apr .. ........ 1988 Brian Fox (bfox at rice-chex.ai.mit.edu) * makeinfo.c: added splitting. texinfo-2.15/C/configure.in0000644000175000017500000000043612415566105013056 0ustar ggdnl Process this file with autoconf to produce a configure script. AC_INIT(makeinfo.c) AC_PROG_GCC AC_PROG_CPP AC_GCC_TRADITIONAL AC_PROG_INSTALL AC_AIX AC_MINIX AC_ISC_POSIX AC_HEADER_CHECK(sys/ptem.h, AC_DEFINE(USGr3)) AC_STDC_HEADERS AC_UNISTD_H AC_USG AC_ALLOCA AC_OUTPUT(Makefile) texinfo-2.15/C/configure0000644000175000017500000002540312415566076012461 0ustar gg#!/bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf. # Copyright (C) 1991, 1992 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # Usage: configure [--srcdir=DIR] [--host=HOST] [--gas] [--nfp] [--no-create] # [--prefix=PREFIX] [--exec_prefix=PREFIX] [--with-PROGRAM] [TARGET] # Ignores all args except --srcdir, --prefix, --exec_prefix, and --no-create. trap 'rm -f conftest* core; exit 1' 1 3 15 for arg do # Handle --exec_prefix with a space before the argument. if test x$next_exec_prefix = xyes; then exec_prefix=$arg; next_exec_prefix= # Handle --host with a space before the argument. elif test x$next_host = xyes; then next_host= # Handle --prefix with a space before the argument. elif test x$next_prefix = xyes; then prefix=$arg; next_prefix= # Handle --srcdir with a space before the argument. elif test x$next_srcdir = xyes; then srcdir=$arg; next_srcdir= else case $arg in -exec_prefix=* | --exec_prefix=* | --exec_prefi=* | --exec_pref=* | --exec_pre=* | --exec_pr=* | --exec_p=* | --exec_=* | --exec=* | --exe=* | --ex=* | --e=*) exec_prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; -exec_prefix | --exec_prefix | --exec_prefi | --exec_pref | --exec_pre | --exec_pr | --exec_p | --exec_ | --exec | --exe | --ex | --e) next_exec_prefix=yes ;; -gas | --gas | --ga | --g) ;; -host=* | --host=* | --hos=* | --ho=* | --h=*) ;; -host | --host | --hos | --ho | --h) next_host=yes ;; -nfp | --nfp | --nf) ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre | --no-cr | --no-c | --no- | --no) no_create=1 ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=`echo $arg | sed 's/[-a-z_]*=//'` ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) next_prefix=yes ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=* | --s=*) srcdir=`echo $arg | sed 's/[-a-z_]*=//'` ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr | --s) next_srcdir=yes ;; -with-* | --with-*) ;; *) ;; esac fi done rm -f conftest* compile='${CC-cc} $DEFS conftest.c -o conftest $LIBS >/dev/null 2>&1' # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. unique_file=makeinfo.c # Makefile rules whose targets are searched for in VPATH need to use $<. # However, old makes do not support it, so we use a combination # construction in Makefile.in: `$file<'. # If srcdir is `.', we use sed to change that to `file' for old makes. # Otherwise, we use sed to change it to `$<'. # vpsub is the sed program, which changes `$file<' to one or the other. vpsub='s,\$\([-./a-zA-Z0-9_][-./a-zA-Z0-9_]*\)<,\1,g' # Find the source files, if location was not specified. if test -z "$srcdir"; then srcdirdefaulted=yes; srcdir=. if test ! -r $unique_file; then srcdir=..; fi fi if test ! -r $srcdir/$unique_file; then if test x$srcdirdefaulted = xyes; then echo "configure: Can not find sources in \`.' or \`..'." 1>&2 else echo "configure: Can not find sources in \`${srcdir}'." 1>&2 fi exit 1 fi if test $srcdir != .; then vpsub='s,\$\([-./a-zA-Z0-9_][-./a-zA-Z0-9_]*\)<,\$<,g' fi # Preserve a srcdir of `.' to avoid automounter screwups with pwd. # But we can't avoid them for `..', to make subdirectories work. case $srcdir in .|/*|~*) ;; *) srcdir=`(cd $srcdir; pwd)` ;; # Make relative path absolute. esac # The Bourne shell writes "command not found" to /dev/tty, so if we get # a usage message on stderr, we have the program. # # ksh and zsh write "command not found" to stderr, but test -n does not # want any output if there is no program. So we use the `type' builtin # instead for them (and bash). if test "$RANDOM" = "$RANDOM"; then checkfor='test -n "`$checkprog $checkargs 2>&1`"' else checkfor='type $checkprog >/dev/null 2>&1' fi echo checking for gcc checkprog=gcc checkargs='' test -z "$CC" && eval $checkfor && CC='gcc ' CC=${CC-cc} # Find out if we are using GNU C, under whatever name. cat < conftest.c #ifdef __GNUC__ yes #endif EOF ${CC-cc} -E conftest.c > conftest.out 2>&1 if egrep yes conftest.out >/dev/null 2>&1; then GCC=1 # For later tests. CC="$CC -O" fi rm -f conftest* echo checking how to run the C preprocessor if test -z "$CPP"; then CPP='${CC-cc} -E' cat < conftest.c #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then : else CPP=/lib/cpp fi rm -f conftest* fi if test -n "$GCC"; then echo checking whether -traditional is needed pattern="Autoconf.*'x'" prog='#include Autoconf TIOCGETP' cat < conftest.c $prog EOF eval "$CPP $DEFS conftest.c > conftest.out 2>&1" if egrep "$pattern" conftest.out >/dev/null 2>&1; then need_trad=1 fi rm -f conftest* if test -z "$need_trad"; then prog='#include Autoconf TCGETA' cat < conftest.c $prog EOF eval "$CPP $DEFS conftest.c > conftest.out 2>&1" if egrep "$pattern" conftest.out >/dev/null 2>&1; then need_trad=1 fi rm -f conftest* fi test -n "$need_trad" && CC="$CC -traditional" fi echo checking for install # Make sure to not get the incompatible SysV /etc/install and # /usr/sbin/install, which might be in PATH before a BSD-like install. if test -z "$INSTALL"; then saveifs="$IFS"; IFS="$IFS:" for dir in $PATH; do test -z "$dir" && dir=. case $dir in /etc|/usr/sbin) ;; *) if test -f $dir/install; then INSTALL="$dir/install -c" INSTALL_PROGRAM='$(INSTALL)' INSTALL_DATA='$(INSTALL) -m 644' break fi ;; esac done IFS="$saveifs" fi INSTALL=${INSTALL-cp} INSTALL_PROGRAM=${INSTALL_PROGRAM-'$(INSTALL)'} INSTALL_DATA=${INSTALL_DATA-'$(INSTALL)'} echo checking for AIX cat < conftest.c #ifdef _AIX yes #endif EOF eval "$CPP $DEFS conftest.c > conftest.out 2>&1" if egrep "yes" conftest.out >/dev/null 2>&1; then DEFS="$DEFS -D_ALL_SOURCE=1" fi rm -f conftest* echo checking for minix/config.h cat < conftest.c #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then MINIX=1 fi rm -f conftest* # The Minix shell can't assign to the same variable on the same line! if test -n "$MINIX"; then DEFS="$DEFS -D_POSIX_SOURCE=1" DEFS="$DEFS -D_POSIX_1_SOURCE=2" DEFS="$DEFS -D_MINIX=1" fi echo checking for POSIXized ISC if test -d /etc/conf/kconfig.d && grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1 then ISC=1 # If later tests want to check for ISC. DEFS="$DEFS -D_POSIX_SOURCE=1" if test -n "$GCC"; then CC="$CC -posix" else CC="$CC -Xp" fi fi echo checking for sys/ptem.h cat < conftest.c #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then DEFS="$DEFS -DUSGr3=1" fi rm -f conftest* echo checking for ANSI C header files cat < conftest.c #include #include #include #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then DEFS="$DEFS -DSTDC_HEADERS=1" fi rm -f conftest* echo checking for unistd.h cat < conftest.c #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then DEFS="$DEFS -DHAVE_UNISTD_H=1" fi rm -f conftest* echo checking for BSD string and memory functions echo "#include main() { exit(0); } t() { rindex(0, 0); bzero(0, 0); }" > conftest.c if eval $compile; then : else DEFS="$DEFS -DUSG=1" fi rm -f conftest* echo checking for alloca.h cat < conftest.c #include EOF err=`eval "$CPP $DEFS conftest.c 2>&1 >/dev/null"` if test -z "$err"; then DEFS="$DEFS -DHAVE_ALLOCA_H=1" fi rm -f conftest* decl="#ifdef __GNUC__ #define alloca __builtin_alloca #else #if HAVE_ALLOCA_H #include #else #ifdef _AIX #pragma alloca #else char *alloca (); #endif #endif #endif " echo checking for alloca echo "$decl main() { exit(0); } t() { char *p = (char *) alloca(1); }" > conftest.c if eval $compile; then : else alloca_missing=1 fi rm -f conftest* if test -n "$alloca_missing"; then SAVELIBS="$LIBS" # Maybe alloca is in a different library. if test -f /usr/ucblib/libucb.a; then LIBS="$LIBS -L/usr/ucblib -lucb" trylib=-lucb # SVR4 elif test -f /lib/libPW.a; then LIBS="$LIBS -lPW" trylib=-lPW # SVR2 and SVR3 fi if test -n "$trylib"; then alloca_missing= echo checking for alloca in $trylib echo "$decl main() { exit(0); } t() { char *p = (char *) alloca(1); }" > conftest.c if eval $compile; then : else alloca_missing=1 fi rm -f conftest* fi if test -n "$alloca_missing"; then LIBS="$SAVELIBS" ALLOCA=alloca.o fi fi if test -n "$prefix"; then test -z "$exec_prefix" && exec_prefix='$(prefix)' prsub="s,^prefix[ ]*=.*$,prefix = $prefix," fi if test -n "$exec_prefix"; then prsub="$prsub s,^exec_prefix[ ]*=.*$,exec_prefix = $exec_prefix," fi trap 'rm -f config.status; exit 1' 1 3 15 echo creating config.status rm -f config.status cat < config.status #!/bin/sh # Generated automatically by configure. # Run this file to recreate the current configuration. trap 'rm -f Makefile; exit 1' 1 3 15 CC='$CC' CPP='$CPP' INSTALL='$INSTALL' INSTALL_PROGRAM='$INSTALL_PROGRAM' INSTALL_DATA='$INSTALL_DATA' ALLOCA='$ALLOCA' LIBS='$LIBS' srcdir='$srcdir' DEFS='$DEFS' prefix='$prefix' exec_prefix='$exec_prefix' prsub='$prsub' vpsub='$vpsub' EOF cat <<\EOF >> config.status top_srcdir=$srcdir for file in Makefile; do srcdir=$top_srcdir # Remove last slash and all that follows it. Not all systems have dirname. dir=`echo $file|sed 's,/[^/][^/]*$,,'` if test "$dir" != "$file"; then test "$top_srcdir" != . && srcdir=$top_srcdir/$dir test ! -d $dir && mkdir $dir fi echo creating $file rm -f $file echo "# Generated automatically from `basename $file`.in by configure." > $file sed -e " $vpsub $prsub s,@CC@,$CC, s,@CPP@,$CPP, s,@INSTALL@,$INSTALL, s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM, s,@INSTALL_DATA@,$INSTALL_DATA, s,@ALLOCA@,$ALLOCA, s,@LIBS@,$LIBS, s,@srcdir@,$srcdir, s,@DEFS@,$DEFS," $top_srcdir/${file}.in >> $file done EOF chmod +x config.status test -n "$no_create" || ./config.status texinfo-2.15/C/info.c0000644000175000017500000032460612561752005011652 0ustar gg/* info -- a stand-alone Info program. Copyright (C) 1987, 1991 Free Software Foundation, Inc. This file is part of GNU Info. GNU Info is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the GNU Emacs General Public License for full details. Everyone is granted permission to copy, modify and redistribute GNU Info, but only under the conditions described in the GNU Emacs General Public License. A copy of this license is supposed to have been given to you along with GNU Emacs so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ /* This is GNU Info: Version 1.44 (Change "major_version" and "minor_version" below.) Fri Feb 7 1992 */ #include #include #include #include #include #include #if !defined (errno) extern int errno; #endif /* !errno */ #include #include "getopt.h" #if defined (USG) struct passwd *getpwnam (); # include # include # include # if defined (USGr3) # if !defined (M_XENIX) # include # include # undef TIOCGETC # else /* M_XENIX */ # define tchars tc # include # endif /* M_XENIX */ # endif /* USGr3 */ # define bcopy(source, dest, count) memcpy(dest, source, count) char *index(s,c) char *s; { char *strchr(); return strchr(s,c); } char *rindex(s,c) char *s; { char *strrchr(); return strrchr(s,c); } #else /* !USG */ # include # include # include #endif /* USG */ #if !defined (DEFAULT_INFOPATH) # define DEFAULT_INFOPATH \ ".:/usr/gnu/info:/usr/local/emacs/info:/usr/local/lib/emacs/info" #endif /* !DEFAULT_INFOPATH */ typedef struct nodeinfo { char *filename; char *nodename; int pagetop; int nodetop; struct nodeinfo *next; } NODEINFO; typedef struct indirectinfo { char *filename; int first_byte; } INDIRECT_INFO; typedef int Function (); #define VOID_SIGHANDLER #if defined (VOID_SIGHANDLER) # define SigHandler void #else # define SigHandler int #endif /* !VOID_SIGHANDLER */ #define barf(msg) fprintf(stderr, "%s\n", msg) /* Some character stuff. */ #define control_character_threshold 0x020 /* smaller than this is control */ #define meta_character_threshold 0x07f /* larger than this is Meta. */ #define control_character_bit 0x40 /* 0x000000, must be off. */ #define meta_character_bit 0x080 /* x0000000, must be on. */ #define info_separator_char '\037' #define start_of_node_string "\037" #ifdef CTRL #undef CTRL #endif #define CTRL(c) ((c) & (~control_character_bit)) #define META(c) ((c) | meta_character_bit) #define UNMETA(c) ((c) & (~meta_character_bit)) #define UNCTRL(c) to_upper(((c)|control_character_bit)) #ifndef to_upper #define to_upper(c) (((c) < 'a' || (c) > 'z') ? (c) : (c) - 32) #define to_lower(c) (((c) < 'A' || (c) > 'Z') ? (c) : (c) + 32) #endif #define CTRL_P(c) ((unsigned char) (c) < control_character_threshold) #define META_P(c) ((unsigned char) (c) > meta_character_threshold) #define NEWLINE '\n' #define RETURN CTRL('M') #define DELETE 0x07f #define TAB '\t' #define ABORT_CHAR CTRL('G') #define PAGE CTRL('L') #define SPACE 0x020 #define ESC CTRL('[') #define control_display_prefix '^' #define TAG_TABLE_END_STRING "\037\nEND TAG TABLE" #define TAG_TABLE_BEG_STRING "\nTAG TABLE:\n" #define NODE_ID "Node:" #define NNODENAME 4 /* Default amount to grow nodename list by. */ #define FILENAME_LEN 256 #define NODENAME_LEN 256 #define STRING_SIZE 256 #define nodeend_sequence "\n\037" #define whitespace(c) ((c) == ' ' || (c) == '\t') #define cr_whitespace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n') /* All right, some windows stuff. */ typedef struct { /* Absolute x and y coordinates for usable portion of this window. */ int left, top, right, bottom; /* Absolute cursor position in this window. */ int ch, cv; } WINDOW; typedef struct _wind_list { int left, top, right, bottom; int ch, cv; struct _wind_list *next_window; } WINDOW_LIST; WINDOW the_window = {0, 0, 80, 24, 0, 0}; WINDOW_LIST *window_stack = (WINDOW_LIST *)NULL; WINDOW terminal_window = {0, 0, 80, 24, 0, 0}; /* Not really extern, but defined later in this file. */ extern WINDOW echo_area; void *xmalloc (), *xrealloc (); char *getenv (), *next_info_file (), *opsys_filename (); int build_menu (), find_menu_node (); void swap_filestack (), pop_filestack (); /* A crock, this should be done in a different way. */ #define MAX_INDIRECT_FILES 100 /* The info history list. */ NODEINFO *Info_History = NULL; /* ?Can't have more than xx files in the indirect list? */ INDIRECT_INFO indirect_list[MAX_INDIRECT_FILES]; /* The filename of the currently loaded info file. */ char current_info_file[FILENAME_LEN]; /* The nodename of the node the user is looking at. */ char current_info_node[NODENAME_LEN]; /* The last file actually loaded. Not the same as current info file. */ char last_loaded_info_file[FILENAME_LEN]; /* Offsets in info_file of top and bottom of current_info_node. */ int nodetop, nodebot; /* Number of lines in this node. */ int nodelines; /* Buffer for the info file. */ char *info_file = NULL; /* Length of the above buffer. */ int info_buffer_len; /* Pointer to the start of a tag table, or NULL to show none. */ char *tag_table = NULL; /* Length of the above buffer. */ int tag_buffer_len; /* Non-zero means that the tag table is indirect. */ int indirect = 0; int indirect_top; /* Offset in the buffer of the current pagetop. */ int pagetop; /* Offset in the buffer of the last displayed character. */ int pagebot = 0; /* If non-NULL, this is a colon separated list of directories to search for a specific info file. The user places this variable into his or her environment. */ char *infopath = NULL; /* If filled, the name of a file to write to. */ char dumpfile[FILENAME_LEN] = ""; /* This is the command to print a node. A default value is compiled in, or it can be found from the environment as $INFO_PRINT_COMMAND. */ char *print_command; /* Non-zero means forst redisplay before prompt for the next command. */ int window_bashed = 0; /* **************************************************************** */ /* */ /* Getting Started. */ /* */ /* **************************************************************** */ /* Begin the Info session. */ /* Global is on until we are out of trouble. */ int totally_inhibit_errors = 1; /* Non-zero means print version info only. */ int version_flag = 0; /* The major and minor versions of Info. */ int major_version = 1; int minor_version = 44; struct option long_options[] = { { "directory", 1, 0, 'd' }, { "node", 1, 0, 'n' }, { "file", 1, 0, 'f' }, { "output", 1, 0, 'o' }, { "version", 0, &version_flag, 1 }, {NULL, 0, NULL, 0} }; #define savestring(x) (char *) strcpy ((char *) xmalloc (1 + strlen (x)), (x)) main (argc, argv) int argc; char **argv; { int c, ind, no_such_node = 0; char filename[FILENAME_LEN]; char *nodename; char **nodenames; int nodenames_size, nodenames_index; char *ptr, *env_infopath, *env_print_command; nodenames_index = 0; nodenames = (char **) xmalloc ((nodenames_size = 1) * sizeof (char *)); nodenames[0] = (char *)NULL; env_infopath = getenv ("INFOPATH"); env_print_command = getenv ("INFO_PRINT_COMMAND"); filename[0] = '\0'; if (env_infopath && *env_infopath) infopath = savestring (env_infopath); else infopath = savestring (DEFAULT_INFOPATH); if (env_print_command && *env_print_command) print_command = savestring (env_print_command); else print_command = savestring (INFO_PRINT_COMMAND); while ((c = getopt_long (argc, argv, "d:n:f:o:", long_options, &ind)) != EOF) { if (c == 0 && long_options[ind].flag == 0) c = long_options[ind].val; switch (c) { case 0: break; case 'd': free (infopath); infopath = savestring (optarg); break; case 'n': if (nodenames_index + 2 > nodenames_size) nodenames = (char **) xrealloc (nodenames, (nodenames_size += 10) * sizeof (char *)); nodenames[nodenames_index++] = optarg; nodenames[nodenames_index] = (char *)NULL; break; case 'f': strncpy (filename, optarg, FILENAME_LEN); break; case 'o': strncpy (dumpfile, optarg, FILENAME_LEN); break; default: usage (); } } /* If the user specified `--version' then simply show the version info at this time and exit. */ if (version_flag) { show_version_info (stdout); exit (0); } /* Okay, flags are parsed. Get possible Info menuname. */ if (*filename && (ptr = rindex (filename,'/')) != NULL ) { /* Add filename's directory to path. */ char *temp; temp = (char *) xmalloc (2 + strlen (filename) + strlen (infopath)); strncpy (temp, filename, ptr - filename); sprintf (temp + (ptr - filename), ":%s", infopath); free (infopath); infopath = temp; } /* Start with DIR or whatever was specified. */ if (!get_node (filename, (nodenames[0] == NULL) ? "Top" : nodenames[0], 0)) { if (filename[0]) { fprintf (stderr, "Try just plain `info'.\n"); exit (1); } else { strcpy (filename, "DIR"); if (!get_node ((char *)NULL, (char *)NULL, 1)) { fprintf (stderr, "%s: Cannot find \"%s\", anywhere along the search ", argv[0], filename); fprintf (stderr, "path of\n\"%s\".\n", infopath); exit (1); } } } totally_inhibit_errors = 0; for (ind = 1 ; ind < nodenames_index ; ind++) get_node (filename, nodenames[ind], 0); nodename = nodenames[nodenames_index > 0 ? nodenames_index - 1 : 0]; if (!nodename) { nodename = (char *) xmalloc (NODENAME_LEN); *nodename = '\0'; } if (optind != argc) { while (optind != argc) { if (!build_menu ()) { display_error ("There is no menu in node \"%s\"", current_info_node ); no_such_node++; break; } else if (!find_menu_node (argv[optind], nodename)) { display_error ("There is no menu entry for \"%s\" in node \"%s\"", argv[optind], nodename ); no_such_node++; break; } else if (!get_node ((char *)NULL, nodename, 0)) { no_such_node++; break; } else { #if 1 /* RMS says not to type this stuff out because he expects programs to call Info instead of interactive users. */ printf ("%s.. ",argv[optind]); fflush (stdout); #endif optind++; } } } /* If we are outputting to a file, and the node was not found, exit. */ if (no_such_node && dumpfile[0]) exit (1); else begin_info_session (); exit (0); } usage () { fprintf (stderr,"%s\n%s\n%s\n%s\n", "Usage: info [-d dir-path] [-f info-file] [-n node-name -n node-name ...]", " [-o output-file] [--directory dir-path] [--file info-file]", " [--node node-name --node node-name ...] [--version]", " [--output output-file] [menu-selection...]"); exit (1); } /* Print the version of info to standard output. */ show_version_info (stream) FILE *stream; { fprintf (stream, "GNU Info version %d.%d\n", major_version, minor_version); fflush (stream); } #if defined (SIGTSTP) Function *old_tstp; Function *old_ttou, *old_ttin; #endif /* SIGTSTP */ #if defined (SIGWINCH) Function *old_winch; #endif /* SIGWINCH */ /* Start using Info. */ begin_info_session () { int info_signal_handler (); /* If the user just wants to dump the node, then do that. */ if (dumpfile[0]) { dump_current_node (dumpfile); exit (0); } init_terminal_io (); /* Install handlers for restoring/breaking the screen. */ install_signals (); new_echo_area (); print_string ("Welcome to Info! Type \"?\" for help. "); close_echo_area (); toploop (); goto_xy (the_window.left, the_window.bottom + 1); restore_io (); } /* What to do before processing a stop signal. */ before_stop_signal () { restore_io (); } /* What to do after processing a stop signal. */ after_stop_signal () { clear_screen (); display_page (); goto_xy (the_window.ch, the_window.cv); opsys_init_terminal (); } /* Do the right thing with this signal. */ SigHandler info_signal_handler (sig) int sig; { switch (sig) { #if defined (SIGTSTP) case SIGTSTP: case SIGTTOU: case SIGTTIN: before_stop_signal (); signal (sig, SIG_DFL); #if !defined (USG) sigsetmask (sigblock (0) & ~sigmask (sig)); #endif /* !USG */ kill (getpid (), sig); after_stop_signal (); signal (sig, info_signal_handler); break; #endif /* SIGTSTP */ #if defined (SIGWINCH) case SIGWINCH: /* Window has changed. Get the size of the new window, and rebuild our window chain. */ { int display_page (); extern char *widest_line; extern WINDOW terminal_window; extern WINDOW_LIST *window_stack; extern int terminal_rows, terminal_columns; int delta_width, delta_height, right, bottom; right = get_terminal_columns (); bottom = get_terminal_rows (); delta_width = right - terminal_columns; delta_height = bottom - terminal_rows; terminal_columns = right; terminal_rows = bottom; /* Save current window, whatever it is. */ push_window (); /* Change the value of the widest_line. */ free (widest_line); widest_line = (char *) xmalloc (right); /* Make the new window. Map over all windows in window list. */ { WINDOW_LIST *wind = window_stack; extern WINDOW modeline_window; while (wind != (WINDOW_LIST *)NULL) { adjust_wind ((WINDOW *)wind, delta_width, delta_height); wind = wind->next_window; } /* Adjust the other windows that we know about. */ adjust_wind (&terminal_window, delta_width, delta_height); adjust_wind (&echo_area, delta_width, delta_height); adjust_wind (&modeline_window, delta_width, delta_height); } /* Clear and redisplay the entire terminal window. */ set_window (&terminal_window); clear_screen (); /* Redisplay the contents of the screen. */ with_output_to_window (&terminal_window, display_page); /* Get back the current window. */ pop_window (); } break; #endif /* SIGWINCH */ case SIGINT: restore_io (); exit (1); break; } } install_signals () { #if defined (SIGTSTP) old_tstp = (Function *) signal (SIGTSTP, info_signal_handler); old_ttou = (Function *) signal (SIGTTOU, info_signal_handler); old_ttin = (Function *) signal (SIGTTIN, info_signal_handler); #endif /* SIGTSTP */ #if defined (SIGWINCH) old_winch = (Function *) signal (SIGWINCH, info_signal_handler); #endif /* SIGWINCH */ signal (SIGINT, info_signal_handler); } adjust_wind (wind, delta_width, delta_height) WINDOW *wind; int delta_width, delta_height; { wind->right += delta_width; wind->bottom += delta_height; wind->ch += delta_width; wind->cv += delta_height; /* Ugly hack to fix busted windows code. If the window we are adjusting already has a TOP offset, then adjust that also. */ if (wind->top) wind->top += delta_height; } /* **************************************************************** */ /* */ /* Completing Things */ /* */ /* **************************************************************** */ typedef struct completion_entry { char *identifier; char *data; struct completion_entry *next; } COMP_ENTRY; /* The linked list of COMP_ENTRY structures that you create. */ COMP_ENTRY *completion_list = (COMP_ENTRY *) NULL; /* The vector of COMP_ENTRY pointers that COMPLETE returns. */ COMP_ENTRY **completions = NULL; /* The number of elements in the above vector. */ int completion_count; /* Initial size of COMPLETIONS array. */ #define INITIAL_COMPLETIONS_CORE_SIZE 200 /* Current size of the completion array in core. */ int completions_core_size = 0; /* Ease the typing task. Another name for the I'th IDENTIFIER of COMPLETIONS. */ #define completion_id(i) ((completions[(i)])->identifier) /* The number of completions that can be present before the help function starts asking you about whether it should print them all or not. */ int completion_query_threshold = 100; free_completion_list () { COMP_ENTRY *temp; while (completion_list) { temp = completion_list; if (completion_list->identifier) free (completion_list->identifier); if (completion_list->data) free (completion_list->data); completion_list = completion_list->next; free (temp); } } /* Add a single completion to COMPLETION_LIST. IDENTIFIER is the string that the user should type. DATA should just be a pointer to some random data that you wish to have associated with the identifier, but I'm too stupid for that, so it must be a string as well. This allocates the space for the strings so you don't necessarily have to. */ add_completion (identifier, data) char *identifier, *data; { COMP_ENTRY *temp = (COMP_ENTRY *) xmalloc (sizeof (COMP_ENTRY)); temp->identifier = (char *) xmalloc (strlen (identifier) + 1); strcpy (temp->identifier, identifier); temp->data = (char *) xmalloc (strlen (data) + 1); strcpy (temp->data, data); temp->next = completion_list; completion_list = temp; } /* Function for reading a line. Supports completion on COMPLETION_LIST if you pass COMPLETING as non-zero. Prompt is either a prompt or NULL, LINE is the place to store the characters that are read. LINE may start out already containing some characters; if so, they are printed. MAXCHARS tells how many characters can fit in the buffer at LINE. readline () returns zero if the user types the abort character. LINE is returned with a '\0' at the end, not a '\n'. */ int readline (prompt, line, maxchars, completing) char *prompt, *line; int maxchars; int completing; { int character; int readline_ch, readline_cv; int current_len = strlen (line); int just_completed = 0; /* Have we just done a completion? */ int meta_flag = 0; new_echo_area (); if (prompt) print_string ("%s", prompt); readline_ch = the_window.ch; readline_cv = the_window.cv; print_string ("%s", line); while (1) { line[current_len] = '\0'; goto_xy (readline_ch, readline_cv); print_string ("%s", line); clear_eol (); if (just_completed) just_completed--; character = blink_cursor (); if (meta_flag) { character = META (character); meta_flag = 0; } if (META_P (character)) character = META (to_upper (UNMETA (character))); switch (character) { case EOF: character = '\n'; case ESC: meta_flag++; break; case META (DELETE): case CTRL ('W'): while (current_len && line[current_len] == SPACE) current_len--; if (!current_len) break; while (current_len && line[current_len] != SPACE) current_len--; break; case CTRL ('U'): current_len = 0; break; case '\b': case 0x07f: if (current_len) current_len--; else ding (); break; case '\n': case '\r': if (completing) { extern int completion_count; try_complete (line); if (completion_count >= 1) { close_echo_area (); return (1); } else { current_len = strlen (line); break; } } else { close_echo_area (); return (1); } case ABORT_CHAR: ding (); if (current_len) { current_len = 0; } else { close_echo_area (); clear_echo_area (); return (0); } break; case ' ': case '\t': case '?': if (completing) { extern int completion_count; if (character == '?' || just_completed) { help_possible_completions (line); break; } else { char temp_line[NODENAME_LEN]; strcpy (temp_line, line); try_complete (line); just_completed = 2; if (completion_count != 1 && character == SPACE) { if (strcmp (temp_line, line) == 0) { line[current_len] = SPACE; line[current_len + 1] = '\0'; strcpy (temp_line, line); try_complete (line); if (completion_count == 0) { line[current_len] = '\0'; ding (); } } } current_len = strlen (line); if (completion_count == 0) ding (); break; } } /* Do *NOT* put anything in-between the completing cases and the default: case. No. Because the SPC, TAB and `?' get treated as normal characters by falling through the "if (completing)" test above. */ default: if (!CTRL_P (character) && !META_P (character) && current_len < maxchars) line[current_len++] = character; else ding (); } } } /* Initialize whatever the completer is using. */ init_completer () { if (completions_core_size != INITIAL_COMPLETIONS_CORE_SIZE) { if (completions) free (completions); completions = (COMP_ENTRY **) xmalloc ((sizeof (COMP_ENTRY *)) * (completions_core_size = INITIAL_COMPLETIONS_CORE_SIZE)); } completion_count = 0; } /* Reverse the completion list passed in LIST, and return a pointer to the new head. */ COMP_ENTRY * reverse_list (list) COMP_ENTRY *list; { COMP_ENTRY *next; COMP_ENTRY *prev = (COMP_ENTRY *) NULL; while (list) { next = list->next; list->next = prev; prev = list; list = next; } return (prev); } /* Remember the possible completion passed in POINTER on the completions list. */ remember_completion (pointer) COMP_ENTRY *pointer; { if (completion_count == completions_core_size) { COMP_ENTRY **temp = (COMP_ENTRY **) realloc (completions, ((sizeof (COMP_ENTRY *)) * (completions_core_size += INITIAL_COMPLETIONS_CORE_SIZE))); if (!temp) { display_error ("Too many completions (~d)! Out of core!", completion_count); return; } else completions = temp; } completions[completion_count++] = pointer; } /* Complete TEXT from identifiers in LIST. Place the resultant completions in COMPLETIONS, and the number of completions in COMPLETION_COUNT. Modify TEXT to contain the least common denominator of all the completions found. */ int complete (text, list) char *text; COMP_ENTRY *list; { int low_match, i, idx; int string_length = strlen (text); init_completer (); low_match = 100000; /* Some large number. */ while (list) { if (strnicmp (text, list->identifier, string_length) == 0) remember_completion (list); list = list->next; } if (completion_count == 0) return (0); if (completion_count == 1) { /* One completion */ strcpy (text, completion_id (0)); return (1); } /* Else find the least common denominator */ idx = 1; while (idx < completion_count) { int c1, c2; for (i = 0; (c1 = to_lower (completion_id (idx - 1)[i])) && (c2 = to_lower (completion_id (idx)[i])); i++) if (c1 != c2) break; if (low_match > i) low_match = i; idx++; } strncpy (text, completion_id (0), low_match); text[low_match] = '\0'; return (1); } /* Complete TEXT from the completion structures in COMPLETION_LIST. */ int try_complete (text) char *text; { return (complete (text, completion_list)); } /* The function that prints out the possible completions. */ help_possible_completions (text) char *text; { char temp_string[2000]; goto_xy (the_window.left, the_window.top); strcpy (temp_string, text); try_complete (temp_string); open_typeout (); if (completion_count == 0) { print_string ("There are no possible completions.\n"); goto print_done; } if (completion_count == 1) { print_string ("The only possible completion of what you have typed is:\n\n"); print_string ("%s", completion_id(0)); goto print_done; } if (completion_count >= completion_query_threshold) { print_string ("\nThere are %d completions. Do you really want to see them all", completion_count); if (!get_y_or_n_p ()) return; } print_string ("\nThe %d completions of what you have typed are:\n\n", completion_count); { int idx = 0; int counter = 0; int columns = (the_window.right - the_window.left) / 30; while (idx < completion_count) { if (counter == columns) { charout ('\n'); counter = 0; } indent_to (counter * 30); print_string ("%s", completion_id (idx)); counter++; idx++; } } print_done: print_string ("\n\n-----------------\n"); close_typeout (); } /* Return the next file that should be searched, or NULL if we are at the end of the info file. If the FILE argument is provided, begin the search there, if REWIND is non-zero start the search at the beginning of the list. The list is the one built by an indirect tag table, on the supposition that those files form a logical set to search if we are in one of them. If no such list is current (either it doesn't exist, or FILE isn't on it) the search list is set to be last_loaded_info_file */ char * next_info_file (file, rewind) char *file; /* file to set `next' to. May be NULL. */ int rewind; /* should I rewind the file list? */ { static int index = -1; if (file != NULL) { char *ptr = rindex (file,'/'); if (ptr != NULL) file = ptr + 1; for (index = 0; index < MAX_INDIRECT_FILES && indirect_list[index].filename != (char *)NULL; index++) { if (strcmp (file, indirect_list[index].filename) == 0) return (file); } /* OK, we are not on the current indirect_list. This means that we have switched to another node that has no indirect list, so forget the old one. */ for (index = 0; index < MAX_INDIRECT_FILES && indirect_list[index].filename != (char *)NULL; index++) { free (indirect_list[index].filename); indirect_list[index].filename = (char *)NULL; } return (indirect_list[0].filename = savestring (file)); } else if (rewind) { index = 0; if (indirect_list[0].filename == (char *)NULL) indirect_list[0].filename = savestring (last_loaded_info_file); } else index++; if (index < MAX_INDIRECT_FILES && indirect_list[index].filename != (char *)NULL) return (indirect_list[index].filename); index = -1; return (NULL); } /* **************************************************************** */ /* */ /* Getting Nodes */ /* */ /* **************************************************************** */ /* A node name looks like: Node: nodename with spaces but not a comma, or Node: (filename-containing-node)node-within-file or Node: (filename) The latter case implies a nodename of "Top". All files are supposed to have one. Lastly, the nodename specified could be "*", which specifies the entire file. */ /* Return the directory portion of FILENAME, i.e., everything before the last slash. */ static char * file_directory (filename) char *filename; { register char *scan; register int length; char *result; scan = filename; while (*scan++ != '\0'); while (1) { if (scan == filename) break; if ((*--scan) == '/') { scan++; break; } } length = scan - filename; result = (char *) xmalloc (length + 1); strncpy (result, filename, length); result[length] = '\0'; return (result); } /* Given FILENAME and DIRECTORY return a newly allocated string which is either the two concatenated, or simply FILENAME if it is absolute already. */ static char * file_absolutize (filename, directory) char *filename, *directory; { register int filename_len, directory_len; char *result; if (filename[0] == '/') return (savestring (filename)); filename_len = strlen (filename); directory_len = strlen (directory); result = (char *) xmalloc (directory_len + filename_len + 1); strcpy (result, directory); strcat (result, filename); return (result); } /* Load FILENAME. If REMEMBER_NAME is non-zero, then remember the loaded filename in CURRENT_INFO_FILE. In either case, remember the name of this file in LAST_LOADED_INFO_FILE. */ int get_info_file (filename, remember_name) char *filename; int remember_name; { FILE *input_stream; struct stat file_info; int pointer, result; char tempname[FILENAME_LEN]; /* Get real filename. */ strcpy (tempname, opsys_filename (filename)); /* If the file doesn't exist, try again with the name in lower case. */ result = stat (tempname, &file_info); if (result < 0) { register int i; char *lowered_name; lowered_name = (char *)xmalloc (1 + strlen (filename)); for (i = 0; lowered_name[i] = to_lower (filename[i]); i++) ; strcpy (tempname, opsys_filename (lowered_name)); result = stat (tempname, &file_info); } /* See if this file is the last loaded one. */ if (!result && (strcmp (last_loaded_info_file, tempname) == 0)) return (1); /* Now try to open the file. */ if (result || (input_stream = fopen (tempname, "r")) == NULL) { file_error (tempname); return (0); } /* If we already have a file loaded, then free it first. */ if (info_file) { free (info_file); if (!indirect) { /* Then the tag table is also no longer valid. */ tag_table = (char *) NULL; } } /* Read the contents of the file into a new buffer. */ info_file = (char *) xmalloc (info_buffer_len = file_info.st_size); fread (info_file, 1, info_buffer_len, input_stream); fclose (input_stream); strcpy (last_loaded_info_file, tempname); if (remember_name) { strcpy (current_info_file, tempname); if (indirect) { int idx; indirect = 0; free (tag_table); } } else return (1); /* Force redisplay, since we are looking at a new file. */ window_bashed = 1; /* The file has been read, and we don't know anything about it. Find out if it contains a tag table. */ tag_table = NULL; /* assume none. */ indirect = 0; tag_buffer_len = 0; set_search_constraints (info_file, info_buffer_len); /* Go to the last few lines in the file. */ pointer = back_lines (8, info_buffer_len); pointer = search_forward (TAG_TABLE_END_STRING, pointer); if (pointer > -1) { /* Then there is a tag table. Find the start of it, and remember that. */ pointer = search_backward (TAG_TABLE_BEG_STRING, pointer); /* Handle error for malformed info file. */ if (pointer < 0) display_error ("Start of tag table not found!"); else { /* No problem. If this file is an indirect file, then the contents of the tag table must remain in RAM the entire time. Otherwise, we can flush the tag table with the file when the file is flushed. So, if indirect, remember that, and copy the table to another place.*/ int indirect_check = forward_lines (2, pointer); tag_table = info_file + pointer; tag_buffer_len = info_buffer_len - pointer; /* Shorten the search constraints. */ info_buffer_len = pointer; if (looking_at ("(Indirect)\n", indirect_check)) { /* We have to find the start of the indirect file's information. */ tag_table = (char *) xmalloc (tag_buffer_len); bcopy (&info_file[indirect_check], tag_table, tag_buffer_len); /* Find the list of filenames. */ indirect_top = search_backward ("Indirect:\n", indirect_check); if (indirect_top < 0) { free (tag_table); tag_table = (char *) NULL; display_error ("Start of INDIRECT tag table not found!"); return (0); } /* Remember the filenames, and their byte offsets. */ { /* Index into the filename/offsets array. */ int idx, temp_first_byte; char temp_filename[FILENAME_LEN]; char *directory = file_directory (tempname); info_buffer_len = indirect_top; /* For each line, scan the info into globals. Then save the information in the INDIRECT_INFO structure. */ for (idx = 0; idx < MAX_INDIRECT_FILES && indirect_list[idx].filename != (char *) NULL; idx++) { free (indirect_list[idx].filename); indirect_list[idx].filename = (char *) NULL; } for (idx = 0;info_file[indirect_top] != info_separator_char && idx < MAX_INDIRECT_FILES;) { indirect_top = forward_lines (1, indirect_top); if (info_file[indirect_top] == info_separator_char) break; /* Ignore blank lines. */ if (info_file[indirect_top] == '\n') continue; sscanf (&info_file[indirect_top], "%s%d", temp_filename, &temp_first_byte); if (strlen (temp_filename)) { temp_filename[strlen (temp_filename) - 1] = '\0'; indirect_list[idx].filename = file_absolutize (temp_filename, directory); indirect_list[idx].first_byte = temp_first_byte; idx++; } } free (directory); /* Terminate the table. */ if (idx == MAX_INDIRECT_FILES) { display_error ("Sorry, the INDIRECT file array isn't large enough."); idx--; } indirect_list[idx].filename = (char *) NULL; } indirect = 1; } else { ; } } } return (1); } /* Make current_info_node be NODENAME. This could involve loading a file, etc. POPPING is non-zero if we got here because we are popping one level. */ int get_node (filename, nodename, popping) char *nodename, *filename; int popping; { int pointer; char internal_filename[FILENAME_LEN]; char internal_nodename[NODENAME_LEN]; if (nodename && *nodename) { /* Maybe nodename looks like: (filename)nodename, or worse: (filename). If so, extract the stuff out. */ if (*nodename == '(') { int temp = 1, temp1 = 0; char character; filename = internal_filename; while ((character = nodename[temp]) && character != ')') { filename[temp - 1] = character; temp++; } filename[temp - 1] = '\0'; temp++; /* skip the closing ')' */ /* We have the filename now. The nodename follows. */ internal_nodename[0] = '\0'; while (nodename[temp] == ' ' || nodename[temp] == '\t' || nodename[temp] == '\n') temp++; if (nodename[temp]) while (internal_nodename[temp1++] = nodename[temp++]) ; else if (*filename != '\0') strcpy (internal_nodename,"Top"); nodename = internal_nodename; } } if (!popping) push_node (current_info_file, current_info_node, pagetop, nodetop); if (!nodename || !*nodename) { nodename = internal_nodename; strcpy (nodename, "Top"); } if (!filename || !*filename) { filename = internal_filename; strcpy (filename, current_info_file); } if (!*filename) strcpy (filename, "DIR"); if (!get_info_file (filename, 1)) goto node_not_found; if (strcmp (nodename, "*") == 0) { /* The "node" that we want is the entire file. */ pointer = 0; goto found_node; } /* If we are using a tag table, see if we can find the nodename in it. */ if (tag_table) { pointer = find_node_in_tag_table (nodename, 0); if (pointer < 1) { int pop_node (); /* The search through the tag table failed. Maybe we should try searching the buffer? Nahh, just barf. */ node_not_found: if (popping) return (0); /* Second time through. */ { int save_inhibit = totally_inhibit_errors; totally_inhibit_errors = 0; display_error ("Sorry, unable to find the node \"%s\" in the file \"%s\".", nodename, filename); totally_inhibit_errors = save_inhibit; } current_info_file[0] = '\0'; current_info_node[0] = '\0'; last_loaded_info_file[0] = '\0'; pop_node (internal_filename, internal_nodename, &nodetop, &pagetop); get_node (internal_filename, internal_nodename, 1); return (0); } /* Otherwise, the desired location is right here. Scarf the position byte. */ while (tag_table[pointer] != '\177') pointer++; sscanf (&tag_table[pointer + 1], "%d", &pointer); /* Okay, we have a position pointer. If this is an indirect file, then we should look through the indirect_list for the first element.first_byte which is larger than this. Then we can load the specified file, and win. */ if (indirect) { /* Find the filename for this node. */ int idx; for (idx = 0; idx < MAX_INDIRECT_FILES && indirect_list[idx].filename != (char *) NULL; idx++) { if (indirect_list[idx].first_byte > pointer) { /* We found it. */ break; } } if (!get_info_file (indirect_list[idx - 1].filename, 1)) goto node_not_found; pointer -= indirect_list[idx - 1].first_byte; /* Here is code to compensate for the header of an indirect file. */ { int tt = find_node_start (0); if (tt > -1) pointer += tt; } } else { /* This tag table is *not* indirect. The filename of the file containing this node is the same as the current file. The line probably looks like: File: info, Node: Checking25796 */ } } else { #if defined (NOTDEF) /* We don't have a tag table. The node can only be found by searching this file in its entirety. */ if (!get_info_file (filename, 1)) return (0); #endif /* NOTDEF */ pointer = 0; } /* Search this file, using pointer as a good guess where to start. */ /* This is the same number that RMS used. It might be right or wrong. */ pointer -= 1000; if (pointer < 0) pointer = 0; pointer = find_node_in_file (nodename, pointer); if (pointer < 0) goto node_not_found; /* We found the node in its file. Remember exciting information. */ found_node: back_lines (0, pointer); nodetop = pagetop = pointer; strcpy (current_info_node, nodename); strcpy (current_info_file, filename); get_node_extent (); return (1); } /* Get the bounds for this node. NODETOP points to the start of the node. Scan forward looking for info_separator_char, and remember that in NODEBOT. */ get_node_extent () { int idx = nodetop; int character; int do_it_till_end = (strcmp (current_info_node, "*") == 0); nodelines = 0; again: while ((idx < info_buffer_len) && ((character = info_file[idx]) != info_separator_char)) { if (character == '\n') nodelines++; idx++; } if (do_it_till_end && idx != info_buffer_len) { idx++; goto again; } nodebot = idx; } /* Locate the start of a node in the current search_buffer. Return the offset to the node start, or minus one. START is the place in the file at where to begin the search. */ find_node_start (start) int start; { return (search_forward (start_of_node_string, start)); } /* Find NODENAME in TAG_TABLE. */ find_node_in_tag_table (nodename, offset) char *nodename; int offset; { int temp; set_search_constraints (tag_table, tag_buffer_len); temp = offset; while (1) { offset = search_forward (NODE_ID, temp); if (offset < 0) return (offset); temp = skip_whitespace (offset + strlen (NODE_ID)); if (strnicmp (tag_table + temp, nodename, strlen (nodename)) == 0) if (*(tag_table + temp + strlen (nodename)) == '\177') return (temp); } } /* Find NODENAME in INFO_FILE. */ find_node_in_file (nodename, offset) char *nodename; int offset; { int temp, last_offset = -1; set_search_constraints (info_file, info_buffer_len); while (1) { offset = find_node_start (offset); if (offset == last_offset) offset = -1; else last_offset = offset; if (offset < 0) return (offset); else temp = forward_lines (1, offset); if (temp == offset) return (-1); /* At last line now, just a node start. */ else offset = temp; temp = string_in_line (NODE_ID, offset); if (temp > -1) { temp = skip_whitespace (temp + strlen (NODE_ID)); if (strnicmp (info_file + temp, nodename, strlen (nodename)) == 0) { int check_exact = *(info_file + temp + strlen (nodename)); if (check_exact == '\t' || check_exact == ',' || check_exact == '.' || check_exact == '\n') return (offset); } } } } /* **************************************************************** */ /* */ /* Dumping and Printing Nodes */ /* */ /* **************************************************************** */ /* Make a temporary filename based on STARTER and the PID of this Info. */ char * make_temp_filename (starter) char *starter; { register int i; char *temp; temp = (char *) xmalloc (strlen (starter) + 10); sprintf (temp, "%s-%d", starter, getpid ()); for (i = 0; temp[i]; i++) if (!isalnum (temp[i])) temp[i] = '-'; return (temp); } /* Delete a file. Print errors if necessary. */ deletefile (filename) char *filename; { if (unlink (filename) != 0) { file_error (filename); return (1); } return (0); } printfile (filename) char *filename; { int length = strlen (print_command) + strlen (filename) + strlen ("\n") + 1; char *command = (char *) xmalloc (length); int error; display_error ("Printing file `%s'...\n", filename); sprintf (command, "%s %s", print_command, filename); error = system (command); if (error) display_error ("Can't invoke `%s'", command); free (command); return (error); } /* Dump the current node into a file named FILENAME. Return 0 if the dump was successful, otherwise, print error and exit. */ dump_current_node (filename) char *filename; { int c, i = nodetop; FILE *output_stream; if (strcmp (filename, "-") == 0) output_stream = stdout; else output_stream = fopen (filename, "w"); if (output_stream == (FILE *) NULL) { file_error (filename); return (1); } while (i < nodebot && i < info_buffer_len) { c = info_file[i]; if (CTRL_P (c) && !(index ("\n\t\f", c))) { putc ('^', output_stream); c = UNCTRL (c); } if (putc (c, output_stream) == EOF) { if (output_stream != stdout) fclose (output_stream); file_error (filename); return (1); } i++; } if (output_stream != stdout) fclose (output_stream); return (0); } /* **************************************************************** */ /* */ /* Toplevel eval loop. */ /* */ /* **************************************************************** */ #define MENU_HEADER "\n* Menu:" #define MENU_ID "\n* " #define FOOTNOTE_HEADER "*Note" /* Number of items that the current menu has. */ int the_menu_size = 0; /* The node that last made a menus completion list. */ char menus_nodename[NODENAME_LEN]; char menus_filename[NODENAME_LEN]; static int search_start = 0; /* The default prompt string for the Follow Reference command. */ char *visible_footnote = (char *)NULL; toploop () { int done, inhibit_display; int command, last_command; int last_pointer, count, new_ypos, last_pagetop; char nodename[NODENAME_LEN]; done = inhibit_display = 0; command = last_command = 0; new_ypos = last_pagetop = -1; while (!done) { if (!inhibit_display && (window_bashed || (pagetop != last_pagetop))) display_page (); inhibit_display = window_bashed = 0; last_pagetop = pagetop; nodename[0] = '\0'; /* Don't display old text in input line. */ last_command = command; if (last_command == 'S') cursor_to (search_start); else goto_xy (echo_area.left, echo_area.top); command = blink_cursor (); clear_echo_area (); if (command == EOF) { done = 1; continue; } command = to_upper (command); switch (command) { case 'D': get_node ((char *) NULL, "(dir)Top", 0); break; case 'H': if ((the_window.bottom - the_window.top) < 24) get_node ((char *) NULL, "(info)Help-Small-Screen", 0); else get_node ((char *) NULL, "(info)Help", 0); break; case 'N': if (!next_node ()) { display_error ("No NEXT for this node!"); inhibit_display = 1; } break; case 'P': if (!prev_node ()) { display_error ("No PREV for this node!"); inhibit_display = 1; } break; case 'U': { int savetop = pagetop; if (!up_node ()) { display_error ("No UP for this node!"); inhibit_display = 1; pagetop = savetop; } break; } case 'M': if (!build_menu ()) { display_error ("No menu in this node!"); inhibit_display = 1; break; } if (!readline ("Menu item: ", nodename, NODENAME_LEN, 1)) { clear_echo_area (); inhibit_display = 1; break; } I_goto_xy (echo_area.left, echo_area.top); if (!find_menu_node (nodename, nodename)) { display_error ("\"%s\" is not a menu item!", nodename); inhibit_display = 1; break; } if (get_node ((char *) NULL, nodename, 0)) clear_echo_area (); break; case 'F': { char footnote[NODENAME_LEN]; if (!build_notes ()) { display_error ("No cross-references in this node!"); inhibit_display = 1; break; } strcpy (footnote, visible_footnote); if (!readline ("Follow reference: ", footnote, NODENAME_LEN, 1)) { inhibit_display = 1; break; } I_goto_xy (echo_area.left, echo_area.top); if (!find_note_node (footnote, nodename)) { display_error ("\"%s\" is not a cross-reference in this node!", footnote); inhibit_display = 1; break; } if (get_node ((char *)NULL, nodename, 0)) clear_echo_area (); break; } case 'L': { char filename[FILENAME_LEN], nodename[NODENAME_LEN]; int ptop, ntop; if (pop_node (filename, nodename, &ntop, &ptop) && get_node (filename, nodename, 1)) { pagetop = ptop; } else inhibit_display = 1; break; } case SPACE: case CTRL ('V'): if (!next_page ()) { display_error ("At last page of this node now!"); inhibit_display = 1; } break; case META ('V'): case DELETE: if (!prev_page ()) { display_error ("At first page of this node now!"); inhibit_display = 1; } break; case 'B': if (pagetop == nodetop) { display_error ("Already at beginning of this node!"); inhibit_display = 1; } else pagetop = nodetop; break; /* I don't want to do this this way, but the documentation clearly states that '6' doesn't work. It states this for a reason, and ours is not to wonder why... */ case '1': case '2': case '3': case '4': case '5': { int item = command - '0'; if (!build_menu ()) { display_error ("No menu in this node!"); inhibit_display = 1; break; } if (item > the_menu_size) { display_error ("There are only %d items in the menu!", the_menu_size); inhibit_display = 1; break; } if (!get_menu (item)) inhibit_display = 1; } break; case 'G': if (!readline ("Goto node: ", nodename, NODENAME_LEN, 0)) { inhibit_display = 1; break; } if (get_node ((char *) NULL, nodename, 0)) clear_echo_area (); break; /* Search from the starting position forward for a string. Select the node containing the desired string. Put the top of the page screen_lines / 2 lines behind it, but not before nodetop. */ case 'S': { int pointer, temp; char prompt[21 + NODENAME_LEN + 1]; static char search_string[NODENAME_LEN] = ""; static char *starting_filename = NULL, *starting_nodename = NULL; static int starting_pagetop = 0; static int wrap_search = 0; sprintf (prompt, "Search for string [%s]: ", search_string); if (!readline (prompt , nodename, NODENAME_LEN, 0)) { inhibit_display = 1; break; } /* If the user defaulted the search string, and the previous command was search, then this is a continuation of the previous search. */ if (((strcmp (nodename, search_string) == 0) || (!*nodename && *search_string)) && (last_command == 'S')) { search_start++; } else { /* Initialize the start of a new search. */ if (starting_filename) free (starting_filename); starting_filename = savestring (last_loaded_info_file); if (starting_nodename) free (starting_nodename); starting_nodename = savestring (nodename ? nodename : ""); starting_pagetop = pagetop; search_start = pagetop; wrap_search = 0; if (*nodename != '\0') strcpy (search_string, nodename); } I_goto_xy (echo_area.left, echo_area.top); { static int pushed = 0; /* How many files are pushed? */ int found_string = 0; /* Did we find our string? */ if (wrap_search) { push_filestack (next_info_file ((char *)NULL, 1), 0); pushed++; search_start = 0; } for (;;) { set_search_constraints (info_file, info_buffer_len); pointer = search_forward (search_string, search_start); if (pointer != -1) { found_string = 1; break; } else { char *next_file; next_file = next_info_file ((char *)NULL, 0); if (next_file != NULL) { if (pushed) { pop_filestack (); pushed--; } push_filestack (next_file, 0); pushed++; search_start = 0; #if 1 I_goto_xy (echo_area.left, echo_area.top); print_string ("Searching file %s...\n", next_file); #endif continue; } if (wrap_search) { display_error ("\"%s\" not found!", search_string); inhibit_display = 1; wrap_search = 0; if (pushed) { pop_filestack (); pushed--; } break; } else { display_error ("Search: End of file"); inhibit_display = 1; wrap_search = 1; if (pushed) { pop_filestack (); pushed--; } break; } } } if (pushed) { swap_filestack (); pop_filestack (); pushed--; } if (!found_string) break; wrap_search = 0; temp = search_backward (start_of_node_string, pointer); if (temp != -1) { search_start = pointer; pointer = forward_lines (1, temp); } if (temp == -1 || !extract_field ("Node:", nodename, pointer)) { display_error ("There doesn't appear to be a nodename for this node."); get_node ((char *)NULL, "*", 0); pagetop = pointer; break; } /* Get the node if it is different than the one already loaded. */ if (strcmp (nodename, starting_nodename) != 0) { free (starting_nodename); starting_nodename = savestring (nodename); if (get_node ((char *) NULL, nodename, 0)) clear_echo_area (); } /* Reset the top of page if necessary. */ { if ((strcmp (last_loaded_info_file, starting_filename) != 0) || (starting_pagetop != pagetop) || (search_start > pagebot)) { pointer = back_lines ((the_window.bottom - the_window.top) / 2, forward_lines (1, search_start)); if (pointer < nodetop) pointer = nodetop; pagetop = pointer; window_bashed = 1; } else inhibit_display = 1; } break; } } case CTRL ('H'): case '?': help_use_info (); last_pagetop = -1; break; case 'Q': done = 1; break; case CTRL ('L'): /* Control-l is redisplay. */ window_bashed = 1; if (last_command == 'S') command = 'S'; break; case '(': /* You *must* be trying to type a complete nodename. */ strcpy (nodename, "("); if (!readline ("Goto node: ", nodename, NODENAME_LEN, 0)) { inhibit_display = 1; clear_echo_area (); break; } I_goto_xy (echo_area.left, echo_area.top); if (get_node ((char *) NULL, nodename, 0)) clear_echo_area (); break; case CTRL ('P'): /* Print the contents of this node on the default printer. We would like to let the user specify the printer, but we don't want to ask her each time which printer to use. Besides, he might not know, which is why it (the user) is in the need of Info. */ { char *tempname = make_temp_filename (current_info_node); if (dump_current_node (tempname) == 0 && printfile (tempname) == 0 && deletefile (tempname) == 0) { display_error ("Printed node. Go pick up your output.\n"); } inhibit_display = 1; free (tempname); } break; default: inhibit_display = 1; display_error ("Unknown command! Press '?' for help."); } } } /* Return the screen column width that the line from START to END requires to display. */ line_length (start, end) int start, end; { int count = 0; while (start < end) { if (info_file[start] == '\t') count += 7 - (count % 8); else if (CTRL_P (info_file[start])) count += 2; else count++; start++; } return (count); } /* Tell this person how to use Info. */ help_use_info () { open_typeout (); clear_screen (); print_string ("\n\ Commands in Info\n\ \n\ h Invoke the Info tutorial.\n\ \n\ Selecting other nodes:\n\ n Move to the \"next\" node of this node.\n\ p Move to the \"previous\" node of this node.\n\ u Move \"up\" from this node.\n\ m Pick menu item specified by name.\n\ Picking a menu item causes another node to be selected.\n\ f Follow a cross reference. Reads name of reference.\n\ l Move to the last node you were at.\n\ d Move to the `directory' node. Equivalent to `gDIR'.\n\ \n\ Moving within a node:\n\ Space Scroll forward a page.\n\ DEL Scroll backward a page.\n\ b Go to the beginning of this node.\n\ \n\ Advanced commands:\n\ q Quit Info.\n\ 1 Pick first item in node's menu.\n\ 2 - 5 Pick second ... fifth item in node's menu.\n\ g Move to node specified by name.\n\ You may include a filename as well, as (FILENAME)NODENAME.\n\ s Search through this Info file for a specified string,\n\ and select the node in which the next occurrence is found.\n\ Ctl-p Print the contents of this node using `%s'.\n\ \n\ Done.\n\n",print_command); close_typeout (); } /* Move to the node specified in the NEXT field. */ int next_node () { char nodename[NODENAME_LEN]; if (!extract_field ("Next:", nodename, nodetop)) return (0); return (get_node ((char *) NULL, nodename, 0)); } /* Move to the node specified in the PREVIOUS field. */ int prev_node () { char nodename[NODENAME_LEN]; if (!extract_field ("Previous:", nodename, nodetop) && !extract_field ("Prev:", nodename, nodetop)) return (0); return (get_node ((char *) NULL, nodename, 0)); } /* Move to the node specified in the UP field. */ int up_node () { char nodename[NODENAME_LEN]; if (!extract_field ("Up:", nodename, nodetop)) return (0); return (get_node ((char *) NULL, nodename, 0)); } /* Build a completion list of menuname/nodename for each line in this node that is a menu item. */ int build_menu () { int pointer = nodetop; char menuname[NODENAME_LEN]; char nodename[NODENAME_LEN]; if (strcmp (menus_nodename, current_info_node) == 0 && strcmp (menus_filename, current_info_file) == 0) return (the_menu_size != 0); strcpy (menus_nodename, current_info_node); strcpy (menus_filename, current_info_file); free_completion_list (); the_menu_size = 0; set_search_constraints (info_file, nodebot); if ((pointer = search_forward (MENU_HEADER, nodetop)) < 0) return (0); /* There is a menu here. Look for members of it. */ pointer += strlen (MENU_HEADER); while (1) { int idx; pointer = search_forward (MENU_ID, pointer); if (pointer < 0) break; /* No more menus in this node. */ pointer = (skip_whitespace (pointer + strlen (MENU_ID))); idx = 0; while ((menuname[idx] = info_file[pointer]) && menuname[idx] != ':') idx++, pointer++; menuname[idx] = '\0'; pointer++; if (info_file[pointer] == ':') { strcpy (nodename, menuname); } else { int in_parens; pointer = skip_whitespace (pointer); idx = in_parens = 0; while ((nodename[idx] = info_file[pointer]) && (in_parens || (nodename[idx] != '\t' && nodename[idx] != '.' && nodename[idx] != ','))) { if (nodename[idx] == '(') in_parens++; else if (nodename[idx] == ')') in_parens--; idx++, pointer++; } nodename[idx] = '\0'; } add_completion (menuname, nodename); the_menu_size++; } if (the_menu_size) completion_list = reverse_list (completion_list); return (the_menu_size != 0); } /* Select ITEMth item from a list built by build_menu (). */ int get_menu (item) int item; { if (!build_menu ()) return (0); if (item > the_menu_size) return (0); else { COMP_ENTRY *temp = completion_list; while (--item && temp) temp = temp->next; return (get_node ((char *) NULL, temp->data, 0)); } } /* Scan through the ?already? built menu list looking for STRING. If you find it, put the corresponding nodes name in NODENAME. */ int find_menu_node (string, nodename) char *string, *nodename; { return (scan_list (string, nodename)); } /* The work part of find_menu_node and find_note_node. */ int scan_list (string, nodename) char *string, *nodename; { COMP_ENTRY *temp = completion_list; while (temp) { if (stricmp (string, temp->identifier, strlen (string)) == 0) { strcpy (nodename, temp->data); return (1); } temp = temp->next; } return (0); } /* Remove and whitespace from string, replacing them with only one space. Exception: at end of string disappears. */ clean_up (string) char *string; { char *to; /* Skip all whitespace characters found at the start of STRING. */ while (whitespace (*string)) string++; to = string; while (*to = *string++) { if (*to == '\n' || *to == ' ') { *to = ' '; while (*string == ' ' || *string == '\t') string++; } to++; } } /* Find a reference to "*Note". Return the offset of the start of that reference, or -1. */ find_footnote_ref (from) int from; { while (1) { from = search_forward (FOOTNOTE_HEADER, from); if (from < 0) return (from); else from += strlen (FOOTNOTE_HEADER); if (info_file[from] == ' ' || info_file[from] == '\n' || info_file[from] == '\t') return (from); } } /* Build an array of (footnote.nodename) for each footnote in this node. */ int build_notes () { int pointer; char notename[NODENAME_LEN]; char nodename[NODENAME_LEN]; set_search_constraints (info_file, nodebot); if ((find_footnote_ref (nodetop)) < 0) return (0); pointer = nodetop; menus_filename[0] = menus_nodename[0] = '\0'; visible_footnote = ""; free_completion_list (); while (1) { int idx; pointer = find_footnote_ref (pointer); if (pointer < 0) break; /* no more footnotes in this node. */ pointer = skip_whitespace_and_cr (pointer); idx = 0; while ((notename[idx] = info_file[pointer]) && notename[idx] != ':') { idx++, pointer++; } notename[idx] = '\0'; clean_up (notename); pointer++; if (info_file[pointer] == ':') { strcpy (nodename, notename); } else { int in_parens = 0; pointer = skip_whitespace (pointer); idx = 0; while ((nodename[idx] = info_file[pointer]) && (in_parens || (nodename[idx] != '\t' && nodename[idx] != '.' && nodename[idx] != ','))) { if (nodename[idx] == '(') in_parens++; else if (nodename[idx] == ')') in_parens--; idx++, pointer++; } nodename[idx] = '\0'; clean_up (nodename); } /* Add the notename/nodename to the list. */ add_completion (notename, nodename); the_menu_size++; /* Remember this identifier as the default if it is the first one in the page. */ if (!(*visible_footnote) && pointer > pagetop && pointer < forward_lines (the_window.bottom - the_window.top, pointer)) visible_footnote = completion_list->identifier; } if (the_menu_size) completion_list = reverse_list (completion_list); return (the_menu_size != 0); } /* Scan through the ?already? built footnote list looking for STRING. If found, place the corresponding node name in NODENAME. */ int find_note_node (string, nodename) char *string, *nodename; { return (scan_list (string, nodename)); } /* **************************************************************** */ /* */ /* Page Display */ /* */ /* **************************************************************** */ /* The display functions for GNU Info. */ int display_ch, display_cv; int display_point; /* Display the current page from pagetop down to the bottom of the page or the bottom of the node, whichever comes first. */ display_page () { display_point = pagetop; display_ch = the_window.left; display_cv = the_window.top; generic_page_display (); } /* Print the page from display_point to bottom of node, or window, whichever comes first. Start printing at display_ch, display_cv. */ generic_page_display () { int done_with_display = 0; int character; goto_xy (display_ch, display_cv); while (!done_with_display) { if (display_point == nodebot) { clear_eop (); goto display_finish; } character = info_file[display_point]; if ((display_width (character, the_window.ch) + the_window.ch) >= the_window.right) display_carefully (character); else charout (character); if ((the_window.cv >= the_window.bottom) || (the_window.cv == the_window.top && the_window.ch == the_window.left)) { display_finish: pagebot = display_point; make_modeline (); done_with_display++; continue; } else display_point++; } fflush (stdout); } /* Display character carefully, ensuring that no scrolling takes place, even in the case of funky control characters. */ display_carefully (character) int character; { if (CTRL_P (character)) { switch (character) { case RETURN: case NEWLINE: case TAB: clear_eol (); advance (the_window.right - the_window.ch); break; default: charout ('^'); if (the_window.cv == the_window.bottom) break; else charout (UNCTRL (character)); } } else charout (character); } /* Move the cursor to POSITION in page. Return non-zero if successful. */ cursor_to (position) int position; { int ch, cv, character; int point; if (position > pagebot || position < pagetop) return (0); point = pagetop; ch = the_window.left; cv = the_window.top; while (point < position) { character = info_file[point++]; ch += display_width (character, ch); if (ch >= the_window.right) { ch = ch - the_window.right; cv++; if (cv >= the_window.bottom) return (0); } } goto_xy (ch, cv); return (1); } /* Move to the next page in this node. Return 0 if we can't get to the next page. */ int next_page () { int pointer; pointer = forward_lines ((the_window.bottom - the_window.top) - 2, pagetop); if (pointer >= nodebot) return (0); /* Hack for screens smaller than displayed line width. */ if (pointer > display_point) { pointer = display_point; back_lines (1); } pagetop = pointer; return (1); } /* Move to the previous page in this node. Return zero if there is no previous page. */ int prev_page () { int pointer = back_lines ((the_window.bottom - the_window.top) - 2, pagetop); if (pagetop == nodetop) return (0); if (pointer < nodetop) pointer = nodetop; pagetop = pointer; return (1); } /* **************************************************************** */ /* */ /* Utility Functions */ /* */ /* **************************************************************** */ char *search_buffer; /* area in ram to scan through. */ int buffer_bottom; /* Length of this area. */ /* Set the global variables that all of these routines use. */ set_search_constraints (buffer, extent) char *buffer; int extent; { search_buffer = buffer; buffer_bottom = extent; } /* Move back to the start of this line. */ to_beg_line (from) int from; { while (from && search_buffer[from - 1] != '\n') from--; return (from); } /* Move forward to the end of this line. */ to_end_line (from) { while (from < buffer_bottom && search_buffer[from] != '\n') from++; return (from); } /* Move back count lines in search_buffer starting at starting_pos. Returns the start of that line. */ back_lines (count, starting_pos) int count, starting_pos; { starting_pos = to_beg_line (starting_pos); while (starting_pos && count) { starting_pos = to_beg_line (starting_pos - 1); count--; } return (starting_pos); } /* Move forward count lines starting at starting_pos. Returns the start of that line. */ forward_lines (count, starting_pos) int count, starting_pos; { starting_pos = to_end_line (starting_pos); while (starting_pos < buffer_bottom && count) { starting_pos = to_end_line (starting_pos + 1); count--; } return (to_beg_line (starting_pos)); } /* Search for STRING in SEARCH_BUFFER starting at STARTING_POS. Return the location of the string, or -1 if not found. */ search_forward (string, starting_pos) char *string; int starting_pos; { register int c, i, len; register char *buff, *end; char *alternate; /* We match characters in SEARCH_BUFFER against STRING and ALTERNATE. ALTERNATE is a case reversed version of STRING; this is cheaper than case folding each character before comparison. */ /* Build the alternate string. */ alternate = savestring (string); len = strlen (string); for (i = 0; i < len; i++) { c = alternate[i]; if (c >= 'a' && c <= 'z') alternate[i] = c - 32; else if (c >= 'A' && c <= 'Z') alternate[i] = c + 32; } buff = search_buffer + starting_pos; end = search_buffer + buffer_bottom + 1; while (buff < end) { for (i = 0; i < len; i++) { c = buff[i]; if (c != string[i] && c != alternate[i]) break; } if (!string[i]) { free (alternate); return (buff - search_buffer); } buff++; } free (alternate); return (-1); } /* Search for STRING in SEARCH_BUFFER starting at STARTING_POS. Return the location of the string, or -1 if not found. */ search_backward (string, starting_pos) char *string; int starting_pos; { int len = strlen (string); while (starting_pos - len > -1) { if (strnicmp (search_buffer + (starting_pos - len), string, len) == 0) return (starting_pos - len); else starting_pos--; } return (-1); } /* Only search for STRING from POINTER to end of line. Return offset of string, or -1 if not found. */ string_in_line (string, pointer) char *string; int pointer; { int old_buffer_bottom = buffer_bottom; set_search_constraints (search_buffer, to_end_line (pointer)); pointer = search_forward (string, pointer); buffer_bottom = old_buffer_bottom; return (pointer); } /* Skip whitespace characters at OFFSET in SEARCH_BUFFER. Return the next non-whitespace character or -1 if BUFFER_BOTTOM is reached. */ skip_whitespace (offset) int offset; { int character; while (offset < buffer_bottom) { character = search_buffer[offset]; if (character == ' ' || character == '\t') offset++; else return (offset); } return (-1); } /* Skip whitespace characters including at OFFSET in SEARCH_BUFFER. Return the position of the next non-whitespace character, or -1 if BUFFER_BOTTOM is reached. */ skip_whitespace_and_cr (offset) int offset; { while (1) { offset = skip_whitespace (offset); if (offset > 0 && search_buffer[offset] != '\n') return (offset); else offset++; } } /* Extract the node name part of the of the text after the FIELD. Place the node name into NODENAME. Assume the line starts at OFFSET in SEARCH_BUFFER. */ int extract_field (field_name, nodename, offset) char *field_name, *nodename; int offset; { int temp, character; temp = string_in_line (field_name, offset); if (temp < 0) return (0); temp += strlen (field_name); temp = skip_whitespace (temp); /* Okay, place the following text into NODENAME. */ while ((character = search_buffer[temp]) != ',' && character != '\n' && character != '\t') { *nodename = character; nodename++; temp++; } *nodename = '\0'; return (1); } /* Return non-zero if pointer is exactly at string, else zero. */ int looking_at (string, pointer) char *string; int pointer; { if (strnicmp (search_buffer + pointer, string, strlen (string)) == 0) return (1); else return (0); } /* File stack stuff. This is currently only used to push one file while searching indirect files, but we may as well write it in full generality. */ typedef struct filestack { struct filestack *next; char filename[FILENAME_LEN]; char current_filename[FILENAME_LEN]; char *tag_table; char *info_file; int info_buffer_len; } FILESTACK; FILESTACK *filestack = NULL; int push_filestack (filename, remember_name) char *filename; int remember_name; { FILESTACK *element = (FILESTACK *) xmalloc (sizeof (FILESTACK)); element->next = filestack; filestack = element; strcpy (filestack->filename, last_loaded_info_file); strcpy (filestack->current_filename, current_info_file); filestack->tag_table = tag_table; filestack->info_file = info_file; filestack->info_buffer_len = info_buffer_len; *last_loaded_info_file = '\0'; /* force the file to be read */ info_file = (char *)NULL; /* Pretend we have no buffer. */ if (get_info_file (filename, remember_name)) { return (1); } else { pop_filestack (); return (0); } } void pop_filestack () { FILESTACK *temp; if (filestack == NULL) { fprintf (stderr , "File stack is empty and can't be popped\n"); brians_error (); return; } free (info_file); strcpy (last_loaded_info_file, filestack->filename); strcpy (current_info_file, filestack->current_filename); tag_table = filestack->tag_table; info_file = filestack->info_file; info_buffer_len = filestack->info_buffer_len; set_search_constraints (info_file, info_buffer_len); temp = filestack; filestack = filestack->next; free ((char *)temp); } /* Swap the current info file with the bottom of the filestack */ void swap_filestack () { char t_last_loaded_info_file[FILENAME_LEN]; char t_current_info_file[FILENAME_LEN]; char *t_tag_table; char *t_info_file; int t_info_buffer_len; if (filestack == NULL) { fprintf (stderr , "File stack is empty and can't be swapped\n"); brians_error (); return; } strcpy (t_last_loaded_info_file, filestack->filename); strcpy (t_current_info_file, filestack->current_filename); t_tag_table = filestack->tag_table; t_info_file = info_file; t_info_buffer_len = info_buffer_len; strcpy (filestack->filename, last_loaded_info_file); strcpy (filestack->current_filename, current_info_file); filestack->tag_table = tag_table; filestack->info_file = info_file; filestack->info_buffer_len = info_buffer_len; strcpy (last_loaded_info_file, t_last_loaded_info_file); strcpy (current_info_file, t_current_info_file); tag_table = t_tag_table; info_file = t_info_file; info_buffer_len = t_info_buffer_len; } /* Now the node history stack */ extern NODEINFO *Info_History; /* Save the current filename, nodename, and position on the history list. We prepend. */ int push_node (filename, nodename, page_position, node_position) char *filename, *nodename; int page_position, node_position; { NODEINFO *newnode = (NODEINFO *) xmalloc (sizeof (NODEINFO)); newnode->next = Info_History; newnode->filename = (char *) xmalloc (strlen (filename) + 1); strcpy (newnode->filename, filename); newnode->nodename = (char *) xmalloc (strlen (nodename) + 1); strcpy (newnode->nodename, nodename); newnode->pagetop = page_position; newnode->nodetop = node_position; Info_History = newnode; return (1); } /* Pop one node from the node list, leaving the values in passed variables. */ int pop_node (filename, nodename, nodetop, pagetop) char *filename, *nodename; int *nodetop, *pagetop; { if (Info_History->next == (NODEINFO *) NULL) { display_error ("At beginning of history now!"); return (0); } else { NODEINFO *releaser = Info_History; /* If the popped file is not the current file, then force the popped file to be loaded. */ if (strcmp (Info_History->filename, last_loaded_info_file) != 0) last_loaded_info_file[0] = '\0'; strcpy (filename, Info_History->filename); strcpy (nodename, Info_History->nodename); *pagetop = Info_History->pagetop; *nodetop = Info_History->nodetop; free (Info_History->nodename); free (Info_History->filename); Info_History = Info_History->next; free (releaser); return (1); } } /* Whoops, Unix doesn't have strnicmp. */ /* Compare at most COUNT characters from string1 to string2. Case doesn't matter. */ int strnicmp (string1, string2, count) char *string1, *string2; { char ch1, ch2; while (count) { ch1 = *string1++; ch2 = *string2++; if (to_upper (ch1) == to_upper (ch2)) count--; else break; } return (count); } /* Compare string1 to string2. Case doesn't matter. */ int stricmp (string1, string2) char *string1, *string2; { char ch1, ch2; while (1) { ch1 = *string1++; ch2 = *string2++; if (ch1 == '\0') return (ch2 != '\0'); if ((ch2 == '\0') || (to_upper (ch1) != to_upper (ch2))) return (1); } } /* Make the user type "Y" or "N". */ int get_y_or_n_p () { int character; print_string (" (Y or N)?"); clear_eol (); until_we_like_it: character = blink_cursor (); if (character == EOF) return (0); if (to_upper (character) == 'Y') { charout (character); return (1); } if (to_upper (character) == 'N') { charout (character); return (0); } if (character == ABORT_CHAR) { ding (); return (0); } goto until_we_like_it; } /* Move the cursor to the desired column in the window. */ indent_to (screen_column) int screen_column; { int counter = screen_column - the_window.ch; if (counter > 0) { while (counter--) charout (' '); } else if (screen_column != 0) charout (' '); } /* **************************************************************** */ /* */ /* Error output/handling. */ /* */ /* **************************************************************** */ /* Display specific error from known file error table. */ file_error (file) char *file; { extern int errno; extern int sys_nerr; extern char *sys_errlist[]; if (errno < sys_nerr) display_error ("%s: %s", file, sys_errlist[errno]); else display_error ("%s: Unknown error %d", file, errno); } /* Display the error in the echo-area using format_string and args. This is a specialized interface to printf. */ display_error (format_string, arg1, arg2) char *format_string; { extern int terminal_inited_p; char output_buffer[1024]; if (totally_inhibit_errors) return; sprintf (output_buffer, format_string, arg1, arg2); if (terminal_inited_p) { new_echo_area (); ding (); print_string ("%s", output_buffer); close_echo_area (); } else { fprintf (stderr, "%s\n", output_buffer); } } /* Tell everybody what a loser I am. If you see this error, send me a bug report. */ brians_error () { display_error ("You are never supposed to see this error.\n"); display_error ("Tell bfox@ai.mit.edu to fix this someday.\n"); return (-1); } /* **************************************************************** */ /* */ /* Terminal IO, and Driver */ /* */ /* **************************************************************** */ /* The Unix termcap interface code. */ #define NO_ERROR 0 #define GENERIC_ERROR 1 #define NO_TERMINAL_DESCRIPTOR 2 #define OUT_OF_MEMORY 3 #define BAD_TERMINAL 4 #define FERROR(msg) fprintf (stderr, msg); exit (GENERIC_ERROR) extern int tgetnum (), tgetflag (); extern char *tgetstr (); extern char *tgoto (); #define Certainly_enough_space 2048 /* page 3, Section 1.1, para 4 */ #if defined (unix) char termcap_buffer[Certainly_enough_space]; #else /* !unix */ #define termcap_buffer NULL #endif /* !unix */ /* You CANNOT remove these next four vars. TERMCAP needs them to operate. */ char PC; char *BC; char *UP; /* A huge array of stuff to get from termcap initialization. */ #define tc_int 0 #define tc_char tc_int+1 #define tc_flag tc_char+1 #define tc_last tc_flag+1 typedef int flag; /* First, the variables which this array refers to */ /* Capabilities */ int terminal_columns; /* {tc_int, "co" */ int terminal_rows; /* {tc_int, "li" */ flag terminal_is_generic; /* {tc_flag,"gn" */ /* Cursor Motion */ char *terminal_goto; /* {tc_char,"cm" */ char *terminal_home; /* {tc_char,"ho" */ char *terminal_cursor_left; /* {tc_char,"le" */ char *terminal_cursor_right; /* {tc_char,"nd" */ char *terminal_cursor_up; /* {tc_char,"up" */ char *terminal_cursor_down; /* {tc_char,"do" */ /* Screen Clearing */ char *terminal_clearpage; /* {tc_char,"cl" */ char *terminal_clearEOP; /* {tc_char,"cd" */ char *terminal_clearEOL; /* {tc_char,"ce" */ /* "Standout" */ char *terminal_standout_begin; /* {tc_char,"so" */ char *terminal_standout_end; /* {tc_char,"se" */ /* Reverse Video */ char *terminal_inverse_begin; /* {tc_char,"mr" */ char *terminal_end_attributes; /* {tc_char,"me" */ /* Ding! */ char *terminal_ear_bell; /* {tc_char,"bl" */ /* Terminal Initialization */ char *terminal_use_begin; /* {tc_char,"ti" */ char *terminal_use_end; /* {tc_char,"te" */ /* Padding Stuff */ char *terminal_padding; /* {tc_char,"pc" */ /* Now the whopping big array */ typedef struct { char type; char *name; char *value; } termcap_capability_struct; termcap_capability_struct capabilities[] = { /* Capabilities */ {tc_int, "co", (char *) &terminal_columns}, {tc_int, "li", (char *) &terminal_rows}, {tc_flag, "gn", (char *) &terminal_is_generic}, /* Cursor Motion */ {tc_char, "cm", (char *) &terminal_goto}, {tc_char, "ho", (char *) &terminal_home}, {tc_char, "le", (char *) &terminal_cursor_left}, {tc_char, "nd", (char *) &terminal_cursor_right}, {tc_char, "up", (char *) &terminal_cursor_up}, {tc_char, "do", (char *) &terminal_cursor_down}, /* Screen Clearing */ {tc_char, "cl", (char *) &terminal_clearpage}, {tc_char, "cd", (char *) &terminal_clearEOP}, {tc_char, "ce", (char *) &terminal_clearEOL}, /* "Standout" */ {tc_char, "so", (char *) &terminal_standout_begin}, {tc_char, "se", (char *) &terminal_standout_end}, /* Reverse Video */ {tc_char, "mr", (char *) &terminal_inverse_begin}, {tc_char, "me", (char *) &terminal_end_attributes}, /* Ding! */ {tc_char, "bl", (char *) &terminal_ear_bell}, /* Terminal Initialization */ {tc_char, "ti", (char *) &terminal_use_begin}, {tc_char, "te", (char *) &terminal_use_end}, /* Padding Stuff */ {tc_char, "pc", (char *) &terminal_padding}, /* Terminate this array with a var of type tc_last */ {tc_last, NULL, NULL} }; int terminal_opened_p = 0; open_terminal_io () { int error; if (terminal_opened_p) return (NO_ERROR); if ((error = get_terminal_info ()) != NO_ERROR) return (error); if ((error = get_terminal_vars (capabilities)) != NO_ERROR) return (error); /* Now, make sure we have the capabilites that we need. */ if (terminal_is_generic) return (BAD_TERMINAL); terminal_opened_p++; return (NO_ERROR); } get_terminal_info () { char temp_string_buffer[256]; int result; char *terminal_name = getenv ("TERM"); if (terminal_name == NULL || *terminal_name == 0 || (strcmp (terminal_name, "dialup") == 0)) { terminal_name = temp_string_buffer; printf ("\nTerminal Type:"); fflush (stdout); fgets (terminal_name, 256, stdin); if (!(*terminal_name)) return (NO_TERMINAL_DESCRIPTOR); } /* #define VERBOSE_GET_TERMINAL 1 */ #ifdef VERBOSE_GET_TERMINAL #define buffer_limit 256 #define opsys_termcap_filename "/etc/termcap" /* We hack question mark if that is what the user typed. All this means is we read /etc/termcap, and prettily print out the names of terminals that we find. */ if (terminal_name[0] == '?' && !terminal_name[1]) { FILE *termcap_file; if ((termcap_file = fopen (opsys_termcap_filename, "r")) != NULL) { int result; char line_buffer[buffer_limit]; int terminal_count = 0; while ((readline_termcap (termcap_file, line_buffer)) != EOF) { char first_char = *line_buffer; if (first_char == '#' || first_char == ' ' || first_char == '\t' || first_char == '\n') ; else { /* Print the names the pretty way. */ printf ("\n%s", line_buffer); /* liar */ terminal_count++; } } fclose (termcap_file); if (terminal_count) printf ("\n%d terminals listed.\n", terminal_count); else printf ("\nNo terminals were listed. Brian's mistake.\n"); } else { fprintf (stderr, "\nNo such system file as %s!\nWe lose badly.\n", opsys_termcap_filename); return (NO_TERMINAL_DESCRIPTOR); } return (get_terminal_info ()); } #endif /* VERBOSE_GET_TERMINAL */ result = tgetent (termcap_buffer, terminal_name); if (!result) return (NO_TERMINAL_DESCRIPTOR); else return (NO_ERROR); } #ifdef VERBOSE_GET_TERMINAL readline_termcap (stream, buffer) FILE *stream; char *buffer; { int c; int buffer_index = 0; while ((c = getc (stream)) != EOF && c != '\n') { if (buffer_index != buffer_limit - 1) buffer[buffer_index++] = c; } buffer[buffer_index] = 0; if (c == EOF) return ((buffer_index) ? 0 : EOF); else return (0); } #endif /* VERBOSE_GET_TERMINAL */ /* For each element of "from_array", read the corresponding variable's value into the right place. */ get_terminal_vars (from_array) termcap_capability_struct from_array[]; { int i; register termcap_capability_struct *item; char *buffer; #if !defined (GNU_TERMCAP) buffer = (char *) xmalloc (sizeof (termcap_buffer) + 1); # define buffer_space &buffer #else # define buffer_space 0 #endif for (i = 0; (item = &from_array[i]) && (item->type != tc_last); i++) { switch (item->type) { case tc_int: *((int *) (item->value)) = tgetnum (item->name); break; case tc_flag: *((int *) item->value) = tgetflag (item->name); break; case tc_char: *((char **) item->value) = tgetstr (item->name, buffer_space); break; default: FERROR ("Bad entry scanned in tc_struct[].\n \ Ask bfox@ai.mit.edu to fix this someday.\n"); } } PC = terminal_padding ? terminal_padding[0] : 0; BC = terminal_cursor_left; UP = terminal_cursor_up; return (NO_ERROR); } /* Return the number of rows this terminal has. */ int get_terminal_rows () { int rows = 0; #if defined (TIOCGWINSZ) { int tty; struct winsize size; tty = fileno (stdin); if (ioctl (tty, TIOCGWINSZ, &size) != -1) rows = size.ws_row; } #endif /* TIOCGWINSZ */ if (!rows) rows = tgetnum ("li"); if (rows <= 0) rows = 24; return (rows); } /* Return the number of columns this terminal has. */ get_terminal_columns () { int columns = 0; #if defined (TIOCGWINSZ) { int tty; struct winsize size; tty = fileno (stdin); if (ioctl (tty, TIOCGWINSZ, &size) != -1) columns = size.ws_col; } #endif /* TIOCGWINSZ */ if (!columns) columns = tgetnum ("co"); if (columns <= 0) columns = 80; return (columns); } /* #define TERMINAL_INFO_PRINTING */ #ifdef TERMINAL_INFO_PRINTING /* Scan this (already "get_terminal_vars"ed) array, printing out the capability name, and value for each entry. Pretty print the value so that the terminal doesn't actually do anything, shitbrain. */ show_terminal_info (from_array) termcap_capability_struct from_array[]; { register int i; register termcap_capability_struct *item; for (i = 0; ((item = &from_array[i]) && ((item->type) != tc_last)); i++) { char *type_name; switch (item->type) { case tc_int: type_name = "int "; break; case tc_flag: type_name = "flag"; break; case tc_char: type_name = "char"; break; default: type_name = "Broken"; } printf ("\t%s\t%s = ", type_name, item->name); switch (item->type) { case tc_int: case tc_flag: printf ("%d", *((int *) item->value)); break; case tc_char: tc_pretty_print (*((char **) item->value)); break; } printf ("\n"); } } /* Print the contents of string without sending anything that isn't a normal printing ASCII character. */ tc_pretty_print (string) register char *string; { register char c; while (c = *string++) { if (CTRLP (c)) { putchar ('^'); c += 64; } putchar (c); } } #endif TERMINAL_INFO_PRINTING /* **************************************************************** */ /* */ /* Character IO, and driver */ /* */ /* **************************************************************** */ char *widest_line; int terminal_inited_p = 0; /* Start up the character io stuff. */ init_terminal_io () { if (!terminal_inited_p) { opsys_init_terminal (); terminal_rows = get_terminal_rows (); terminal_columns = get_terminal_columns (); widest_line = (char *) xmalloc (terminal_columns); terminal_inited_p = 1; } terminal_window.left = 0; terminal_window.top = 0; terminal_window.right = terminal_columns; terminal_window.bottom = terminal_rows; set_window (&terminal_window); terminal_window.bottom -= 2; set_window (&terminal_window); init_echo_area (the_window.left, the_window.bottom + 1, the_window.right, terminal_rows); /* Here is a list of things that the terminal has to be able to do. Do you think that this is too harsh? */ if (!terminal_goto || /* We can't move the cursor. */ !terminal_rows) /* We don't how many lines it has. */ { fprintf (stderr, "Your terminal is not clever enough to run info. Sorry.\n"); exit (1); } } /* Ring the terminal bell. */ ding () { extern char *terminal_ear_bell; if (terminal_ear_bell) do_term (terminal_ear_bell); else putchar (CTRL ('G')); fflush (stdout); } int untyi_char = 0; int inhibit_output = 0; /* Return a character from stdin, or the last unread character if there is one available. */ blink_cursor () { int character; fflush (stdout); if (untyi_char) { character = untyi_char; untyi_char = 0; } else do { character = getc (stdin); } while (character == -1 && errno == EINTR); return (character); } /* Display single character on the terminal screen. If the character would run off the right hand edge of the screen, advance the cursor to the next line. */ charout (character) int character; { if (inhibit_output) return; /* This character may need special treatment if it is a control character. */ if (CTRL_P (character)) { switch (character) { case NEWLINE: case RETURN: print_cr (); break; case TAB: print_tab (); break; default: charout ('^'); charout (UNCTRL (character)); } } else { putchar (character); advance (1); } } /* Move the cursor AMOUNT character positions. */ advance (amount) int amount; { int old_window_cv = the_window.cv; while (amount-- > 0) { the_window.ch++; if (the_window.ch >= the_window.right) { the_window.ch = (the_window.ch - the_window.right) + the_window.left; the_window.cv++; if (the_window.cv >= the_window.bottom) the_window.cv = the_window.top; } } if (the_window.cv != old_window_cv) goto_xy (the_window.ch, the_window.cv); } /* Print STRING and args using charout */ print_string (string, a1, a2, a3, a4, a5) char *string; { int character; char buffer[2048]; int idx = 0; sprintf (buffer, string, a1, a2, a3, a4, a5); while (character = buffer[idx++]) charout (character); fflush (stdout); } /* Display a carriage return. Clears to the end of the line first. */ print_cr () { extern int typing_out; clear_eol (); if (typing_out) { /* Do the "MORE" stuff. */ int response; if (the_window.cv + 2 == the_window.bottom) { goto_xy (the_window.left, the_window.cv + 1); clear_eol (); print_string ("[More]"); response = blink_cursor (); if (response != SPACE) { untyi_char = response; inhibit_output = 1; return; } else { goto_xy (the_window.left, the_window.cv); clear_eol (); goto_xy (the_window.left, the_window.top); return; } } } advance (the_window.right - the_window.ch); } /* Move the cursor to the next tab stop, blanking the intervening spaces along the way. */ print_tab () { int hpos, width, destination; hpos = the_window.ch - the_window.left; width = ((hpos + 8) & 0xf8) - hpos; destination = hpos + width + the_window.left; if (destination >= the_window.right) destination -= the_window.right; while (the_window.ch != destination) charout (SPACE); } display_width (character, hpos) int character, hpos; { int width = 1; if (CTRL_P (character)) { switch (character) { case RETURN: case NEWLINE: width = the_window.right - hpos; break; case TAB: width = ((hpos + 8) & 0xf8) - hpos; break; default: width = 2; } } return (width); } /* Like GOTO_XY, but do it right away. */ I_goto_xy (xpos, ypos) int xpos, ypos; { goto_xy (xpos, ypos); fflush (stdout); } /* Move the cursor, (and cursor variables) to xpos, ypos. */ goto_xy (xpos, ypos) int xpos, ypos; { the_window.ch = xpos; the_window.cv = ypos; opsys_goto_pos (xpos, ypos); } /* Clear the screen, leaving ch and cv at the top of the window. */ clear_screen () { goto_xy (the_window.left, the_window.top); clear_eop_slowly (); } clear_eop_slowly () { int temp_ch = the_window.ch; int temp_cv = the_window.cv; clear_eol (); while (++the_window.cv < the_window.bottom) { goto_xy (the_window.left, the_window.cv); clear_eol (); } goto_xy (temp_ch, temp_cv); } /* Clear from current cursor position to end of page. */ clear_eop () { if (terminal_clearEOP) do_term (terminal_clearEOP); else clear_eop_slowly (); } /* Clear from current cursor position to end of screen line */ clear_eol () { int temp_ch = the_window.ch; if (terminal_clearEOL) do_term (terminal_clearEOL); else { char *line = widest_line; int i; for (i = 0; i < the_window.right - the_window.ch; i++) line[i] = ' '; line[i] = '\0'; printf ("%s", line); } goto_xy (temp_ch, the_window.cv); } /* Call FUNCTION with WINDOW active. You can pass upto 5 args to the function. This returns whatever FUNCTION returns. */ int with_output_to_window (window, function, arg1, arg2, arg3, arg4, arg5) WINDOW *window; Function *function; { int result; push_window (); set_window (window); result = (*function) (arg1, arg2, arg3, arg4, arg5); pop_window (); return (result); } /* Given a pointer to a window data structure, make that the current window. */ set_window (window) WINDOW *window; { bcopy (window, &the_window, sizeof (WINDOW)); } /* Save the current window on the window stack. */ push_window () { WINDOW_LIST *new_window = (WINDOW_LIST *) xmalloc (sizeof (WINDOW_LIST)); new_window->next_window = window_stack; window_stack = new_window; new_window->ch = the_window.ch; new_window->cv = the_window.cv; new_window->top = the_window.top; new_window->bottom = the_window.bottom; new_window->left = the_window.left; new_window->right = the_window.right; } /* Pop the top of the window_stack into the_window. */ pop_window () { set_window ((WINDOW *)window_stack); if (window_stack->next_window) { WINDOW_LIST *thing_to_free = window_stack; window_stack = window_stack->next_window; free (thing_to_free); } goto_xy (the_window.ch, the_window.cv); } /* **************************************************************** */ /* */ /* "Opsys" functions. */ /* */ /* **************************************************************** */ /* The lowlevel terminal/file interface. Nothing ever really gets low level when you're writing in C, though. This file contains all of the "opsys" labels. You have to make a different one if you want GNU Info to run on machines that don't have Unix. */ extern char *terminal_use_begin, *terminal_use_end, *terminal_goto; #if defined (TIOCGETC) struct tchars original_tchars; #endif #if defined (TIOCGLTC) struct ltchars original_ltchars; #endif #if defined (USG) struct termio original_termio, ttybuff; #else int original_tty_flags = 0; int original_lmode; struct sgttyb ttybuff; #endif /* !USG */ /* Yes, that's right, do things that the machine needs to get the terminal into a usable mode. */ opsys_init_terminal () { int tty = fileno (stdin); #if defined (USG) ioctl (tty, TCGETA, &original_termio); ioctl (tty, TCGETA, &ttybuff); ttybuff.c_iflag &= (~ISTRIP & ~INLCR & ~IGNCR & ~ICRNL &~IXON); ttybuff.c_oflag &= (~ONLCR & ~OCRNL); ttybuff.c_lflag &= (~ICANON & ~ECHO); ttybuff.c_cc[VMIN] = 1; ttybuff.c_cc[VTIME] = 0; if (ttybuff.c_cc[VINTR] = DELETE) ttybuff.c_cc[VINTR] = -1; if (ttybuff.c_cc[VQUIT] = DELETE) ttybuff.c_cc[VQUIT] = -1; ioctl (tty, TCSETA, &ttybuff); #else /* !USG */ ioctl (tty, TIOCGETP, &ttybuff); if (!original_tty_flags) original_tty_flags = ttybuff.sg_flags; /* Make this terminal pass 8 bits around while we are using it. */ #ifdef PASS8 ttybuff.sg_flags |= PASS8; #endif #if defined (TIOCLGET) && defined (LPASS8) { int flags; ioctl (tty, TIOCLGET, &flags); original_lmode = flags; flags |= LPASS8; ioctl (tty, TIOCLSET, &flags); } #endif #ifdef TIOCGETC { struct tchars temp; ioctl (tty, TIOCGETC, &original_tchars); bcopy (&original_tchars, &temp, sizeof (struct tchars)); temp.t_startc = temp.t_stopc = -1; /* If the quit character conflicts with one of our commands, then make it go away. */ if (temp.t_intrc == DELETE) temp.t_intrc == -1; if (temp.t_quitc == DELETE) temp.t_quitc == -1; ioctl (tty, TIOCSETC, &temp); } #endif /* TIOCGETC */ #ifdef TIOCGLTC { struct ltchars temp; ioctl (tty, TIOCGLTC, &original_ltchars); bcopy (&original_ltchars, &temp, sizeof (struct ltchars)); /* Make the interrupt keys go away. Just enough to make people happy. */ temp.t_lnextc = -1; /* C-v */ ioctl (tty, TIOCSLTC, &temp); } #endif /* TIOCGLTC */ ttybuff.sg_flags &= ~ECHO; ttybuff.sg_flags |= CBREAK; ioctl (tty, TIOCSETN, &ttybuff); #endif /* !USG */ open_terminal_io (); do_term (terminal_use_begin); } /* Fix the terminal that I broke. */ restore_io () { int tty = fileno (stdin); #if defined (USG) ioctl (tty, TCSETA, &original_termio); #else ioctl (tty, TIOCGETP, &ttybuff); ttybuff.sg_flags = original_tty_flags; ioctl (tty, TIOCSETN, &ttybuff); #ifdef TIOCGETC ioctl (tty, TIOCSETC, &original_tchars); #endif /* TIOCGETC */ #ifdef TIOCGLTC ioctl (tty, TIOCSLTC, &original_ltchars); #endif /* TIOCGLTC */ #if defined (TIOCLGET) && defined (LPASS8) ioctl (tty, TIOCLSET, &original_lmode); #endif #endif /* !USG */ do_term (terminal_use_end); } opsys_goto_pos (xpos, ypos) int xpos, ypos; { do_term (tgoto (terminal_goto, xpos, ypos)); } character_output_function (character) char character; { putchar (character); } /* Generic interface to tputs. */ do_term (command) char *command; { /* Send command to the terminal, with appropriate padding. */ if (command) tputs (command, 1, character_output_function); } /* Filename manipulators, and the like. */ char local_temp_filename[FILENAME_LEN]; char *info_suffixes[] = { "", ".info", "-info", (char *)NULL }; /* A structure which associates the argument passed into a function with the result from that function. */ typedef struct { char *called; char *result; } CALLED_RESULTS; /* An array of remembered arguments and results. */ static CALLED_RESULTS **opsys_callers_and_results = (CALLED_RESULTS **)NULL; static int next_caller_and_result = 0; static int callers_and_results_size = 0; /* Find the result for having already called opsys_filename () with CALLER. */ char * find_opsys_filename_result (caller) char *caller; { if (caller && opsys_callers_and_results) { register int i; for (i = 0; opsys_callers_and_results[i]; i++) { if (strcmp (opsys_callers_and_results[i]->called, caller) == 0) return (opsys_callers_and_results[i]->result); } } return (char *)NULL;; } /* Add an argument and result to our list. */ void add_caller_and_result (caller, result) char *caller, *result; { CALLED_RESULTS *new; if (next_caller_and_result + 2 > callers_and_results_size) { int alloc_size; callers_and_results_size += 10; alloc_size = callers_and_results_size * sizeof (CALLED_RESULTS *); opsys_callers_and_results = (CALLED_RESULTS **) xrealloc (opsys_callers_and_results, alloc_size); } new = (CALLED_RESULTS *)xmalloc (sizeof (CALLED_RESULTS)); new->called = savestring (caller); new->result = result ? savestring (result) : (char *)NULL; opsys_callers_and_results[next_caller_and_result++] = new; opsys_callers_and_results[next_caller_and_result] = (CALLED_RESULTS *)NULL; } /* Expand the filename in partial to make a real name for this operating system. This looks in INFO_PATHS in order to find the correct file. If it can't find the file, it just returns the path as you gave it. */ char * opsys_filename (partial) char *partial; { int initial_character; char *my_infopath; if (partial && (initial_character = *partial)) { char *possible_result; if (initial_character == '/') return (partial); possible_result = find_opsys_filename_result (partial); if (possible_result) return (possible_result); if (initial_character == '~') { if (partial[1] == '/') { /* Return the concatenation of HOME and the rest of the string. */ strcpy (local_temp_filename, getenv ("HOME")); strcat (local_temp_filename, &partial[2]); return (local_temp_filename); } else { struct passwd *user_entry; int i, c; char username[257]; for (i = 1; c = partial[i]; i++) { if (c == '/') break; else username[i - 1] = c; } username[i - 1] = '\0'; if (!(user_entry = getpwnam (username))) { display_error ("Not a registered user!"); return (partial); } strcpy (local_temp_filename, user_entry->pw_dir); strcat (local_temp_filename, &partial[i]); return (local_temp_filename); } } if (initial_character == '.' && (partial[1]) == '/' || (partial[1] == '.' && partial[2] == '/')) { #if defined (USG) if (!getcwd (local_temp_filename, FILENAME_LEN)) #else if (!getwd (local_temp_filename)) #endif { display_error (local_temp_filename); return (partial); } strcat (local_temp_filename, "/"); strcat (local_temp_filename, partial); return (local_temp_filename); } /* If the current info file has a directory, then search that directory first. */ { register char *ptr, *file; file = find_opsys_filename_result (current_info_file); if (file && (ptr = (char *)rindex (file, '/')) != (char *)NULL) { register int len = (ptr - file); my_infopath = (char *) xmalloc (2 + strlen (file) + strlen (infopath)); strncpy (my_infopath, file, len); sprintf (my_infopath + len, ":%s", infopath); } else my_infopath = savestring (infopath); } if (opsys_info_file_in_path (partial, my_infopath, local_temp_filename)) { free (my_infopath); add_caller_and_result (partial, local_temp_filename); return (local_temp_filename); } free (my_infopath); } return (partial); } #if !defined (S_ISREG) && defined (S_IFREG) # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) #endif /* !S_ISREG && S_IFREG */ #if !defined (S_ISDIR) && defined (S_IFDIR) # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif /* !S_ISDIR && S_IFDIR */ /* Scan the list of directories in PATH looking for FILENAME. If we find one that is a regular file, stuff the answer into RETURN_STRING. Return non-zero if a file was found, zero otherwise. */ int opsys_info_file_in_path (filename, path, return_string) char *filename, *path; char *return_string; { struct stat finfo; char *temp_dirname, *extract_colon_unit (); char *test_file = return_string; int statable, dirname_index = 0; while (temp_dirname = extract_colon_unit (path, &dirname_index)) { register int i, pre_suffix_length; strcpy (test_file, temp_dirname); if (temp_dirname[(strlen (temp_dirname)) - 1] != '/') strcat (test_file, "/"); strcat (test_file, filename); pre_suffix_length = strlen (test_file); free (temp_dirname); for (i = 0; info_suffixes[i]; i++) { strcpy (test_file + pre_suffix_length, info_suffixes[i]); statable = (stat (test_file, &finfo) == 0); /* If we have found a regular file, then use that. Else, if we have found a directory, look in that directory for this file. */ if (statable) { if (S_ISREG (finfo.st_mode)) return (1); else if (S_ISDIR (finfo.st_mode)) { char *newpath = savestring (test_file); char *filename_only = (char *)rindex (filename, '/'); if (opsys_info_file_in_path (filename_only ? filename_only : filename, newpath, return_string)) { free (newpath); return (1); } } } } } return (0); } /* Given a string containing units of information separated by colons, return the next one pointed to by IDX, or NULL if there are no more. Advance IDX to the character after the colon. */ char * extract_colon_unit (string, idx) char *string; int *idx; { register int i, start; i = start = *idx; if ((i >= strlen (string)) || !string) return ((char *) NULL); while (string[i] && string[i] != ':') i++; if (i == start) { return ((char *) NULL); } else { char *value = (char *) xmalloc (1 + (i - start)); strncpy (value, &string[start], (i - start)); value[i - start] = '\0'; if (string[i]) ++i; *idx = i; return (value); } } /* **************************************************************** */ /* */ /* The echo area. */ /* */ /* **************************************************************** */ WINDOW echo_area = {0, 0, 0, 0, 0, 0}; int echo_area_open_p = 0; char modeline[256]; WINDOW modeline_window = {0, 0, 0, 0, 0, 0}; /* Define the location of the echo area. Also inits the modeline as well. */ init_echo_area (left, top, right, bottom) int left, top, right, bottom; { echo_area.left = modeline_window.left = left; echo_area.top = top; modeline_window.top = top - 1; echo_area.right = modeline_window.right = right; echo_area.bottom = bottom; modeline_window.bottom = modeline_window.top; } /* Make the echo_area_window be the current window, and only allow output in there. Clear the window to start. */ new_echo_area () { if (!echo_area_open_p) { push_window (); set_window (&echo_area); echo_area_open_p = 1; } goto_xy (the_window.left, the_window.top); clear_eop (); } /* Return output to the previous window. */ close_echo_area () { if (!echo_area_open_p) return; pop_window (); echo_area_open_p = 0; } /* Clear the contents of the echo area. */ clear_echo_area () { new_echo_area (); close_echo_area (); } /* Create and display the modeline. */ make_modeline () { int width = modeline_window.right - modeline_window.left; char textual_position[6]; if (pagetop == nodetop) { if (pagebot == nodebot) sprintf (textual_position, "All"); else sprintf (textual_position, "Top"); } else { if (pagebot == nodebot) sprintf (textual_position, "Bot"); else sprintf (textual_position, "%2d%%", 100 * (pagetop - nodetop) / (nodebot - nodetop)); } sprintf (modeline, "Info: (%s)%s, %d lines ---%s", current_info_file, current_info_node, nodelines, textual_position); if (strnicmp (opsys_filename (current_info_file), last_loaded_info_file, strlen (last_loaded_info_file)) != 0) { sprintf (&modeline[strlen (modeline)], ", Subfile: %s", last_loaded_info_file); } if (strlen (modeline) < width) { int idx = strlen (modeline); while (idx != width) modeline[idx++] = '-'; modeline[idx] = '\0'; } if (strlen (modeline) > width) modeline[width] = '\0'; push_window (); set_window (&modeline_window); goto_xy (the_window.left, the_window.top); if (terminal_inverse_begin) do_term (terminal_inverse_begin); print_string ("%s", modeline); if (terminal_inverse_begin) do_term (terminal_end_attributes); pop_window (); } int typing_out = 0; /* Prepare to do output to the typeout window. If the typeout window is already open, ignore this clown. */ open_typeout () { if (typing_out) return; push_window (); set_window (&terminal_window); goto_xy (the_window.ch, the_window.cv); typing_out = window_bashed = 1; } /* Close the currently open typeout window. */ close_typeout () { if (inhibit_output) inhibit_output = 0; else { do { untyi_char = getc (stdin); } while (untyi_char == -1 && errno == EINTR); if (untyi_char == SPACE) untyi_char = 0; } pop_window (); typing_out = 0; } void * xrealloc (pointer, bytes) char *pointer; int bytes; { void *temp; if (pointer == (char *)NULL) temp = (void *) xmalloc (bytes); else temp = (void *) realloc (pointer, bytes); if (temp == (void *)NULL) { fprintf (stderr, "Virtual memory exhausted\n"); restore_io (); exit (2); } return (temp); } void * xmalloc (bytes) int bytes; { void *temp = (void *) malloc (bytes); if (temp == (void *) NULL) { fprintf (stderr, "Virtual memory exhausted\n"); restore_io (); exit (2); } return (temp); } texinfo-2.15/C/getopt.h0000644000175000017500000000770312415566121012222 0ustar gg/* Declarations for getopt. Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GETOPT_H #define _GETOPT_H 1 #ifdef __cplusplus extern "C" { #endif /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ extern char *optarg; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ extern int optind; /* Callers store zero here to inhibit the error message `getopt' prints for unrecognized options. */ extern int opterr; /* Describe the long-named options requested by the application. The LONG_OPTIONS argument to getopt_long or getopt_long_only is a vector of `struct option' terminated by an element containing a name which is zero. The field `has_arg' is: no_argument (or 0) if the option does not take an argument, required_argument (or 1) if the option requires an argument, optional_argument (or 2) if the option takes an optional argument. If the field `flag' is not NULL, it points to a variable that is set to the value given in the field `val' when the option is found, but left unchanged if the option is not found. To have a long-named option do something other than set an `int' to a compiled-in constant, such as set a value from `optarg', set the option's `flag' field to zero and its `val' field to a nonzero value (the equivalent single-letter option character, if there is one). For long options that have a zero `flag' field, `getopt' returns the contents of the `val' field. */ struct option { #if __STDC__ const char *name; #else char *name; #endif /* has_arg can't be an enum because some compilers complain about type mismatches in all the code that assumes it is an int. */ int has_arg; int *flag; int val; }; /* Names for the values of the `has_arg' field of `struct option'. */ enum _argtype { no_argument, required_argument, optional_argument }; #if __STDC__ extern int getopt (int argc, char *const *argv, const char *shortopts); extern int getopt_long (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); extern int getopt_long_only (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind); /* Internal only. Users should not call this directly. */ extern int _getopt_internal (int argc, char *const *argv, const char *shortopts, const struct option *longopts, int *longind, int long_only); #else /* not __STDC__ */ extern int getopt (); extern int getopt_long (); extern int getopt_long_only (); extern int _getopt_internal (); #endif /* not __STDC__ */ #ifdef __cplusplus } #endif #endif /* _GETOPT_H */ texinfo-2.15/C/getopt.c0000644000175000017500000004473512561754670012235 0ustar gg/* Getopt for GNU. NOTE: getopt is now part of the C library, so if you don't know what "Keep this file name-space clean" means, talk to roland@gnu.ai.mit.edu before changing it! Copyright (C) 1987, 88, 89, 90, 91, 1992 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* AIX requires this to be the first thing in the file. */ #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not __GNUC__ */ #if defined(sparc) && (defined(sun) || (!defined(USG) && !defined(SVR4) && !defined(__svr4__))) #include #else #ifdef _AIX #pragma alloca #else char *alloca (); #endif #endif /* sparc */ #endif /* not __GNUC__ */ #include /* This needs to come after some library #include to get __GNU_LIBRARY__ defined. */ #ifdef __GNU_LIBRARY__ #undef alloca #include #include #else /* Not GNU C library. */ #define __alloca alloca #endif /* GNU C library. */ #ifndef __STDC__ #define const #endif /* If GETOPT_COMPAT is defined, `+' as well as `--' can introduce a long-named option. Because this is not POSIX.2 compliant, it is being phased out. */ #define GETOPT_COMPAT /* This version of `getopt' appears to the caller like standard Unix `getopt' but it behaves differently for the user, since it allows the user to intersperse the options with the other arguments. As `getopt' works, it permutes the elements of ARGV so that, when it is done, all the options precede everything else. Thus all application programs are extended to handle flexible argument order. Setting the environment variable POSIXLY_CORRECT disables permutation. Then the behavior is completely standard. GNU application programs can use a third alternative mode in which they can distinguish the relative order of options and other arguments. */ #include "getopt.h" /* For communication from `getopt' to the caller. When `getopt' finds an option that takes an argument, the argument value is returned here. Also, when `ordering' is RETURN_IN_ORDER, each non-option ARGV-element is returned here. */ char *optarg = 0; /* Index in ARGV of the next element to be scanned. This is used for communication to and from the caller and for communication between successive calls to `getopt'. On entry to `getopt', zero means this is the first call; initialize. When `getopt' returns EOF, this is the index of the first of the non-option elements that the caller should itself scan. Otherwise, `optind' communicates from one call to the next how much of ARGV has been scanned so far. */ int optind = 0; /* The next char to be scanned in the option-element in which the last option character we returned was found. This allows us to pick up the scan where we left off. If this is zero, or a null string, it means resume the scan by advancing to the next ARGV-element. */ static char *nextchar; /* Callers store zero here to inhibit the error message for unrecognized options. */ int opterr = 1; /* Describe how to deal with options that follow non-option ARGV-elements. If the caller did not specify anything, the default is REQUIRE_ORDER if the environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise. REQUIRE_ORDER means don't recognize them as options; stop option processing when the first non-option is seen. This is what Unix does. This mode of operation is selected by either setting the environment variable POSIXLY_CORRECT, or using `+' as the first character of the list of option characters. PERMUTE is the default. We permute the contents of ARGV as we scan, so that eventually all the non-options are at the end. This allows options to be given in any order, even with programs that were not written to expect this. RETURN_IN_ORDER is an option available to programs that were written to expect options and other ARGV-elements in any order and that care about the ordering of the two. We describe each non-option ARGV-element as if it were the argument of an option with character code 1. Using `-' as the first character of the list of option characters selects this mode of operation. The special argument `--' forces an end of option-scanning regardless of the value of `ordering'. In the case of RETURN_IN_ORDER, only `--' can cause `getopt' to return EOF with `optind' != ARGC. */ static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; #ifdef __GNU_LIBRARY__ #include #define my_index strchr #define my_bcopy(src, dst, n) memcpy ((dst), (src), (n)) #else /* Avoid depending on library functions or files whose names are inconsistent. */ char *getenv (); static char * my_index (string, chr) char *string; int chr; { while (*string) { if (*string == chr) return string; string++; } return 0; } static void my_bcopy (from, to, size) char *from, *to; int size; { int i; for (i = 0; i < size; i++) to[i] = from[i]; } #endif /* GNU C library. */ /* Handle permutation of arguments. */ /* Describe the part of ARGV that contains non-options that have been skipped. `first_nonopt' is the index in ARGV of the first of them; `last_nonopt' is the index after the last of them. */ static int first_nonopt; static int last_nonopt; /* Exchange two adjacent subsequences of ARGV. One subsequence is elements [first_nonopt,last_nonopt) which contains all the non-options that have been skipped so far. The other is elements [last_nonopt,optind), which contains all the options processed since those non-options were skipped. `first_nonopt' and `last_nonopt' are relocated so that they describe the new indices of the non-options in ARGV after they are moved. */ static void exchange (argv) char **argv; { int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); char **temp = (char **) __alloca (nonopts_size); /* Interchange the two blocks of data in ARGV. */ my_bcopy (&argv[first_nonopt], temp, nonopts_size); my_bcopy (&argv[last_nonopt], &argv[first_nonopt], (optind - last_nonopt) * sizeof (char *)); my_bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size); /* Update records for the slots the non-options now occupy. */ first_nonopt += (optind - last_nonopt); last_nonopt = optind; } /* Scan elements of ARGV (whose length is ARGC) for option characters given in OPTSTRING. If an element of ARGV starts with '-', and is not exactly "-" or "--", then it is an option element. The characters of this element (aside from the initial '-') are option characters. If `getopt' is called repeatedly, it returns successively each of the option characters from each of the option elements. If `getopt' finds another option character, it returns that character, updating `optind' and `nextchar' so that the next call to `getopt' can resume the scan with the following option character or ARGV-element. If there are no more option characters, `getopt' returns `EOF'. Then `optind' is the index in ARGV of the first ARGV-element that is not an option. (The ARGV-elements have been permuted so that those that are not options now come last.) OPTSTRING is a string containing the legitimate option characters. If an option character is seen that is not listed in OPTSTRING, return '?' after printing an error message. If you set `opterr' to zero, the error message is suppressed but we still return '?'. If a char in OPTSTRING is followed by a colon, that means it wants an arg, so the following text in the same ARGV-element, or the text of the following ARGV-element, is returned in `optarg'. Two colons mean an option that wants an optional arg; if there is text in the current ARGV-element, it is returned in `optarg', otherwise `optarg' is set to zero. If OPTSTRING starts with `-' or `+', it requests different methods of handling the non-option ARGV-elements. See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. Long-named options begin with `--' instead of `-'. Their names may be abbreviated as long as the abbreviation is unique or is an exact match for some defined option. If they have an argument, it follows the option name in the same ARGV-element, separated from the option name by a `=', or else the in next ARGV-element. When `getopt' finds a long-named option, it returns 0 if that option's `flag' field is nonzero, the value of the option's `val' field if the `flag' field is zero. The elements of ARGV aren't really const, because we permute them. But we pretend they're const in the prototype to be compatible with other systems. LONGOPTS is a vector of `struct option' terminated by an element containing a name which is zero. LONGIND returns the index in LONGOPT of the long-named option found. It is only valid when a long-named option has been found by the most recent call. If LONG_ONLY is nonzero, '-' as well as '--' can introduce long-named options. */ int _getopt_internal (argc, argv, optstring, longopts, longind, long_only) int argc; char *const *argv; const char *optstring; const struct option *longopts; int *longind; int long_only; { int option_index; optarg = 0; /* Initialize the internal data when the first call is made. Start processing options with ARGV-element 1 (since ARGV-element 0 is the program name); the sequence of previously skipped non-option ARGV-elements is empty. */ if (optind == 0) { first_nonopt = last_nonopt = optind = 1; nextchar = NULL; /* Determine how to handle the ordering of options and nonoptions. */ if (optstring[0] == '-') { ordering = RETURN_IN_ORDER; ++optstring; } else if (optstring[0] == '+') { ordering = REQUIRE_ORDER; ++optstring; } else if (getenv ("POSIXLY_CORRECT") != NULL) ordering = REQUIRE_ORDER; else ordering = PERMUTE; } if (nextchar == NULL || *nextchar == '\0') { if (ordering == PERMUTE) { /* If we have just processed some options following some non-options, exchange them so that the options come first. */ if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (last_nonopt != optind) first_nonopt = optind; /* Now skip any additional non-options and extend the range of non-options previously skipped. */ while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) optind++; last_nonopt = optind; } /* Special ARGV-element `--' means premature end of options. Skip it like a null option, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ if (optind != argc && !strcmp (argv[optind], "--")) { optind++; if (first_nonopt != last_nonopt && last_nonopt != optind) exchange ((char **) argv); else if (first_nonopt == last_nonopt) first_nonopt = optind; last_nonopt = argc; optind = argc; } /* If we have done all the ARGV-elements, stop the scan and back over any non-options that we skipped and permuted. */ if (optind == argc) { /* Set the next-arg-index to point at the non-options that we previously skipped, so the caller will digest them. */ if (first_nonopt != last_nonopt) optind = first_nonopt; return EOF; } /* If we have come to a non-option and did not permute it, either stop the scan or describe it to the caller and pass it by. */ if ((argv[optind][0] != '-' || argv[optind][1] == '\0') #ifdef GETOPT_COMPAT && (longopts == NULL || argv[optind][0] != '+' || argv[optind][1] == '\0') #endif /* GETOPT_COMPAT */ ) { if (ordering == REQUIRE_ORDER) return EOF; optarg = argv[optind++]; return 1; } /* We have found another option-ARGV-element. Start decoding its characters. */ nextchar = (argv[optind] + 1 + (longopts != NULL && argv[optind][1] == '-')); } if (longopts != NULL && ((argv[optind][0] == '-' && (argv[optind][1] == '-' || long_only)) #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ )) { const struct option *p; char *s = nextchar; int exact = 0; int ambig = 0; const struct option *pfound = NULL; int indfound; while (*s && *s != '=') s++; /* Test all options for either exact match or abbreviated matches. */ for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, s - nextchar)) { if (s - nextchar == strlen (p->name)) { /* Exact match found. */ pfound = p; indfound = option_index; exact = 1; break; } else if (pfound == NULL) { /* First nonexact match found. */ pfound = p; indfound = option_index; } else /* Second nonexact match found. */ ambig = 1; } if (ambig && !exact) { if (opterr) fprintf (stderr, "%s: option `%s' is ambiguous\n", argv[0], argv[optind]); nextchar += strlen (nextchar); optind++; return '?'; } if (pfound != NULL) { option_index = indfound; optind++; if (*s) { /* Don't test has_arg with >, because some C compilers don't allow it to be used on enums. */ if (pfound->has_arg) optarg = s + 1; else { if (opterr) { if (argv[optind - 1][1] == '-') /* --option */ fprintf (stderr, "%s: option `--%s' doesn't allow an argument\n", argv[0], pfound->name); else /* +option or -option */ fprintf (stderr, "%s: option `%c%s' doesn't allow an argument\n", argv[0], argv[optind - 1][0], pfound->name); } nextchar += strlen (nextchar); return '?'; } } else if (pfound->has_arg == 1) { if (optind < argc) optarg = argv[optind++]; else { if (opterr) fprintf (stderr, "%s: option `%s' requires an argument\n", argv[0], argv[optind - 1]); nextchar += strlen (nextchar); return '?'; } } nextchar += strlen (nextchar); if (longind != NULL) *longind = option_index; if (pfound->flag) { *(pfound->flag) = pfound->val; return 0; } return pfound->val; } /* Can't find it as a long option. If this is not getopt_long_only, or the option starts with '--' or is not a valid short option, then it's an error. Otherwise interpret it as a short option. */ if (!long_only || argv[optind][1] == '-' #ifdef GETOPT_COMPAT || argv[optind][0] == '+' #endif /* GETOPT_COMPAT */ || my_index (optstring, *nextchar) == NULL) { if (opterr) { if (argv[optind][1] == '-') /* --option */ fprintf (stderr, "%s: unrecognized option `--%s'\n", argv[0], nextchar); else /* +option or -option */ fprintf (stderr, "%s: unrecognized option `%c%s'\n", argv[0], argv[optind][0], nextchar); } nextchar = (char *) ""; optind++; return '?'; } } /* Look at and handle the next option-character. */ { char c = *nextchar++; char *temp = my_index (optstring, c); /* Increment `optind' when we start to process its last character. */ if (*nextchar == '\0') ++optind; if (temp == NULL || c == ':') { if (opterr) { if (c < 040 || c >= 0177) fprintf (stderr, "%s: unrecognized option, character code 0%o\n", argv[0], c); else fprintf (stderr, "%s: unrecognized option `-%c'\n", argv[0], c); } return '?'; } if (temp[1] == ':') { if (temp[2] == ':') { /* This is an option that accepts an argument optionally. */ if (*nextchar != '\0') { optarg = nextchar; optind++; } else optarg = 0; nextchar = NULL; } else { /* This is an option that requires an argument. */ if (*nextchar != '\0') { optarg = nextchar; /* If we end this ARGV-element by taking the rest as an arg, we must advance to the next element now. */ optind++; } else if (optind == argc) { if (opterr) fprintf (stderr, "%s: option `-%c' requires an argument\n", argv[0], c); c = '?'; } else /* We already incremented `optind' once; increment it again when taking next ARGV-elt as argument. */ optarg = argv[optind++]; nextchar = NULL; } } return c; } } int getopt (argc, argv, optstring) int argc; char *const *argv; const char *optstring; { return _getopt_internal (argc, argv, optstring, (const struct option *) 0, (int *) 0, 0); } #ifdef TEST /* Compile with -DTEST to make an executable for use in testing the above definition of `getopt'. */ int main (argc, argv) int argc; char **argv; { int c; int digit_optind = 0; while (1) { int this_option_optind = optind ? optind : 1; c = getopt (argc, argv, "abc:d:0123456789"); if (c == EOF) break; switch (c) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (digit_optind != 0 && digit_optind != this_option_optind) printf ("digits occur in two different argv-elements.\n"); digit_optind = this_option_optind; printf ("option %c\n", c); break; case 'a': printf ("option a\n"); break; case 'b': printf ("option b\n"); break; case 'c': printf ("option c with value `%s'\n", optarg); break; case '?': break; default: printf ("?? getopt returned character code 0%o ??\n", c); } } if (optind < argc) { printf ("non-option ARGV-elements: "); while (optind < argc) printf ("%s ", argv[optind++]); printf ("\n"); } exit (0); } #endif /* TEST */ texinfo-2.15/C/makeinfo.c0000644000175000017500000053072312415566137012516 0ustar gg/* Makeinfo -- convert texinfo format files into info files. Copyright (C) 1987, 1991 Free Software Foundation, Inc. This file is part of GNU Info. Makeinfo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to anyone for the consequences of using it or for whether it serves any particular purpose or works at all, unless he says so in writing. Refer to the GNU Emacs General Public License for full details. Everyone is granted permission to copy, modify and redistribute Makeinfo, but only under the conditions described in the GNU Emacs General Public License. A copy of this license is supposed to have been given to you along with GNU Emacs so you can know your rights and responsibilities. It should be in a file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ /* This is Makeinfo version 1.47. If you change the version number of Makeinfo, please change it here and at the lines reading: int major_version = 1; int minor_version = 47; in the code below. */ /* You can change some of the behaviour of Makeinfo by changing the following defines: */ /* Define INDENT_PARAGRAPHS_IN_TABLE if you want the paragraphs which appear within an @table, @ftable, or @itemize environment to have standard paragraph indentation. Without this, such paragraphs have no starting indentation. */ /* #define INDENT_PARAGRAPHS_IN_TABLE */ /* Define DEFAULT_INDENTATION_INCREMENT as an integer which is the amount that @example should increase indentation by. This incremement is used for all insertions which indent the enclosed text. */ #define DEFAULT_INDENTATION_INCREMENT 5 /* Define PARAGRAPH_START_INDENT to be the amount of indentation that the first lines of paragraphs receive by default, where no other value has been specified. Users can change this value on the command line, with the +paragraph-indent option, or within the texinfo file, with the @paragraphindent command. */ #define PARAGRAPH_START_INDENT 3 /* Define DEFAULT_PARAGRAPH_SPACING as the number of blank lines that you wish to appear between paragraphs. A value of 1 creates a single blank line between paragraphs. Paragraphs are defined by 2 or more consecutive newlines in the input file (i.e., one or more blank lines). */ #define DEFAULT_PARAGRAPH_SPACING 1 /* **************************************************************** */ /* */ /* Include File Declarations */ /* */ /* **************************************************************** */ /* Indent #pragma so that older Cpp's don't try to parse it. */ #if defined (_AIX) # pragma alloca #endif /* _AIX */ #include #include #include #include #include #include #include #include "getopt.h" #if defined (VMS) # include #endif #if defined (USG) || defined (VMS) # include # include #else /* !USG && !VMS */ # include # include #endif /* !USG && !VMS */ #include #include #if defined (USG) || defined (hpux) #define bcopy(source, dest, count) memcpy (dest, source, count) char *index (s, c) char *s; { char *strchr (); return strchr (s, c); } char *rindex (s, c) char *s; { char *strrchr (); return (strrchr (s, c)); } #endif /* USG || hpux */ #if defined (__GNUC__) # define alloca __builtin_alloca #else # if defined (sparc) # include # else # if !defined (_AIX) extern char *alloca (); # endif /* _AIX */ # endif /* !sparc */ #endif /* !__GNUC__ */ /* Forward declarations. */ void *xmalloc (), *xrealloc (); /* Non-zero means that we are currently hacking the insides of an insertion which would use a fixed width font. */ static int in_fixed_width_font = 0; /* Non-zero means that start_paragraph () MUST be called before we pay any attention to close_paragraph () calls. */ int must_start_paragraph = 0; /* Some systems don't declare this function in pwd.h. */ struct passwd *getpwnam (); /* **************************************************************** */ /* */ /* Global Defines */ /* */ /* **************************************************************** */ /* Error levels */ #define NO_ERROR 0 #define SYNTAX 2 #define FATAL 4 /* How to allocate permanent storage for STRING. */ #define savestring(x) \ ((char *)strcpy ((char *)xmalloc (1 + ((x) ? strlen (x) : 0)), \ (x) ? (x) : "")) /* C's standard macros don't check to make sure that the characters being changed are within range. So I have to check explicitly. */ /* GNU Library doesn't have toupper(). Until GNU gets this fixed, I will have to do it. */ #ifndef toupper #define toupper(c) ((c) - 32) #endif #define coerce_to_upper(c) ((islower(c) ? toupper(c) : (c))) #define coerce_to_lower(c) ((isupper(c) ? tolower(c) : (c))) #define control_character_bit 0x40 /* %01000000, must be off. */ #define meta_character_bit 0x080/* %10000000, must be on. */ #define CTL(c) ((c) & (~control_character_bit)) #define UNCTL(c) coerce_to_upper(((c)|control_character_bit)) #define META(c) ((c) | (meta_character_bit)) #define UNMETA(c) ((c) & (~meta_character_bit)) #define whitespace(c) (((c) == '\t') || ((c) == ' ')) #define sentence_ender(c) ((c) == '.' || (c) == '?' || (c) == '!') #define cr_or_whitespace(c) (((c) == '\t') || ((c) == ' ') || ((c) == '\n')) #ifndef isletter #define isletter(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z')) #endif #ifndef isupper #define isupper(c) ((c) >= 'A' && (c) <= 'Z') #endif #ifndef isdigit #define isdigit(c) ((c) >= '0' && (c) <= '9') #endif #ifndef digit_value #define digit_value(c) ((c) - '0') #endif #define member(c, s) (index (s, c) != NULL) #define COMMAND_PREFIX '@' /* Stuff for splitting large files. */ #define SPLIT_SIZE_THRESHOLD 70000 /* What's good enough for Stallman... */ #define DEFAULT_SPLIT_SIZE 50000/* Is probably good enough for me. */ int splitting = 1; /* Always true for now. */ typedef int FUNCTION (); /* So I can say FUNCTION *foo; */ /* **************************************************************** */ /* */ /* Global Variables */ /* */ /* **************************************************************** */ /* Global pointer to argv[0]. */ char *progname; /* The current input file state. */ char *input_filename; char *input_text; int size_of_input_text; int input_text_offset; int line_number; #define curchar() input_text[input_text_offset] #define command_char(c) ((!whitespace(c)) && \ ((c) != '\n') && \ ((c) != '{') && \ ((c) != '}') && \ ((c) != '=')) #define skip_whitespace() while (input_text_offset != size_of_input_text \ && whitespace(curchar()))\ input_text_offset++ /* Return non-zero if STRING is the text at input_text + input_text_offset, else zero. */ #define looking_at(string) \ (strncmp (input_text + input_text_offset, string, strlen (string)) == 0) /* And writing to the output. */ /* The output file name. */ char *output_filename = (char *)NULL; char *pretty_output_filename; /* Name of the output file that the user elected to pass on the command line. Such a name overrides any name found with the @setfilename command. */ char *command_output_filename = (char *)NULL; /* A colon separated list of directories to search for files included with @include. This can be controlled with the `-I' option to makeinfo. */ char *include_files_path = (char *)NULL; /* Current output stream. */ FILE *output_stream; /* Position in the output file. */ int output_position; /* Output paragraph buffer. */ unsigned char *output_paragraph; /* Offset into OUTPUT_PARAGRAPH. */ int output_paragraph_offset; /* The output paragraph "cursor" horizontal position. */ int output_column = 0; /* Non-zero means output_paragraph contains text. */ int paragraph_is_open = 0; #define INITIAL_PARAGRAPH_SPACE 5000 int paragraph_buffer_len = INITIAL_PARAGRAPH_SPACE; /* Filling.. */ /* Non-zero indicates that filling will take place on long lines. */ int filling_enabled = 1; /* Non-zero means that words are not to be split, even in long lines. This gets changed for cm_w (). */ int non_splitting_words = 0; /* Non-zero indicates that filling a line also indents the new line. */ int indented_fill = 0; /* The column at which long lines are broken. */ int fill_column = 72; /* The amount of indentation to apply at the start of each line. */ int current_indent = 0; /* The amount of indentation to add at the starts of paragraphs. 0 means don't change existing indentation at paragraph starts. > 0 is amount to indent new paragraphs by. < 0 means indent to column zero by removing indentation if necessary. This is normally zero, but some people prefer paragraph starts to be somewhat more indented than paragraph bodies. A pretty value for this is 3. */ int paragraph_start_indent = PARAGRAPH_START_INDENT; /* Non-zero means that the use of paragraph_start_indent is inhibited. @example uses this to line up the left columns of the example text. A negative value for this variable is incremented each time it is used. @noindent uses this to inhibit indentation for a single paragraph. */ int inhibit_paragraph_indentation = 0; /* Indentation that is pending insertion. We have this for hacking lines which look blank, but contain whitespace. We want to treat those as blank lines. */ int pending_indent = 0; /* The amount that indentation increases/decreases by. */ int default_indentation_increment = DEFAULT_INDENTATION_INCREMENT; /* Non-zero indicates that indentation is temporarily turned off. */ int no_indent = 1; /* Non-zero means forcing output text to be flushright. */ int force_flush_right = 0; /* Non-zero means that the footnote style for this document was set on the command line, which overrides any other settings. */ int footnote_style_preset = 0; /* Non-zero means that we automatically number footnotes that have no specified marker. */ int number_footnotes = 1; /* The current footnote number in this node. Each time a new node is started this is reset to 1. */ int current_footnote_number = 1; /* Command name in the process of being hacked. */ char *command; /* The index in our internal command table of the currently executing command. */ int command_index; /* A stack of file information records. If a new file is read in with "@input", we remember the old input file state on this stack. */ typedef struct fstack { struct fstack *next; char *filename; char *text; int size; int offset; int line_number; } FSTACK; FSTACK *filestack = (FSTACK *) NULL; /* Stuff for nodes. */ /* The current nodes node name. */ char *current_node = (char *)NULL; /* The current nodes section level. */ int current_section = 0; /* The filename of the current input file. This is never freed. */ char *node_filename = (char *)NULL; /* What we remember for each node. */ typedef struct tentry { struct tentry *next_ent; char *node; /* name of this node. */ char *prev; /* name of "Prev:" for this node. */ char *next; /* name of "Next:" for this node. */ char *up; /* name of "Up:" for this node. */ int position; /* output file position of this node. */ int line_no; /* defining line in source file. */ char *filename; /* The file that this node was found in. */ int touched; /* non-zero means this node has been referenced. */ int flags; /* Room for growth. Right now, contains 1 bit. */ } TAG_ENTRY; /* If node-a has a "Next" for node-b, but node-b has no "Prev" for node-a, we turn on this flag bit in node-b's tag entry. This means that when it is time to validate node-b, we don't report an additional error if there was no "Prev" field. */ #define PREV_ERROR 0x1 #define NEXT_ERROR 0x2 #define UP_ERROR 0x4 #define NO_WARN 0x8 #define IS_TOP 0x10 TAG_ENTRY *tag_table = (TAG_ENTRY *) NULL; #define HAVE_MACROS #if defined (HAVE_MACROS) /* Macro definitions for user-defined commands. */ typedef struct { char *name; /* Name of the macro. */ char *definition; /* Definition text. */ char *filename; /* File where this macro is defined. */ int lineno; /* Line number within FILENAME. */ } MACRO_DEF; void add_macro (), execute_macro (); MACRO_DEF *find_macro (), *delete_macro (); #endif /* HAVE_MACROS */ /* Menu reference, *note reference, and validation hacking. */ /* The various references that we know about. */ enum reftype { menu_reference, followed_reference }; /* A structure to remember references with. A reference to a node is either an entry in a menu, or a cross-reference made with [px]ref. */ typedef struct node_ref { struct node_ref *next; char *node; /* Name of node referred to. */ char *containing_node; /* Name of node containing this reference. */ int line_no; /* Line number where the reference occurs. */ int section; /* Section level where the reference occurs. */ char *filename; /* Name of file where the reference occurs. */ enum reftype type; /* Type of reference, either menu or note. */ } NODE_REF; /* The linked list of such structures. */ NODE_REF *node_references = (NODE_REF *) NULL; /* Flag which tells us whether to examine menu lines or not. */ int in_menu = 0; /* Flags controlling the operation of the program. */ /* Default is to notify users of bad choices. */ int print_warnings = 1; /* Default is to check node references. */ int validating = 1; /* Non-zero means do not output "Node: Foo" for node separations. */ int no_headers = 0; /* Number of errors that we tolerate on a given fileset. */ int max_error_level = 100; /* Maximum number of references to a single node before complaining. */ int reference_warning_limit = 1000; /* Non-zero means print out information about what is going on when it is going on. */ int verbose_mode = 0; /* The list of commands that we hack in texinfo. Each one has an associated function. When the command is encountered in the text, the associated function is called with START as the argument. If the function expects arguments in braces, it remembers itself on the stack. When the corresponding close brace is encountered, the function is called with END as the argument. */ #define START 0 #define END 1 typedef struct brace_element { struct brace_element *next; FUNCTION *proc; int pos, line; } BRACE_ELEMENT; BRACE_ELEMENT *brace_stack = (BRACE_ELEMENT *) NULL; /* Forward declarations. */ int insert_self (), cm_ignore_line (); int cm_tex (), cm_asterisk (), cm_dots (), cm_bullet (), cm_TeX (), cm_copyright (), cm_code (), cm_samp (), cm_file (), cm_kbd (), cm_key (), cm_ctrl (), cm_var (), cm_dfn (), cm_emph (), cm_strong (), cm_cite (), cm_italic (), cm_bold (), cm_roman (), cm_title (), cm_w (), cm_refill (), cm_titlefont (); int cm_chapter (), cm_unnumbered (), cm_appendix (), cm_top (), cm_section (), cm_unnumberedsec (), cm_appendixsec (), cm_subsection (), cm_unnumberedsubsec (), cm_appendixsubsec (), cm_subsubsection (), cm_unnumberedsubsubsec (), cm_appendixsubsubsec (), cm_heading (), cm_chapheading (), cm_subheading (), cm_subsubheading (), cm_majorheading (); /* All @defxxx commands map to cm_defun (). */ int cm_defun (); int cm_node (), cm_menu (), cm_xref (), cm_ftable (), cm_vtable (), cm_pxref (), cm_inforef (), cm_quotation (), cm_display (), cm_itemize (), cm_enumerate (), cm_table (), cm_itemx (), cm_noindent (), cm_setfilename (), cm_br (), cm_sp (), cm_page (), cm_group (), cm_center (), cm_include (), cm_bye (), cm_item (), cm_end (), cm_infoinclude (), cm_ifinfo (), cm_kindex (), cm_cindex (), cm_findex (), cm_pindex (), cm_vindex (), cm_tindex (), cm_asis (), cm_synindex (), cm_printindex (), cm_minus (), cm_footnote (), cm_force_abbreviated_whitespace (), cm_example (), cm_smallexample (), cm_lisp (), cm_format (), cm_exdent (), cm_defindex (), cm_defcodeindex (), cm_sc (), cm_result (), cm_expansion (), cm_equiv (), cm_print (), cm_error (), cm_point (), cm_today (), cm_flushleft (), cm_flushright (), cm_smalllisp (), cm_finalout (), cm_math (), cm_cartouche (), cm_ignore_sentence_ender (); /* Conditionals. */ int cm_set (), cm_clear (), cm_ifset (), cm_ifclear (), cm_value (); #if defined (HAVE_MACROS) /* Define a user-defined command which is simple substitution. */ int cm_macro (), cm_unmacro (); #endif /* HAVE_MACROS */ /* Options. */ int cm_paragraphindent (), cm_footnotestyle (); /* Internals. */ int do_nothing (), command_name_condition (); int misplaced_brace (), cm_obsolete (); typedef struct { char *name; FUNCTION *proc; int argument_in_braces; } COMMAND; /* Stuff for defining commands on the fly. */ COMMAND **user_command_array = (COMMAND **) NULL; int user_command_array_len = 0; #define NO_BRACE_ARGS 0 #define BRACE_ARGS 1 static COMMAND CommandTable[] = { { "!", cm_ignore_sentence_ender, NO_BRACE_ARGS }, { "'", insert_self, NO_BRACE_ARGS }, { "*", cm_asterisk, NO_BRACE_ARGS }, { ".", cm_ignore_sentence_ender, NO_BRACE_ARGS }, { ":", cm_force_abbreviated_whitespace, NO_BRACE_ARGS }, { "?", cm_ignore_sentence_ender, NO_BRACE_ARGS }, { "@", insert_self, NO_BRACE_ARGS }, { " ", insert_self, NO_BRACE_ARGS }, { "\n", insert_self, NO_BRACE_ARGS }, { "TeX", cm_TeX, BRACE_ARGS }, { "`", insert_self, NO_BRACE_ARGS }, { "appendix", cm_appendix, NO_BRACE_ARGS }, { "appendixsection", cm_appendixsec, NO_BRACE_ARGS }, { "appendixsec", cm_appendixsec, NO_BRACE_ARGS }, { "appendixsubsec", cm_appendixsubsec, NO_BRACE_ARGS }, { "appendixsubsubsec", cm_appendixsubsubsec, NO_BRACE_ARGS }, { "asis", cm_asis, BRACE_ARGS }, { "b", cm_bold, BRACE_ARGS }, { "br", cm_br, NO_BRACE_ARGS }, { "bullet", cm_bullet, BRACE_ARGS }, { "bye", cm_bye, NO_BRACE_ARGS }, { "c", cm_ignore_line, NO_BRACE_ARGS }, { "cartouche", cm_cartouche, NO_BRACE_ARGS }, { "center", cm_center, NO_BRACE_ARGS }, { "chapheading", cm_chapheading, NO_BRACE_ARGS }, { "chapter", cm_chapter, NO_BRACE_ARGS }, { "cindex", cm_cindex, NO_BRACE_ARGS }, { "cite", cm_cite, BRACE_ARGS }, { "clear", cm_clear, NO_BRACE_ARGS }, { "code", cm_code, BRACE_ARGS }, { "comment", cm_ignore_line, NO_BRACE_ARGS }, { "contents", do_nothing, NO_BRACE_ARGS }, { "copyright", cm_copyright, BRACE_ARGS }, { "ctrl", cm_ctrl, BRACE_ARGS }, { "defcodeindex", cm_defcodeindex, NO_BRACE_ARGS }, { "defindex", cm_defindex, NO_BRACE_ARGS }, { "dfn", cm_dfn, BRACE_ARGS }, /* The `def' commands. */ { "deffn", cm_defun, NO_BRACE_ARGS }, { "deffnx", cm_defun, NO_BRACE_ARGS }, { "defun", cm_defun, NO_BRACE_ARGS }, { "defunx", cm_defun, NO_BRACE_ARGS }, { "defmac", cm_defun, NO_BRACE_ARGS }, { "defmacx", cm_defun, NO_BRACE_ARGS }, { "defspec", cm_defun, NO_BRACE_ARGS }, { "defspecx", cm_defun, NO_BRACE_ARGS }, { "defvr", cm_defun, NO_BRACE_ARGS }, { "defvrx", cm_defun, NO_BRACE_ARGS }, { "defvar", cm_defun, NO_BRACE_ARGS }, { "defvarx", cm_defun, NO_BRACE_ARGS }, { "defopt", cm_defun, NO_BRACE_ARGS }, { "defoptx", cm_defun, NO_BRACE_ARGS }, { "deftypefn", cm_defun, NO_BRACE_ARGS }, { "deftypefnx", cm_defun, NO_BRACE_ARGS }, { "deftypefun", cm_defun, NO_BRACE_ARGS }, { "deftypefunx", cm_defun, NO_BRACE_ARGS }, { "deftypevr", cm_defun, NO_BRACE_ARGS }, { "deftypevrx", cm_defun, NO_BRACE_ARGS }, { "deftypevar", cm_defun, NO_BRACE_ARGS }, { "deftypevarx", cm_defun, NO_BRACE_ARGS }, { "defcv", cm_defun, NO_BRACE_ARGS }, { "defcvx", cm_defun, NO_BRACE_ARGS }, { "defivar", cm_defun, NO_BRACE_ARGS }, { "defivarx", cm_defun, NO_BRACE_ARGS }, { "defop", cm_defun, NO_BRACE_ARGS }, { "defopx", cm_defun, NO_BRACE_ARGS }, { "defmethod", cm_defun, NO_BRACE_ARGS }, { "defmethodx", cm_defun, NO_BRACE_ARGS }, { "deftypemethod", cm_defun, NO_BRACE_ARGS }, { "deftypemethodx", cm_defun, NO_BRACE_ARGS }, { "deftp", cm_defun, NO_BRACE_ARGS }, { "deftpx", cm_defun, NO_BRACE_ARGS }, /* The end of the `def' commands. */ { "display", cm_display, NO_BRACE_ARGS }, { "dots", cm_dots, BRACE_ARGS }, { "dmn", do_nothing, BRACE_ARGS }, { "emph", cm_emph, BRACE_ARGS }, { "end", cm_end, NO_BRACE_ARGS }, { "enumerate", cm_enumerate, NO_BRACE_ARGS }, { "equiv", cm_equiv, BRACE_ARGS }, { "error", cm_error, BRACE_ARGS }, { "example", cm_example, NO_BRACE_ARGS }, { "exdent", cm_exdent, NO_BRACE_ARGS }, { "expansion", cm_expansion, BRACE_ARGS }, { "file", cm_file, BRACE_ARGS }, { "findex", cm_findex, NO_BRACE_ARGS }, { "finalout", do_nothing, NO_BRACE_ARGS }, { "flushleft", cm_flushleft, NO_BRACE_ARGS }, { "flushright", cm_flushright, NO_BRACE_ARGS }, { "format", cm_format, NO_BRACE_ARGS }, { "ftable", cm_ftable, NO_BRACE_ARGS }, { "group", cm_group, NO_BRACE_ARGS }, { "heading", cm_heading, NO_BRACE_ARGS }, { "headings", cm_ignore_line, NO_BRACE_ARGS }, { "i", cm_italic, BRACE_ARGS }, { "iappendix", cm_appendix, NO_BRACE_ARGS }, { "iappendixsection", cm_appendixsec, NO_BRACE_ARGS }, { "iappendixsec", cm_appendixsec, NO_BRACE_ARGS }, { "iappendixsubsec", cm_appendixsubsec, NO_BRACE_ARGS }, { "iappendixsubsubsec", cm_appendixsubsubsec, NO_BRACE_ARGS }, { "ichapter", cm_chapter, NO_BRACE_ARGS }, { "ifclear", cm_ifclear, NO_BRACE_ARGS }, { "ifinfo", cm_ifinfo, NO_BRACE_ARGS }, { "ifset", cm_ifset, NO_BRACE_ARGS }, { "iftex", command_name_condition, NO_BRACE_ARGS }, { "ignore", command_name_condition, NO_BRACE_ARGS }, { "include", cm_include, NO_BRACE_ARGS }, { "inforef", cm_inforef, BRACE_ARGS }, { "input", cm_include, NO_BRACE_ARGS }, { "isection", cm_section, NO_BRACE_ARGS }, { "isubsection", cm_subsection, NO_BRACE_ARGS }, { "isubsubsection", cm_subsubsection, NO_BRACE_ARGS }, { "item", cm_item, NO_BRACE_ARGS }, { "itemize", cm_itemize, NO_BRACE_ARGS }, { "itemx", cm_itemx, NO_BRACE_ARGS }, { "iunnumbered", cm_unnumbered, NO_BRACE_ARGS }, { "iunnumberedsec", cm_unnumberedsec, NO_BRACE_ARGS }, { "iunnumberedsubsec", cm_unnumberedsubsec, NO_BRACE_ARGS }, { "iunnumberedsubsubsec", cm_unnumberedsubsubsec, NO_BRACE_ARGS }, { "kbd", cm_kbd, BRACE_ARGS }, { "key", cm_key, BRACE_ARGS }, { "kindex", cm_kindex, NO_BRACE_ARGS }, { "lisp", cm_lisp, NO_BRACE_ARGS }, { "macro", cm_macro, NO_BRACE_ARGS }, { "majorheading", cm_majorheading, NO_BRACE_ARGS }, { "math", cm_math, BRACE_ARGS }, { "menu", cm_menu, NO_BRACE_ARGS }, { "minus", cm_minus, BRACE_ARGS }, { "need", cm_ignore_line, NO_BRACE_ARGS }, { "node", cm_node, NO_BRACE_ARGS }, { "noindent", cm_noindent, NO_BRACE_ARGS }, { "nwnode", cm_node, NO_BRACE_ARGS }, { "overfullrule", cm_ignore_line, NO_BRACE_ARGS }, { "page", do_nothing, NO_BRACE_ARGS }, { "pindex", cm_pindex, NO_BRACE_ARGS }, { "point", cm_point, BRACE_ARGS }, { "print", cm_print, BRACE_ARGS }, { "printindex", cm_printindex, NO_BRACE_ARGS }, { "pxref", cm_pxref, BRACE_ARGS }, { "quotation", cm_quotation, NO_BRACE_ARGS }, { "r", cm_roman, BRACE_ARGS }, { "ref", cm_xref, BRACE_ARGS }, { "refill", cm_refill, NO_BRACE_ARGS }, { "result", cm_result, BRACE_ARGS }, { "samp", cm_samp, BRACE_ARGS }, { "sc", cm_sc, BRACE_ARGS }, { "section", cm_section, NO_BRACE_ARGS }, { "set", cm_set, NO_BRACE_ARGS }, { "setchapternewpage", cm_ignore_line, NO_BRACE_ARGS }, { "setchapterstyle", cm_ignore_line, NO_BRACE_ARGS }, { "setfilename", cm_setfilename, NO_BRACE_ARGS }, { "settitle", cm_ignore_line, NO_BRACE_ARGS }, { "shortcontents", do_nothing, NO_BRACE_ARGS }, { "smallbook", cm_ignore_line, NO_BRACE_ARGS }, { "smallexample", cm_smallexample, NO_BRACE_ARGS }, { "smalllisp", cm_smalllisp, NO_BRACE_ARGS }, { "sp", cm_sp, NO_BRACE_ARGS }, { "strong", cm_strong, BRACE_ARGS }, { "subheading", cm_subheading, NO_BRACE_ARGS }, { "subsection", cm_subsection, NO_BRACE_ARGS }, { "subsubheading", cm_subsubheading, NO_BRACE_ARGS }, { "subsubsection", cm_subsubsection, NO_BRACE_ARGS }, { "summarycontents", do_nothing, NO_BRACE_ARGS }, { "syncodeindex", cm_synindex, NO_BRACE_ARGS }, { "synindex", cm_synindex, NO_BRACE_ARGS }, { "t", cm_title, BRACE_ARGS }, { "table", cm_table, NO_BRACE_ARGS }, { "tex", command_name_condition, NO_BRACE_ARGS }, { "tindex", cm_tindex, NO_BRACE_ARGS }, { "titlefont", cm_titlefont, BRACE_ARGS }, { "titlepage", command_name_condition, NO_BRACE_ARGS }, { "titlespec", command_name_condition, NO_BRACE_ARGS }, { "today", cm_today, BRACE_ARGS }, { "top", cm_top, NO_BRACE_ARGS }, { "unmacro", cm_unmacro, NO_BRACE_ARGS }, { "unnumbered", cm_unnumbered, NO_BRACE_ARGS }, { "unnumberedsec", cm_unnumberedsec, NO_BRACE_ARGS }, { "unnumberedsubsec", cm_unnumberedsubsec, NO_BRACE_ARGS }, { "unnumberedsubsubsec", cm_unnumberedsubsubsec, NO_BRACE_ARGS }, { "value", cm_value, BRACE_ARGS }, { "var", cm_var, BRACE_ARGS }, { "vindex", cm_vindex, NO_BRACE_ARGS }, { "vtable", cm_vtable, NO_BRACE_ARGS }, { "w", cm_w, BRACE_ARGS }, { "xref", cm_xref, BRACE_ARGS }, { "{", insert_self, NO_BRACE_ARGS }, { "}", insert_self, NO_BRACE_ARGS }, /* Some obsoleted commands. */ { "infotop", cm_obsolete, NO_BRACE_ARGS }, { "infounnumbered", cm_obsolete, NO_BRACE_ARGS }, { "infounnumberedsec", cm_obsolete, NO_BRACE_ARGS }, { "infounnumberedsubsec", cm_obsolete, NO_BRACE_ARGS }, { "infounnumberedsubsubsec", cm_obsolete, NO_BRACE_ARGS }, { "infoappendix", cm_obsolete, NO_BRACE_ARGS }, { "infoappendixsec", cm_obsolete, NO_BRACE_ARGS }, { "infoappendixsubsec", cm_obsolete, NO_BRACE_ARGS }, { "infoappendixsubsubsec", cm_obsolete, NO_BRACE_ARGS }, { "infochapter", cm_obsolete, NO_BRACE_ARGS }, { "infosection", cm_obsolete, NO_BRACE_ARGS }, { "infosubsection", cm_obsolete, NO_BRACE_ARGS }, { "infosubsubsection", cm_obsolete, NO_BRACE_ARGS }, /* Now @include does what this was supposed to. */ { "infoinclude", cm_infoinclude, NO_BRACE_ARGS }, { "footnote", cm_footnote, NO_BRACE_ARGS}, /* self-arg eater */ { "footnotestyle", cm_footnotestyle, NO_BRACE_ARGS }, { "paragraphindent", cm_paragraphindent, NO_BRACE_ARGS }, {(char *) NULL, (FUNCTION *) NULL}, NO_BRACE_ARGS}; int major_version = 1; int minor_version = 47; struct option long_options[] = { { "error-limit", 1, 0, 'e' }, /* formerly -el */ { "fill-column", 1, 0, 'f' }, /* formerly -fc */ { "footnote-style", 1, 0, 's' }, /* formerly -ft */ { "no-headers", 0, &no_headers, 1 }, /* Do not output Node: foo */ { "no-pointer-validate", 0, &validating, 0 }, /* formerly -nv */ { "no-validate", 0, &validating, 0 }, /* formerly -nv */ { "no-split", 0, &splitting, 0 }, /* formerly -ns */ { "no-warn", 0, &print_warnings, 0 }, /* formerly -nw */ { "number-footnotes", 0, &number_footnotes, 1 }, { "no-number-footnotes", 0, &number_footnotes, 0 }, { "output", 1, 0, 'o' }, { "paragraph-indent", 1, 0, 'p' }, /* formerly -pi */ { "reference-limit", 1, 0, 'r' }, /* formerly -rl */ { "verbose", 0, &verbose_mode, 1 }, /* formerly -verbose */ { "version", 0, 0, 'V' }, {NULL, 0, NULL, 0} }; /* Values for calling handle_variable_internal (). */ #define SET 1 #define CLEAR 2 #define IFSET 3 #define IFCLEAR 4 /* **************************************************************** */ /* */ /* Main () Start of code */ /* */ /* **************************************************************** */ /* For each file mentioned in the command line, process it, turning texinfo commands into wonderfully formatted output text. */ main (argc, argv) int argc; char **argv; { extern int errors_printed; char *filename_part (); int c, ind; /* The name of this program is the last filename in argv[0]. */ progname = filename_part (argv[0]); /* Parse argument flags from the input line. */ while ((c = getopt_long (argc, argv, "D:U:I:f:o:p:e:r:s:V", long_options, &ind)) != EOF) { if (c == 0 && long_options[ind].flag == 0) c = long_options[ind].val; switch (c) { /* User specified variable to set or clear? */ case 'D': case 'U': handle_variable_internal ((c == 'D') ? SET : CLEAR, optarg); break; /* User specified include file path? */ case 'I': if (!include_files_path) include_files_path = savestring ("."); include_files_path = (char *) xrealloc (include_files_path, 2 + strlen (include_files_path) + strlen (optarg)); strcat (include_files_path, ":"); strcat (include_files_path, optarg); break; /* User specified fill_column? */ case 'f': if (sscanf (optarg, "%d", &fill_column) != 1) usage (); break; /* User specified output file? */ case 'o': command_output_filename = savestring (optarg); break; /* User specified paragraph indent (paragraph_start_index)? */ case 'p': if (set_paragraph_indent (optarg) < 0) usage (); break; /* User specified error level? */ case 'e': if (sscanf (optarg, "%d", &max_error_level) != 1) usage (); break; /* User specified reference warning limit? */ case 'r': if (sscanf (optarg, "%d", &reference_warning_limit) != 1) usage (); break; /* User specified footnote style? */ case 's': if (set_footnote_style (optarg) < 0) usage (); footnote_style_preset = 1; break; /* User requested version info? */ case 'V': print_version_info (); exit (NO_ERROR); break; case '?': usage (); } } if (optind == argc) usage (); else if (verbose_mode) print_version_info (); /* Remaining arguments are file names of texinfo files. Convert them, one by one. */ while (optind != argc) convert (argv[optind++]); if (errors_printed) exit (SYNTAX); else exit (NO_ERROR); } /* Display the version info of this invocation of Makeinfo. */ print_version_info () { fprintf (stderr, "This is GNU Makeinfo version %d.%d.\n", major_version, minor_version); } /* **************************************************************** */ /* */ /* Generic Utilities */ /* */ /* **************************************************************** */ /* Just like malloc, but kills the program in case of fatal error. */ void * xmalloc (nbytes) int nbytes; { void *temp = (void *) malloc (nbytes); if (nbytes && temp == (void *)NULL) memory_error ("xmalloc", nbytes); return (temp); } /* Like realloc (), but barfs if there isn't enough memory. */ void * xrealloc (pointer, nbytes) void *pointer; int nbytes; { void *temp; if (!pointer) temp = (void *)xmalloc (nbytes); else temp = (void *)realloc (pointer, nbytes); if (nbytes && !temp) memory_error ("xrealloc", nbytes); return (temp); } memory_error (callers_name, bytes_wanted) char *callers_name; int bytes_wanted; { char printable_string[80]; sprintf (printable_string, "Virtual memory exhausted in %s ()! Needed %d bytes.", callers_name, bytes_wanted); error (printable_string); abort (); } /* Tell the user how to use this program. */ usage () { fprintf (stderr, "Usage: %s [options] texinfo-file...\n\ \n\ This program accepts as input files of texinfo commands and text\n\ and outputs a file suitable for reading with GNU Info.\n\ \n\ The options are:\n\ `-I DIR' to add DIR to the directory search list for including\n\ files with the `@include' command.\n\ -D VAR to define a variable, as with `@set'.\n\ -U VAR to undefine a variable, as with `@clear'.\n\ `--no-validate' to suppress node cross reference validation.\n\ `--no-warn' to suppress warning messages (errors are still output).\n\ `--no-split' to suppress the splitting of large files.\n\ `--no-headers' to suppress the output of Node: Foo headers.\n\ `--verbose' to print information about what is being done.\n\ `--version' to print the version number of Makeinfo.\n\ `--output FILE' or `-o FILE'\n\ to specify the output file. When you specify the\n\ output file in this way, any `@setfilename' in the\n\ input file is ignored.\n\ `--paragraph-indent NUM'\n\ to set the paragraph indent to NUM (default %d).\n\ `--fill-column NUM' to set the filling column to NUM (default %d).\n\ `--error-limit NUM' to set the error limit to NUM (default %d).\n\ `--reference-limit NUM'\n\ to set the reference warning limit to NUM (default %d).\n\ `--footnote-style STYLE'\n\ to set the footnote style to STYLE. STYLE should\n\ either be `separate' to place footnotes in their own\n\ node, or `end', to place the footnotes at the end of\n\ the node in which they are defined (the default).\n\n", progname, paragraph_start_indent, fill_column, max_error_level, reference_warning_limit); exit (FATAL); } /* **************************************************************** */ /* */ /* Manipulating Lists */ /* */ /* **************************************************************** */ typedef struct generic_list { struct generic_list *next; } GENERIC_LIST; /* Reverse the chain of structures in LIST. Output the new head of the chain. You should always assign the output value of this function to something, or you will lose the chain. */ GENERIC_LIST * reverse_list (list) register GENERIC_LIST *list; { register GENERIC_LIST *next; register GENERIC_LIST *prev = (GENERIC_LIST *) NULL; while (list) { next = list->next; list->next = prev; prev = list; list = next; } return (prev); } /* **************************************************************** */ /* */ /* Pushing and Popping Files */ /* */ /* **************************************************************** */ /* Find and load the file named FILENAME. Return a pointer to the loaded file, or NULL if it can't be loaded. */ char * find_and_load (filename) char *filename; { struct stat fileinfo; int file, n, i, count = 0; char *fullpath, *result, *get_file_info_in_path (); result = fullpath = (char *)NULL; fullpath = get_file_info_in_path (filename, include_files_path, &fileinfo); if (!fullpath) goto error_exit; filename = fullpath; file = open (filename, O_RDONLY); if (file < 0) goto error_exit; /* Load the file. */ result = (char *)xmalloc (fileinfo.st_size); /* VMS stat lies about the st_size value. The actual number of readable bytes is always less than this value. The arcane mysteries of VMS/RMS are too much to probe, so this hack suffices to make things work. */ #if defined (VMS) while ((n = read (file, result + count, fileinfo.st_size)) > 0) count += n; if (n == -1) #else /* !VMS */ count = fileinfo.st_size; if (read (file, result, fileinfo.st_size) != fileinfo.st_size) #endif /* !VMS */ error_exit: { if (result) free (result); if (fullpath) free (fullpath); if (file != -1) close (file); return ((char *) NULL); } close (file); /* Set the globals to the new file. */ input_text = result; size_of_input_text = fileinfo.st_size; input_filename = savestring (fullpath); node_filename = savestring (fullpath); input_text_offset = 0; line_number = 1; return (result); } /* Save the state of the current input file. */ pushfile () { FSTACK *newstack = (FSTACK *) xmalloc (sizeof (FSTACK)); newstack->filename = input_filename; newstack->text = input_text; newstack->size = size_of_input_text; newstack->offset = input_text_offset; newstack->line_number = line_number; newstack->next = filestack; filestack = newstack; push_node_filename (); } /* Make the current file globals be what is on top of the file stack. */ popfile () { extern int executing_string; FSTACK *temp = filestack; if (!filestack) abort (); /* My fault. I wonder what I did? */ /* Make sure that commands with braces have been satisfied. */ if (!executing_string) discard_braces (); /* Get the top of the stack into the globals. */ input_filename = filestack->filename; input_text = filestack->text; size_of_input_text = filestack->size; input_text_offset = filestack->offset; line_number = filestack->line_number; /* Pop the stack. */ filestack = filestack->next; free (temp); pop_node_filename (); } /* Flush all open files on the file stack. */ flush_file_stack () { while (filestack) { free (input_filename); free (input_text); popfile (); } } int node_filename_stack_index = 0; int node_filename_stack_size = 0; char **node_filename_stack = (char **)NULL; push_node_filename () { if (node_filename_stack_index + 1 > node_filename_stack_size) { if (!node_filename_stack) node_filename_stack = (char **)xmalloc ((node_filename_stack_size += 10) * sizeof (char *)); else node_filename_stack = (char **)xrealloc (node_filename_stack, (node_filename_stack_size + 10) * sizeof (char *)); } node_filename_stack[node_filename_stack_index] = node_filename; node_filename_stack_index++; } pop_node_filename () { node_filename = node_filename_stack[--node_filename_stack_index]; } /* Return just the simple part of the filename; i.e. the filename without the path information, or extensions. This conses up a new string. */ char * filename_part (filename) char *filename; { register int i = strlen (filename) - 1; while (i && filename[i] != '/') i--; if (filename[i] == '/') i++; #if defined (REMOVE_OUTPUT_EXTENSIONS) result = savestring (&filename[i]); /* See if there is an extension to remove. If so, remove it. */ if (rindex (result, '.')) *(rindex (result, '.')) = '\0'; return (result); #else return (savestring (&filename[i])); #endif /* REMOVE_OUTPUT_EXTENSIONS */ } /* Return the pathname part of filename. This can be NULL. */ char * pathname_part (filename) char *filename; { char *expand_filename (); char *result = (char *) NULL; register int i; filename = expand_filename (filename, ""); i = strlen (filename) - 1; while (i && filename[i] != '/') i--; if (filename[i] == '/') i++; if (i) { result = (char *)xmalloc (1 + i); strncpy (result, filename, i); result[i] = '\0'; } free (filename); return (result); } /* Return the expansion of FILENAME. */ char * expand_filename (filename, input_name) char *filename, *input_name; { char *full_pathname (); filename = full_pathname (filename); if (filename[0] == '.') return (filename); if (filename[0] != '/' && input_name[0] == '/') { /* Make it so that relative names work. */ char *result; int i = strlen (input_name) - 1; result = (char *)xmalloc (1 + strlen (input_name) + strlen (filename)); strcpy (result, input_name); while (result[i] != '/' && i) i--; if (result[i] == '/') i++; strcpy (&result[i], filename); free (filename); return (result); } return (filename); } /* Return the full path to FILENAME. */ char * full_pathname (filename) char *filename; { int initial_character; if (filename && (initial_character = *filename)) { if (initial_character == '/') return (savestring (filename)); if (initial_character != '~') { return (savestring (filename)); } else { if (filename[1] == '/') { /* Return the concatenation of HOME and the rest of the string. */ char *temp_home; char *temp_name; temp_home = (char *) getenv ("HOME"); temp_name = (char *)xmalloc (strlen (&filename[2]) + 1 + temp_home ? strlen (temp_home) : 0); if (temp_home) strcpy (temp_name, temp_home); strcat (temp_name, &filename[2]); return (temp_name); } else { struct passwd *user_entry; int i, c; char *username = (char *)xmalloc (257); char *temp_name; for (i = 1; c = filename[i]; i++) { if (c == '/') break; else username[i - 1] = c; } if (c) username[i - 1] = '\0'; user_entry = getpwnam (username); if (!user_entry) return (savestring (filename)); temp_name = (char *)xmalloc (1 + strlen (user_entry->pw_dir) + strlen (&filename[i])); strcpy (temp_name, user_entry->pw_dir); strcat (temp_name, &filename[i]); return (temp_name); } } } else { return (savestring (filename)); } } /* **************************************************************** */ /* */ /* Error Handling */ /* */ /* **************************************************************** */ /* Number of errors encountered. */ int errors_printed = 0; /* Print the last error gotten from the file system. */ fs_error (filename) char *filename; { remember_error (); perror (filename); return (0); } /* Print an error message, and return false. */ error (format, arg1, arg2, arg3, arg4, arg5) char *format; { remember_error (); fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); fprintf (stderr, "\n"); return ((int) 0); } /* Just like error (), but print the line number as well. */ line_error (format, arg1, arg2, arg3, arg4, arg5) char *format; { remember_error (); fprintf (stderr, "%s:%d: ", input_filename, line_number); fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); fprintf (stderr, ".\n"); return ((int) 0); } warning (format, arg1, arg2, arg3, arg4, arg5) char *format; { if (print_warnings) { fprintf (stderr, "%s:%d: Warning: ", input_filename, line_number); fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5); fprintf (stderr, ".\n"); } return ((int) 0); } /* Remember that an error has been printed. If this is the first error printed, then tell them which program is printing them. If more than max_error_level have been printed, then exit the program. */ remember_error () { errors_printed++; if (max_error_level && (errors_printed > max_error_level)) { fprintf (stderr, "Too many errors! Gave up.\n"); flush_file_stack (); cm_bye (); exit (1); } } /* **************************************************************** */ /* */ /* Hacking Tokens and Strings */ /* */ /* **************************************************************** */ /* Return the next token as a string pointer. We cons the string. */ char * read_token () { int i, character; char *result; /* If the first character to be read is self-delimiting, then that is the command itself. */ character = curchar (); if (self_delimiting (character)) { input_text_offset++; result = savestring (" "); *result = character; return (result); } for (i = 0; ((input_text_offset != size_of_input_text) && (character = curchar ()) && command_char (character)); i++, input_text_offset++); result = (char *)xmalloc (i + 1); bcopy (&input_text[input_text_offset - i], result, i); result[i] = '\0'; return (result); } /* Return non-zero if CHARACTER is self-delimiting. */ int self_delimiting (character) int character; { return (member (character, "{}:.@*'`,!?; \n")); } /* Clear whitespace from the front and end of string. */ canon_white (string) char *string; { int len = strlen (string); int x; if (!len) return; for (x = 0; x < len; x++) { if (!whitespace (string[x])) { strcpy (string, string + x); break; } } len = strlen (string); if (len) len--; while (len > -1 && cr_or_whitespace (string[len])) len--; string[len + 1] = '\0'; } /* Bash STRING, replacing all whitespace with just one space. */ fix_whitespace (string) char *string; { char *temp = (char *)xmalloc (strlen (string) + 1); int string_index = 0; int temp_index = 0; int c; canon_white (string); while (string[string_index]) { c = temp[temp_index++] = string[string_index++]; if (c == ' ' || c == '\n' || c == '\t') { temp[temp_index - 1] = ' '; while ((c = string[string_index]) && (c == ' ' || c == '\t' || c == '\n')) string_index++; } } temp[temp_index] = '\0'; strcpy (string, temp); free (temp); } /* Discard text until the desired string is found. The string is included in the discarded text. */ discard_until (string) char *string; { int temp = search_forward (string, input_text_offset); int tt = (temp < 0) ? size_of_input_text : temp + strlen (string); int from = input_text_offset; /* Find out what line we are on. */ while (from != tt) if (input_text[from++] == '\n') line_number++; if (temp < 0) { input_text_offset = size_of_input_text - strlen (string); if (strcmp (string, "\n") != 0) { line_error ("Expected `%s'", string); return; } } else input_text_offset = temp; input_text_offset += strlen (string); } /* Read characters from the file until we are at MATCH. Place the characters read into STRING. On exit input_text_offset is after the match string. Return the offset where the string starts. */ int get_until (match, string) char *match, **string; { int len, current_point, x, new_point, tem; current_point = x = input_text_offset; new_point = search_forward (match, input_text_offset); if (new_point < 0) new_point = size_of_input_text; len = new_point - current_point; /* Keep track of which line number we are at. */ tem = new_point + (strlen (match) - 1); while (x != tem) if (input_text[x++] == '\n') line_number++; *string = (char *)xmalloc (len + 1); bcopy (&input_text[current_point], *string, len); (*string)[len] = '\0'; /* Now leave input_text_offset in a consistent state. */ input_text_offset = tem; if (input_text_offset > size_of_input_text) input_text_offset = size_of_input_text; return (new_point); } /* Read characters from the file until we are at MATCH or end of line. Place the characters read into STRING. */ get_until_in_line (match, string) char *match, **string; { int real_bottom, temp; real_bottom = size_of_input_text; temp = search_forward ("\n", input_text_offset); if (temp < 0) temp = size_of_input_text; size_of_input_text = temp; get_until (match, string); size_of_input_text = real_bottom; } get_rest_of_line (string) char **string; { get_until ("\n", string); canon_white (*string); if (curchar () == '\n') /* as opposed to the end of the file... */ { line_number++; input_text_offset++; } } /* Backup the input pointer to the previous character, keeping track of the current line number. */ backup_input_pointer () { if (input_text_offset) { input_text_offset--; if (curchar () == '\n') line_number--; } } /* Read characters from the file until we are at MATCH or closing brace. Place the characters read into STRING. */ get_until_in_braces (match, string) char *match, **string; { int i, brace = 0; int match_len = strlen (match); char *temp; for (i = input_text_offset; i < size_of_input_text; i++) { if (input_text[i] == '{') brace++; else if (input_text[i] == '}') brace--; else if (input_text[i] == '\n') line_number++; if (brace < 0 || (brace == 0 && strncmp (input_text + i, match, match_len) == 0)) break; } match_len = i - input_text_offset; temp = (char *)xmalloc (2 + match_len); strncpy (temp, input_text + input_text_offset, match_len); temp[match_len] = '\0'; input_text_offset = i; *string = temp; } /* **************************************************************** */ /* */ /* Converting the File */ /* */ /* **************************************************************** */ /* Convert the file named by NAME. The output is saved on the file named as the argument to the @setfilename command. */ static char *suffixes[] = { "", ".texinfo", ".texi", ".txinfo", (char *)NULL }; convert (name) char *name; { char *real_output_filename, *expand_filename (), *filename_part (); char *filename = (char *)xmalloc (strlen (name) + 50); register int i; init_tag_table (); init_indices (); init_internals (); init_paragraph (); /* Try to load the file specified by NAME. If the file isn't found, and there is no suffix in NAME, then try NAME.texinfo, and NAME.texi. */ for (i = 0; suffixes[i]; i++) { strcpy (filename, name); strcat (filename, suffixes[i]); if (find_and_load (filename)) break; if (!suffixes[i][0] && rindex (filename, '.')) { fs_error (filename); free (filename); return; } } if (!suffixes[i]) { fs_error (name); free (filename); return; } input_filename = filename; /* Search this file looking for the special string which starts conversion. Once found, we may truly begin. */ input_text_offset = search_forward ("@setfilename", 0); if (input_text_offset < 0) { if (!command_output_filename) { error ("No `@setfilename' found in `%s'", name); goto finished; } } else input_text_offset += strlen ("@setfilename"); real_output_filename = (char *)NULL; if (!command_output_filename) get_until ("\n", &output_filename); else { discard_until ("\n"); real_output_filename = output_filename = command_output_filename; command_output_filename = (char *)NULL; } canon_white (output_filename); printf ("Making info file `%s' from `%s'.\n", output_filename, name); if (verbose_mode) fprintf (stderr, " The input file contains %d characters.\n", size_of_input_text); if (real_output_filename && strcmp (real_output_filename, "-") == 0) { output_stream = stdout; } else { if (!real_output_filename) real_output_filename = expand_filename (output_filename, name); output_stream = fopen (real_output_filename, "w"); } if (output_stream == NULL) { fs_error (real_output_filename); goto finished; } /* Make the displayable filename from output_filename. Only the base portion of the filename need be displayed. */ pretty_output_filename = filename_part (output_filename); /* For this file only, count the number of newlines from the top of the file to here. This way, we keep track of line numbers for error reporting. Line_number starts at 1, since the user isn't zero-based. */ { int temp = 0; line_number = 1; while (temp != input_text_offset) if (input_text[temp++] == '\n') line_number++; } add_word_args ("This is Info file %s, produced by Makeinfo-%d.%d from ", output_filename, major_version, minor_version); add_word_args ("the input file %s.\n", input_filename); close_paragraph (); reader_loop (); finished: close_paragraph (); flush_file_stack (); if (output_stream != NULL) { output_pending_notes (); free_pending_notes (); if (tag_table != NULL) { tag_table = (TAG_ENTRY *) reverse_list (tag_table); if (!no_headers) write_tag_table (); } if (output_stream != stdout) fclose (output_stream); /* If validating, then validate the entire file right now. */ if (validating) validate_file (real_output_filename, tag_table); /* This used to test && !errors_printed. But some files might have legit warnings. So split anyway. */ if (splitting) split_file (real_output_filename, 0); } } free_and_clear (pointer) char **pointer; { if ((*pointer) != (char *) NULL) { free (*pointer); *pointer = (char *) NULL; } } /* Initialize some state. */ init_internals () { free_and_clear (¤t_node); free_and_clear (&output_filename); free_and_clear (&command); free_and_clear (&input_filename); free_node_references (); init_insertion_stack (); init_brace_stack (); command_index = 0; in_menu = 0; } init_paragraph () { free_and_clear (&output_paragraph); output_paragraph = (unsigned char *)xmalloc (paragraph_buffer_len); output_position = 0; output_paragraph[0] = '\0'; output_paragraph_offset = 0; output_column = 0; paragraph_is_open = 0; current_indent = 0; } /* Okay, we are ready to start the conversion. Call the reader on some text, and fill the text as it is output. Handle commands by remembering things like open braces and the current file position on a stack, and when the corresponding close brace is found, you can call the function with the proper arguments. */ reader_loop () { int character; int done = 0; int dash_count = 0; while (!done) { if (input_text_offset >= size_of_input_text) { if (filestack) { free (input_filename); free (input_text); popfile (); } else break; } character = curchar (); if (!in_fixed_width_font && (character == '\'' || character == '`') && input_text[input_text_offset + 1] == character) { input_text_offset++; character = '"'; } if (character == '-') { dash_count++; if (dash_count == 3 && !in_fixed_width_font) { input_text_offset++; continue; } } else { dash_count = 0; } /* If this is a whitespace character, then check to see if the line is blank. If so, advance to the carriage return. */ if (whitespace (character)) { register int i = input_text_offset + 1; while (i < size_of_input_text && whitespace (input_text[i])) i++; if (i == size_of_input_text || input_text[i] == '\n') { if (i == size_of_input_text) i--; input_text_offset = i; character = curchar (); } } if (character == '\n') { line_number++; if (in_menu && input_text_offset + 1 < size_of_input_text) { char *glean_node_from_menu (), *tem; /* Note that the value of TEM is discarded, since it is gauranteed to be NULL when glean_node_from_menu () is called with a non-zero argument. */ tem = glean_node_from_menu (1); } } switch (character) { case COMMAND_PREFIX: read_command (); if (strcmp (command, "bye") == 0) { done = 1; continue; } break; case '{': /* Special case. I'm not supposed to see this character by itself. If I do, it means there is a syntax error in the input text. Report the error here, but remember this brace on the stack so you can ignore its partner. */ line_error ("Misplaced `{'"); remember_brace (misplaced_brace); /* Don't advance input_text_offset since this happens in remember_brace (). input_text_offset++; */ break; case '}': pop_and_call_brace (); input_text_offset++; break; default: add_char (character); input_text_offset++; } } } /* Find the command corresponding to STRING. If the command is found, return a pointer to the data structure. Otherwise return (-1). */ COMMAND * get_command_entry (string) char *string; { register int i; for (i = 0; CommandTable[i].name; i++) if (strcmp (CommandTable[i].name, string) == 0) return (&CommandTable[i]); /* This command is not in our predefined command table. Perhaps it is a user defined command. */ for (i = 0; i < user_command_array_len; i++) if (user_command_array[i] && (strcmp (user_command_array[i]->name, string) == 0)) return (user_command_array[i]); /* Nope, we never heard of this command. */ return ((COMMAND *) -1); } /* input_text_offset is right at the command prefix character. Read the next token to determine what to do. */ read_command () { COMMAND *entry; input_text_offset++; free_and_clear (&command); command = read_token (); #if defined (HAVE_MACROS) /* Check to see if this command is a macro. If so, execute it here. */ { MACRO_DEF *def; def = find_macro (command); if (def) { execute_macro (def); return; } } #endif /* HAVE_MACROS */ entry = get_command_entry (command); if ((int) entry == -1) { line_error ("Unknown info command `%s'", command); return; } if (entry->argument_in_braces) remember_brace (entry->proc); (*(entry->proc)) (START); } /* Return the string which invokes PROC; a pointer to a function. */ char * find_proc_name (proc) FUNCTION *proc; { register int i; for (i = 0; CommandTable[i].name; i++) if (proc == CommandTable[i].proc) return (CommandTable[i].name); return ("NO_NAME!"); } init_brace_stack () { brace_stack = (BRACE_ELEMENT *) NULL; } remember_brace (proc) FUNCTION *proc; { if (curchar () != '{') line_error ("@%s expected `{..}'", command); else input_text_offset++; remember_brace_1 (proc, output_paragraph_offset); } /* Remember the current output position here. Save PROC along with it so you can call it later. */ remember_brace_1 (proc, position) FUNCTION *proc; int position; { BRACE_ELEMENT *new = (BRACE_ELEMENT *) xmalloc (sizeof (BRACE_ELEMENT)); new->next = brace_stack; new->proc = proc; new->pos = position; new->line = line_number; brace_stack = new; } /* Pop the top of the brace stack, and call the associated function with the args END and POS. */ pop_and_call_brace () { BRACE_ELEMENT *temp; FUNCTION *proc; int pos; if (brace_stack == (BRACE_ELEMENT *) NULL) return (line_error ("Unmatched close brace")); pos = brace_stack->pos; proc = brace_stack->proc; temp = brace_stack->next; free (brace_stack); brace_stack = temp; return ((*proc) (END, pos, output_paragraph_offset)); } /* You call discard_braces () when you shouldn't have any braces on the stack. I used to think that this happens for commands that don't take arguments in braces, but that was wrong because of things like @code{foo @@}. So now I only detect it at the beginning of nodes. */ discard_braces () { int temp_line_number = line_number; char *proc_name; if (!brace_stack) return; while (brace_stack) { line_number = brace_stack->line; proc_name = find_proc_name (brace_stack->proc); line_error ("@%s missing close brace", proc_name); line_number = temp_line_number; pop_and_call_brace (); } } get_char_len (character) int character; { /* Return the printed length of the character. */ int len; switch (character) { case '\t': len = (output_column + 8) & 0xf7; if (len > fill_column) len = fill_column - output_column; else len = len - output_column; break; case '\n': len = fill_column - output_column; break; default: if (character < ' ') len = 2; else len = 1; } return (len); } add_word_args (format, arg1, arg2, arg3, arg4, arg5) char *format; { char buffer[1000]; sprintf (buffer, format, arg1, arg2, arg3, arg4, arg5); add_word (buffer); } /* Add STRING to output_paragraph. */ add_word (string) char *string; { while (*string) add_char (*string++); } /* Non-zero if the last character inserted has the syntax class of NEWLINE. */ int last_char_was_newline = 1; /* The actual last inserted character. Note that this may be something other than NEWLINE even if last_char_was_newline is 1. */ int last_inserted_character = 0; /* Non-zero means that a newline character has already been inserted, so close_paragraph () should insert one less. */ int line_already_broken = 0; /* When non-zero we have finished an insertion (see end_insertion ()) and we want to ignore false continued paragraph closings. */ int insertion_paragraph_closed = 0; /* Add the character to the current paragraph. If filling_enabled is non-zero, then do filling as well. */ add_char (character) int character; { /* If we are avoiding outputting headers, and we are currently in a menu, then simply return. */ if (no_headers && in_menu) return; /* If we are adding a character now, then we don't have to ignore close_paragraph () calls any more. */ if (must_start_paragraph && character != '\n') { must_start_paragraph = 0; line_already_broken = 0; /* The line is no longer broken. */ if (current_indent > output_column) { indent (current_indent - output_column); output_column = current_indent; } } if (non_splitting_words && member (character, " \t\n")) character = ' ' | 0x80; insertion_paragraph_closed = 0; switch (character) { case '\n': if (!filling_enabled) { insert ('\n'); if (force_flush_right) { close_paragraph (); /* Hack to force single blank lines out in this mode. */ flush_output (); } output_column = 0; if (!no_indent && paragraph_is_open) indent (output_column = current_indent); break; } else /* CHARACTER is newline, and filling is enabled. */ { #if defined (NOTDEF) if (sentence_ender (last_inserted_character)) { insert (' '); output_column++; last_inserted_character = character; } #endif /* NOTDEF */ } if (last_char_was_newline) { close_paragraph (); pending_indent = 0; } else { last_char_was_newline = 1; insert (' '); output_column++; } break; default: { int len = get_char_len (character); if ((character == ' ') && (last_char_was_newline)) { if (!paragraph_is_open) { pending_indent++; return; } } if (!paragraph_is_open) { start_paragraph (); /* If the paragraph is supposed to be indented a certain way, then discard all of the pending whitespace. Otherwise, we let the whitespace stay. */ if (!paragraph_start_indent) indent (pending_indent); pending_indent = 0; } if ((output_column += len) > fill_column) { if (filling_enabled) { int temp = output_paragraph_offset; while (--temp > 0 && output_paragraph[temp] != '\n') { /* If we have found a space, we have the place to break the line. */ if (output_paragraph[temp] == ' ') { output_paragraph[temp++] = '\n'; /* We have correctly broken the line where we want to. What we don't want is spaces following where we have decided to break the line. We get rid of them. */ { int t1 = temp; while (t1 < output_paragraph_offset && whitespace (output_paragraph[t1])) t1++; if (t1 != temp) { strncpy ((char *) &output_paragraph[temp], (char *) &output_paragraph[t1], (output_paragraph_offset - t1)); output_paragraph_offset -= (t1 - temp); } } /* Filled, but now indent if that is right. */ if (indented_fill && current_indent) { int buffer_len = ((output_paragraph_offset - temp) + current_indent); char *temp_buffer = (char *)xmalloc (buffer_len); int indentation = 0; /* We have to shift any markers that are in front of the wrap point. */ { register BRACE_ELEMENT *stack = brace_stack; while (stack) { if (stack->pos > temp) stack->pos += current_indent; stack = stack->next; } } while (current_indent > 0 && indentation != current_indent) temp_buffer[indentation++] = ' '; strncpy ((char *) &temp_buffer[current_indent], (char *) &output_paragraph[temp], buffer_len - current_indent); if (output_paragraph_offset + buffer_len >= paragraph_buffer_len) { unsigned char *tt = xrealloc (output_paragraph, (paragraph_buffer_len += buffer_len)); output_paragraph = tt; } strncpy ((char *) &output_paragraph[temp], temp_buffer, buffer_len); output_paragraph_offset += current_indent; free (temp_buffer); } output_column = 0; while (temp < output_paragraph_offset) output_column += get_char_len (output_paragraph[temp++]); output_column += len; break; } } } } insert (character); line_already_broken = 0; last_char_was_newline = 0; last_inserted_character = character; } } } /* Insert CHARACTER into OUTPUT_PARAGRAPH. */ insert (character) int character; { output_paragraph[output_paragraph_offset++] = character; if (output_paragraph_offset == paragraph_buffer_len) { output_paragraph = xrealloc (output_paragraph, (paragraph_buffer_len += 100)); } } /* Remove upto COUNT characters of whitespace from the the current output line. If COUNT is less than zero, then remove until none left. */ kill_self_indent (count) int count; { /* Handle infinite case first. */ if (count < 0) { output_column = 0; while (output_paragraph_offset) { if (whitespace (output_paragraph[output_paragraph_offset - 1])) output_paragraph_offset--; else break; } } else { while (output_paragraph_offset && count--) if (whitespace (output_paragraph[output_paragraph_offset - 1])) output_paragraph_offset--; else break; } } /* Non-zero means do not honor calls to flush_output (). */ static int flushing_ignored = 0; /* Prevent calls to flush_output () from having any effect. */ inhibit_output_flushing () { flushing_ignored++; } /* Allow calls to flush_output () to write the paragraph data. */ uninhibit_output_flushing () { flushing_ignored--; } flush_output () { register int i; if (!output_paragraph_offset || flushing_ignored) return; for (i = 0; i < output_paragraph_offset; i++) { if (output_paragraph[i] == (unsigned char)(' ' | 0x80) || output_paragraph[i] == (unsigned char)('\t' | 0x80) || output_paragraph[i] == (unsigned char)('\n' | 0x80) || sentence_ender (UNMETA (output_paragraph[i]))) output_paragraph[i] &= 0x7f; } fwrite (output_paragraph, 1, output_paragraph_offset, output_stream); output_position += output_paragraph_offset; output_paragraph_offset = 0; } /* How to close a paragraph controlling the number of lines between this one and the last one. */ /* Paragraph spacing is controlled by this variable. It is the number of blank lines that you wish to appear between paragraphs. A value of 1 creates a single blank line between paragraphs. */ int paragraph_spacing = DEFAULT_PARAGRAPH_SPACING; /* Close the current paragraph, leaving no blank lines between them. */ close_single_paragraph () { close_paragraph_with_lines (0); } /* Close a paragraph after an insertion has ended. */ close_insertion_paragraph () { if (!insertion_paragraph_closed) { /* Close the current paragraph, breaking the line. */ close_single_paragraph (); /* Start a new paragraph here, inserting whatever indention is correct for the now current insertion level (one above the one that we are ending). */ start_paragraph (); /* Tell close_paragraph () that the previous line has already been broken, so it should insert one less newline. */ line_already_broken = 1; /* Let functions such as add_char () know that we have already found a newline. */ ignore_blank_line (); } else { /* If the insertion paragraph is closed already, then we are seeing two `@end' commands in a row. Note that the first one we saw was handled in the first part of this if-then-else clause, and at that time start_paragraph () was called, partially to handle the proper indentation of the current line. However, the indentation level may have just changed again, so we may have to outdent the current line to the new indentation level. */ if (current_indent < output_column) kill_self_indent (output_column - current_indent); } insertion_paragraph_closed = 1; } close_paragraph_with_lines (lines) int lines; { int old_spacing = paragraph_spacing; paragraph_spacing = lines; close_paragraph (); paragraph_spacing = old_spacing; } /* Close the currently open paragraph. */ close_paragraph () { register int i; /* The insertion paragraph is no longer closed. */ insertion_paragraph_closed = 0; if (paragraph_is_open && !must_start_paragraph) { register int tindex, c; tindex = output_paragraph_offset; /* Back up to last non-newline/space character, forcing all such subsequent characters to be newlines. This isn't strictly necessary, but a couple of functions use the presence of a newline to make decisions. */ for (tindex = output_paragraph_offset - 1; tindex >= 0; --tindex) { c = output_paragraph[tindex]; if (c == ' '|| c == '\n') output_paragraph[tindex] = '\n'; else break; } /* All trailing whitespace is ignored. */ output_paragraph_offset = ++tindex; /* Break the line if that is appropriate. */ if (paragraph_spacing >= 0) insert ('\n'); /* Add as many blank lines as is specified in PARAGRAPH_SPACING. */ if (!force_flush_right) { for (i = 0; i < (paragraph_spacing - line_already_broken); i++) insert ('\n'); } /* If we are doing flush right indentation, then do it now on the paragraph (really a single line). */ if (force_flush_right) do_flush_right_indentation (); flush_output (); paragraph_is_open = 0; no_indent = 0; output_column = 0; } ignore_blank_line (); } /* Make the last line just read look as if it were only a newline. */ ignore_blank_line () { last_inserted_character = '\n'; last_char_was_newline = 1; } /* Align the end of the text in output_paragraph with fill_column. */ do_flush_right_indentation () { char *temp; int temp_len; kill_self_indent (-1); if (output_paragraph[0] != '\n') { output_paragraph[output_paragraph_offset] = '\0'; if (output_paragraph_offset < fill_column) { register int i; if (fill_column >= paragraph_buffer_len) output_paragraph = xrealloc (output_paragraph, (paragraph_buffer_len += fill_column)); temp_len = strlen ((char *)output_paragraph); temp = (char *)xmalloc (temp_len + 1); bcopy ((char *)output_paragraph, temp, temp_len); for (i = 0; i < fill_column - output_paragraph_offset; i++) output_paragraph[i] = ' '; bcopy (temp, (char *)output_paragraph + i, temp_len); free (temp); output_paragraph_offset = fill_column; } } } /* Begin a new paragraph. */ start_paragraph () { /* First close existing one. */ if (paragraph_is_open) close_paragraph (); /* In either case, the insertion paragraph is no longer closed. */ insertion_paragraph_closed = 0; /* However, the paragraph is open! */ paragraph_is_open = 1; /* If we MUST_START_PARAGRAPH, that simply means that start_paragraph () had to be called before we would allow any other paragraph operations to have an effect. */ if (!must_start_paragraph) { int amount_to_indent = 0; /* If doing indentation, then insert the appropriate amount. */ if (!no_indent) { if (inhibit_paragraph_indentation) { amount_to_indent = current_indent; if (inhibit_paragraph_indentation < 0) inhibit_paragraph_indentation++; } else if (paragraph_start_indent < 0) amount_to_indent = current_indent; else amount_to_indent = current_indent + paragraph_start_indent; if (amount_to_indent >= output_column) { amount_to_indent -= output_column; indent (amount_to_indent); output_column += amount_to_indent; } } } else must_start_paragraph = 0; } /* Insert the indentation specified by AMOUNT. */ indent (amount) int amount; { while (--amount >= 0) insert (' '); } /* Search forward for STRING in input_text. FROM says where where to start. */ search_forward (string, from) char *string; int from; { int len = strlen (string); while (from < size_of_input_text) { if (strnicmp (input_text + from, string, len) == 0) return (from); from++; } return (-1); } /* Whoops, Unix doesn't have stricmp, or strnicmp. */ /* Case independent string compare. */ stricmp (string1, string2) char *string1, *string2; { char ch1, ch2; for (;;) { ch1 = *string1++; ch2 = *string2++; if (!(ch1 | ch2)) return (0); ch1 = coerce_to_upper (ch1); ch2 = coerce_to_upper (ch2); if (ch1 != ch2) return (1); } } /* Compare at most COUNT characters from string1 to string2. Case doesn't matter. */ strnicmp (string1, string2, count) char *string1, *string2; { char ch1, ch2; while (count) { ch1 = *string1++; ch2 = *string2++; if (coerce_to_upper (ch1) == coerce_to_upper (ch2)) count--; else break; } return (count); } enum insertion_type { menu, quotation, lisp, smalllisp, example, smallexample, display, itemize, format, enumerate, cartouche, table, ftable, vtable, group, ifinfo, flushleft, flushright, ifset, ifclear, deffn, defun, defmac, defspec, defvr, defvar, defopt, deftypefn, deftypefun, deftypevr, deftypevar, defcv, defivar, defop, defmethod, deftypemethod, deftp, bad_type }; char *insertion_type_names[] = { "menu", "quotation", "lisp", "smalllisp", "example", "smallexample", "display", "itemize", "format", "enumerate", "cartouche", "table", "ftable", "vtable", "group", "ifinfo", "flushleft", "flushright", "ifset", "ifclear", "deffn", "defun", "defmac", "defspec", "defvr", "defvar", "defopt", "deftypefn", "deftypefun", "deftypevr", "deftypevar", "defcv", "defivar", "defop", "defmethod", "deftypemethod", "deftp", "bad_type" }; int insertion_level = 0; typedef struct istack_elt { struct istack_elt *next; char *item_function; int line_number; int filling_enabled; int indented_fill; enum insertion_type insertion; int inhibited; } INSERTION_ELT; INSERTION_ELT *insertion_stack = (INSERTION_ELT *) NULL; init_insertion_stack () { insertion_stack = (INSERTION_ELT *) NULL; } /* Return the type of the current insertion. */ enum insertion_type current_insertion_type () { if (!insertion_level) return (bad_type); else return (insertion_stack->insertion); } /* Return a pointer to the string which is the function to wrap around items. */ char * current_item_function () { if (!insertion_level) return ((char *) NULL); else return (insertion_stack->item_function); } char * get_item_function () { char *item_function; get_rest_of_line (&item_function); backup_input_pointer (); canon_white (item_function); return (item_function); } /* Push the state of the current insertion on the stack. */ push_insertion (type, item_function) enum insertion_type type; char *item_function; { INSERTION_ELT *new = (INSERTION_ELT *) xmalloc (sizeof (INSERTION_ELT)); new->item_function = item_function; new->filling_enabled = filling_enabled; new->indented_fill = indented_fill; new->insertion = type; new->line_number = line_number; new->inhibited = inhibit_paragraph_indentation; new->next = insertion_stack; insertion_stack = new; insertion_level++; } /* Pop the value on top of the insertion stack into the global variables. */ pop_insertion () { INSERTION_ELT *temp = insertion_stack; if (temp == (INSERTION_ELT *) NULL) return; inhibit_paragraph_indentation = temp->inhibited; filling_enabled = temp->filling_enabled; indented_fill = temp->indented_fill; free_and_clear (&(temp->item_function)); insertion_stack = insertion_stack->next; free (temp); insertion_level--; } /* Return a pointer to the print name of this enumerated type. */ char * insertion_type_pname (type) enum insertion_type type; { if ((int) type < (int) bad_type) return (insertion_type_names[(int) type]); else return ("Broken-Type in insertion_type_pname"); } /* Return the insertion_type associated with NAME. If the type is not one of the known ones, return BAD_TYPE. */ enum insertion_type find_type_from_name (name) char *name; { int index = 0; while (index < (int) bad_type) { if (stricmp (name, insertion_type_names[index]) == 0) return (enum insertion_type) index; index++; } return (bad_type); } do_nothing () { } int defun_insertion (type) enum insertion_type type; { return ((type == deffn) || (type == defun) || (type == defmac) || (type == defspec) || (type == defvr) || (type == defvar) || (type == defopt) || (type == deftypefn) || (type == deftypefun) || (type == deftypevr) || (type == deftypevar) || (type == defcv) || (type == defivar) || (type == defop) || (type == defmethod) || (type == deftypemethod) || (type == deftp)); } /* MAX_NS is the maximum nesting level for enumerations. I picked 100 which seemed reasonable. This doesn't control the number of items, just the number of nested lists. */ #define max_stack_depth 100 #define ENUM_DIGITS 1 #define ENUM_ALPHA 2 typedef struct { int enumtype; int enumval; } DIGIT_ALPHA; DIGIT_ALPHA enumstack[max_stack_depth]; int enumstack_offset = 0; int current_enumval = 1; int current_enumtype = ENUM_DIGITS; char *enumeration_arg = (char *)NULL; start_enumerating (at, type) int at, type; { if ((enumstack_offset + 1) == max_stack_depth) { line_error ("Enumeration stack overflow"); return; } enumstack[enumstack_offset].enumtype = current_enumtype; enumstack[enumstack_offset].enumval = current_enumval; enumstack_offset++; current_enumval = at; current_enumtype = type; } stop_enumerating () { --enumstack_offset; if (enumstack_offset < 0) enumstack_offset = 0; current_enumval = enumstack[enumstack_offset].enumval; current_enumtype = enumstack[enumstack_offset].enumtype; } /* Place a letter or digits into the output stream. */ enumerate_item () { char temp[10]; if (current_enumtype == ENUM_ALPHA) { if (current_enumval == ('z' + 1) || current_enumval == ('Z' + 1)) { current_enumval = ((current_enumval - 1) == 'z' ? 'a' : 'A'); warning ("Lettering overflow, restarting at %c", current_enumval); } sprintf (temp, "%c. ", current_enumval); } else sprintf (temp, "%d. ", current_enumval); indent (output_column += (current_indent - strlen (temp))); add_word (temp); current_enumval++; } /* This is where the work for all the "insertion" style commands is done. A huge switch statement handles the various setups, and generic code is on both sides. */ begin_insertion (type) enum insertion_type type; { int no_discard = 0; if (defun_insertion (type)) { push_insertion (type, savestring ("")); no_discard++; } else push_insertion (type, get_item_function ()); switch (type) { case menu: if (!no_headers) close_paragraph (); filling_enabled = no_indent = 0; inhibit_paragraph_indentation = 1; if (!no_headers) add_word ("* Menu:\n"); in_menu++; no_discard++; break; /* I think @quotation is meant to do filling. If you don't want filling, then use @example. */ case quotation: close_single_paragraph (); last_char_was_newline = no_indent = 0; indented_fill = filling_enabled = 1; inhibit_paragraph_indentation = 1; current_indent += default_indentation_increment; break; case display: case example: case smallexample: case lisp: case smalllisp: /* Just like @example, but no indentation. */ case format: close_single_paragraph (); inhibit_paragraph_indentation = 1; in_fixed_width_font++; filling_enabled = 0; last_char_was_newline = 0; if (type != format) current_indent += default_indentation_increment; break; case table: case ftable: case vtable: case itemize: close_single_paragraph (); current_indent += default_indentation_increment; filling_enabled = indented_fill = 1; #if defined (INDENT_PARAGRAPHS_IN_TABLE) inhibit_paragraph_indentation = 0; #else inhibit_paragraph_indentation = 1; #endif /* !INDENT_PARAGRAPHS_IN_TABLE */ /* Make things work for losers who forget the itemize syntax. */ if (type == itemize) { if (!(*insertion_stack->item_function)) { free (insertion_stack->item_function); insertion_stack->item_function = savestring ("@bullet"); } } break; case enumerate: close_single_paragraph (); no_indent = 0; #if defined (INDENT_PARAGRAPHS_IN_TABLE) inhibit_paragraph_indentation = 0; #else inhibit_paragraph_indentation = 1; #endif /* !INDENT_PARAGRAPHS_IN_TABLE */ current_indent += default_indentation_increment; filling_enabled = indented_fill = 1; if (isdigit (*enumeration_arg)) start_enumerating (atoi (enumeration_arg), ENUM_DIGITS); else start_enumerating (*enumeration_arg, ENUM_ALPHA); break; /* Does nothing special in makeinfo. */ case group: /* Only close the paragraph if we are not inside of an @example. */ if (!insertion_stack->next || insertion_stack->next->insertion != example) close_single_paragraph (); break; /* Insertions that are no-ops in info, but do something in TeX. */ case ifinfo: case ifset: case ifclear: case cartouche: break; case deffn: case defun: case defmac: case defspec: case defvr: case defvar: case defopt: case deftypefn: case deftypefun: case deftypevr: case deftypevar: case defcv: case defivar: case defop: case defmethod: case deftypemethod: case deftp: inhibit_paragraph_indentation = 1; filling_enabled = indented_fill = 1; current_indent += default_indentation_increment; no_indent = 0; break; case flushleft: close_single_paragraph (); inhibit_paragraph_indentation = 1; filling_enabled = indented_fill = no_indent = 0; break; case flushright: close_single_paragraph (); filling_enabled = indented_fill = no_indent = 0; inhibit_paragraph_indentation = 1; force_flush_right++; break; } if (!no_discard) discard_until ("\n"); } /* Try to end the insertion with the specified TYPE. TYPE, with a value of bad_type, gets translated to match the value currently on top of the stack. Otherwise, if TYPE doesn't match the top of the insertion stack, give error. */ end_insertion (type) enum insertion_type type; { enum insertion_type temp_type; if (!insertion_level) return; temp_type = current_insertion_type (); if (type == bad_type) type = temp_type; if (type != temp_type) { line_error ("Expected `%s', but saw `%s'.", insertion_type_pname (temp_type), insertion_type_pname (type)); return; } pop_insertion (); switch (type) { /* "Insertions which have no effect on paragraph formatting. */ case ifinfo: case ifset: case ifclear: break; case menu: in_menu--; /* No longer hacking menus. */ if (!no_headers) close_insertion_paragraph (); break; case enumerate: stop_enumerating (); close_insertion_paragraph (); current_indent -= default_indentation_increment; break; case flushleft: case group: case cartouche: close_insertion_paragraph (); break; case format: case display: case example: case smallexample: case lisp: case smalllisp: case quotation: /* @quotation is the only one of the above without a fixed width font. */ if (type != quotation) in_fixed_width_font--; /* @format is the only fixed_width insertion without a change in indentation. */ if (type != format) current_indent -= default_indentation_increment; /* The ending of one of these insertions always marks the start of a new paragraph. */ close_insertion_paragraph (); break; case table: case ftable: case vtable: case itemize: current_indent -= default_indentation_increment; break; case flushright: force_flush_right--; close_insertion_paragraph (); break; /* Handle the @defun style insertions with a default clause. */ default: current_indent -= default_indentation_increment; close_insertion_paragraph (); break; } } /* Insertions cannot cross certain boundaries, such as node beginnings. In code that creates such boundaries, you should call discard_insertions () before doing anything else. It prints the errors for you, and cleans up the insertion stack. */ discard_insertions () { int real_line_number = line_number; while (insertion_stack) { if (insertion_stack->insertion == ifinfo || insertion_stack->insertion == ifset || insertion_stack->insertion == ifclear || insertion_stack->insertion == cartouche) break; else { char *offender = (char *) insertion_type_pname (insertion_stack->insertion); line_number = insertion_stack->line_number; line_error ("This `%s' doesn't have a matching `%cend %s'", offender, COMMAND_PREFIX, offender); pop_insertion (); } } line_number = real_line_number; } /* The actual commands themselves. */ /* Commands which insert themselves. */ insert_self () { add_word (command); } /* Force a line break in the output. */ cm_asterisk () { close_single_paragraph (); #if !defined (ASTERISK_NEW_PARAGRAPH) cm_noindent (); #endif /* ASTERISK_NEW_PARAGRAPH */ } /* Insert ellipsis. */ cm_dots (arg) int arg; { if (arg == START) add_word ("..."); } cm_bullet (arg) int arg; { if (arg == START) add_char ('*'); } cm_minus (arg) int arg; { if (arg == START) add_char ('-'); } /* Insert "TeX". */ cm_TeX (arg) int arg; { if (arg == START) add_word ("TeX"); } cm_copyright (arg) int arg; { if (arg == START) add_word ("(C)"); } cm_today (arg) int arg; { static char * months [12] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; if (arg == START) { long timer = (time (0)); struct tm * ts = (localtime (&timer)); add_word_args ("%d %s %d", (ts -> tm_mday), (months [ts -> tm_mon]), ((ts -> tm_year) + 1900)); } } cm_code (arg) int arg; { extern int printing_index; if (printing_index) return; if (arg == START) { in_fixed_width_font++; add_char ('`'); } else { add_word ("'"); in_fixed_width_font--; } } cm_samp (arg) int arg; { cm_code (arg); } cm_file (arg) int arg; { cm_code (arg); } cm_kbd (arg) int arg; { cm_code (arg); } cm_key (arg) int arg; { } /* Convert the character at position into CTL. */ cm_ctrl (arg, position) int arg, position; { if (arg == END) output_paragraph[position - 1] = CTL (output_paragraph[position]); } /* Small Caps in makeinfo just does all caps. */ cm_sc (arg, start_pos, end_pos) int arg, start_pos, end_pos; { if (arg == END) { while (start_pos < end_pos) { output_paragraph[start_pos] = coerce_to_upper (output_paragraph[start_pos]); start_pos++; } } } /* @var in makeinfo just uppercases the text. */ cm_var (arg, start_pos, end_pos) int arg, start_pos, end_pos; { if (arg == END) { while (start_pos < end_pos) { output_paragraph[start_pos] = coerce_to_upper (output_paragraph[start_pos]); start_pos++; } } } cm_dfn (arg, position) int arg, position; { add_char ('"'); } cm_emph (arg) int arg; { add_char ('*'); } cm_strong (arg, position) int arg, position; { cm_emph (arg); } cm_cite (arg, position) int arg, position; { if (arg == START) add_word ("`"); else add_word ("'"); } /* Current text is italicized. */ cm_italic (arg, start, end) int arg, start, end; { } /* Current text is highlighted. */ cm_bold (arg, start, end) int arg, start, end; { cm_italic (arg); } /* Current text is in roman font. */ cm_roman (arg, start, end) int arg, start, end; { } /* Current text is in roman font. */ cm_titlefont (arg, start, end) int arg, start, end; { } /* Italicize titles. */ cm_title (arg, start, end) int arg, start, end; { cm_italic (arg); } /* @refill is a NOP. */ cm_refill () { } /* Prevent the argument from being split across two lines. */ cm_w (arg, start, end) int arg, start, end; { if (arg == START) non_splitting_words++; else non_splitting_words--; } /* Explain that this command is obsolete, thus the user shouldn't do anything with it. */ cm_obsolete (arg, start, end) int arg, start, end; { if (arg == START) warning ("The command `@%s' is obsolete", command); } /* Insert the text following input_text_offset up to the end of the line in a new, separate paragraph. Directly underneath it, insert a line of WITH_CHAR, the same length of the inserted text. */ insert_and_underscore (with_char) int with_char; { int len, i, old_no_indent; char *temp; close_paragraph (); filling_enabled = indented_fill = 0; old_no_indent = no_indent; no_indent = 1; get_rest_of_line (&temp); len = output_position; execute_string ("%s\n", temp); free (temp); len = ((output_position + output_paragraph_offset) - 1) - len; for (i = 0; i < len; i++) add_char (with_char); insert ('\n'); close_paragraph (); filling_enabled = 1; no_indent = old_no_indent; } /* The remainder of the text on this line is a chapter heading. */ cm_chapter () { insert_and_underscore ('*'); } /* The remainder of the text on this line is a section heading. */ cm_section () { insert_and_underscore ('='); } /* The remainder of the text on this line is a subsection heading. */ cm_subsection () { insert_and_underscore ('-'); } /* The remainder of the text on this line is a subsubsection heading. */ cm_subsubsection () { insert_and_underscore ('.'); } /* Here is a structure which associates sectioning commands with an integer, hopefully to reflect the `depth' of the current section. */ struct { char *name; int level; } section_alist[] = { { "unnumberedsubsubsec", 5 }, { "unnumberedsubsec", 4 }, { "unnumberedsec", 3 }, { "unnumbered", 2 }, { "appendixsubsubsec", 5 }, { "appendixsubsec", 4 }, { "appendixsec", 3 }, { "appendixsection", 3 }, { "appendix", 2 }, { "subsubsec", 5 }, { "subsubsection", 5 }, { "subsection", 4 }, { "section", 3 }, { "chapter", 2 }, { "top", 1 }, { (char *)NULL, 0 } }; /* Return an integer which identifies the type section present in TEXT. */ int what_section (text) char *text; { register int i, j; char *t; find_section_command: for (j = 0; text[j] && cr_or_whitespace (text[j]); j++); if (text[j] != '@') return (-1); text = text + j + 1; /* We skip @comment commands. */ if ((strncmp (text, "comment", strlen ("comment")) == 0) || (strncmp (text, "c ", strlen ("c ")) == 0)) { while (*text++ != '\n'); goto find_section_command; } /* Handle italicized sectioning commands. */ if (*text == 'i') text++; for (j = 0; text[j] && !cr_or_whitespace (text[j]); j++); for (i = 0; t = section_alist[i].name; i++) { if (j == strlen (t) && strncmp (t, text, j) == 0) return (section_alist[i].level); } return (-1); } /* Treat this just like @unnumbered. The only difference is in node defaulting. */ cm_top () { static int top_encountered = 0; cm_unnumbered (); /* It is an error to have more than one @top. */ if (top_encountered) { TAG_ENTRY *tag = tag_table; line_error ("There already is a node having @top as a section"); while (tag != (TAG_ENTRY *)NULL) { if ((tag->flags & IS_TOP)) { int old_line_number = line_number; line_number = tag->line_no; line_error ("Here is the @top node."); line_number = old_line_number; return; } tag = tag->next_ent; } } else { top_encountered = 1; /* The most recently defined node is the top node. */ if (tag_table) tag_table->flags |= IS_TOP; /* Now set the logical hierarchical level of the Top node. */ { int orig_offset = input_text_offset; input_text_offset = search_forward ("\n@node", orig_offset); if (input_text_offset > 0) { int this_section; /* Move to the end of this line, and find out what the sectioning command is here. */ while (input_text[input_text_offset] != '\n') input_text_offset++; if (input_text_offset < size_of_input_text) input_text_offset++; this_section = what_section (input_text + input_text_offset); /* If we found a sectioning command, then give the top section a level of this section - 1. */ if (this_section != -1) { register int i; for (i = 0; section_alist[i].name; i++) if (strcmp (section_alist[i].name, "Top") == 0) { section_alist[i].level = this_section - 1; break; } } } input_text_offset = orig_offset; } } } /* The remainder of the text on this line is an unnumbered heading. */ cm_unnumbered () { cm_chapter (); } /* The remainder of the text on this line is an unnumbered section heading. */ cm_unnumberedsec () { cm_section (); } /* The remainder of the text on this line is an unnumbered subsection heading. */ cm_unnumberedsubsec () { cm_subsection (); } /* The remainder of the text on this line is an unnumbered subsubsection heading. */ cm_unnumberedsubsubsec () { cm_subsubsection (); } /* The remainder of the text on this line is an appendix heading. */ cm_appendix () { cm_chapter (); } /* The remainder of the text on this line is an appendix section heading. */ cm_appendixsec () { cm_section (); } /* The remainder of the text on this line is an appendix subsection heading. */ cm_appendixsubsec () { cm_subsection (); } /* The remainder of the text on this line is an appendix subsubsection heading. */ cm_appendixsubsubsec () { cm_subsubsection (); } /* Compatibility functions substitute for chapter, section, etc. */ cm_majorheading () { cm_chapheading (); } cm_chapheading () { cm_chapter (); } cm_heading () { cm_section (); } cm_subheading () { cm_subsection (); } cm_subsubheading () { cm_subsubsection (); } /* **************************************************************** */ /* */ /* Adding nodes, and making tags */ /* */ /* **************************************************************** */ /* Start a new tag table. */ init_tag_table () { while (tag_table != (TAG_ENTRY *) NULL) { TAG_ENTRY *temp = tag_table; free (temp->node); free (temp->prev); free (temp->next); free (temp->up); tag_table = tag_table->next_ent; free (temp); } } write_tag_table () { return (write_tag_table_internal (0)); /* Not indirect. */ } write_tag_table_indirect () { return (write_tag_table_internal (1)); } /* Write out the contents of the existing tag table. INDIRECT_P says how to format the output. */ write_tag_table_internal (indirect_p) int indirect_p; { TAG_ENTRY *node = tag_table; int old_indent = no_indent; no_indent = 1; filling_enabled = 0; must_start_paragraph = 0; close_paragraph (); if (!indirect_p) { no_indent = 1; insert ('\n'); } add_word_args ("\037\nTag Table:\n%s", indirect_p ? "(Indirect)\n" : ""); while (node != (TAG_ENTRY *) NULL) { add_word_args ("Node: %s\177%d\n", node->node, node->position); node = node->next_ent; } add_word ("\037\nEnd Tag Table\n"); flush_output (); no_indent = old_indent; } char * get_node_token () { char *string; get_until_in_line (",", &string); if (curchar () == ',') input_text_offset++; canon_white (string); /* Allow things like @@nodename. */ normalize_node_name (string); return (string); } /* Given a node name in STRING, remove double @ signs, replacing them with just one. */ normalize_node_name (string) char *string; { register int i, l = strlen (string); for (i = 0; i < l; i++) { if (string[i] == '@' && string[i + 1] == '@') { strncpy (string + i, string + i + 1, l - i); l--; } } } /* Look up NAME in the tag table, and return the associated tag_entry. If the node is not in the table return NULL. */ TAG_ENTRY * find_node (name) char *name; { TAG_ENTRY *tag = tag_table; while (tag != (TAG_ENTRY *) NULL) { if (stricmp (tag->node, name) == 0) return (tag); tag = tag->next_ent; } return ((TAG_ENTRY *) NULL); } /* Remember NODE and associates. */ remember_node (node, prev, next, up, position, line_no, no_warn) char *node, *prev, *next, *up; int position, line_no, no_warn; { /* Check for existence of this tag already. */ if (validating) { register TAG_ENTRY *tag = find_node (node); if (tag) { line_error ("Node `%s' multiply defined (%d is first definition)", node, tag->line_no); return; } } /* First, make this the current node. */ current_node = node; /* Now add it to the list. */ { TAG_ENTRY *new = (TAG_ENTRY *) xmalloc (sizeof (TAG_ENTRY)); new->node = node; new->prev = prev; new->next = next; new->up = up; new->position = position; new->line_no = line_no; new->filename = node_filename; new->touched = 0; /* not yet referenced. */ new->flags = 0; if (no_warn) new->flags |= NO_WARN; new->next_ent = tag_table; tag_table = new; } } /* The order is: nodename, nextnode, prevnode, upnode. If all of the NEXT, PREV, and UP fields are empty, they are defaulted. You must follow a node command which has those fields defaulted with a sectioning command (e.g. @chapter) giving the "level" of that node. It is an error not to do so. The defaults come from the menu in this nodes parent. */ cm_node () { char *node, *prev, *next, *up; int new_node_pos, defaulting, this_section, no_warn = 0; extern int already_outputting_pending_notes; if (strcmp (command, "nwnode") == 0) no_warn = 1; /* Get rid of unmatched brace arguments from previous commands. */ discard_braces (); /* There also might be insertions left lying around that haven't been ended yet. Do that also. */ discard_insertions (); if (!already_outputting_pending_notes) { close_paragraph (); output_pending_notes (); free_pending_notes (); } filling_enabled = indented_fill = 0; new_node_pos = output_position + 1; current_footnote_number = 1; node = get_node_token (); next = get_node_token (); prev = get_node_token (); up = get_node_token (); no_indent = 1; if (!no_headers) add_word_args ("\037\nFile: %s, Node: %s", pretty_output_filename, node); /* Check for defaulting of this node's next, prev, and up fields. */ defaulting = ((strlen (next) == 0) && (strlen (prev) == 0) && (strlen (up) == 0)); this_section = what_section (input_text + input_text_offset); /* If we are defaulting, then look at the immediately following sectioning command (error if none) to determine the node's level. Find the node that contains the menu mentioning this node that is one level up (error if not found). That node is the "Up" of this node. Default the "Next" and "Prev" from the menu. */ if (defaulting) { NODE_REF *last_ref = (NODE_REF *)NULL; NODE_REF *ref = node_references; if (this_section < 0) { char *polite_section_name = "top"; int i; for (i = 0; section_alist[i].name; i++) if (section_alist[i].level == current_section + 1) { polite_section_name = section_alist[i].name; break; } line_error ("Node `%s' requires a sectioning command (e.g. @%s)", node, polite_section_name); } else { if (stricmp (node, "Top") == 0) { /* Default the NEXT pointer to be the first menu item in this node, if there is a menu in this node. */ { int orig_offset, orig_size; char *glean_node_from_menu (); orig_offset = input_text_offset; orig_size = search_forward ("\n@node ", orig_offset); if (orig_size < 0) orig_size = size_of_input_text; input_text_offset = search_forward ("\n@menu", orig_offset); if (input_text_offset > -1) { input_text_offset = search_forward ("\n* ", input_text_offset); if (input_text_offset > -1) next = glean_node_from_menu (0); if (next) { prev = savestring ("(DIR)"); up = savestring ("(DIR)"); } } input_text_offset = orig_offset; } } while (ref) { if (ref->section == (this_section - 1) && ref->type == menu_reference && stricmp (ref->node, node) == 0) { char *containing_node = ref->containing_node; free (up); up = savestring (containing_node); if (last_ref && last_ref->type == menu_reference && strcmp (last_ref->containing_node, containing_node) == 0) { free (next); next = savestring (last_ref->node); } while ((ref->section == this_section - 1) && (ref->next) && (ref->next->type != menu_reference)) ref = ref->next; if (ref->next && ref->type == menu_reference && strcmp (ref->next->containing_node, containing_node) == 0) { free (prev); prev = savestring (ref->next->node); } else if (!ref->next && stricmp (ref->containing_node, "Top") == 0) { free (prev); prev = savestring (ref->containing_node); } break; } last_ref = ref; ref = ref->next; } } } if (!no_headers) { if (*next) add_word_args (", Next: %s", next); if (*prev) add_word_args (", Prev: %s", prev); if (*up) add_word_args (", Up: %s", up); } insert ('\n'); close_paragraph (); no_indent = 0; if (!*node) { line_error ("No node name specified for `@%s' command", command); free (node); free (next); free (prev); free (up); } else { if (!*next) { free (next); next = (char *)NULL; } if (!*prev) { free (prev); prev = (char *)NULL; } if (!*up) { free (up); up = (char *)NULL; } remember_node (node, prev, next, up, new_node_pos, line_number, no_warn); } /* Change the section only if there was a sectioning command. */ if (this_section >= 0) current_section = this_section; filling_enabled = 1; } /* Validation of an info file. Scan through the list of tag entrys touching the Prev, Next, and Up elements of each. It is an error not to be able to touch one of them, except in the case of external node references, such as "(DIR)". If the Prev is different from the Up, then the Prev node must have a Next pointing at this node. Every node except Top must have an Up. The Up node must contain some sort of reference, other than a Next, to this node. If the Next is different from the Next of the Up, then the Next node must have a Prev pointing at this node. */ validate_file (filename, tag_table) char *filename; TAG_ENTRY *tag_table; { char *old_input_filename = input_filename; TAG_ENTRY *tags = tag_table; while (tags != (TAG_ENTRY *) NULL) { register TAG_ENTRY *temp_tag; input_filename = tags->filename; line_number = tags->line_no; /* If this node has a Next, then make sure that the Next exists. */ if (tags->next) { validate (tags->next, tags->line_no, "Next"); /* If the Next node exists, and there is no Up, then make sure that the Prev of the Next points back. */ if (temp_tag = find_node (tags->next)) { char *prev = temp_tag->prev; if (!prev || (stricmp (prev, tags->node) != 0)) { line_error ("Node `%s''s Next field not pointed back to", tags->node); line_number = temp_tag->line_no; input_filename = temp_tag->filename; line_error ("This node (`%s') is the one with the bad `Prev'", temp_tag->node); input_filename = tags->filename; line_number = tags->line_no; temp_tag->flags |= PREV_ERROR; } } } /* Validate the Prev field if there is one, and we haven't already complained about it in some way. You don't have to have a Prev field at this stage. */ if (!(tags->flags & PREV_ERROR) && tags->prev) { int valid = validate (tags->prev, tags->line_no, "Prev"); if (!valid) tags->flags |= PREV_ERROR; else { /* If the Prev field is not the same as the Up field, then the node pointed to by the Prev field must have a Next field which points to this node. */ if (tags->up && (stricmp (tags->prev, tags->up) != 0)) { temp_tag = find_node (tags->prev); if (!temp_tag->next || (stricmp (temp_tag->next, tags->node) != 0)) { line_error ("Node `%s''s Prev field not pointed back to", tags->node); line_number = temp_tag->line_no; input_filename = temp_tag->filename; line_error ("This node (`%s') is the one with the bad `Next'", temp_tag->node); input_filename = tags->filename; line_number = tags->line_no; temp_tag->flags |= NEXT_ERROR; } } } } if (!tags->up && (stricmp (tags->node, "Top") != 0)) line_error ("Node `%s' is missing an \"Up\" field", tags->node); else if (tags->up) { int valid = validate (tags->up, tags->line_no, "Up"); /* If node X has Up: Y, then warn if Y fails to have a menu item or note pointing at X, if Y isn't of the form "(Y)". */ if (valid && *tags->up != '(') { NODE_REF *nref, *tref, *list; NODE_REF *find_node_reference (); tref = (NODE_REF *) NULL; list = node_references; for (;;) { if (!(nref = find_node_reference (tags->node, list))) break; if (stricmp (nref->containing_node, tags->up) == 0) { if (nref->type != menu_reference) { tref = nref; list = nref->next; } else break; } list = nref->next; } if (!nref) { temp_tag = find_node (tags->up); line_number = temp_tag->line_no; filename = temp_tag->filename; if (!tref) line_error ( "`%s' has an Up field of `%s', but `%s' has no menu item for `%s'", tags->node, tags->up, tags->up, tags->node); line_number = tags->line_no; filename = tags->filename; } } } tags = tags->next_ent; } validate_other_references (node_references); /* We have told the user about the references which didn't exist. Now tell him about the nodes which aren't referenced. */ tags = tag_table; while (tags != (TAG_ENTRY *) NULL) { /* Special hack. If the node in question appears to have been referenced more than REFERENCE_WARNING_LIMIT times, give a warning. */ if (tags->touched > reference_warning_limit) { input_filename = tags->filename; line_number = tags->line_no; warning ("Node `%s' has been referenced %d times", tags->node, tags->touched); } if (tags->touched == 0) { input_filename = tags->filename; line_number = tags->line_no; /* Notice that the node "Top" is special, and doesn't have to be referenced. */ if (stricmp (tags->node, "Top") != 0) warning ("Unreferenced node `%s'", tags->node); } tags = tags->next_ent; } input_filename = old_input_filename; } /* Return 1 if tag correctly validated, or 0 if not. */ validate (tag, line, label) char *tag; int line; char *label; { TAG_ENTRY *result; /* If there isn't a tag to verify, or if the tag is in another file, then it must be okay. */ if (!tag || !*tag || *tag == '(') return (1); /* Otherwise, the tag must exist. */ result = find_node (tag); if (!result) { line_number = line; line_error ( "Validation error. `%s' field points to node `%s', which doesn't exist", label, tag); return (0); } result->touched++; return (1); } /* Split large output files into a series of smaller files. Each file is pointed to in the tag table, which then gets written out as the original file. The new files have the same name as the original file with a "-num" attached. SIZE is the largest number of bytes to allow in any single split file. */ split_file (filename, size) char *filename; int size; { char *root_filename, *root_pathname; char *the_file, *filename_part (); struct stat fileinfo; char *the_header; int header_size; /* Can only do this to files with tag tables. */ if (!tag_table) return; if (size == 0) size = DEFAULT_SPLIT_SIZE; if ((stat (filename, &fileinfo) != 0) || (fileinfo.st_size < SPLIT_SIZE_THRESHOLD)) return; the_file = find_and_load (filename); if (!the_file) return; root_filename = filename_part (filename); root_pathname = pathname_part (filename); if (!root_pathname) root_pathname = savestring (""); /* Start splitting the file. Walk along the tag table outputting sections of the file. When we have written all of the nodes in the tag table, make the top-level pointer file, which contains indirect pointers and tags for the nodes. */ { int which_file = 1; TAG_ENTRY *tags = tag_table; char *indirect_info = (char *)NULL; /* Remember the `header' of this file. The first tag in the file is the bottom of the header; the top of the file is the start. */ the_header = (char *)xmalloc (1 + (header_size = (tags->position - 2))); bcopy (the_file, the_header, header_size); while (tags) { int file_top, file_bot, limit; /* Have to include the Control-_. */ file_top = file_bot = tags->position - 2; limit = file_top + size; /* If the rest of this file is only one node, then that is the entire subfile. */ if (!tags->next_ent) { int i = tags->position + 1; char last_char = the_file[i]; while (i < fileinfo.st_size) { if ((the_file[i] == '\037') && ((last_char == '\n') || (last_char == '\014'))) break; else last_char = the_file[i]; i++; } file_bot = i; tags = tags->next_ent; goto write_region; } /* Otherwise, find the largest number of nodes that can fit in this subfile. */ for (; tags; tags = tags->next_ent) { if (!tags->next_ent) { /* This entry is the last node. Search forward for the end of this node, and that is the end of this file. */ int i = tags->position + 1; char last_char = the_file[i]; while (i < fileinfo.st_size) { if ((the_file[i] == '\037') && ((last_char == '\n') || (last_char == '\014'))) break; else last_char = the_file[i]; i++; } file_bot = i; if (file_bot < limit) { tags = tags->next_ent; goto write_region; } else { /* Here we want to write out everything before the last node, and then write the last node out in a file by itself. */ file_bot = tags->position; goto write_region; } } if (tags->next_ent->position > limit) { if ((tags->position) - 2 == file_top) tags = tags->next_ent; file_bot = tags->position; write_region: { int fd; char *split_file = (char *) xmalloc (10 + strlen (root_pathname) + strlen (root_filename)); sprintf (split_file, "%s%s-%d", root_pathname, root_filename, which_file); if (((fd = open (split_file, O_WRONLY | O_TRUNC | O_CREAT, 0666)) < 0) || (write (fd, the_header, header_size) != header_size) || (write (fd, the_file + file_top, file_bot - file_top) != (file_bot - file_top)) || ((close (fd)) < 0)) { perror (split_file); close (fd); exit (FATAL); } if (!indirect_info) { indirect_info = the_file + file_top; sprintf (indirect_info, "\037\nIndirect:\n"); indirect_info += strlen (indirect_info); } sprintf (indirect_info, "%s-%d: %d\n", root_filename, which_file, file_top); free (split_file); indirect_info += strlen (indirect_info); which_file++; break; } } } } /* We have sucessfully created the subfiles. Now write out the original again. We must use `output_stream', or write_tag_table_indirect () won't know where to place the output. */ output_stream = fopen (filename, "w"); if (!output_stream) { perror (filename); exit (FATAL); } { int distance = indirect_info - the_file; fwrite (the_file, 1, distance, output_stream); /* Inhibit newlines. */ paragraph_is_open = 0; write_tag_table_indirect (); fclose (output_stream); free (the_header); free (the_file); return; } } } /* Some menu hacking. This is used to remember menu references while reading the input file. After the output file has been written, if validation is on, then we use the contents of NODE_REFERENCES as a list of nodes to validate. */ char * reftype_type_string (type) enum reftype type; { switch (type) { case menu_reference: return ("Menu"); case followed_reference: return ("Followed-Reference"); default: return ("Internal-bad-reference-type"); } } /* Remember this node name for later validation use. */ remember_node_reference (node, line, type) char *node; int line; enum reftype type; { NODE_REF *temp = (NODE_REF *) xmalloc (sizeof (NODE_REF)); temp->next = node_references; temp->node = savestring (node); temp->line_no = line; temp->section = current_section; temp->type = type; temp->containing_node = savestring (current_node); temp->filename = node_filename; node_references = temp; } validate_other_references (ref_list) register NODE_REF *ref_list; { char *old_input_filename = input_filename; while (ref_list != (NODE_REF *) NULL) { input_filename = ref_list->filename; validate (ref_list->node, ref_list->line_no, reftype_type_string (ref_list->type)); ref_list = ref_list->next; } input_filename = old_input_filename; } /* Find NODE in REF_LIST. */ NODE_REF * find_node_reference (node, ref_list) char *node; register NODE_REF *ref_list; { while (ref_list) { if (stricmp (node, ref_list->node) == 0) break; ref_list = ref_list->next; } return (ref_list); } free_node_references () { register NODE_REF *list, *temp; list = node_references; while (list) { temp = list; free (list->node); free (list->containing_node); list = list->next; free (temp); } node_references = (NODE_REF *) NULL; } /* This function gets called at the start of every line while inside of a menu. It checks to see if the line starts with "* ", and if so, remembers the node reference that this menu refers to. input_text_offset is at the \n just before the line start. */ #define menu_starter "* " char * glean_node_from_menu (remember_reference) int remember_reference; { int i, orig_offset = input_text_offset; char *nodename; if (strncmp (&input_text[input_text_offset + 1], menu_starter, strlen (menu_starter)) != 0) return ((char *)NULL); else input_text_offset += strlen (menu_starter) + 1; get_until_in_line (":", &nodename); if (curchar () == ':') input_text_offset++; canon_white (nodename); if (curchar () == ':') goto save_node; free (nodename); get_rest_of_line (&nodename); /* Special hack: If the nodename follows the menu item name, then we have to read the rest of the line in order to find out what the nodename is. But we still have to read the line later, in order to process any formatting commands that might be present. So un-count the carriage return that has just been counted. */ line_number--; canon_white (nodename); for (i = 0; i < strlen (nodename); i++) { if (nodename[i] == '\t' || nodename[i] == '.' || nodename[i] == ',') { nodename[i] = '\0'; break; } } save_node: input_text_offset = orig_offset; normalize_node_name (nodename); i = strlen (nodename); if (i && nodename[i - 1] == ':') nodename[i - 1] = '\0'; if (remember_reference) { remember_node_reference (nodename, line_number, menu_reference); free (nodename); return ((char *)NULL); } else return (nodename); } cm_menu () { begin_insertion (menu); } /* **************************************************************** */ /* */ /* Cross Reference Hacking */ /* */ /* **************************************************************** */ char * get_xref_token () { char *string; get_until_in_braces (",", &string); if (curchar () == ',') input_text_offset++; fix_whitespace (string); return (string); } int px_ref_flag = 0; /* Controls initial output string. */ /* Make a cross reference. */ cm_xref (arg) { if (arg == START) { char *arg1, *arg2, *arg3, *arg4, *arg5; arg1 = get_xref_token (); arg2 = get_xref_token (); arg3 = get_xref_token (); arg4 = get_xref_token (); arg5 = get_xref_token (); add_word_args ("%s", px_ref_flag ? "*note " : "*Note "); if (*arg5 || *arg4) { char *node_name; if (!*arg2) { if (*arg3) node_name = arg3; else node_name = arg1; } else node_name = arg2; execute_string ("%s: (%s)%s", node_name, arg4, arg1); return; } else remember_node_reference (arg1, line_number, followed_reference); if (*arg3) { if (!*arg2) execute_string ("%s: %s", arg3, arg1); else execute_string ("%s: %s", arg2, arg1); return; } if (*arg2) execute_string ("%s: %s", arg2, arg1); else execute_string ("%s::", arg1); } else { /* Check to make sure that the next non-whitespace character is either a period or a comma. input_text_offset is pointing at the "}" which ended the xref or pxref command. */ int temp = input_text_offset + 1; if (output_paragraph[output_paragraph_offset - 2] == ':' && output_paragraph[output_paragraph_offset - 1] == ':') return; while (temp < size_of_input_text) { if (cr_or_whitespace (input_text[temp])) temp++; else { if (input_text[temp] == '.' || input_text[temp] == ',' || input_text[temp] == '\t') return; else { line_error ("Cross-reference must be terminated with a period or a comma"); return; } } } } } cm_pxref (arg) int arg; { if (arg == START) { px_ref_flag++; cm_xref (arg); px_ref_flag--; } else add_char ('.'); } cm_inforef (arg) int arg; { if (arg == START) { char *node, *pname, *file; node = get_xref_token (); pname = get_xref_token (); file = get_xref_token (); execute_string ("*note %s: (%s)%s", pname, file, node); } } /* **************************************************************** */ /* */ /* Insertion Command Stubs */ /* */ /* **************************************************************** */ cm_quotation () { begin_insertion (quotation); } cm_example () { begin_insertion (example); } cm_smallexample () { begin_insertion (smallexample); } cm_lisp () { begin_insertion (lisp); } cm_smalllisp () { begin_insertion (smalllisp); } /* @cartouche/@end cartouche draws box with rounded corners in TeX output. Right now, just a NOP insertion. */ cm_cartouche () { begin_insertion (cartouche); } cm_format () { begin_insertion (format); } cm_display () { begin_insertion (display); } cm_itemize () { begin_insertion (itemize); } cm_enumerate () { do_enumeration (enumerate, "1"); } /* Start an enumeration insertion of type TYPE. If the user supplied no argument on the line, then use DEFAULT_STRING as the initial string. */ do_enumeration (type, default_string) int type; char *default_string; { get_until_in_line (".", &enumeration_arg); canon_white (enumeration_arg); if (!*enumeration_arg) { free (enumeration_arg); enumeration_arg = savestring (default_string); } if (!isdigit (*enumeration_arg) && !isletter (*enumeration_arg)) { warning ("%s requires a letter or a digit", insertion_type_pname (type)); switch (type) { case enumerate: default_string = "1"; break; } enumeration_arg = savestring (default_string); } begin_insertion (type); } cm_table () { begin_insertion (table); } cm_ftable () { begin_insertion (ftable); } cm_vtable () { begin_insertion (vtable); } cm_group () { begin_insertion (group); } cm_ifinfo () { begin_insertion (ifinfo); } /* Begin an insertion where the lines are not filled or indented. */ cm_flushleft () { begin_insertion (flushleft); } /* Begin an insertion where the lines are not filled, and each line is forced to the right-hand side of the page. */ cm_flushright () { begin_insertion (flushright); } /* **************************************************************** */ /* */ /* Conditional Handling */ /* */ /* **************************************************************** */ /* A structure which contains `defined' variables. */ typedef struct _defines { struct _defines *next; char *name; char *value; } DEFINE; /* The linked list of `set' defines. */ DEFINE *defines = (DEFINE *)NULL; /* Add NAME to the list of `set' defines. */ set (name, value) char *name; char *value; { DEFINE *temp; for (temp = defines; temp; temp = temp->next) if (strcmp (name, temp->name) == 0) { free (temp->value); temp->value = savestring (value); return; } temp = (DEFINE *)xmalloc (sizeof (DEFINE)); temp->next = defines; temp->name = savestring (name); temp->value = savestring (value); defines = temp; } /* Remove NAME from the list of `set' defines. */ clear (name) char *name; { register DEFINE *temp, *last; last = (DEFINE *)NULL; temp = defines; while (temp) { if (strcmp (temp->name, name) == 0) { if (last) last->next = temp->next; else defines = temp->next; free (temp->name); free (temp->value); free (temp); break; } last = temp; temp = temp->next; } } /* Return the value of NAME. The return value is NULL if NAME is unset. */ char * set_p (name) char *name; { register DEFINE *temp; for (temp = defines; temp; temp = temp->next) if (strcmp (temp->name, name) == 0) return (temp->value); return ((char *)NULL); } /* Conditionally parse based on the current command name. */ command_name_condition () { char *discarder; discarder = (char *)xmalloc (8 + strlen (command)); sprintf (discarder, "\n@end %s", command); discard_until (discarder); discard_until ("\n"); free (discarder); } /* Create a variable whose name appears as the first word on this line. */ cm_set () { handle_variable (SET); } /* Remove a variable whose name appears as the first word on this line. */ cm_clear () { handle_variable (CLEAR); } cm_ifset () { handle_variable (IFSET); } cm_ifclear () { handle_variable (IFCLEAR); } cm_value (arg, start_pos, end_pos) int arg, start_pos, end_pos; { if (arg == END) { char *name, *value; name = (char *)&output_paragraph[start_pos]; output_paragraph[end_pos] = '\0'; name = savestring (name); value = set_p (name); output_paragraph_offset = start_pos; if (value) add_word_args ("%s", value); else add_word_args ("{No Value For \"%s\"}", name); free (name); } } /* Set, clear, or conditionalize based on ACTION. */ handle_variable (action) int action; { char *name; get_rest_of_line (&name); backup_input_pointer (); canon_white (name); handle_variable_internal (action, name); free (name); } handle_variable_internal (action, name) int action; char *name; { char *value, *temp; int delimiter; /* Only the first word of NAME is a valid tag. */ temp = name; delimiter = 0; while (*temp && (delimiter || !whitespace (*temp))) { if (*temp == '"' || *temp == '\'') { if (*temp == delimiter) delimiter = 0; else delimiter = *temp; } temp++; } *temp = '\0'; if (!*name) line_error ("@%s requires a name", command); else { switch (action) { case SET: { /* Allow a value to be saved along with a variable. The value is the text following an `=' sign in NAME, if any is present. */ char *value; int delimiter; for (value = name; *value && *value != '='; value++); if (*value) *value++ = '\0'; if (*value == '"' || *value == '\'') { value++; value[strlen (value) - 1] = '\0'; } set (name, value); } break; case CLEAR: clear (name); break; case IFSET: case IFCLEAR: /* If IFSET and NAME is not set, or if IFCLEAR and NAME is set, read lines from the the file until we reach a matching "@end CONDITION". This means that we only take note of "@ifset/clear" and "@end" commands. */ { char condition[8]; int condition_len; if (action == IFSET) strcpy (condition, "ifset"); else strcpy (condition, "ifclear"); condition_len = strlen (condition); if ((action == IFSET && !set_p (name)) || (action == IFCLEAR && set_p (name))) { int level = 0, done = 0; while (!done) { char *freeable_line, *line; get_rest_of_line (&freeable_line); for (line = freeable_line; whitespace (*line); line++); if (*line == COMMAND_PREFIX && (strncmp (line + 1, condition, condition_len) == 0)) level++; else if (strncmp (line, "@end", 4) == 0) { char *cname = line + 4; char *temp; while (*cname && whitespace (*cname)) cname++; temp = cname; while (*temp && !whitespace (*temp)) temp++; *temp = '\0'; if (strcmp (cname, condition) == 0) { if (!level) { done = 1; } else level--; } } free (freeable_line); } break; } else { if (action == IFSET) begin_insertion (ifset); else begin_insertion (ifclear); } } break; } } } /* **************************************************************** */ /* */ /* @itemx, @item */ /* */ /* **************************************************************** */ /* Non-zero means a string is in execution, as opposed to a file. */ int executing_string = 0; /* Execute the string produced by formatting the ARGs with FORMAT. This is like submitting a new file with @include. */ execute_string (format, arg1, arg2, arg3, arg4, arg5) char *format; { static char temp_string[4000]; sprintf (temp_string, format, arg1, arg2, arg3, arg4, arg5); strcat (temp_string, "@bye\n"); pushfile (); input_text_offset = 0; input_text = temp_string; input_filename = savestring (input_filename); size_of_input_text = strlen (temp_string); executing_string++; reader_loop (); popfile (); executing_string--; free_and_clear (&command); command = savestring ("not bye"); } int itemx_flag = 0; cm_itemx () { itemx_flag++; cm_item (); itemx_flag--; } cm_item () { char *rest_of_line, *item_func; /* Can only hack "@item" while inside of an insertion. */ if (insertion_level) { INSERTION_ELT *stack = insertion_stack; int original_input_text_offset; skip_whitespace (); original_input_text_offset = input_text_offset; get_rest_of_line (&rest_of_line); canon_white (rest_of_line); item_func = current_item_function (); /* Okay, do the right thing depending on which insertion function is active. */ switch_top: switch (stack->insertion) { case ifinfo: case ifset: case ifclear: case cartouche: stack = stack->next; if (!stack) goto no_insertion; else goto switch_top; break; case menu: case quotation: case example: case smallexample: case lisp: case format: case display: case group: line_error ("The `@%s' command is meaningless within a `@%s' block", command, insertion_type_pname (current_insertion_type ())); break; case itemize: case enumerate: if (itemx_flag) { line_error ("@itemx is not meaningful inside of a `%s' block", insertion_type_pname (current_insertion_type ())); } else { start_paragraph (); kill_self_indent (-1); filling_enabled = indented_fill = 1; if (current_insertion_type () == itemize) { indent (output_column = current_indent - 2); /* I need some way to determine whether this command takes braces or not. I believe the user can type either "@bullet" or "@bullet{}". Of course, they can also type "o" or "#" or whatever else they want. */ if (item_func && *item_func) { if (*item_func == '@') if (item_func[strlen (item_func) - 1] != '}') execute_string ("%s{}", item_func); else execute_string ("%s", item_func); else execute_string ("%s", item_func); } insert (' '); output_column++; } else enumerate_item (); /* Special hack. This makes close paragraph ignore you until the start_paragraph () function has been called. */ must_start_paragraph = 1; /* Ultra special hack. It appears that some people incorrectly place text directly after the @item, instead of on a new line by itself. This happens to work in TeX, so I make it work here. */ if (*rest_of_line) { line_number--; input_text_offset = original_input_text_offset; } } break; case table: case ftable: case vtable: { /* Get rid of extra characters. */ kill_self_indent (-1); /* close_paragraph () almost does what we want. The problem is when paragraph_is_open, and last_char_was_newline, and the last newline has been turned into a space, because filling_enabled. I handle it here. */ if (last_char_was_newline && filling_enabled && paragraph_is_open) insert ('\n'); close_paragraph (); #if defined (INDENT_PARAGRAPHS_IN_TABLE) /* Indent on a new line, but back up one indentation level. */ { int t; t = inhibit_paragraph_indentation; inhibit_paragraph_indentation = 1; /* At this point, inserting any non-whitespace character will force the existing indentation to be output. */ add_char ('i'); inhibit_paragraph_indentation = t; } #else /* !INDENT_PARAGRAPHS_IN_TABLE */ add_char ('i'); #endif /* !INDENT_PARAGRAPHS_IN_TABLE */ output_paragraph_offset--; kill_self_indent (default_indentation_increment + 1); /* Add item's argument to the line. */ filling_enabled = 0; if (!item_func && !(*item_func)) execute_string ("%s", rest_of_line); else execute_string ("%s{%s}", item_func, rest_of_line); if (current_insertion_type () == ftable) execute_string ("@findex %s\n", rest_of_line); if (current_insertion_type () == vtable) execute_string ("@vindex %s\n", rest_of_line); /* Start a new line, and let start_paragraph () do the indenting of it for you. */ close_single_paragraph (); indented_fill = filling_enabled = 1; } } free (rest_of_line); } else { no_insertion: line_error ("@%s found outside of an insertion block", command); } } /* **************************************************************** */ /* */ /* Defun and Friends */ /* */ /* **************************************************************** */ #define DEFUN_SELF_DELIMITING(c) \ (((c) == '(') \ || ((c) == ')') \ || ((c) == '[') \ || ((c) == ']')) struct token_accumulator { unsigned int length; unsigned int index; char **tokens; }; void initialize_token_accumulator (accumulator) struct token_accumulator *accumulator; { (accumulator->length) = 0; (accumulator->index) = 0; (accumulator->tokens) = NULL; } void accumulate_token (accumulator, token) struct token_accumulator *accumulator; char *token; { if ((accumulator->index) >= (accumulator->length)) { (accumulator->length) += 10; (accumulator->tokens) = (char **) xrealloc (accumulator->tokens, (accumulator->length * sizeof (char *))); } accumulator->tokens[accumulator->index] = token; accumulator->index += 1; } char * copy_substring (start, end) char *start; char *end; { char *result, *scan, *scan_result; result = (char *) xmalloc ((end - start) + 1); scan_result = result; scan = start; while (scan < end) *scan_result++ = *scan++; *scan_result = '\0'; return (result); } /* Given `string' pointing at an open brace, skip forward and return a pointer to just past the matching close brace. */ int scan_group_in_string (string_pointer) char **string_pointer; { register int c; register char *scan_string; register unsigned int level = 1; scan_string = (*string_pointer) + 1; while (1) { if (level == 0) { (*string_pointer) = scan_string; return (1); } c = (*scan_string++); if (c == '\0') { /* Tweak line_number to compensate for fact that we gobbled the whole line before coming here. */ line_number -= 1; line_error ("Missing `}' in @def arg"); line_number += 1; (*string_pointer) = (scan_string - 1); return (0); } if (c == '{') level += 1; if (c == '}') level -= 1; } } /* Return a list of tokens from the contents of `string'. Commands and brace-delimited groups count as single tokens. Contiguous whitespace characters are converted to a token consisting of a single space. */ char ** args_from_string (string) char *string; { struct token_accumulator accumulator; register char *scan_string = string; char *token_start, *token_end; initialize_token_accumulator (&accumulator); while ((*scan_string) != '\0') { /* Replace arbitrary whitespace by a single space. */ if (whitespace (*scan_string)) { scan_string += 1; while (whitespace (*scan_string)) scan_string += 1; accumulate_token ((&accumulator), (savestring (" "))); continue; } /* Commands count as single tokens. */ if ((*scan_string) == COMMAND_PREFIX) { token_start = scan_string; scan_string += 1; if (self_delimiting (*scan_string)) scan_string += 1; else { register int c; while (1) { c = *scan_string++; if ((c == '\0') || (c == '{') || (whitespace (c))) { scan_string -= 1; break; } } if (*scan_string == '{') { char *s = scan_string; (void) scan_group_in_string (&s); scan_string = s; } } token_end = scan_string; } /* Parentheses and brackets are self-delimiting. */ else if (DEFUN_SELF_DELIMITING (*scan_string)) { token_start = scan_string; scan_string += 1; token_end = scan_string; } /* Open brace introduces a group that is a single token. */ else if (*scan_string == '{') { char *s = scan_string; int balanced = scan_group_in_string (&s); token_start = scan_string + 1; scan_string = s; token_end = balanced ? (scan_string - 1) : scan_string; } /* Otherwise a token is delimited by whitespace, parentheses, brackets, or braces. A token is also ended by a command. */ else { token_start = scan_string; while (1) { register int c; c = *scan_string++; if (!c || (whitespace (c) || DEFUN_SELF_DELIMITING (c) || c == '{' || c == '}')) { scan_string--; break; } /* If we encounter a command imbedded within a token, then end the token. */ if (c == COMMAND_PREFIX) { scan_string--; break; } } token_end = scan_string; } accumulate_token (&accumulator, copy_substring (token_start, token_end)); } accumulate_token (&accumulator, NULL); return (accumulator.tokens); } void process_defun_args (defun_args, auto_var_p) char **defun_args; int auto_var_p; { int pending_space = 0; while (1) { char *defun_arg = *defun_args++; if (defun_arg == NULL) break; if (defun_arg[0] == ' ') { pending_space = 1; continue; } if (pending_space) { add_char (' '); pending_space = 0; } if (DEFUN_SELF_DELIMITING (defun_arg[0])) add_char (defun_arg[0]); else if (defun_arg[0] == '&') add_word (defun_arg); else if (defun_arg[0] == COMMAND_PREFIX) execute_string ("%s", defun_arg); else if (auto_var_p) execute_string ("@var{%s}", defun_arg); else add_word (defun_arg); } } char * next_nonwhite_defun_arg (arg_pointer) char ***arg_pointer; { char **scan = (*arg_pointer); char *arg = (*scan++); if ((arg != 0) && (*arg == ' ')) arg = *scan++; if (arg == 0) scan -= 1; *arg_pointer = scan; return ((arg == 0) ? "" : arg); } /* Make the defun type insertion. TYPE says which insertion this is. X_P says not to start a new insertion if non-zero. */ void defun_internal (type, x_p) enum insertion_type type; int x_p; { enum insertion_type base_type; char **defun_args, **scan_args; char *category, *defined_name, *type_name, *type_name2; { char *line; get_rest_of_line (&line); defun_args = (args_from_string (line)); free (line); } scan_args = defun_args; switch (type) { case defun: category = "Function"; base_type = deffn; break; case defmac: category = "Macro"; base_type = deffn; break; case defspec: category = "Special Form"; base_type = deffn; break; case defvar: category = "Variable"; base_type = defvr; break; case defopt: category = "User Option"; base_type = defvr; break; case deftypefun: category = "Function"; base_type = deftypefn; break; case deftypevar: category = "Variable"; base_type = deftypevr; break; case defivar: category = "Instance Variable"; base_type = defcv; break; case defmethod: category = "Method"; base_type = defop; break; case deftypemethod: category = "Method"; base_type = deftypemethod; break; default: category = next_nonwhite_defun_arg (&scan_args); base_type = type; break; } if ((base_type == deftypefn) || (base_type == deftypevr) || (base_type == defcv) || (base_type == defop) || (base_type == deftypemethod)) type_name = next_nonwhite_defun_arg (&scan_args); if (base_type == deftypemethod) type_name2 = next_nonwhite_defun_arg (&scan_args); defined_name = next_nonwhite_defun_arg (&scan_args); /* This hack exists solely for the purposes of formatting the texinfo manual. I couldn't think of a better way. The token might be a simple @@ followed immediately by more text. If this is the case, then the next defun arg is part of this one, and we should concatenate them. */ if (*scan_args && **scan_args && !whitespace (**scan_args) && (strcmp (defined_name, "@@") == 0)) { char *tem = (char *)xmalloc (3 + strlen (scan_args[0])); sprintf (tem, "@@%s", scan_args[0]); free (scan_args[0]); scan_args[0] = tem; scan_args++; defined_name = tem; } if (!x_p) begin_insertion (type); /* Write the definition header line. This should start at the normal indentation. */ current_indent -= default_indentation_increment; start_paragraph (); switch (base_type) { case deffn: case defvr: case deftp: execute_string (" -- %s: %s", category, defined_name); break; case deftypefn: case deftypevr: execute_string (" -- %s: %s %s", category, type_name, defined_name); break; case defcv: execute_string (" -- %s of %s: %s", category, type_name, defined_name); break; case defop: execute_string (" -- %s on %s: %s", category, type_name, defined_name); break; case deftypemethod: execute_string (" -- %s on %s: %s %s", category, type_name, type_name2, defined_name); break; } current_indent += default_indentation_increment; /* Now process the function arguments, if any. If these carry onto the next line, they should be indented by two increments to distinguish them from the body of the definition, which is indented by one increment. */ current_indent += default_indentation_increment; switch (base_type) { case deffn: case defop: process_defun_args (scan_args, 1); break; case deftp: case deftypefn: case deftypemethod: process_defun_args (scan_args, 0); break; } current_indent -= default_indentation_increment; close_single_paragraph (); /* Make an entry in the appropriate index. */ switch (base_type) { case deffn: case deftypefn: execute_string ("@findex %s\n", defined_name); break; case defvr: case deftypevr: case defcv: execute_string ("@vindex %s\n", defined_name); break; case defop: case deftypemethod: execute_string ("@findex %s on %s\n", defined_name, type_name); break; case deftp: execute_string ("@tindex %s\n", defined_name); break; } /* Deallocate the token list. */ scan_args = defun_args; while (1) { char * arg = (*scan_args++); if (arg == NULL) break; free (arg); } free (defun_args); } /* Add an entry for a function, macro, special form, variable, or option. If the name of the calling command ends in `x', then this is an extra entry included in the body of an insertion of the same type. */ cm_defun () { int x_p; enum insertion_type type; char *temp = savestring (command); x_p = (command[strlen (command) - 1] == 'x'); if (x_p) temp[strlen (temp) - 1] = '\0'; type = find_type_from_name (temp); free (temp); /* If we are adding to an already existing insertion, then make sure that we are already in an insertion of type TYPE. */ if (x_p && (!insertion_level || insertion_stack->insertion != type)) { line_error ("Must be in a `%s' insertion in order to use `%s'x", command, command); discard_until ("\n"); return; } defun_internal (type, x_p); } /* End existing insertion block. */ cm_end () { char *temp; enum insertion_type type; if (!insertion_level) { line_error ("Unmatched `@%s'", command); return; } get_rest_of_line (&temp); canon_white (temp); if (strlen (temp) == 0) line_error ("`@%s' needs something after it", command); type = find_type_from_name (temp); if (type == bad_type) { line_error ("Bad argument to `%s', `%s', using `%s'", command, temp, insertion_type_pname (current_insertion_type ())); } end_insertion (type); free (temp); } /* **************************************************************** */ /* */ /* Other Random Commands */ /* */ /* **************************************************************** */ /* This says to inhibit the indentation of the next paragraph, but not of following paragraphs. */ cm_noindent () { if (!inhibit_paragraph_indentation) inhibit_paragraph_indentation = -1; } /* I don't know exactly what to do with this. Should I allow someone to switch filenames in the middle of output? Since the file could be partially written, this doesn't seem to make sense. Another option: ignore it, since they don't *really* want to switch files. Finally, complain, or at least warn. */ cm_setfilename () { char *filename; get_rest_of_line (&filename); /* warning ("`@%s %s' encountered and ignored", command, filename); */ free (filename); } cm_ignore_line () { discard_until ("\n"); } /* @br can be immediately followed by `{}', so we have to read those here. It should simply close the paragraph. */ cm_br () { if (looking_at ("{}")) input_text_offset += 2; if (curchar () == '\n') { input_text_offset++; line_number++; } close_paragraph (); } /* Insert the number of blank lines passed as argument. */ cm_sp () { int lines; char *line; get_rest_of_line (&line); sscanf (line, "%d", &lines); while (lines--) add_char ('\n'); free (line); } /* Start a new line with just this text on it. Then center the line of text. This always ends the current paragraph. */ cm_center () { register int i, start, length; int fudge_factor = 1; unsigned char *line; close_paragraph (); filling_enabled = indented_fill = 0; cm_noindent (); start = output_paragraph_offset; inhibit_output_flushing (); get_rest_of_line ((char **)&line); execute_string ((char *)line); free (line); uninhibit_output_flushing (); i = output_paragraph_offset - 1; while (i > (start - 1) && output_paragraph[i] == '\n') i--; output_paragraph_offset = ++i; length = output_paragraph_offset - start; if (length < (fill_column - fudge_factor)) { line = (unsigned char *)xmalloc (1 + length); bcopy (output_paragraph + start, line, length); i = (fill_column - fudge_factor - length) / 2; output_paragraph_offset = start; while (i--) insert (' '); for (i = 0; i < length; i++) insert (line[i]); free (line); } insert ('\n'); close_paragraph (); filling_enabled = 1; } /* Show what an expression returns. */ cm_result (arg) int arg; { if (arg == END) add_word ("=>"); } /* What an expression expands to. */ cm_expansion (arg) int arg; { if (arg == END) add_word ("==>"); } /* Indicates two expressions are equivalent. */ cm_equiv (arg) int arg; { if (arg == END) add_word ("=="); } /* What an expression may print. */ cm_print (arg) int arg; { if (arg == END) add_word ("-|"); } /* An error signaled. */ cm_error (arg) int arg; { if (arg == END) add_word ("error-->"); } /* The location of point in an example of a buffer. */ cm_point (arg) int arg; { if (arg == END) add_word ("-!-"); } /* Start a new line with just this text on it. The text is outdented one level if possible. */ cm_exdent () { char *line; int i = current_indent; if (current_indent) current_indent -= default_indentation_increment; get_rest_of_line (&line); close_single_paragraph (); execute_string (line); current_indent = i; free (line); close_single_paragraph (); } cm_include () { cm_infoinclude (); } /* Remember this file, and move onto the next. */ cm_infoinclude () { char *filename; close_paragraph (); get_rest_of_line (&filename); pushfile (); /* In verbose mode we print info about including another file. */ if (verbose_mode) { register int i = 0; register FSTACK *stack = filestack; for (i = 0, stack = filestack; stack; stack = stack->next, i++); i *= 2; printf ("%*s", i, ""); printf ("%c%s %s\n", COMMAND_PREFIX, command, filename); fflush (stdout); } if (!find_and_load (filename)) { extern char *sys_errlist[]; extern int errno, sys_nerr; popfile (); /* Cannot "@include foo", in line 5 of "/wh/bar". */ line_error ("`%c%s %s': %s", COMMAND_PREFIX, command, filename, ((errno < sys_nerr) ? sys_errlist[errno] : "Unknown file system error")); } free (filename); } /* The other side of a malformed expression. */ misplaced_brace () { line_error ("Misplaced `}'"); } /* Don't let the filling algorithm insert extra whitespace here. */ cm_force_abbreviated_whitespace () { } /* Do not let this character signify the end of a sentence, though if it was seen without the command prefix it normally would. We do this by turning on the 8th bit of the character. */ cm_ignore_sentence_ender () { add_char (META ((*command))); } /* Signals end of processing. Easy to make this happen. */ cm_bye () { input_text_offset = size_of_input_text; } cm_asis () { } cm_math () { } /* **************************************************************** */ /* */ /* Indexing Stuff */ /* */ /* **************************************************************** */ /* An index element... */ typedef struct index_elt { struct index_elt *next; char *entry; /* The index entry itself. */ char *node; /* The node from whence it came. */ int code; /* Non-zero means add `@code{...}' when printing this element. */ int defining_line; /* Line number where this entry was written. */ } INDEX_ELT; /* A list of short-names for each index, and the index to that index in our index array, the_indices. In addition, for each index, it is remembered whether that index is a code index or not. Code indices have @code{} inserted around the first word when they are printed with printindex. */ typedef struct { char *name; int index; int code; } INDEX_ALIST; INDEX_ALIST **name_index_alist = (INDEX_ALIST **) NULL; /* An array of pointers. Each one is for a different index. The "synindex" command changes which array slot is pointed to by a given "index". */ INDEX_ELT **the_indices = (INDEX_ELT **) NULL; /* The number of defined indices. */ int defined_indices = 0; /* We predefine these. */ #define program_index 0 #define function_index 1 #define concept_index 2 #define variable_index 3 #define datatype_index 4 #define key_index 5 init_indices () { int i; /* Create the default data structures. */ /* Initialize data space. */ if (!the_indices) { the_indices = (INDEX_ELT **) xmalloc ((1 + defined_indices) * sizeof (INDEX_ELT *)); the_indices[defined_indices] = (INDEX_ELT *) NULL; name_index_alist = (INDEX_ALIST **) xmalloc ((1 + defined_indices) * sizeof (INDEX_ALIST *)); name_index_alist[defined_indices] = (INDEX_ALIST *) NULL; } /* If there were existing indices, get rid of them now. */ for (i = 0; i < defined_indices; i++) undefindex (name_index_alist[i]->name); /* Add the default indices. */ defindex ("pg", 0); defindex ("fn", 1); /* "fn" is a code index. */ defindex ("cp", 0); defindex ("vr", 0); defindex ("tp", 0); defindex ("ky", 0); } /* Find which element in the known list of indices has this name. Returns -1 if NAME isn't found. */ int find_index_offset (name) char *name; { register int i; for (i = 0; i < defined_indices; i++) if (name_index_alist[i] && stricmp (name, name_index_alist[i]->name) == 0) return (name_index_alist[i]->index); return (-1); } /* Return a pointer to the entry of (name . index) for this name. Return NULL if the index doesn't exist. */ INDEX_ALIST * find_index (name) char *name; { int offset = find_index_offset (name); if (offset > -1) return (name_index_alist[offset]); else return ((INDEX_ALIST *) NULL); } /* Given an index name, return the offset in the_indices of this index, or -1 if there is no such index. */ translate_index (name) char *name; { INDEX_ALIST *which = find_index (name); if (which) return (which->index); else return (-1); } /* Return the index list which belongs to NAME. */ INDEX_ELT * index_list (name) char *name; { int which = translate_index (name); if (which < 0) return ((INDEX_ELT *) - 1); else return (the_indices[which]); } /* Please release me, let me go... */ free_index (index) INDEX_ELT *index; { INDEX_ELT *temp; while ((temp = index) != (INDEX_ELT *) NULL) { free (temp->entry); free (temp->node); index = index->next; free (temp); } } /* Flush an index by name. */ undefindex (name) char *name; { int i; int which = find_index_offset (name); if (which < 0) return (which); i = name_index_alist[which]->index; free_index (the_indices[i]); the_indices[i] = (INDEX_ELT *) NULL; free (name_index_alist[which]->name); free (name_index_alist[which]); name_index_alist[which] = (INDEX_ALIST *) NULL; } /* Define an index known as NAME. We assign the slot number. CODE if non-zero says to make this a code index. */ defindex (name, code) char *name; int code; { register int i, slot; /* If it already exists, flush it. */ undefindex (name); /* Try to find an empty slot. */ slot = -1; for (i = 0; i < defined_indices; i++) if (!name_index_alist[i]) { slot = i; break; } if (slot < 0) { /* No such luck. Make space for another index. */ slot = defined_indices; defined_indices++; name_index_alist = (INDEX_ALIST **) xrealloc ((char *)name_index_alist, (1 + defined_indices) * sizeof (INDEX_ALIST *)); the_indices = (INDEX_ELT **) xrealloc ((char *)the_indices, (1 + defined_indices) * sizeof (INDEX_ELT *)); } /* We have a slot. Start assigning. */ name_index_alist[slot] = (INDEX_ALIST *) xmalloc (sizeof (INDEX_ALIST)); name_index_alist[slot]->name = savestring (name); name_index_alist[slot]->index = slot; name_index_alist[slot]->code = code; the_indices[slot] = (INDEX_ELT *) NULL; } /* Add the arguments to the current index command to the index NAME. */ index_add_arg (name) char *name; { int which; char *index_entry; INDEX_ALIST *tem; tem = find_index (name); which = tem ? tem->index : -1; get_rest_of_line (&index_entry); ignore_blank_line (); if (which < 0) { line_error ("Unknown index reference `%s'", name); free (index_entry); } else { INDEX_ELT *new = (INDEX_ELT *) xmalloc (sizeof (INDEX_ELT)); new->next = the_indices[which]; new->entry = index_entry; new->node = current_node; new->code = tem->code; new->defining_line = line_number - 1; the_indices[which] = new; } } #define INDEX_COMMAND_SUFFIX "index" /* The function which user defined index commands call. */ gen_index () { char *name = savestring (command); if (strlen (name) >= strlen ("index")) name[strlen (name) - strlen ("index")] = '\0'; index_add_arg (name); free (name); } /* Define a new index command. Arg is name of index. */ cm_defindex () { gen_defindex (0); } cm_defcodeindex () { gen_defindex (1); } gen_defindex (code) int code; { char *name; get_rest_of_line (&name); if (find_index (name)) { line_error ("Index `%s' already exists", name); free (name); return; } else { char *temp = (char *) alloca (1 + strlen (name) + strlen ("index")); sprintf (temp, "%sindex", name); define_user_command (temp, gen_index, 0); defindex (name, code); free (name); } } /* Append LIST2 to LIST1. Return the head of the list. */ INDEX_ELT * index_append (head, tail) INDEX_ELT *head, *tail; { register INDEX_ELT *t_head = head; if (!t_head) return (tail); while (t_head->next) t_head = t_head->next; t_head->next = tail; return (head); } /* Expects 2 args, on the same line. Both are index abbreviations. Make the first one be a synonym for the second one, i.e. make the first one have the same index as the second one. */ cm_synindex () { int redirector, redirectee; char *temp; skip_whitespace (); get_until_in_line (" ", &temp); redirectee = find_index_offset (temp); skip_whitespace (); free_and_clear (&temp); get_until_in_line (" ", &temp); redirector = find_index_offset (temp); free (temp); if (redirector < 0 || redirectee < 0) { line_error ("Unknown index reference"); } else { /* I think that we should let the user make indices synonymous to each other without any lossage of info. This means that one can say @synindex cp dt anywhere in the file, and things that used to be in cp will go into dt. */ INDEX_ELT *i1 = the_indices[redirectee], *i2 = the_indices[redirector]; if (i1 || i2) { if (i1) the_indices[redirectee] = index_append (i1, i2); else the_indices[redirectee] = index_append (i2, i1); } name_index_alist[redirectee]->index = name_index_alist[redirector]->index; } } cm_pindex () /* Pinhead index. */ { index_add_arg ("pg"); } cm_vindex () /* Variable index. */ { index_add_arg ("vr"); } cm_kindex () /* Key index. */ { index_add_arg ("ky"); } cm_cindex () /* Concept index. */ { index_add_arg ("cp"); } cm_findex () /* Function index. */ { index_add_arg ("fn"); } cm_tindex () /* Data Type index. */ { index_add_arg ("tp"); } /* Sorting the index. */ index_element_compare (element1, element2) INDEX_ELT **element1, **element2; { /* This needs to ignore leading non-text characters. */ return (strcmp ((*element1)->entry, (*element2)->entry)); } /* Sort the index passed in INDEX, returning an array of pointers to elements. The array is terminated with a NULL pointer. We call qsort because it's supposed to be fast. I think this looks bad. */ INDEX_ELT ** sort_index (index) INDEX_ELT *index; { INDEX_ELT *temp = index; INDEX_ELT **array; int count = 0; while (temp != (INDEX_ELT *) NULL) { count++; temp = temp->next; } /* We have the length. Make an array. */ array = (INDEX_ELT **) xmalloc ((count + 1) * sizeof (INDEX_ELT *)); count = 0; temp = index; while (temp != (INDEX_ELT *) NULL) { array[count++] = temp; temp = temp->next; } array[count] = (INDEX_ELT *) NULL; /* terminate the array. */ /* Sort the array. */ qsort (array, count, sizeof (INDEX_ELT *), index_element_compare); return (array); } /* Non-zero means that we are in the middle of printing an index. */ int printing_index = 0; /* Takes one arg, a short name of an index to print. Outputs a menu of the sorted elements of the index. */ cm_printindex () { int item; INDEX_ELT *index; INDEX_ELT **array; char *index_name; int old_inhibitions = inhibit_paragraph_indentation; int previous_filling_enabled_value = filling_enabled; close_paragraph (); get_rest_of_line (&index_name); index = index_list (index_name); if ((int) index == -1) { line_error ("Unknown index name `%s'", index_name); free (index_name); return; } else free (index_name); array = sort_index (index); filling_enabled = 0; inhibit_paragraph_indentation = 1; close_paragraph (); add_word ("* Menu:\n\n"); printing_index = 1; for (item = 0; (index = array[item]); item++) { int real_line_number = line_number; /* Let errors generated while making the index entry point back at the line which contains the entry. */ line_number = index->defining_line; /* If this particular entry should be printed as a "code" index, then wrap the entry with "@code{...}". */ if (index->code) execute_string ("* @code{%s}: ", index->entry); else execute_string ("* %s: ", index->entry); /* Pad the front of the destination nodename so that the output looks nice. */ if (fill_column > 40 && output_column < 40) indent (40 - output_column); execute_string ("%s.\n", index->node); line_number = real_line_number; flush_output (); } printing_index = 0; free (array); close_single_paragraph (); filling_enabled = previous_filling_enabled_value; inhibit_paragraph_indentation = old_inhibitions; } /* **************************************************************** */ /* */ /* Making User Defined Commands */ /* */ /* **************************************************************** */ define_user_command (name, proc, needs_braces_p) char *name; FUNCTION *proc; int needs_braces_p; { int slot = user_command_array_len; user_command_array_len++; if (!user_command_array) user_command_array = (COMMAND **) xmalloc (1 * sizeof (COMMAND *)); user_command_array = (COMMAND **) xrealloc (user_command_array, (1 + user_command_array_len) * sizeof (COMMAND *)); user_command_array[slot] = (COMMAND *) xmalloc (sizeof (COMMAND)); user_command_array[slot]->name = savestring (name); user_command_array[slot]->proc = proc; user_command_array[slot]->argument_in_braces = needs_braces_p; } /* Make ALIAS run the named FUNCTION. Copies properties from FUNCTION. */ define_alias (alias, function) char *alias, *function; { } /* Set the paragraph indentation variable to the value specified in STRING. Values can be: `asis': Don't change existing indentation. `none': Remove existing indentation. NUM: Indent NUM spaces at the starts of paragraphs. Note that if NUM is zero, we assume `none'. Returns 0 if successful, or non-zero if STRING isn't one of the above. */ int set_paragraph_indent (string) char *string; { if (strcmp (string, "asis") == 0) paragraph_start_indent = 0; else if (strcmp (string, "none") == 0) paragraph_start_indent = -1; else { if (sscanf (string, "%d", ¶graph_start_indent) != 1) return (-1); else { if (paragraph_start_indent == 0) paragraph_start_indent = -1; } } return (0); } cm_paragraphindent () { char *arg; get_rest_of_line (&arg); if (set_paragraph_indent (arg) != 0) line_error ("Bad argument to @paragraphindent"); free (arg); } /* Some support for footnotes. */ /* Footnotes are a new construct in Info. We don't know the best method of implementing them for sure, so we present two possiblities. SeparateNode: Make them look like followed references, with the reference destinations in a makeinfo manufactured node or, EndNode: Make them appear at the bottom of the node that they originally appeared in. */ #define SeparateNode 0 #define EndNode 1 int footnote_style = EndNode; int first_footnote_this_node = 1; int footnote_count = 0; /* Set the footnote style based on he style identifier in STRING. */ int set_footnote_style (string) char *string; { if ((stricmp (string, "separate") == 0) || (stricmp (string, "MN") == 0)) footnote_style = SeparateNode; else if ((stricmp (string, "end") == 0) || (stricmp (string, "EN") == 0)) footnote_style = EndNode; else return (-1); return (0); } cm_footnotestyle () { char *arg; get_rest_of_line (&arg); if (set_footnote_style (arg) != 0) line_error ("Bad argument to @footnotestyle"); free (arg); } typedef struct fn { struct fn *next; char *marker; char *note; } FN; FN *pending_notes = (FN *) NULL; /* A method for remembering footnotes. Note that this list gets output at the end of the current node. */ remember_note (marker, note) char *marker, *note; { FN *temp = (FN *) xmalloc (sizeof (FN)); temp->marker = savestring (marker); temp->note = savestring (note); temp->next = pending_notes; pending_notes = temp; footnote_count++; } /* How to get rid of existing footnotes. */ free_pending_notes () { FN *temp; while ((temp = pending_notes) != (FN *) NULL) { free (temp->marker); free (temp->note); pending_notes = pending_notes->next; free (temp); } first_footnote_this_node = 1; footnote_count = 0; } /* What to do when you see a @footnote construct. */ /* Handle a "footnote". footnote *{this is a footnote} where "*" is the marker character for this note. */ cm_footnote () { char *marker; char *note; get_until ("{", &marker); canon_white (marker); /* Read the argument in braces. */ if (curchar () != '{') { line_error ("`@%s' expected more than just `%s'. It needs something in `{...}'", command, marker); free (marker); return; } else { int braces = 1; int temp = ++input_text_offset; int len; while (braces) { if (temp == size_of_input_text) { line_error ("No closing brace for footnote `%s'", marker); return; } if (input_text[temp] == '{') braces++; else if (input_text[temp] == '}') braces--; else if (input_text[temp] == '\n') line_number ++; temp++; } len = (temp - input_text_offset) - 1; note = (char *)xmalloc (len + 1); strncpy (note, &input_text[input_text_offset], len); note[len] = '\0'; input_text_offset = temp; } if (!current_node || !*current_node) { line_error ("Footnote defined without parent node"); free (marker); free (note); return; } if (!*marker) { free (marker); if (number_footnotes) { marker = (char *)xmalloc (10); sprintf (marker, "%d", current_footnote_number); current_footnote_number++; } else marker = savestring ("*"); } remember_note (marker, note); /* Your method should at least insert MARKER. */ switch (footnote_style) { case SeparateNode: add_word_args ("(%s)", marker); if (first_footnote_this_node) { char *temp_string; temp_string = (char *) xmalloc ((strlen (current_node)) + (strlen ("-Footnotes")) + 1); add_word_args (" (*note %s-Footnotes::)", current_node); strcpy (temp_string, current_node); strcat (temp_string, "-Footnotes"); remember_node_reference (temp_string, line_number, followed_reference); free (temp_string); first_footnote_this_node = 0; } break; case EndNode: add_word_args ("(%s)", marker); break; default: break; } free (marker); free (note); } /* Non-zero means that we are currently in the process of outputting footnotes. */ int already_outputting_pending_notes = 0; /* Output the footnotes. We are at the end of the current node. */ output_pending_notes () { FN *footnote = pending_notes; if (!pending_notes) return; switch (footnote_style) { case SeparateNode: { char *old_current_node = current_node; char *old_command = savestring (command); already_outputting_pending_notes++; execute_string ("@node %s-Footnotes,,,%s\n", current_node, current_node); already_outputting_pending_notes--; current_node = old_current_node; free (command); command = old_command; } break; case EndNode: close_paragraph (); in_fixed_width_font++; execute_string ("---------- Footnotes ----------\n\n"); in_fixed_width_font--; break; } /* Handle the footnotes in reverse order. */ { FN **array = (FN **) xmalloc ((footnote_count + 1) * sizeof (FN *)); array[footnote_count] = (FN *) NULL; while (--footnote_count > -1) { array[footnote_count] = footnote; footnote = footnote->next; } filling_enabled = 1; indented_fill = 1; while (footnote = array[++footnote_count]) { switch (footnote_style) { case SeparateNode: case EndNode: execute_string ("(%s) %s", footnote->marker, footnote->note); close_paragraph (); break; } } close_paragraph (); free (array); } } /* **************************************************************** */ /* */ /* User definable Macros (text substitution) */ /* */ /* **************************************************************** */ #if defined (HAVE_MACROS) /* Array of macros and definitions. */ MACRO_DEF **macro_list = (MACRO_DEF **)NULL; int macro_list_len = 0; /* Number of elements. */ int macro_list_size = 0; /* Number of slots in total. */ /* Return the macro definition of NAME or NULL if NAME is not defined. */ MACRO_DEF * find_macro (name) char *name; { register int i; register MACRO_DEF *def; def = (MACRO_DEF *)NULL; for (i = 0; macro_list && (def = macro_list[i]); i++) if (strcmp (def->name, name) == 0) break; return (def); } /* Add the macro NAME with DEFINITION to macro_list. FILENAME is the name of the file where this definition can be found, and LINENO is the line number within that file. If a macro already exists with NAME, then a warning is produced, and that previous definition is overwritten. */ void add_macro (name, definition, filename, lineno) char *name, *definition; char *filename; int lineno; { register MACRO_DEF *def; def = find_macro (name); if (!def) { if (macro_list_len + 2 >= macro_list_size) macro_list = (MACRO_DEF **)xrealloc (macro_list, ((macro_list_size += 10) * sizeof (MACRO_DEF *))); macro_list[macro_list_len] = (MACRO_DEF *)xmalloc (sizeof (MACRO_DEF)); macro_list[macro_list_len + 1] = (MACRO_DEF *)NULL; def = macro_list[macro_list_len]; macro_list_len += 1; def->name = savestring (name); } else { char *temp_filename = input_filename; int temp_line = line_number; warning ("The macro `%s' is previously defined.", name); input_filename = def->filename; line_number = def->lineno; warning ("Here is the previous definition of `%s'.", name); input_filename = temp_filename; line_number = temp_line; free (def->filename); free (def->definition); } def->filename = savestring (filename); def->lineno = lineno; def->definition = savestring (definition); } /* Delete the macro with name NAME. The macro is deleted from the list, but it is also returned. If there was no macro defined, NULL is returned. */ MACRO_DEF * delete_macro (name) char *name; { register int i; register MACRO_DEF *def; def = (MACRO_DEF *)NULL; for (i = 0; macro_list && (def = macro_list[i]); i++) if (strcmp (def->name, name) == 0) { bcopy (macro_list + i + 1, macro_list + i, ((macro_list_len + 1) - i) * sizeof (MACRO_DEF *)); break; } return (def); } /* Execute the macro passed in DEF, a pointer to a MACRO_DEF. */ void execute_macro (def) MACRO_DEF *def; { if (def != (MACRO_DEF *)NULL) { char *line, *string; get_until ("\n", &line); if (curchar () == '\n') /* as opposed to the end of the file... */ { line_number++; input_text_offset++; } string = (char *)xmalloc (1 + strlen (def->definition) + strlen (line)); strcpy (string, def->definition); strcat (string, line); free (line); execute_string ("%s\n", string); free (string); } } int cm_macro () { register int i; char *line, *name, *expansion; get_rest_of_line (&line); canon_white (line); for (i = 0; line[i] && !whitespace (line[i]); i++); name = (char *)xmalloc (i); strncpy (name, line, i); name[i] = '\0'; while (whitespace (line[i])) i++; add_macro (name, line + i, input_filename, line_number - 1); free (line); free (name); } int cm_unmacro () { register int i; char *line, *name; MACRO_DEF *def; get_rest_of_line (&line); canon_white (line); for (i = 0; line[i] && !whitespace (line[i]); i++); name = (char *)xmalloc (i); strncpy (name, line, i); name[i] = '\0'; def = delete_macro (name); if (def) { free (def->filename); free (def->name); free (def->definition); free (def); } free (line); free (name); } #endif /* HAVE_MACROS */ /* **************************************************************** */ /* */ /* Looking For Include Files */ /* */ /* **************************************************************** */ /* Given a string containing units of information separated by colons, return the next one pointed to by INDEX, or NULL if there are no more. Advance INDEX to the character after the colon. */ char * extract_colon_unit (string, index) char *string; int *index; { int i, start; i = *index; if (!string || (i >= strlen (string))) return ((char *)NULL); /* Each call to this routine leaves the index pointing at a colon if there is more to the path. If I is > 0, then increment past the `:'. If I is 0, then the path has a leading colon. Trailing colons are handled OK by the `else' part of the if statement; an empty string is returned in that case. */ if (i && string[i] == ':') i++; start = i; while (string[i] && string[i] != ':') i++; *index = i; if (i == start) { if (string[i]) (*index)++; /* Return "" in the case of a trailing `:'. */ return (savestring ("")); } else { char *value; value = (char *)xmalloc (1 + (i - start)); strncpy (value, &string[start], (i - start)); value [i - start] = '\0'; return (value); } } /* Return the full pathname for FILENAME by searching along PATH. When found, return the stat () info for FILENAME in FINFO. If PATH is NULL, only the current directory is searched. If the file could not be found, return a NULL pointer. */ char * get_file_info_in_path (filename, path, finfo) char *filename, *path; struct stat *finfo; { char *dir; int result, index = 0; if (path == (char *)NULL) path = "."; /* Handle absolute pathnames. "./foo", "/foo", "../foo". */ if (*filename == '/' || (*filename == '.' && (filename[1] == '/' || (filename[1] == '.' && filename[2] == '/')))) { if (stat (filename, finfo) == 0) return (savestring (filename)); else return ((char *)NULL); } while (dir = extract_colon_unit (path, &index)) { char *fullpath; if (!*dir) { free (dir); dir = savestring ("."); } fullpath = (char *)xmalloc (2 + strlen (dir) + strlen (filename)); sprintf (fullpath, "%s/%s", dir, filename); free (dir); result = stat (fullpath, finfo); if (result == 0) return (fullpath); else free (fullpath); } return ((char *)NULL); } texinfo-2.15/texi2dvi0000644000175000017500000002307212415566463012054 0ustar gg#!/bin/sh # texi2dvi -- smartly produce DVI files from texinfo sources # # Copyright (C) 1992 Free Software Foundation. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, you can either send email to this # program's author (see below) or write to: # # Free Software Foundation, Inc. # 675 Mass Ave. # Cambridge, MA 02139, USA. # # Please send bug reports, etc. to friedman@prep.ai.mit.edu # If possible, please send a copy of the output of the script called with # the `--debug' option when making a bug report. # # Version 0.2 # # Please note that in the interest of general portability, some common # bourne shell constructs were avoided because they weren't guaranteed to # be available in some earlier implementations. I've tried to make this as # portable as possible. # # Among the more interesting lossages I noticed with some bourne shells # are: # 1) Some don't have an `unset' builtin # 2) In some implementations the `shift' builtin can't take a # numerical argument. progname=`basename $0` usage="Usage: ${progname} {-d} {-f} {-h} [file1] {file2} {...} {--debug} {--force} {--help} Options in braces are optional. Those in brackets are required. " if [ $# -eq 0 ]; then echo "${usage}" 1>&2; exit 1 fi backup_extension=".bak" texindex="texindex" tex="tex" bq="\`" # To prevent hairy quoting and escaping later. eq="'" orig_pwd="`pwd`" if [ "z${TEXINDEX}" != "z" ]; then texindex="${TEXINDEX}" fi if [ "z${TEX}" != "z" ]; then tex="${TEX}" fi # Parse command line options # "unset" option variables to make sure they weren't accidentally # exported force="" debug="" # If you add new commands be sure to change the wildcards below to make # sure they are unambiguous (i.e. only match one possible long option) # Be sure to show at least one instance of the full long option name to # document what the long option is canonically called. while [ $# -gt 0 ]; do case z$1 in z-d | z--debug | z--d* ) debug="t" shift ;; z-f | z--force | z--f* ) force="t" shift ;; z-h | z--help | z--h* ) echo "${usage}" 1>&2 exit 1 ;; z-- ) shift break ;; z-* ) echo "${progname}: ${bq}${1}${eq} is not a valid option." 1>&2 echo "" 1>&2 echo "${usage}" 1>&2 exit 1 ;; * ) break ;; esac done # See if there are any command line args left (which will be interpreted as # filename arguments) if [ $# -eq 0 ]; then echo "${progname}: at least one file name is required as an argument." 1>&2 echo "" 1>&2 echo "${usage}" 1>&2 exit 1 fi if [ "z${debug}" = "zt" ]; then set -x fi # Texify files for command_line_filename in "$@" ; do # Always chdir to original working directory so that all relative # pathnames in command-line arguments are evaluated with respect to the # parent environment, rather than the working directory of the last file # (which might not have been the same). cd "${orig_pwd}" # Roughly equivalent to `dirname ...`, but more portable directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`" file="`basename ${command_line_filename}`" # Strip off the last extension part (probably .texinfo or .texi) filename_noext="`echo ${file} | sed 's/\.[^.]*$//'`" # "Unset" variables that might have values from previous iterations and # which won't be completely reset later. definite_index_files="" # If directory and file are the same, then it's probably because there's # no pathname component. Set dirname to `.', the current directory. if [ "z${directory}" = "z${file}" ]; then directory="." fi # Change to directory where file is located. cd "${directory}" if [ $? -ne 0 ]; then echo "${progname}: could not chdir to ${bq}${directory}${eq}" 1>&2 continue fi # See if file exists here. If it doesn't we're in trouble since, even # though the user may be able to reenter a valid filename at the tex # prompt (assuming they're attending the terminal), this script won't be # able to find the right index files and so forth. if [ ! -r "${file}" ]; then echo "${progname}: ${file}: No such file or permission denied." 1>&2 continue; fi # If dvi file is newer than the texinfo source, don't do anything # (unless --force option was specified) if [ ! "${force}" ]; then # List file.dvi first, just in case mtimes are identical and ls -t # sorts stably. filename_newest="`set -$- \`ls -t \"${filename_noext}.dvi\" \"${file}\" 2> /dev/null\`; echo \"\$1\"`" if [ "${filename_newest}" = "${filename_noext}.dvi" ]; then echo "${progname}: ${bq}${filename_noext}.dvi${eq} is up to date." 1>&2 continue fi fi # Find all files having root filename with a two-letter extension, # determine whether they're really index files, and save them. Foo.aux # is actually the cross-references file, but we need to keep track of # that too. possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" for this_file in ${possible_index_files} ; do # If file is empty, forget it. if [ ! -s "${this_file}" ]; then continue; fi # Examine first character of file. If it's not a backslash or # single quote, then it's definitely not an index or xref file. first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" if [ "${first_character}" = "\\" -o "${first_character}" = "'" ]; then definite_index_files="${definite_index_files} ${this_file}" fi done orig_index_files="${definite_index_files}" orig_index_files_sans_aux="`echo ${definite_index_files} \ | sed 's/'${filename_noext}'\.aux//; s/^[ ]*//;s/[ ]*$//;'`" # Now save copies of original index files so we have some means of # comparison later. for index_file_to_save in ${orig_index_files} ; do cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}" done # Run texindex on current index files. If they already exist, and # after running TeX a first time the index files don't change, then # there's no reason to run TeX again. But we won't know that if the # index files are out of date or nonexistent. if [ "${orig_index_files_sans_aux}" ]; then ${texindex} ${orig_index_files_sans_aux} fi if ${tex} ${file} ; then # TeX run first time definite_index_files="" # Get list of new index files possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`" for this_file in ${possible_index_files} ; do # If file is empty, forget it. if [ ! -s ${this_file} ]; then continue; fi # Examine first character of file. If it's not a backslash or # single quote, then it's definitely not an index or xref file. first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`" if [ "${first_character}" = "\\" -o "${first_character}" = "'" ]; then definite_index_files="${definite_index_files} ${this_file}" fi done new_index_files="${definite_index_files}" new_index_files_sans_aux="`echo ${definite_index_files} \ | sed 's/'${filename_noext}'\.aux//; s/^[ ]*//;s/[ ]*$//;'`" # If old and new list don't at least have the same file list, then one # file or another has definitely changed. if [ "${orig_index_files}" != "${new_index_files}" ]; then index_files_changed_p=t else # File list is the same. We must compare each file until we find a # difference. index_files_changed_p="" for file in ${new_index_files} ; do # cmp -s will return nonzero exit status if files differ. cmp -s "${file}" "${file}${backup_extension}" if [ $? -ne 0 ] ; then # We only need to keep comparing until we find *one* that # differs, because we'll have to run texindex & tex no # matter what. index_files_changed_p=t break fi done fi # If index files have changed since TeX has been run, or if the aux # file wasn't present originally, run texindex and TeX again. if [ "${index_files_changed_p}" ] ; then retval=0 if [ "${new_index_files_sans_aux}" ]; then ${texindex} ${new_index_files_sans_aux} retval=$? fi if [ ${retval} -eq 0 ]; then ${tex} "${file}" fi fi fi # Generate list of files to delete, then call rm once with the entire # list. This is significantly faster than multiple executions of rm. file_list="" for file in ${orig_index_files} ; do file_list="${file_list} ${file}${backup_extension}" done if [ "${file_list}" ]; then rm -f ${file_list} fi done # # eof # texinfo-2.15/elisp/0000755000175000017500000000000012415567333011500 5ustar ggtexinfo-2.15/elisp/texinfo.el0000644000175000017500000006260112415567321013500 0ustar gg;;;; texinfo.el ;;; Major mode for editing Texinfo files. ;;; Version 2.11 14 November 1991 ;;; Robert J. Chassell ;;; Please send bug reports to: bob@gnu.ai.mit.edu ;; Copyright (C) 1985, 1988, 1989, 1990, 1991 Free Software Foundation, Inc. ;;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Autoloads (autoload 'texinfo-format-region "texinfmt" "Convert the current region of the Texinfo file to Info format. This lets you see what that part of the file will look like in Info. The command is bound to \\[texinfo-format-region]. The text that is converted to Info is stored in a temporary buffer." t nil) (autoload 'texinfo-format-buffer "texinfmt" "Process the current buffer as texinfo code, into an Info file. The Info file output is generated in a buffer visiting the Info file names specified in the @setfilename command. Non-nil argument (prefix, if interactive) means don't make tag table and don't split the file if large. You can use Info-tagify and Info-split to do these manually." t nil) (autoload 'makeinfo-region "makeinfo" "Make Info file from region of current Texinfo source file. The \\[next-error] command can be used to move to the next error \(if any are found\)." t nil) (autoload 'makeinfo-buffer "makeinfo" "Make Info file from current buffer. The \\[next-error] command can be used to move to the next error \(if any are found\)." t nil) (autoload 'kill-compilation "compile" "Kill the process made by the \\[compile] command." t nil) (autoload 'makeinfo-recenter-compilation-buffer "makeinfo" "Redisplay *compilation* buffer so that most recent output can be seen. The last line of the buffer is displayed on line LINE of the window, or centered if LINE is nil." t nil) (autoload 'texinfo-tex-region "texnfo-tex" "Run tex on the current region. A temporary file is written in the default directory, and tex is run in that directory. The first line of the file is copied to the temporary file; and if the buffer has a header, it is written to the temporary file before the region itself. The buffer's header is all lines between the strings defined by texinfo-start-of-header and texinfo-end-of-header inclusive. The header must start in the first 100 lines. The value of texinfo-tex-trailer is appended to the temporary file after the region." t nil) (autoload 'texinfo-tex-buffer "texnfo-tex" "Run TeX on current buffer. After running TeX the first time, you may have to run \\[texinfo-texindex] and then \\[texinfo-tex-buffer] again." t nil) (autoload 'texinfo-kill-tex-job "texnfo-tex" "Kill the currently running TeX job." t nil) (autoload 'texinfo-recenter-tex-output-buffer "texnfo-tex" "Redisplay buffer of TeX job output so that most recent output can be seen. The last line of the buffer is displayed on line LINE of the window, or centered if LINE is nil." t nil) (autoload 'texinfo-delete-from-tex-print-queue "texnfo-tex" "Delete job from the line printer spooling queue. You are prompted for the job number (shown by a previous \\[texinfo-show-tex-print-queue] command." t nil) (autoload 'texinfo-show-tex-print-queue "texnfo-tex" "Show the print queue that \\[texinfo-tex-print] put your job on. Runs the shell command defined by texinfo-show-tex-queue-command." t nil) (autoload 'texinfo-tex-print "texnfo-tex" "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. Runs the shell command defined by texinfo-tex-dvi-print-command." t nil) (autoload 'texinfo-texindex "texnfo-tex" "Run texindex on unsorted index files. The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. Runs the shell command defined by texinfo-texindex-command." t nil) (autoload 'texinfo-make-menu "texnfo-upd" "Without any prefix argument, make or update a menu. Make the menu for the section enclosing the node found following point. Non-nil argument (prefix, if interactive) means make or update menus for nodes within or part of the marked region. Whenever a menu exists, and is being updated, the descriptions that are associated with node names in the pre-existing menu are incorporated into the new menu. Otherwise, the nodes' section titles are inserted as descriptions." t nil) (autoload 'texinfo-update-node "texnfo-upd" "Without any prefix argument, update the node in which point is located. Non-nil argument (prefix, if interactive) means update the nodes in the marked region. The functions for creating or updating nodes and menus, and their keybindings, are: texinfo-update-node (&optional region-p) \\[texinfo-update-node] texinfo-every-node-update () \\[texinfo-every-node-update] texinfo-sequential-node-update (&optional region-p) texinfo-make-menu (&optional region-p) \\[texinfo-make-menu] texinfo-all-menus-update () \\[texinfo-all-menus-update] texinfo-master-menu () texinfo-indent-menu-description (column &optional region-p) The `texinfo-column-for-description' variable specifies the column to which menu descriptions are indented. Its default value is 24." t nil) (autoload 'texinfo-every-node-update "texnfo-upd" "Update every node in a Texinfo file." t nil) (autoload 'texinfo-all-menus-update "texnfo-upd" "Update every regular menu in a Texinfo file. Remove pre-existing master menu, if there is one. If called with a non-nil argument, this function first updates all the nodes in the buffer before updating the menus." t nil) (autoload 'texinfo-master-menu "texnfo-upd" "Make a master menu for a whole Texinfo file. Non-nil argument (prefix, if interactive) means first update all existing nodes and menus. Remove pre-existing master menu, if there is one. This function creates a master menu that follows the top node. The master menu includes every entry from all the other menus. It replaces any existing ordinary menu that follows the top node. If called with a non-nil argument, this function first updates all the menus in the buffer (incorporating descriptions from pre-existing menus) before it constructs the master menu. The function removes the detailed part of an already existing master menu. This action depends on the pre-exisitng master menu using the standard `texinfo-master-menu-header'. The master menu has the following format, which is adapted from the recommendation in the Texinfo Manual: * The first part contains the major nodes in the Texinfo file: the nodes for the chapters, chapter-like sections, and the major appendices. This includes the indices, so long as they are in chapter-like sections, such as unnumbered sections. * The second and subsequent parts contain a listing of the other, lower level menus, in order. This way, an inquirer can go directly to a particular node if he or she is searching for specific information. Each of the menus in the detailed node listing is introduced by the title of the section containing the menu." t nil) (autoload 'texinfo-indent-menu-description "texnfo-upd" "Indent every description in menu following point to COLUMN. Non-nil argument (prefix, if interactive) means indent every description in every menu in the region. Does not indent second and subsequent lines of a multi-line description." t nil) (autoload 'texinfo-sequential-node-update "texnfo-upd" "Update one node (or many) in a Texinfo file with sequential pointers. This function causes the `Next' or `Previous' pointer to point to the immediately preceding or following node, even if it is at a higher or lower hierarchical level in the document. Continually pressing `n' or `p' takes you straight through the file. Without any prefix argument, update the node in which point is located. Non-nil argument (prefix, if interactive) means update the nodes in the marked region. This command makes it awkward to navigate among sections and subsections; it should be used only for those documents that are meant to be read like a novel rather than a reference, and for which the Info `g*' command is inadequate." t nil) (autoload 'texinfo-insert-node-lines "texnfo-upd" "Insert missing `@node' lines in region of Texinfo file. Non-nil argument (prefix, if interactive) means also to insert the section titles as node names; and also to insert the section titles as node names in pre-existing @node lines that lack names." t nil) (autoload 'texinfo-multiple-files-update "texnfo-upd" "Update first node pointers in each file included in OUTER-FILE; create or update main menu in the outer file that refers to such nodes. This does not create or update menus or pointers within the included files. With optional MAKE-MASTER-MENU argument (prefix arg, if interactive), insert a master menu in OUTER-FILE. This does not create or update menus or pointers within the included files. With optional UPDATE-EVERYTHING argument (numeric prefix arg, if interactive), update all the menus and all the `Next', `Previous', and `Up' pointers of all the files included in OUTER-FILE before inserting a master menu in OUTER-FILE. The command also updates the `Top' level node pointers of OUTER-FILE. Notes: * this command does NOT save any files--you must save the outer file and any modified, included files. * except for the `Top' node, this command does NOT handle any pre-existing nodes in the outer file; hence, indices must be enclosed in an included file. Requirements: * each of the included files must contain exactly one highest hierarchical level node, * this highest node must be the first node in the included file, * each highest hierarchical level node must be of the same type. Thus, normally, each included file contains one, and only one, chapter." t nil) ;;; Syntax table (defvar texinfo-mode-syntax-table nil) (if texinfo-mode-syntax-table nil (setq texinfo-mode-syntax-table (make-syntax-table)) (modify-syntax-entry ?\" " " texinfo-mode-syntax-table) (modify-syntax-entry ?\\ " " texinfo-mode-syntax-table) (modify-syntax-entry ?@ "\\" texinfo-mode-syntax-table) (modify-syntax-entry ?\^q "\\" texinfo-mode-syntax-table) (modify-syntax-entry ?\[ "(]" texinfo-mode-syntax-table) (modify-syntax-entry ?\] ")[" texinfo-mode-syntax-table) (modify-syntax-entry ?{ "(}" texinfo-mode-syntax-table) (modify-syntax-entry ?} "){" texinfo-mode-syntax-table) (modify-syntax-entry ?\' "w" texinfo-mode-syntax-table)) ;;; Keybindings (defvar texinfo-mode-map nil) ;;; Keys common both to Texinfo mode and to TeX shell. (defun texinfo-define-common-keys (keymap) "Define the keys both in Texinfo mode and in the texinfo-tex-shell." (define-key keymap "\C-c\C-t\C-k" 'texinfo-kill-tex-job) (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-tex-job) (define-key keymap "\C-c\C-t\C-l" 'texinfo-recenter-tex-output-buffer) (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-tex-print-queue) (define-key keymap "\C-c\C-t\C-q" 'texinfo-show-tex-print-queue) (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) ;; Mode documentation displays commands in reverse order ;; from how they are listed in the texinfo-mode-map. (if texinfo-mode-map nil (setq texinfo-mode-map (make-sparse-keymap)) ;; bindings for `texnfo-tex.el' (texinfo-define-common-keys texinfo-mode-map) ;; bindings for `texinfmt.el' (define-key texinfo-mode-map "\C-c\C-e\C-r" 'texinfo-format-region) (define-key texinfo-mode-map "\C-c\C-e\C-b" 'texinfo-format-buffer) ;; bindings for `makeinfo.el' (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) (define-key texinfo-mode-map "\C-c\C-m\C-l" 'makeinfo-recenter-compilation-buffer) (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) ;; bindings for updating nodes and menus (define-key texinfo-mode-map "\C-c\C-um" 'texinfo-master-menu) (define-key texinfo-mode-map "\C-c\C-u\C-m" 'texinfo-make-menu) (define-key texinfo-mode-map "\C-c\C-u\C-n" 'texinfo-update-node) (define-key texinfo-mode-map "\C-c\C-u\C-e" 'texinfo-every-node-update) (define-key texinfo-mode-map "\C-c\C-u\C-a" 'texinfo-all-menus-update) (define-key texinfo-mode-map "\C-c\C-s" 'texinfo-show-structure) (define-key texinfo-mode-map "\C-c\C-c}" 'up-list) (define-key texinfo-mode-map "\C-c\C-c]" 'up-list) ; easier to type (define-key texinfo-mode-map "\C-c\C-c{" 'texinfo-insert-braces) ;; bindings for inserting strings (define-key texinfo-mode-map "\C-c\C-cv" 'texinfo-insert-@var) (define-key texinfo-mode-map "\C-c\C-ct" 'texinfo-insert-@table) (define-key texinfo-mode-map "\C-c\C-cs" 'texinfo-insert-@samp) (define-key texinfo-mode-map "\C-c\C-co" 'texinfo-insert-@noindent) (define-key texinfo-mode-map "\C-c\C-cn" 'texinfo-insert-@node) (define-key texinfo-mode-map "\C-c\C-ck" 'texinfo-insert-@kbd) (define-key texinfo-mode-map "\C-c\C-ci" 'texinfo-insert-@item) (define-key texinfo-mode-map "\C-c\C-cf" 'texinfo-insert-@file) (define-key texinfo-mode-map "\C-c\C-cx" 'texinfo-insert-@example) (define-key texinfo-mode-map "\C-c\C-ce" 'texinfo-insert-@end) (define-key texinfo-mode-map "\C-c\C-cd" 'texinfo-insert-@dfn) (define-key texinfo-mode-map "\C-c\C-cc" 'texinfo-insert-@code)) ;;; Texinfo mode (defvar texinfo-chapter-level-regexp "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" "*Regexp matching chapter-level headings (but not the top node).") (defun texinfo-mode () "Major mode for editing Texinfo files. It has these extra commands: \\{texinfo-mode-map} These are files that are used as input for TeX to make printed manuals and also to be turned into Info files by \\[texinfo-format-buffer] or `makeinfo'. These files must be written in a very restricted and modified version of TeX input format. Editing commands are like text-mode except that the syntax table is set up so expression commands skip Texinfo bracket groups. To see what the Info version of a region of the Texinfo file will look like, use \\[texinfo-format-region]. This command runs Info on the current region of the Texinfo file and formats it properly. You can show the structure of a Texinfo file with \\[texinfo-show-structure]. This command shows the structure of a Texinfo file by listing the lines with the @-sign commands for @chapter, @section, and the like. These lines are displayed in another window called the *Occur* window. In that window, you can position the cursor over one of the lines and use \\[occur-mode-goto-occurrence], to jump to the corresponding spot in the Texinfo file. In addition, Texinfo mode provides commands that insert various frequently used @-sign commands into the buffer. You can use these commands to save keystrokes. And you can insert balanced braces with \\[texinfo-insert-braces] and later use the command \\[up-list] to move forward past the closing brace. Also, Texinfo mode provides functions for automatically creating or updating menus and node pointers. These functions * insert the `Next', `Previous' and `Up' pointers of a node, * insert or update the menu for a section, and * create a master menu for a Texinfo source file. Here are the functions: texinfo-update-node \\[texinfo-update-node] texinfo-every-node-update \\[texinfo-every-node-update] texinfo-sequential-node-update texinfo-make-menu \\[texinfo-make-menu] texinfo-all-menus-update \\[texinfo-all-menus-update] texinfo-master-menu texinfo-indent-menu-description (column &optional region-p) The `texinfo-column-for-description' variable specifies the column to which menu descriptions are indented. Passed an argument (a prefix argument, if interactive), the `texinfo-update-node' and `texinfo-make-menu' functions do their jobs in the region. To use the updating commands, you must structure your Texinfo file hierarchically, such that each `@node' line, with the exception of the Top node, is accompanied by some kind of section line, such as an `@chapter' or `@section' line. If the file has a `top' node, it must be called `top' or `Top' and be the first node in the file. Entering Texinfo mode calls the value of text-mode-hook, and then the value of texinfo-mode-hook." (interactive) (text-mode) (setq mode-name "Texinfo") (setq major-mode 'texinfo-mode) (use-local-map texinfo-mode-map) (set-syntax-table texinfo-mode-syntax-table) (make-local-variable 'page-delimiter) (setq page-delimiter (concat "^@node [ \t]*[Tt]op\\|^@\\(" texinfo-chapter-level-regexp "\\)")) (make-local-variable 'require-final-newline) (setq require-final-newline t) (make-local-variable 'indent-tabs-mode) (setq indent-tabs-mode nil) (make-local-variable 'paragraph-separate) (setq paragraph-separate (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-separate)) (make-local-variable 'paragraph-start) (setq paragraph-start (concat "^\b\\|^@[a-zA-Z]*[ \n]\\|" paragraph-start)) (make-local-variable 'fill-column) (setq fill-column 72) (make-local-variable 'comment-start) (setq comment-start "@c ") (make-local-variable 'comment-start-skip) (setq comment-start-skip "@c +") (make-local-variable 'words-include-escapes) (setq words-include-escapes t) (make-local-variable 'texinfo-start-of-header) (setq texinfo-start-of-header "%**start") (make-local-variable 'texinfo-end-of-header) (setq texinfo-end-of-header "%**end") (run-hooks 'text-mode-hook 'texinfo-mode-hook)) ;;; Define start and end of header expressions ;; The start-of-header and end-of-header expressions are defined here ;; since they used by both by `texinfmt.el' and by `texnfo-tex.el', ;; only one of which is likely to be loaded at one time. (defvar texinfo-start-of-header "%**start" "String to mark start of header for texinfo-tex-region.") (defvar texinfo-end-of-header "%**end" "String to mark end of header for texinfo-tex-region.") ;;; Insert string commands (defconst texinfo-environment-regexp "^@\\(f?table\\|enumerate\\|itemize\\|ifinfo\\|iftex\\|example\\|quotation\\|lisp\\|smallexample\\|smalllisp\\|display\\|format\\|flushleft\\|flushright\\|ignore\\|group\\|tex\\)" "Regexp for environment-like TexInfo list commands. Subexpression 1 is what goes into the corresponding `@end' statement.") ;; The following texinfo-insert-@end command not only inserts a SPC ;; after the @end, but tries to find out what belongs there. It is ;; not very smart: it does not understand nested lists. (defun texinfo-insert-@end () "Insert the matching `@end' for a @table etc. in a texinfo buffer. BUG: Does not understand nested lists." (interactive) (let ((string (save-excursion (if (re-search-backward texinfo-environment-regexp nil t) (buffer-substring (match-beginning 1) (match-end 1)))))) (insert "@end ") (if string (insert string)))) ; Earlier version of texinfo-insert-@end ; (defun texinfo-insert-@end () ; "Insert the string `@end ' (end followed by a space) in a texinfo buffer." ; (interactive) ; (insert "@end ")) ;; The following insert commands accept a prefix arg N, which is the ;; number of words (actually s-exprs) that should be surrounded by ;; braces. Thus you can first paste a variable name into a .texinfo ;; buffer, then say C-u 1 C-c C-c v at the beginning of the just ;; pasted variable name to put @var{...} *around* the variable name. ;; Operate on previous word or words with negative arg. ;; These commands use texinfo-insert-@-with-arg (defun texinfo-insert-@-with-arg (string &optional arg) (if arg (progn (setq arg (prefix-numeric-value arg)) (if (< arg 0) (progn (skip-chars-backward " \t\n\r\f") (save-excursion (forward-sexp arg) (insert "@" string "{")) (insert "}")) (skip-chars-forward " \t\n\r\f") (insert "@" string "{") (forward-sexp arg) (insert "}"))) (insert "@" string "{}") (backward-char))) (defun texinfo-insert-braces () "Make a pair of braces and be poised to type inside of them. Use \\[up-list] to move forward out of the braces." (interactive) (insert "{}") (backward-char)) ; (defun texinfo-insert-@code () ; "Insert the string @code in a texinfo buffer." ; (interactive) ; (insert "@code{}") ; (backward-char)) (defun texinfo-insert-@code (&optional arg) "Insert the string @code in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "code" arg)) ; (defun texinfo-insert-@dfn () ; "Insert the string @dfn in a texinfo buffer." ; (interactive) ; (insert "@dfn{}") ; (backward-char)) (defun texinfo-insert-@dfn (&optional arg) "Insert the string @dfn in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "dfn" arg)) (defun texinfo-insert-@example () "Insert the string @example in a texinfo buffer." (interactive) (insert "@example\n")) (defun texinfo-insert-@file (&optional arg) "Insert the string @file in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "file" arg)) ; (defun texinfo-insert-@item () ; "Insert the string @item in a texinfo buffer." ; (interactive) ; (insert "@item") ; (newline)) (defun texinfo-insert-@item () "Insert the string @item in a texinfo buffer." (interactive) (insert "@item") (newline)) ; (defun texinfo-insert-@kbd () ; "Insert the string @kbd in a texinfo buffer." ; (interactive) ; (insert "@kbd{}") ; (backward-char)) (defun texinfo-insert-@kbd (&optional arg) "Insert the string @kbd in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "kbd" arg)) ; (defun texinfo-insert-@node () ; "Insert the string @node in a texinfo buffer, ; along with a comment indicating the arguments to @node." ; (interactive) ; (insert "@node \n@comment node-name, next, previous, up") ; (forward-line -1) ; (forward-char 6)) (defun texinfo-insert-@node () "Insert the string @node in a texinfo buffer, along with a comment indicating the arguments to @node." (interactive) (insert "@node \n@comment node-name, next, previous, up") (forward-line -1) (forward-char 6)) ; (defun texinfo-insert-@noindent () ; "Insert the string @noindent in a texinfo buffer." ; (interactive) ; (insert "@noindent\n")) (defun texinfo-insert-@noindent () "Insert the string @noindent in a texinfo buffer." (interactive) (insert "@noindent\n")) ; (defun texinfo-insert-@samp () ; "Insert the string @samp in a texinfo buffer." ; (interactive) ; (insert "@samp{}") ; (backward-char)) (defun texinfo-insert-@samp (&optional arg) "Insert the string @samp in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "samp" arg)) (defun texinfo-insert-@table (&optional arg) "Insert the string @table in a texinfo buffer." (interactive "P") (insert "@table ")) ; (defun texinfo-insert-@var () ; "Insert the string @var in a texinfo buffer." ; (interactive) ; (insert "@var{}") ; (backward-char)) (defun texinfo-insert-@var (&optional arg) "Insert the string @var in a texinfo buffer." (interactive "P") (texinfo-insert-@-with-arg "var" arg)) ;;; Texinfo file structure ; The following is defined in `texnfo-upd.el' ; (defvar texinfo-section-types-regexp ; "^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" ; "Regexp matching chapter, section, other headings (but not the top node).") (defun texinfo-show-structure (&optional nodes-too) "Show the structure of a Texinfo file. List the lines in the file that begin with the @-sign commands for @chapter, @section, and the like. With optional argument (prefix if interactive), list both the lines with @-sign commands for @chapter, @section, and the like, and list @node lines. Lines with structuring commands beginning in them are displayed in another window called the *Occur* window. In that window, you can position the cursor over one of the lines and use \\[occur-mode-goto-occurrence], to jump to the corresponding spot in the Texinfo file." (interactive "P") (require 'texnfo-upd) (save-excursion (goto-char (point-min)) (if nodes-too (occur (concat "\\(^@node\\)\\|" texinfo-section-types-regexp)) (occur texinfo-section-types-regexp))) (pop-to-buffer "*Occur*") (goto-char (point-min)) (flush-lines "-----")) ;;; Place provide at end of file. (provide 'texinfo) ;;;;;;;;;;;;;;;; end texinfo.el ;;;;;;;;;;;;;;;; texinfo-2.15/elisp/info.el0000644000175000017500000005701312415567275012770 0ustar gg;; Info package for Emacs -- could use a "create node" feature. ;; Copyright (C) 1985, 1986 Free Software Foundation, Inc. ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (provide 'info) (defvar Info-history nil "List of info nodes user has visited. Each element of list is a list (FILENAME NODENAME BUFFERPOS).") (defvar Info-enable-edit nil "Non-nil means the \\[Info-edit] command in Info can edit the current node.") (defvar Info-enable-active-nodes t "Non-nil allows Info to execute Lisp code associated with nodes. The Lisp code is executed when the node is selected.") (defvar Info-directory nil "Default directory for Info documentation files.") (defvar Info-current-file nil "Info file that Info is now looking at, or nil.") (defvar Info-current-subfile nil "Info subfile that is actually in the *info* buffer now, or nil if current info file is not split into subfiles.") (defvar Info-current-node nil "Name of node that Info is now looking at, or nil.") (defvar Info-tag-table-marker (make-marker) "Marker pointing at beginning of current Info file's tag table. Marker points nowhere if file has no tag table.") (defun info () "Enter Info, the documentation browser." (interactive) (if (get-buffer "*info*") (switch-to-buffer "*info*") (Info-directory))) ;; Go to an info node specified as separate filename and nodename. ;; no-going-back is non-nil if recovering from an error in this function; ;; it says do not attempt further (recursive) error recovery. (defun Info-find-node (filename nodename &optional no-going-back) ;; Convert filename to lower case if not found as specified. ;; Expand it. (if filename (let (temp) (setq filename (substitute-in-file-name filename)) (setq temp (expand-file-name filename ;; Use Info's default dir ;; unless the filename starts with `./'. (if (not (string-match "^\\./" filename)) Info-directory))) (if (file-exists-p temp) (setq filename temp) (if (file-exists-p (concat temp ".info")) (setq filename (concat temp ".info")) (setq temp (expand-file-name (downcase filename) Info-directory)) (if (file-exists-p temp) (setq filename temp) (if (file-exists-p (concat temp ".info")) (setq filename (concat temp ".info")) (error "Info file %s does not exist" (expand-file-name filename Info-directory)))))))) ;; Record the node we are leaving. (if (and Info-current-file (not no-going-back)) (setq Info-history (cons (list Info-current-file Info-current-node (point)) Info-history))) ;; Go into info buffer. (switch-to-buffer "*info*") (or (eq major-mode 'Info-mode) (Info-mode)) (widen) (setq Info-current-node nil) (unwind-protect (progn ;; Switch files if necessary (or (null filename) (equal Info-current-file filename) (let ((buffer-read-only nil)) (setq Info-current-file nil Info-current-subfile nil) (erase-buffer) (insert-file-contents filename t) (set-buffer-modified-p nil) (setq default-directory (file-name-directory filename)) ;; See whether file has a tag table. Record the location if yes. (set-marker Info-tag-table-marker nil) (goto-char (point-max)) (forward-line -8) (or (equal nodename "*") (not (search-forward "\^_\nEnd tag table\n" nil t)) (let (pos) ;; We have a tag table. Find its beginning. ;; Is this an indirect file? (search-backward "\nTag table:\n") (setq pos (point)) (if (save-excursion (forward-line 2) (looking-at "(Indirect)\n")) ;; It is indirect. Copy it to another buffer ;; and record that the tag table is in that buffer. (save-excursion (let ((buf (current-buffer))) (set-buffer (get-buffer-create " *info tag table*")) (setq case-fold-search t) (erase-buffer) (insert-buffer-substring buf) (set-marker Info-tag-table-marker (match-end 0)))) (set-marker Info-tag-table-marker pos)))) (setq Info-current-file (file-name-sans-versions buffer-file-name)))) (if (equal nodename "*") (progn (setq Info-current-node nodename) (Info-set-mode-line)) ;; Search file for a suitable node. ;; First get advice from tag table if file has one. ;; Also, if this is an indirect info file, ;; read the proper subfile into this buffer. (let ((guesspos (point-min))) (if (marker-position Info-tag-table-marker) (save-excursion (set-buffer (marker-buffer Info-tag-table-marker)) (goto-char Info-tag-table-marker) (if (search-forward (concat "Node: " nodename "\177") nil t) (progn (setq guesspos (read (current-buffer))) ;; If this is an indirect file, ;; determine which file really holds this node ;; and read it in. (if (not (eq (current-buffer) (get-buffer "*info*"))) (setq guesspos (Info-read-subfile guesspos)))) (error "No such node: \"%s\"" nodename)))) (goto-char (max (point-min) (- guesspos 1000)))) ;; Now search from our advised position (or from beg of buffer) ;; to find the actual node. (let ((regexp (concat "Node: *" (regexp-quote nodename) " *[,\t\n]"))) (catch 'foo (while (search-forward "\n\^_" nil t) (forward-line 1) (let ((beg (point))) (forward-line 1) (if (re-search-backward regexp beg t) (throw 'foo t)))) (error "No such node: %s" nodename))) (Info-select-node))) ;; If we did not finish finding the specified node, ;; go back to the previous one. (or Info-current-node no-going-back (let ((hist (car Info-history))) (setq Info-history (cdr Info-history)) (Info-find-node (nth 0 hist) (nth 1 hist) t) (goto-char (nth 2 hist))))) (goto-char (point-min))) (defun Info-read-subfile (nodepos) (set-buffer (marker-buffer Info-tag-table-marker)) (goto-char (point-min)) (search-forward "\n\^_") (let (lastfilepos lastfilename) (forward-line 2) (catch 'foo (while (not (looking-at "\^_")) (if (not (eolp)) (let ((beg (point)) thisfilepos thisfilename) (search-forward ": ") (setq thisfilename (buffer-substring beg (- (point) 2))) (setq thisfilepos (read (current-buffer))) (if (> thisfilepos nodepos) (throw 'foo t)) (setq lastfilename thisfilename) (setq lastfilepos thisfilepos)) (forward-line 1)))) (set-buffer (get-buffer "*info*")) (or (equal Info-current-subfile lastfilename) (let ((buffer-read-only nil)) (setq buffer-file-name nil) (widen) (erase-buffer) (insert-file-contents lastfilename) (set-buffer-modified-p nil) (setq Info-current-subfile lastfilename))) (goto-char (point-min)) (search-forward "\n\^_") (+ (- nodepos lastfilepos) (point)))) ;; Select the info node that point is in. (defun Info-select-node () (save-excursion ;; Find beginning of node. (search-backward "\n\^_") (forward-line 2) ;; Get nodename spelled as it is in the node. (re-search-forward "Node:[ \t]*") (setq Info-current-node (buffer-substring (point) (progn (skip-chars-forward "^,\t\n") (point)))) (Info-set-mode-line) ;; Find the end of it, and narrow. (beginning-of-line) (let (active-expression) (narrow-to-region (point) (if (re-search-forward "\n[\^_\f]" nil t) (prog1 (1- (point)) (if (looking-at "[\n\^_\f]*execute: ") (progn (goto-char (match-end 0)) (setq active-expression (read (current-buffer)))))) (point-max))) (if Info-enable-active-nodes (eval active-expression))))) (defun Info-set-mode-line () (setq mode-line-buffer-identification (concat "Info: (" (if Info-current-file (file-name-nondirectory Info-current-file) "") ")" (or Info-current-node "")))) ;; Go to an info node specified with a filename-and-nodename string ;; of the sort that is found in pointers in nodes. (defun Info-goto-node (nodename) "Go to info node named NAME. Give just NODENAME or (FILENAME)NODENAME." (interactive "sGoto node: ") (let (filename) (string-match "\\s *\\((\\s *\\([^\t)]*\\)\\s *)\\s *\\|\\)\\(.*\\)" nodename) (setq filename (if (= (match-beginning 1) (match-end 1)) "" (substring nodename (match-beginning 2) (match-end 2))) nodename (substring nodename (match-beginning 3) (match-end 3))) (let ((trim (string-match "\\s *\\'" filename))) (if trim (setq filename (substring filename 0 trim)))) (let ((trim (string-match "\\s *\\'" nodename))) (if trim (setq nodename (substring nodename 0 trim)))) (Info-find-node (if (equal filename "") nil filename) (if (equal nodename "") "Top" nodename)))) (defvar Info-last-search nil "Default regexp for Info S command to search for.") (defun Info-search (regexp) "Search for REGEXP, starting from point, and select node it's found in." (interactive "sSearch (regexp): ") (if (equal regexp "") (setq regexp Info-last-search) (setq Info-last-search regexp)) (let ((found ()) current (onode Info-current-node) (ofile Info-current-file) (opoint (point)) (osubfile Info-current-subfile)) (save-excursion (save-restriction (widen) (if (null Info-current-subfile) (progn (re-search-forward regexp) (setq found (point))) (condition-case err (progn (re-search-forward regexp) (setq found (point))) (search-failed nil))))) (if (not found) ;can only happen in subfile case -- else would have erred (unwind-protect (let ((list ())) (set-buffer (marker-buffer Info-tag-table-marker)) (goto-char (point-min)) (search-forward "\n\^_\nIndirect:") (save-restriction (narrow-to-region (point) (progn (search-forward "\n\^_") (1- (point)))) (goto-char (point-min)) (search-forward (concat "\n" osubfile ": ")) (beginning-of-line) (while (not (eobp)) (re-search-forward "\\(^.*\\): [0-9]+$") (goto-char (+ (match-end 1) 2)) (setq list (cons (cons (read (current-buffer)) (buffer-substring (match-beginning 1) (match-end 1))) list)) (goto-char (1+ (match-end 0)))) (setq list (nreverse list) current (car (car list)) list (cdr list))) (while list (message "Searching subfile %s..." (cdr (car list))) (Info-read-subfile (car (car list))) (setq list (cdr list)) (goto-char (point-min)) (if (re-search-forward regexp nil t) (setq found (point) list ()))) (if found (message "") (signal 'search-failed (list regexp)))) (if (not found) (progn (Info-read-subfile opoint) (goto-char opoint) (Info-select-node))))) (widen) (goto-char found) (Info-select-node) (or (and (equal onode Info-current-node) (equal ofile Info-current-file)) (setq Info-history (cons (list ofile onode opoint) Info-history))))) (defun Info-extract-pointer (name &optional errorname) (save-excursion (goto-char (point-min)) (forward-line 1) (if (re-search-backward (concat name ":") nil t) nil (error (concat "Node has no " (capitalize (or errorname name))))) (goto-char (match-end 0)) (Info-following-node-name))) (defun Info-following-node-name (&optional allowedchars) (skip-chars-forward " \t") (buffer-substring (point) (progn (while (looking-at (concat "[" (or allowedchars "^,\t\n") "]")) (skip-chars-forward (concat (or allowedchars "^,\t\n") "(")) (if (looking-at "(") (skip-chars-forward "^)"))) (skip-chars-backward " ") (point)))) (defun Info-next () "Go to the next node of this node." (interactive) (Info-goto-node (Info-extract-pointer "next"))) (defun Info-prev () "Go to the previous node of this node." (interactive) (Info-goto-node (Info-extract-pointer "prev[ious]*" "previous"))) (defun Info-up () "Go to the superior node of this node." (interactive) (Info-goto-node (Info-extract-pointer "up"))) (defun Info-last () "Go back to the last node visited." (interactive) (or Info-history (error "This is the first Info node you looked at")) (let (filename nodename opoint) (setq filename (car (car Info-history))) (setq nodename (car (cdr (car Info-history)))) (setq opoint (car (cdr (cdr (car Info-history))))) (setq Info-history (cdr Info-history)) (Info-find-node filename nodename) (setq Info-history (cdr Info-history)) (goto-char opoint))) (defun Info-directory () "Go to the Info directory node." (interactive) (Info-find-node "dir" "top")) (defun Info-follow-reference (footnotename) "Follow cross reference named NAME to the node it refers to. NAME may be an abbreviation of the reference name." (interactive (let ((completion-ignore-case t) completions str i) (save-excursion (goto-char (point-min)) (while (re-search-forward "\\*note[ \n\t]*\\([^:]*\\):" nil t) (setq str (buffer-substring (match-beginning 1) (1- (point)))) (setq i 0) (while (setq i (string-match "[ \n\t]+" str i)) (setq str (concat (substring str 0 i) " " (substring str (match-end 0)))) (setq i (1+ i))) (setq completions (cons (cons str nil) completions)))) (if completions (list (completing-read "Follow reference named: " completions nil t)) (error "No cross-references in this node")))) (let (target beg i (str (concat "\\*note " footnotename))) (while (setq i (string-match " " str i)) (setq str (concat (substring str 0 i) "[ \t\n]+" (substring str (1+ i)))) (setq i (+ i 6))) (save-excursion (goto-char (point-min)) (or (re-search-forward str nil t) (error "No cross-reference named %s" footnotename)) (goto-char (+ (match-beginning 0) 5)) (setq target (Info-extract-menu-node-name "Bad format cross reference" t))) (while (setq i (string-match "[ \t\n]+" target i)) (setq target (concat (substring target 0 i) " " (substring target (match-end 0)))) (setq i (+ i 1))) (Info-goto-node target))) (defun Info-extract-menu-node-name (&optional errmessage multi-line) (skip-chars-forward " \t\n") (let ((beg (point)) str i) (skip-chars-forward "^:") (forward-char 1) (setq str (if (looking-at ":") (buffer-substring beg (1- (point))) (skip-chars-forward " \t\n") (Info-following-node-name (if multi-line "^.,\t" "^.,\t\n")))) (while (setq i (string-match "\n" str i)) (aset str i ?\ )) str)) (defun Info-menu-item-sequence (list) (while list (Info-menu-item (car list)) (setq list (cdr list)))) (defun Info-menu (menu-item) "Go to node for menu item named (or abbreviated) NAME." (interactive (let ((completions '()) ;; If point is within a menu item, use that item as the default (default nil) (p (point)) (last nil)) (save-excursion (goto-char (point-min)) (if (not (search-forward "\n* menu:" nil t)) (error "No menu in this node")) (while (re-search-forward "\n\\* \\([^:\t\n]*\\):" nil t) (if (and (null default) (prog1 (if last (< last p) nil) (setq last (match-beginning 0))) (<= p last)) (setq default (car (car completions)))) (setq completions (cons (cons (buffer-substring (match-beginning 1) (match-end 1)) (match-beginning 1)) completions))) (if (and (null default) last (< last p) (<= p (progn (end-of-line) (point)))) (setq default (car (car completions))))) (let ((item nil)) (while (null item) (setq item (let ((completion-ignore-case t)) (completing-read (if default (format "Menu item (default %s): " default) "Menu item: ") completions nil t))) ;; we rely on the bug (which RMS won't change for his own reasons) ;; that ;; completing-read accepts an input of "" even when the ;; require-match argument is true and "" is not a valid possibility (if (string= item "") (if default (setq item default) ;; ask again (setq item nil)))) (list item)))) (Info-goto-node (Info-extract-menu-item menu-item))) (defun Info-extract-menu-item (menu-item) (save-excursion (goto-char (point-min)) (or (search-forward "\n* menu:" nil t) (error "No menu in this node")) (or (search-forward (concat "\n* " menu-item ":") nil t) (search-forward (concat "\n* " menu-item) nil t) (error "No such item in menu")) (beginning-of-line) (forward-char 2) (Info-extract-menu-node-name))) (defun Info-extract-menu-counting (count) (save-excursion (goto-char (point-min)) (or (search-forward "\n* menu:" nil t) (error "No menu in this node")) (or (search-forward "\n* " nil t count) (error "Too few items in menu")) (Info-extract-menu-node-name))) (defun Info-first-menu-item () "Go to the node of the first menu item." (interactive) (Info-goto-node (Info-extract-menu-counting 1))) (defun Info-second-menu-item () "Go to the node of the second menu item." (interactive) (Info-goto-node (Info-extract-menu-counting 2))) (defun Info-third-menu-item () "Go to the node of the third menu item." (interactive) (Info-goto-node (Info-extract-menu-counting 3))) (defun Info-fourth-menu-item () "Go to the node of the fourth menu item." (interactive) (Info-goto-node (Info-extract-menu-counting 4))) (defun Info-fifth-menu-item () "Go to the node of the fifth menu item." (interactive) (Info-goto-node (Info-extract-menu-counting 5))) (defun Info-exit () "Exit Info by selecting some other buffer." (interactive) (switch-to-buffer (prog1 (other-buffer (current-buffer)) (bury-buffer (current-buffer))))) (defun Info-undefined () "Make command be undefined in Info." (interactive) (ding)) (defun Info-help () "Enter the Info tutorial." (interactive) (Info-find-node "info" (if (< (window-height) 23) "Help-Small-Screen" "Help"))) (defun Info-summary () "Display a brief summary of all Info commands." (interactive) (save-window-excursion (switch-to-buffer "*Help*") (erase-buffer) (insert (documentation 'Info-mode)) (goto-char (point-min)) (let (ch flag) (while (progn (setq flag (not (pos-visible-in-window-p (point-max)))) (message (if flag "Type Space to see more" "Type Space to return to Info")) (if (/= ?\ (setq ch (read-char))) (progn (setq unread-command-char ch) nil) flag)) (scroll-up))))) (defvar Info-mode-map nil "Keymap containing Info commands.") (if Info-mode-map nil (setq Info-mode-map (make-keymap)) (suppress-keymap Info-mode-map) (define-key Info-mode-map "." 'beginning-of-buffer) (define-key Info-mode-map " " 'scroll-up) (define-key Info-mode-map "1" 'Info-first-menu-item) (define-key Info-mode-map "2" 'Info-second-menu-item) (define-key Info-mode-map "3" 'Info-third-menu-item) (define-key Info-mode-map "4" 'Info-fourth-menu-item) (define-key Info-mode-map "5" 'Info-fifth-menu-item) (define-key Info-mode-map "6" 'undefined) (define-key Info-mode-map "7" 'undefined) (define-key Info-mode-map "8" 'undefined) (define-key Info-mode-map "9" 'undefined) (define-key Info-mode-map "0" 'undefined) (define-key Info-mode-map "?" 'Info-summary) (define-key Info-mode-map "b" 'beginning-of-buffer) (define-key Info-mode-map "d" 'Info-directory) (define-key Info-mode-map "e" 'Info-edit) (define-key Info-mode-map "f" 'Info-follow-reference) (define-key Info-mode-map "g" 'Info-goto-node) (define-key Info-mode-map "h" 'Info-help) (define-key Info-mode-map "l" 'Info-last) (define-key Info-mode-map "m" 'Info-menu) (define-key Info-mode-map "n" 'Info-next) (define-key Info-mode-map "p" 'Info-prev) (define-key Info-mode-map "q" 'Info-exit) (define-key Info-mode-map "s" 'Info-search) (define-key Info-mode-map "u" 'Info-up) (define-key Info-mode-map "\177" 'scroll-down)) (defun Info-mode () "Info mode provides commands for browsing through the Info documentation tree. Documentation in Info is divided into \"nodes\", each of which discusses one topic and contains references to other nodes which discuss related topics. Info has commands to follow the references and show you other nodes. h Invoke the Info tutorial. Selecting other nodes: n Move to the \"next\" node of this node. p Move to the \"previous\" node of this node. u Move \"up\" from this node. m Pick menu item specified by name (or abbreviation). Picking a menu item causes another node to be selected. f Follow a cross reference. Reads name of reference. l Move to the last node you were at. Moving within a node: Space scroll forward a page. DEL scroll backward. b Go to beginning of node. Advanced commands: q Quit Info: reselect previously selected buffer. e Edit contents of selected node. 1 Pick first item in node's menu. 2, 3, 4, 5 Pick second ... fifth item in node's menu. g Move to node specified by name. You may include a filename as well, as (FILENAME)NODENAME. s Search through this Info file for specified regexp, and select the node in which the next occurrence is found." (kill-all-local-variables) (setq major-mode 'Info-mode) (setq mode-name "Info") (use-local-map Info-mode-map) (set-syntax-table text-mode-syntax-table) (setq local-abbrev-table text-mode-abbrev-table) (setq case-fold-search t) (setq buffer-read-only t) (make-local-variable 'Info-current-file) (make-local-variable 'Info-current-subfile) (make-local-variable 'Info-current-node) (make-local-variable 'Info-tag-table-marker) (make-local-variable 'Info-history) (Info-set-mode-line)) (defvar Info-edit-map nil "Local keymap used within `e' command of Info.") (if Info-edit-map nil (setq Info-edit-map (copy-keymap text-mode-map)) (define-key Info-edit-map "\C-c\C-c" 'Info-cease-edit)) (defun Info-edit-mode () "Major mode for editing the contents of an Info node. Like text mode with the addition of Info-cease-edit which returns to Info mode for browsing. \\{Info-edit-map}" ) (defun Info-edit () "Edit the contents of this Info node. Allowed only if variable Info-enable-edit is non-nil." (interactive) (or Info-enable-edit (error "Editing info nodes is not enabled")) (use-local-map Info-edit-map) (setq major-mode 'Info-edit-mode) (setq mode-name "Info Edit") (kill-local-variable 'mode-line-buffer-identification) (setq buffer-read-only nil) ;; Make mode line update. (set-buffer-modified-p (buffer-modified-p)) (message (substitute-command-keys "Editing: Type \\[Info-cease-edit] to return to info"))) (defun Info-cease-edit () "Finish editing Info node; switch back to Info proper." (interactive) ;; Do this first, so nothing has changed if user C-g's at query. (and (buffer-modified-p) (y-or-n-p "Save the file? ") (save-buffer)) (use-local-map Info-mode-map) (setq major-mode 'Info-mode) (setq mode-name "Info") (Info-set-mode-line) (setq buffer-read-only t) ;; Make mode line update. (set-buffer-modified-p (buffer-modified-p)) (and (marker-position Info-tag-table-marker) (buffer-modified-p) (message "Tags may have changed. Use Info-tagify if necessary"))) texinfo-2.15/elisp/texnfo-tex.el0000644000175000017500000003311612415567326014131 0ustar gg;;;; texnfo-tex.el ;;; Texinfo mode TeX and hardcopy printing commands. ;; These commands are for running TeX on a region of a Texinfo file in ;; GNU Emacs, or on the whole buffer, and for printing the resulting ;; DVI file. ;;; Version 2.07 22 October 1991 ;;; Robert J. Chassell ;;; Please send bug reports to: bob@gnu.ai.mit.edu ;;; Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. ;;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; The Texinfo mode TeX related commands are: ; texinfo-tex-region to run tex on the current region. ; texinfo-tex-buffer to run tex on the current buffer. ; texinfo-texindex to sort unsorted index files. ; texinfo-tex-print to print the .dvi file made by tex. ; texinfo-kill-tex-job to kill the currently running tex job. ; texinfo-recenter-tex-output-buffer to redisplay tex output buffer. ; texinfo-show-tex-print-queue to show the print queue. ;;; Keys common both to Texinfo mode and to TeX shell. ;; Defined in `texinfo.el' ; (defun texinfo-define-common-keys (keymap) ; "Define the keys both in Texinfo mode and in the texinfo-tex-shell." ; (define-key keymap "\C-c\C-t\C-k" 'texinfo-kill-tex-job) ; (define-key keymap "\C-c\C-t\C-x" 'texinfo-quit-tex-job) ; (define-key keymap "\C-c\C-t\C-l" 'texinfo-recenter-tex-output-buffer) ; (define-key keymap "\C-c\C-t\C-d" 'texinfo-delete-from-tex-print-queue) ; (define-key keymap "\C-c\C-t\C-q" 'texinfo-show-tex-print-queue) ; (define-key keymap "\C-c\C-t\C-p" 'texinfo-tex-print) ; (define-key keymap "\C-c\C-t\C-i" 'texinfo-texindex) ; (define-key keymap "\C-c\C-t\C-r" 'texinfo-tex-region) ; (define-key keymap "\C-c\C-t\C-b" 'texinfo-tex-buffer)) ;; See also texinfo-tex-start-shell. ;; The following is executed in the `texinfo.el' file ;(texinfo-define-common-keys texinfo-mode-map) ;;; Variable definitions: (require 'shell) (defvar texinfo-tex-shell-cd-command "cd" "Command to give to shell running TeX to change directory.") (defvar texinfo-tex-command "tex" "*Command used by texinfo-tex-region to run tex on a region.") (defvar texinfo-texindex-command "texindex" "*Command used by texinfo-texindex to sort unsorted index files.") (defvar texinfo-tex-dvi-print-command "lpr -d" "*Command string used by \\[tex-print] to print a .dvi file.") (defvar texinfo-show-tex-queue-command "lpq" "*Command string used to show the Texinfo TeX print queue. Command is used by \\[texinfo-show-tex-print-queue] and it should show the queue that \\[texinfo-tex-print] puts jobs on.") (defvar texinfo-delete-from-print-queue-command "lprm" "*Command string used to delete a job from the line printer queue. Command is used by \\[texinfo-delete-from-tex-print-queue] based on number provided by a previous \\[texinfo-show-tex-print-queue] command.") (defvar texinfo-tex-trailer "@bye" "String appended after a region sent to TeX by texinfo-tex-region.") (defvar texinfo-tex-original-file "" "Original name of file on which to run TeX.") (defvar texinfo-tex-temp-file nil "Temporary file name used for text being sent as input to TeX.") (defvar texinfo-tex-root-temp-file nil "Temporary file name used for text being sent as input to TeX.") ;;; Texinfo TeX main functions (defun texinfo-tex-region (beginning end) "Run tex on the current region. A temporary file is written in the default directory, and tex is run in that directory. The first line of the file is copied to the temporary file; and if the buffer has a header, it is written to the temporary file before the region itself. The buffer's header is all lines between the strings defined by texinfo-start-of-header and texinfo-end-of-header inclusive. The header must start in the first 100 lines. The value of texinfo-tex-trailer is appended to the temporary file after the region." (interactive "r") (if (get-buffer "*texinfo-tex-shell*") (quit-process (get-process "texinfo-tex-shell") t) (texinfo-tex-start-shell)) (setq texinfo-tex-root-temp-file (expand-file-name (make-temp-name (prin1-to-string (read (buffer-name)))))) (let ((texinfo-tex-temp-file (concat texinfo-tex-root-temp-file ".tex"))) (save-excursion (save-restriction (widen) (goto-char (point-min)) (forward-line 100) (let ((search-end (point)) (header-beginning (point-min)) (header-end (point-min))) (goto-char (point-min)) ;; Copy first line, the `\input texinfo' line, to temp file (write-region (point) (save-excursion (forward-line 1) (point)) texinfo-tex-temp-file nil nil) ;; Don't copy first line twice if region includes it. (forward-line 1) (if (< beginning (point)) (setq beginning (point))) ;; Initialize the temp file with either the header or nothing (if (search-forward texinfo-start-of-header search-end t) (progn (beginning-of-line) (setq header-beginning (point)) ; Mark beginning of header. (if (search-forward texinfo-end-of-header nil t) (progn (beginning-of-line) (setq header-end (point))) ; Mark end of header. (setq header-beginning (point-min))))) ; Else no header. ;; Copy header to temp file. (write-region (min header-beginning beginning ) header-end texinfo-tex-temp-file t nil) ;; Copy region to temp file. (write-region (max beginning header-end) end texinfo-tex-temp-file t nil) ;; This is a kludge to insert the texinfo-tex-trailer into the ;; texinfo-tex-temp-file. We have to create a special buffer ;; in which to insert the texinfo-tex-trailer first because there is ;; no function with which to append a literal string directly ;; to a file. (let ((local-tex-trailer texinfo-tex-trailer) (temp-buffer (get-buffer-create " texinfo-trailer-buffer"))) (set-buffer temp-buffer) (erase-buffer) ;; make sure trailer isn't hidden by a comment (insert-string "\n") (if local-tex-trailer (insert local-tex-trailer)) (write-region (point-min) (point-max) texinfo-tex-temp-file t nil))) (set-process-sentinel (get-process "texinfo-tex-shell") 'texinfo-tex-shell-sentinel) (send-string "texinfo-tex-shell" (concat texinfo-tex-shell-cd-command " " default-directory "\n")) (send-string "texinfo-tex-shell" (concat texinfo-tex-command " " texinfo-tex-temp-file "\n ")) (texinfo-recenter-tex-output-buffer 0))))) (defun texinfo-tex-buffer (buffer) "Run TeX on current buffer. After running TeX the first time, you may have to run \\[texinfo-texindex] and then \\[texinfo-tex-buffer] again." (interactive (list ;; Sometimes you put point into *texinfo-tex-shell*; this prompts ;; you for the correct file regardless. (if (and (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*") texinfo-tex-root-temp-file) (read-string (format "Run TeX on: ") texinfo-tex-original-file) (read-string (format "Run TeX on: ") (buffer-name (current-buffer)))))) ;; Set to original buffer if in *texinfo-tex-shell*; otherwise, ;; record name of current buffer. (if (string= (buffer-name (current-buffer)) "*texinfo-tex-shell*") (set-buffer buffer) (setq texinfo-tex-original-file (buffer-name (current-buffer)))) (if (get-buffer "*texinfo-tex-shell*") (quit-process (get-process "texinfo-tex-shell") t) (texinfo-tex-start-shell)) (cond ((null buffer-file-name) (error "Buffer not visiting any file!")) ((buffer-modified-p) (error "Buffer has been modified since last saved!")) (t (set-process-sentinel (get-process "texinfo-tex-shell") 'texinfo-tex-shell-sentinel) (send-string "texinfo-tex-shell" (concat texinfo-tex-shell-cd-command " " (file-name-directory (buffer-file-name (get-buffer buffer))) "\n")) (send-string "texinfo-tex-shell" (concat texinfo-tex-command " " buffer "\n ")) ;; so the texinfo-tex-print command works (setq texinfo-tex-root-temp-file (substring buffer 0 (or (string-match "\\.tex" buffer) (length buffer)))) (texinfo-recenter-tex-output-buffer 0)))) (defun texinfo-texindex () "Run texindex on unsorted index files. The index files are made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. Runs the shell command defined by texinfo-texindex-command." (interactive) (send-string "texinfo-tex-shell" (concat texinfo-texindex-command " " texinfo-tex-root-temp-file ".??" "\n")) (texinfo-recenter-tex-output-buffer nil)) (defun texinfo-tex-print () "Print .dvi file made by \\[texinfo-tex-region] or \\[texinfo-tex-buffer]. Runs the shell command defined by texinfo-tex-dvi-print-command." (interactive) (send-string "texinfo-tex-shell" (concat texinfo-tex-dvi-print-command " " texinfo-tex-root-temp-file ".dvi" "\n")) (texinfo-recenter-tex-output-buffer nil)) ;;; Texinfo TeX utility functions (defun texinfo-tex-start-shell () (save-excursion (require 'texinfo) (set-buffer (make-shell "texinfo-tex-shell" "/bin/sh" nil "-v")) (setq texinfo-tex-shell-map (copy-keymap shell-mode-map)) (texinfo-define-common-keys texinfo-tex-shell-map) (use-local-map texinfo-tex-shell-map) (run-hooks 'texinfo-tex-shell-hook) (if (zerop (buffer-size)) (sleep-for 1)))) (defun texinfo-quit-tex-job () "Quit currently running TeX job, by sending an `x' to it." (interactive) (if (not (get-process "texinfo-tex-shell")) (error "No TeX shell running.")) (save-excursion (set-buffer (get-buffer "*texinfo-tex-shell*")) (goto-char (point-max)) (insert "x") (shell-send-input))) (defun texinfo-kill-tex-job () "Kill the currently running TeX job." (interactive) (if (get-process "texinfo-tex-shell") ;; Use `texinfo-tex-shell-sentinel' to restart ;; texinfo-tex-shell after it is killed. (kill-process (get-process "texinfo-tex-shell")))) (defun texinfo-tex-shell-sentinel (process event) "Restart texinfo-tex-shell after it is killed." (if (equal event "killed\n") (save-excursion (set-buffer "*texinfo-tex-shell*") (insert "\n") (texinfo-tex-start-shell)))) (defun texinfo-recenter-tex-output-buffer (linenum) "Redisplay buffer of TeX job output so that most recent output can be seen. The last line of the buffer is displayed on line LINE of the window, or centered if LINE is nil." (interactive "P") (let ((texinfo-tex-shell (get-buffer "*texinfo-tex-shell*")) (old-buffer (current-buffer))) (if (null texinfo-tex-shell) (message "No TeX output buffer") (pop-to-buffer texinfo-tex-shell) (bury-buffer texinfo-tex-shell) (goto-char (point-max)) (recenter (if linenum (prefix-numeric-value linenum) (/ (window-height) 2))) (pop-to-buffer old-buffer) ))) (defun texinfo-show-tex-print-queue () "Show the print queue that \\[texinfo-tex-print] put your job on. Runs the shell command defined by texinfo-show-tex-queue-command." (interactive) (if (not (texinfo-tex-shell-running-p)) (texinfo-tex-start-shell)) (send-string "texinfo-tex-shell" (concat texinfo-show-tex-queue-command "\n")) (texinfo-recenter-tex-output-buffer nil)) (defun texinfo-delete-from-tex-print-queue (job-number) "Delete job from the line printer spooling queue. You are prompted for the job number (shown by a previous \\[texinfo-show-tex-print-queue] command." (interactive "nPrinter job number for deletion: ") (if (texinfo-tex-shell-running-p) (texinfo-kill-tex-job) (texinfo-tex-start-shell)) (send-string "texinfo-tex-shell" (concat texinfo-delete-from-print-queue-command " " job-number"\n")) (texinfo-recenter-tex-output-buffer nil)) (defun texinfo-tex-shell-running-p () (and (get-process "texinfo-tex-shell") (eq (process-status (get-process "texinfo-tex-shell")) 'run))) ;;; Place `provide' at end of file. (provide 'texnfo-tex) ;;;;;;;;;;;;;;;; end texnfo-tex.el ;;;;;;;;;;;;;;;; texinfo-2.15/elisp/informat.el0000644000175000017500000003245112415567303013643 0ustar gg;; Info support functions package for Emacs ;; Copyright (C) 1986 Free Software Foundation, Inc. ;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (require 'info) (defun Info-tagify () "Create or update Info-file tag table in current buffer." (interactive) ;; Save and restore point and restrictions. ;; save-restrictions would not work ;; because it records the old max relative to the end. ;; We record it relative to the beginning. (let ((omin (point-min)) (omax (point-max)) (nomax (= (point-max) (1+ (buffer-size)))) (opoint (point))) (unwind-protect (progn (widen) (goto-char (point-min)) (if (search-forward "\^_\nIndirect:\n" nil t) (message "Cannot tagify split info file") (let ((regexp "Node:[ \t]*\\([^,\n\t]\\)*[,\t\n]") (case-fold-search t) list) (while (search-forward "\n\^_" nil t) (forward-line 1) (let ((beg (point))) (forward-line 1) (if (re-search-backward regexp beg t) (setq list (cons (list (buffer-substring (match-beginning 1) (match-end 1)) beg) list))))) (goto-char (point-max)) (forward-line -8) (let ((buffer-read-only nil)) (if (search-forward "\^_\nEnd tag table\n" nil t) (let ((end (point))) (search-backward "\nTag table:\n") (beginning-of-line) (delete-region (point) end))) (goto-char (point-max)) (insert "\^_\f\nTag table:\n") (move-marker Info-tag-table-marker (point)) (setq list (nreverse list)) (while list (insert "Node: " (car (car list)) ?\177) (princ (car (cdr (car list))) (current-buffer)) (insert ?\n) (setq list (cdr list))) (insert "\^_\nEnd tag table\n"))))) (goto-char opoint) (narrow-to-region omin (if nomax (1+ (buffer-size)) (min omax (point-max))))))) (defun Info-split () "Split an info file into an indirect file plus bounded-size subfiles. Each subfile will be up to 50000 characters plus one node. To use this command, first visit a large Info file that has a tag table. The buffer is modified into a (small) indirect info file which should be saved in place of the original visited file. The subfiles are written in the same directory the original file is in, with names generated by appending `-' and a number to the original file name. The indirect file still functions as an Info file, but it contains just the tag table and a directory of subfiles." (interactive) (if (< (buffer-size) 70000) (error "This is too small to be worth splitting")) (goto-char (point-min)) (search-forward "\^_") (forward-char -1) (let ((start (point)) (chars-deleted 0) subfiles (subfile-number 1) (case-fold-search t) (filename (file-name-sans-versions buffer-file-name))) (goto-char (point-max)) (forward-line -8) (setq buffer-read-only nil) (or (search-forward "\^_\nEnd tag table\n" nil t) (error "Tag table required; use M-x Info-tagify")) (search-backward "\nTag table:\n") (if (looking-at "\nTag table:\n\^_") (error "Tag table is just a skeleton; use M-x Info-tagify")) (beginning-of-line) (forward-char 1) (save-restriction (narrow-to-region (point-min) (point)) (goto-char (point-min)) (while (< (1+ (point)) (point-max)) (goto-char (min (+ (point) 50000) (point-max))) (search-forward "\^_" nil 'move) (setq subfiles (cons (list (+ start chars-deleted) (concat (file-name-nondirectory filename) (format "-%d" subfile-number))) subfiles)) ;; Put a newline at end of split file, to make Unix happier. (insert "\n") (write-region (point-min) (point) (concat filename (format "-%d" subfile-number))) (delete-region (1- (point)) (point)) ;; Back up over the final ^_. (forward-char -1) (setq chars-deleted (+ chars-deleted (- (point) start))) (delete-region start (point)) (setq subfile-number (1+ subfile-number)))) (while subfiles (goto-char start) (insert (nth 1 (car subfiles)) (format ": %d" (car (car subfiles))) "\n") (setq subfiles (cdr subfiles))) (goto-char start) (insert "\^_\nIndirect:\n") (search-forward "\nTag Table:\n") (insert "(Indirect)\n"))) (defun Info-validate () "Check current buffer for validity as an Info file. Check that every node pointer points to an existing node." (interactive) (save-excursion (save-restriction (widen) (goto-char (point-min)) (if (search-forward "\nTag table:\n(Indirect)\n" nil t) (error "Don't yet know how to validate indirect info files: \"%s\"" (buffer-name (current-buffer)))) (goto-char (point-min)) (let ((allnodes '(("*"))) (regexp "Node:[ \t]*\\([^,\n\t]*\\)[,\t\n]") (case-fold-search t) (tags-losing nil) (lossages ())) (while (search-forward "\n\^_" nil t) (forward-line 1) (let ((beg (point))) (forward-line 1) (if (re-search-backward regexp beg t) (let ((name (downcase (buffer-substring (match-beginning 1) (progn (goto-char (match-end 1)) (skip-chars-backward " \t") (point)))))) (if (assoc name allnodes) (setq lossages (cons (list name "Duplicate node-name" nil) lossages)) (setq allnodes (cons (list name (progn (end-of-line) (and (re-search-backward "prev[ious]*:" beg t) (progn (goto-char (match-end 0)) (downcase (Info-following-node-name))))) beg) allnodes))))))) (goto-char (point-min)) (while (search-forward "\n\^_" nil t) (forward-line 1) (let ((beg (point)) thisnode next) (forward-line 1) (if (re-search-backward regexp beg t) (save-restriction (search-forward "\n\^_" nil 'move) (narrow-to-region beg (point)) (setq thisnode (downcase (buffer-substring (match-beginning 1) (progn (goto-char (match-end 1)) (skip-chars-backward " \t") (point))))) (end-of-line) (and (search-backward "next:" nil t) (setq next (Info-validate-node-name "invalid Next")) (assoc next allnodes) (if (equal (car (cdr (assoc next allnodes))) thisnode) ;; allow multiple `next' pointers to one node (let ((tem lossages)) (while tem (if (and (equal (car (cdr (car tem))) "should have Previous") (equal (car (car tem)) next)) (setq lossages (delq (car tem) lossages))) (setq tem (cdr tem)))) (setq lossages (cons (list next "should have Previous" thisnode) lossages)))) (end-of-line) (if (re-search-backward "prev[ious]*:" nil t) (Info-validate-node-name "invalid Previous")) (end-of-line) (if (search-backward "up:" nil t) (Info-validate-node-name "invalid Up")) (if (re-search-forward "\n* Menu:" nil t) (while (re-search-forward "\n\\* " nil t) (Info-validate-node-name (concat "invalid menu item " (buffer-substring (point) (save-excursion (skip-chars-forward "^:") (point)))) (Info-extract-menu-node-name)))) (goto-char (point-min)) (while (re-search-forward "\\*note[ \n]*[^:\t]*:" nil t) (goto-char (+ (match-beginning 0) 5)) (skip-chars-forward " \n") (Info-validate-node-name (concat "invalid reference " (buffer-substring (point) (save-excursion (skip-chars-forward "^:") (point)))) (Info-extract-menu-node-name "Bad format cross-reference"))))))) (setq tags-losing (not (Info-validate-tags-table))) (if (or lossages tags-losing) (with-output-to-temp-buffer " *problems in info file*" (while lossages (princ "In node \"") (princ (car (car lossages))) (princ "\", ") (let ((tem (nth 1 (car lossages)))) (cond ((string-match "\n" tem) (princ (substring tem 0 (match-beginning 0))) (princ "...")) (t (princ tem)))) (if (nth 2 (car lossages)) (progn (princ ": ") (let ((tem (nth 2 (car lossages)))) (cond ((string-match "\n" tem) (princ (substring tem 0 (match-beginning 0))) (princ "...")) (t (princ tem)))))) (terpri) (setq lossages (cdr lossages))) (if tags-losing (princ "\nTags table must be recomputed\n"))) ;; Here if info file is valid. ;; If we already made a list of problems, clear it out. (save-excursion (if (get-buffer " *problems in info file*") (progn (set-buffer " *problems in info file*") (kill-buffer (current-buffer))))) (message "File appears valid")))))) (defun Info-validate-node-name (kind &optional name) (if name nil (goto-char (match-end 0)) (skip-chars-forward " \t") (if (= (following-char) ?\() nil (setq name (buffer-substring (point) (progn (skip-chars-forward "^,\t\n") (skip-chars-backward " ") (point)))))) (if (null name) nil (setq name (downcase name)) (or (and (> (length name) 0) (= (aref name 0) ?\()) (assoc name allnodes) (setq lossages (cons (list thisnode kind name) lossages)))) name) (defun Info-validate-tags-table () (goto-char (point-min)) (if (not (search-forward "\^_\nEnd tag table\n" nil t)) t (not (catch 'losing (let* ((end (match-beginning 0)) (start (progn (search-backward "\nTag table:\n") (1- (match-end 0)))) tem) (setq tem allnodes) (while tem (goto-char start) (or (equal (car (car tem)) "*") (search-forward (concat "Node: " (car (car tem)) "\177") end t) (throw 'losing 'x)) (setq tem (cdr tem))) (goto-char (1+ start)) (while (looking-at ".*Node: \\(.*\\)\177\\([0-9]+\\)$") (setq tem (downcase (buffer-substring (match-beginning 1) (match-end 1)))) (setq tem (assoc tem allnodes)) (if (or (not tem) (< 1000 (progn (goto-char (match-beginning 2)) (setq tem (- (car (cdr (cdr tem))) (read (current-buffer)))) (if (> tem 0) tem (- tem))))) (throw 'losing 'y))) (forward-line 1)) (or (looking-at "End tag table\n") (throw 'losing 'z)) nil)))) (defun batch-info-validate () "Runs Info-validate on the files remaining on the command line. Must be used only with -batch, and kills emacs on completion. Each file will be processed even if an error occurred previously. For example, invoke \"emacs -batch -f batch-info-validate $info/ ~/*.info\"" (if (not noninteractive) (error "batch-info-validate may only be used -batch.")) (let ((version-control t) (auto-save-default nil) (find-file-run-dired nil) (kept-old-versions 259259) (kept-new-versions 259259)) (let ((error 0) file (files ())) (while command-line-args-left (setq file (expand-file-name (car command-line-args-left))) (cond ((not (file-exists-p file)) (message ">> %s does not exist!" file) (setq error 1 command-line-args-left (cdr command-line-args-left))) ((file-directory-p file) (setq command-line-args-left (nconc (directory-files file) (cdr command-line-args-left)))) (t (setq files (cons file files) command-line-args-left (cdr command-line-args-left))))) (while files (setq file (car files) files (cdr files)) (let ((lose nil)) (condition-case err (progn (if buffer-file-name (kill-buffer (current-buffer))) (find-file file) (buffer-flush-undo (current-buffer)) (set-buffer-modified-p nil) (fundamental-mode) (let ((case-fold-search nil)) (goto-char (point-max)) (cond ((search-backward "\n\^_\^L\nTag table:\n" nil t) (message "%s already tagified" file)) ((< (point-max) 30000) (message "%s too small to bother tagifying" file)) (t (message "Tagifying %s..." file) (Info-tagify) (message "Tagifying %s...done" file)))) (let ((loss-name " *problems in info file*")) (message "Checking validity of info file %s..." file) (if (get-buffer loss-name) (kill-buffer loss-name)) (Info-validate) (if (not (get-buffer loss-name)) nil ;(message "Checking validity of info file %s... OK" file) (message "----------------------------------------------------------------------") (message ">> PROBLEMS IN INFO FILE %s" file) (save-excursion (set-buffer loss-name) (princ (buffer-substring (point-min) (point-max)))) (message "----------------------------------------------------------------------") (setq error 1 lose t))) (if (and (buffer-modified-p) (not lose)) (progn (message "Saving modified %s" file) (save-buffer)))) (error (message ">> Error: %s" (prin1-to-string err)))))) (kill-emacs error)))) texinfo-2.15/elisp/texinfmt.el0000644000175000017500000030130212415567315013657 0ustar gg;;;; texinfmt.el ;;; Emacs lisp functions to convert Texinfo files to Info files. ;;; Version 2.23 10 June 1992 ;;; Robert J. Chassell ;;; Please send bug reports to: bob@gnu.ai.mit.edu ;;; Copyright (C) 1985, 1986, 1988, ;;; 1990, 1991, 1992 Free Software Foundation, Inc. ;;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 2, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Variable definitions (require 'texinfo) ; So `texinfo-footnote-style' is defined. (defvar texinfo-format-syntax-table nil) (defvar texinfo-vindex) (defvar texinfo-findex) (defvar texinfo-cindex) (defvar texinfo-pindex) (defvar texinfo-tindex) (defvar texinfo-kindex) (defvar texinfo-last-node) (defvar texinfo-node-names) (defvar texinfo-enclosure-list) ;;; Syntax table (if texinfo-format-syntax-table nil (setq texinfo-format-syntax-table (make-syntax-table)) (modify-syntax-entry ?\" " " texinfo-format-syntax-table) (modify-syntax-entry ?\\ " " texinfo-format-syntax-table) (modify-syntax-entry ?@ "\\" texinfo-format-syntax-table) (modify-syntax-entry ?\^q "\\" texinfo-format-syntax-table) (modify-syntax-entry ?\[ "." texinfo-format-syntax-table) (modify-syntax-entry ?\] "." texinfo-format-syntax-table) (modify-syntax-entry ?\( "." texinfo-format-syntax-table) (modify-syntax-entry ?\) "." texinfo-format-syntax-table) (modify-syntax-entry ?{ "(}" texinfo-format-syntax-table) (modify-syntax-entry ?} "){" texinfo-format-syntax-table) (modify-syntax-entry ?\' "." texinfo-format-syntax-table)) ;;; Top level buffer and region formatting functions (defun texinfo-format-buffer (&optional notagify) "Process the current buffer as texinfo code, into an Info file. The Info file output is generated in a buffer visiting the Info file names specified in the @setfilename command. Non-nil argument (prefix, if interactive) means don't make tag table and don't split the file if large. You can use Info-tagify and Info-split to do these manually." (interactive "P") (let ((lastmessage "Formatting Info file...")) (message lastmessage) (texinfo-format-buffer-1) (if notagify nil (if (> (buffer-size) 30000) (progn (message (setq lastmessage "Making tags table for Info file...")) (Info-tagify))) (if (> (buffer-size) 100000) (progn (message (setq lastmessage "Splitting Info file...")) (Info-split)))) (message (concat lastmessage (if (interactive-p) "done. Now save it." "done."))))) (defvar texinfo-region-buffer-name "*Info Region*" "*Name of the temporary buffer used by \\[texinfo-format-region].") (defun texinfo-format-region (region-beginning region-ending) "Convert the current region of the Texinfo file to Info format. This lets you see what that part of the file will look like in Info. The command is bound to \\[texinfo-format-region]. The text that is converted to Info is stored in a temporary buffer." (interactive "r") (message "Converting region to Info format...") (let (texinfo-command-start texinfo-command-end texinfo-command-name texinfo-vindex texinfo-findex texinfo-cindex texinfo-pindex texinfo-tindex texinfo-kindex texinfo-stack texinfo-format-filename texinfo-example-start texinfo-last-node-pos texinfo-last-node texinfo-node-names (texinfo-footnote-number 0) last-input-buffer (fill-column-for-info fill-column) (input-buffer (current-buffer)) (input-directory default-directory) filename-or-header filename-or-header-beginning filename-or-header-end) ;;; Find a buffer to use. (switch-to-buffer (get-buffer-create texinfo-region-buffer-name)) (erase-buffer) ;; Insert the region into the buffer. ;; First, find file name or tell of its absence. ;; Second, insert lines between beginning and end of header lines, ;; if any, or else insert the filename. ;; Third, insert region. (save-excursion (set-buffer input-buffer) (save-excursion (save-restriction (widen) (goto-char (point-min)) (let ((search-end (save-excursion (forward-line 100) (point)))) ;; Find the filename or else explain that a filename is needed. (or (search-forward "@setfilename" search-end t) (error "The texinfo file needs a line saying: @setfilename ")) ;; Find header and copy it into buffer; or copy just the ;; filename if no header. (goto-char (point-min)) (if (and (prog1 (search-forward texinfo-start-of-header search-end t) (beginning-of-line) ;; Mark beginning of header. (setq filename-or-header-beginning (point))) (prog1 (search-forward texinfo-end-of-header nil t) (beginning-of-line) ;; Mark end of header (setq filename-or-header-end (point)))) ;; Copy header (setq filename-or-header (buffer-substring (min filename-or-header-beginning region-beginning) filename-or-header-end)) ;; Else no header; insert @filename line in buffer (goto-char (point-min)) (search-forward "@setfilename" search-end t) (beginning-of-line) (setq filename-or-header-beginning (point)) (forward-line 1) (setq filename-or-header-end (point)) (setq filename-or-header (buffer-substring (min filename-or-header-beginning region-beginning) filename-or-header-end))))))) ;; Insert the filename or header into the buffer. (insert filename-or-header) ;; Insert the region into the buffer. (insert-buffer-substring input-buffer (max region-beginning filename-or-header-end) region-ending) ;; Make sure region ends in a newline. (or (= (preceding-char) ?\n) (insert "\n")) (texinfo-mode) (setq fill-column fill-column-for-info) ;; Install a syntax table useful for scanning command operands. (set-syntax-table texinfo-format-syntax-table) ;; Append @refill to appropriate paragraphs (goto-char (point-min)) (message "Converting region to Info format...") (texinfo-append-refill) ;; If the region includes the effective end of the data, ;; discard everything after that. (goto-char (point-max)) (if (re-search-backward "^@bye" nil t) (delete-region (point) (point-max))) ;; Make sure buffer ends in a newline. (or (= (preceding-char) ?\n) (insert "\n")) ;; Don't use a previous value of texinfo-enclosure-list. (setq texinfo-enclosure-list nil) ;; Now convert for real. (goto-char (point-min)) (texinfo-format-scan) (goto-char (point-min)) (message "Done."))) ;;; Primary internal formatting function for the whole buffer. (defun texinfo-format-buffer-1 () (let (texinfo-format-filename texinfo-example-start texinfo-command-start texinfo-command-end texinfo-command-name texinfo-last-node texinfo-last-node-pos texinfo-vindex texinfo-findex texinfo-cindex texinfo-pindex texinfo-tindex texinfo-kindex texinfo-stack texinfo-node-names (texinfo-footnote-number 0) last-input-buffer outfile (fill-column-for-info fill-column) (input-buffer (current-buffer)) (input-directory default-directory)) (setq texinfo-enclosure-list nil) (save-excursion (goto-char (point-min)) (search-forward "@setfilename") (setq texinfo-command-end (point)) (setq outfile (texinfo-parse-line-arg))) (find-file outfile) (texinfo-mode) (setq fill-column fill-column-for-info) (set-syntax-table texinfo-format-syntax-table) (erase-buffer) (insert-buffer-substring input-buffer) ;; Append @refill to appropriate paragraphs (goto-char (point-min)) (message "Converting %s to Info format..." (buffer-name input-buffer)) (texinfo-append-refill) (goto-char (point-min)) (search-forward "@setfilename") (beginning-of-line) (delete-region (point-min) (point)) ;; Remove @bye at end of file, if it is there. (goto-char (point-max)) (if (search-backward "@bye" nil t) (delete-region (point) (point-max))) ;; Make sure buffer ends in a newline. (or (= (preceding-char) ?\n) (insert "\n")) ;; Scan the whole buffer, converting to Info format. (texinfo-format-scan) ;; Return data for indices. (goto-char (point-min)) (list outfile texinfo-vindex texinfo-findex texinfo-cindex texinfo-pindex texinfo-tindex texinfo-kindex))) ;;; Perform non-@-command file conversions (defun texinfo-format-convert (min max) ;; Convert left and right quotes to typewriter font quotes. (goto-char min) (while (search-forward "``" max t) (replace-match "\"")) (goto-char min) (while (search-forward "''" max t) (replace-match "\"")) ;; Convert three hyphens in a row to two. (goto-char min) (while (re-search-forward "\\( \\|\\w\\)\\(---\\)\\( \\|\\w\\)" max t) (delete-region (1+ (match-beginning 2)) (+ 2 (match-beginning 2))))) (defvar texinfo-no-refill-regexp "^@\\(example\\|smallexample\\|lisp\\|smalllisp\\|display\\|format\\|flushleft\\|flushright\\|menu\\|titlepage\\|iftex\\|tex\\)" "Regexp specifying environments in which paragraphs are not filled.") (defvar texinfo-part-of-para-regexp "^@\\(b{\\|bullet{\\|cite{\\|code{\\|emph{\\|equiv{\\|error{\\|expansion{\\|file{\\|i{\\|inforef{\\|kbd{\\|key{\\|lisp{\\|minus{\\|point{\\|print{\\|pxref{\\|r{\\|ref{\\|result{\\|samp{\\|sc{\\|t{\\|TeX{\\|today{\\|var{\\|w{\\|xref{\\)" "Regexp specifying @-commands found within paragraphs.") (defun texinfo-append-refill () "Append @refill at end of each paragraph that should be filled. Do not append @refill to paragraphs within @example and similar environments. Do not append @refill to paragraphs containing @w{TEXT} or @*." ;; It is necessary to append @refill before other processing because ;; the other processing removes information that tells Texinfo ;; whether the text should or should not be filled. (while (< (point) (point-max)) (let ((refill-blank-lines "^[ \t\n]*$") (case-fold-search nil)) ; Don't confuse @TeX and @tex.... (beginning-of-line) ;; 1. Skip over blank lines; ;; skip over lines beginning with @-commands, ;; but do not skip over lines ;; that are no-refill environments such as @example or ;; that begin with within-paragraph @-commands such as @code. (while (and (looking-at (concat "^@\\|^\\\\\\|" refill-blank-lines)) (not (looking-at (concat "\\(" texinfo-no-refill-regexp "\\|" texinfo-part-of-para-regexp "\\)"))) (< (point) (point-max))) (forward-line 1)) ;; 2. Skip over @example and similar no-refill environments. (if (looking-at texinfo-no-refill-regexp) (let ((environment (buffer-substring (match-beginning 1) (match-end 1)))) (progn (re-search-forward (concat "^@end " environment) nil t) (forward-line 1))) ;; 3. Do not refill a paragraph containing @w or @* (if (or (>= (point) (point-max)) (re-search-forward "@w{\\|@\\*" (save-excursion (forward-paragraph) (point)) t)) ;; Go to end of paragraph and do nothing. (forward-paragraph) ;; 4. Else go to end of paragraph and insert @refill (forward-paragraph) (forward-line -1) (end-of-line) (delete-region (point) (save-excursion (skip-chars-backward " \t") (point))) ;; `looking-at-backward' not available in v. 18.57 ;; (if (not (looking-at-backward "@refill\\|@bye")) ;) (if (not (re-search-backward "@refill\\|@bye" (save-excursion (beginning-of-line) (point)) t)) (insert "@refill")) (forward-line 1)))))) ;;; Perform those texinfo-to-info conversions that apply to the whole input ;;; uniformly. (defun texinfo-format-scan () (texinfo-format-convert (point-min) (point-max)) ;; Scan for @-commands. (goto-char (point-min)) (while (search-forward "@" nil t) (if (looking-at "[@{}'` *]") ;; Handle a few special @-followed-by-one-char commands. (if (= (following-char) ?*) (progn ;; remove command (delete-region (1- (point)) (1+ (point))) ;; insert return if not at end of line; ;; else line is already broken. (if (not (= (following-char) ?\n)) (insert ?\n))) ;; The other characters are simply quoted. Delete the @. (delete-char -1) (forward-char 1)) ;; @ is followed by a command-word; find the end of the word. (setq texinfo-command-start (1- (point))) (if (= (char-syntax (following-char)) ?w) (forward-word 1) (forward-char 1)) (setq texinfo-command-end (point)) ;; Call the handler for this command. (setq texinfo-command-name (intern (buffer-substring (1+ texinfo-command-start) texinfo-command-end))) (let ((enclosure-type (assoc (symbol-name texinfo-command-name) texinfo-enclosure-list))) (if enclosure-type (progn (insert (car (car (cdr enclosure-type))) (texinfo-parse-arg-discard) (car (cdr (car (cdr enclosure-type))))) (goto-char texinfo-command-start)) (let ((cmd (get texinfo-command-name 'texinfo-format))) (if cmd (funcall cmd) (texinfo-unsupported))))))) (cond (texinfo-stack (goto-char (nth 2 (car texinfo-stack))) (error "Unterminated @%s" (car (car texinfo-stack)))))) (put 'begin 'texinfo-format 'texinfo-format-begin) (defun texinfo-format-begin () (texinfo-format-begin-end 'texinfo-format)) (put 'end 'texinfo-format 'texinfo-format-end) (defun texinfo-format-end () (texinfo-format-begin-end 'texinfo-end)) (defun texinfo-format-begin-end (prop) (setq texinfo-command-name (intern (texinfo-parse-line-arg))) (setq cmd (get texinfo-command-name prop)) (if cmd (funcall cmd) (texinfo-unsupported))) ;;; Parsing functions (defun texinfo-parse-line-arg () (goto-char texinfo-command-end) (let ((start (point))) (cond ((looking-at " ") (skip-chars-forward " ") (setq start (point)) (end-of-line) (skip-chars-backward " ") (delete-region (point) (progn (end-of-line) (point))) (setq texinfo-command-end (1+ (point)))) ((looking-at "{") (setq start (1+ (point))) (forward-list 1) (setq texinfo-command-end (point)) (forward-char -1)) (t (error "Invalid texinfo command arg format"))) (prog1 (buffer-substring start (point)) (if (eolp) (forward-char 1))))) (defun texinfo-parse-expanded-arg () (goto-char texinfo-command-end) (let ((start (point)) marker) (cond ((looking-at " ") (skip-chars-forward " ") (setq start (point)) (end-of-line) (setq texinfo-command-end (1+ (point)))) ((looking-at "{") (setq start (1+ (point))) (forward-list 1) (setq texinfo-command-end (point)) (forward-char -1)) (t (error "Invalid texinfo command arg format"))) (setq marker (move-marker (make-marker) texinfo-command-end)) (texinfo-format-expand-region start (point)) (setq texinfo-command-end (marker-position marker)) (move-marker marker nil) (prog1 (buffer-substring start (point)) (if (eolp) (forward-char 1))))) (defun texinfo-format-expand-region (start end) (save-restriction (narrow-to-region start end) (let (texinfo-command-start texinfo-command-end texinfo-command-name texinfo-stack) (texinfo-format-scan)) (goto-char (point-max)))) (defun texinfo-parse-arg-discard () (prog1 (texinfo-parse-line-arg) (texinfo-discard-command))) (defun texinfo-discard-command () (delete-region texinfo-command-start texinfo-command-end)) (defun texinfo-optional-braces-discard () "Discard braces following command, if any." (goto-char texinfo-command-end) (let ((start (point))) (cond ((looking-at "[ \t]*\n")) ; do nothing ((looking-at "{") ; remove braces, if any (forward-list 1) (setq texinfo-command-end (point))) (t (error "Invalid `texinfo-optional-braces-discard' format \(need braces?\)"))) (delete-region texinfo-command-start texinfo-command-end))) (defun texinfo-format-parse-line-args () (let ((start (1- (point))) next beg end args) (skip-chars-forward " ") (while (not (eolp)) (setq beg (point)) (re-search-forward "[\n,]") (setq next (point)) (if (bolp) (setq next (1- next))) (forward-char -1) (skip-chars-backward " ") (setq end (point)) (setq args (cons (if (> end beg) (buffer-substring beg end)) args)) (goto-char next) (skip-chars-forward " ")) (if (eolp) (forward-char 1)) (setq texinfo-command-end (point)) (nreverse args))) (defun texinfo-format-parse-args () (let ((start (1- (point))) next beg end args) (search-forward "{") (save-excursion (texinfo-format-expand-region (point) (save-excursion (up-list 1) (1- (point))))) ;; The following does not handle cross references of the form: ;; `@xref{bullet, , @code{@@bullet}@{@}}.' because the ;; re-search-forward finds the first right brace after the second ;; comma. (while (/= (preceding-char) ?\}) (skip-chars-forward " \t\n") (setq beg (point)) (re-search-forward "[},]") (setq next (point)) (forward-char -1) (skip-chars-backward " \t\n") (setq end (point)) (cond ((< beg end) (goto-char beg) (while (search-forward "\n" end t) (replace-match " ")))) (setq args (cons (if (> end beg) (buffer-substring beg end)) args)) (goto-char next)) (if (eolp) (forward-char 1)) (setq texinfo-command-end (point)) (nreverse args))) (defun texinfo-format-parse-defun-args () (goto-char texinfo-command-end) (let ((start (point))) (end-of-line) (setq texinfo-command-end (1+ (point))) (let ((marker (move-marker (make-marker) texinfo-command-end))) (texinfo-format-expand-region start (point)) (setq texinfo-command-end (marker-position marker)) (move-marker marker nil)) (goto-char start) (let ((args '()) beg end) (skip-chars-forward " ") (while (not (eolp)) (cond ((looking-at "{") (setq beg (1+ (point))) (forward-list 1) (setq end (1- (point)))) (t (setq beg (point)) (re-search-forward "[\n ]") (forward-char -1) (setq end (point)))) (setq args (cons (buffer-substring beg end) args)) (skip-chars-forward " ")) (forward-char 1) (nreverse args)))) (defun texinfo-discard-line () (goto-char texinfo-command-end) (skip-chars-forward " \t") (or (eolp) (error "Extraneous text at end of command line.")) (goto-char texinfo-command-start) (or (bolp) (error "Extraneous text at beginning of command line.")) (delete-region (point) (progn (forward-line 1) (point)))) (defun texinfo-discard-line-with-args () (goto-char texinfo-command-start) (delete-region (point) (progn (forward-line 1) (point)))) ;;; @setfilename ; 19 October 1990 ; @setfilename modifed to work with include files; see @include ; (defun texinfo-format-setfilename () ; (let ((arg (texinfo-parse-arg-discard))) ; (setq texinfo-format-filename ; (file-name-nondirectory (expand-file-name arg))) ; (insert "Info file: " ; texinfo-format-filename ", -*-Text-*-\n" ; "produced by texinfo-format-buffer\nfrom " ; (if (buffer-file-name input-buffer) ; (concat "file: " ; (file-name-sans-versions ; (file-name-nondirectory ; (buffer-file-name input-buffer)))) ; (concat "buffer " (buffer-name input-buffer))) ; "\n\n"))) (put 'setfilename 'texinfo-format 'texinfo-format-setfilename) (defun texinfo-format-setfilename () (let ((arg (texinfo-parse-arg-discard))) (if (eq input-buffer last-input-buffer) nil ; only use first setfilename in buffer (message "Formatting Info file: %s" arg) (setq texinfo-format-filename (file-name-nondirectory (expand-file-name arg))) (insert "Info file: " texinfo-format-filename ", -*-Text-*-\n" "produced by texinfo-format-buffer\nfrom " (if (buffer-file-name input-buffer) (concat "file: " (file-name-sans-versions (file-name-nondirectory (buffer-file-name input-buffer)))) (concat "buffer " (buffer-name input-buffer))) "\n\n")))) ;;; @node, @menu (put 'node 'texinfo-format 'texinfo-format-node) (defun texinfo-format-node () (let* ((args (texinfo-format-parse-line-args)) (name (nth 0 args)) (next (nth 1 args)) (prev (nth 2 args)) (up (nth 3 args))) (texinfo-discard-command) (setq texinfo-last-node name) (let ((tem (downcase name))) (if (assoc tem texinfo-node-names) (error "Duplicate node name: %s" name) (setq texinfo-node-names (cons (list tem) texinfo-node-names)))) (setq texinfo-footnote-number 0) (or (bolp) (insert ?\n)) (insert "\^_\nFile: " texinfo-format-filename ", Node: " name) (if next (insert ", Next: " next)) (if prev (insert ", Prev: " prev)) (if up (insert ", Up: " up)) (insert ?\n) (setq texinfo-last-node-pos (point)))) (put 'menu 'texinfo-format 'texinfo-format-menu) (defun texinfo-format-menu () (texinfo-discard-line) (insert "* Menu:\n\n")) (put 'menu 'texinfo-end 'texinfo-discard-command) ;;; Cross references ; @xref {NODE, FNAME, NAME, FILE, DOCUMENT} ; -> *Note FNAME: (FILE)NODE ; If FILE is missing, ; *Note FNAME: NODE ; If FNAME is empty and NAME is present ; *Note NAME: Node ; If both NAME and FNAME are missing ; *Note NODE:: ; texinfo ignores the DOCUMENT argument. ; -> See section [NAME, else NODE], page ; If FILE is specified, (FILE)NODE is used for xrefs. ; If fifth argument DOCUMENT is specified, produces ; See section [NAME, else NODE], page ; of DOCUMENT ; @ref a reference that does not put `See' or `see' in ; the hardcopy and is the same as @xref in Info (put 'ref 'texinfo-format 'texinfo-format-xref) (put 'xref 'texinfo-format 'texinfo-format-xref) (defun texinfo-format-xref () (let ((args (texinfo-format-parse-args))) (texinfo-discard-command) (insert "*Note ") (let ((fname (or (nth 1 args) (nth 2 args)))) (if (null (or fname (nth 3 args))) (insert (car args) "::") (insert (or fname (car args)) ": ") (if (nth 3 args) (insert "(" (nth 3 args) ")")) (insert (car args)))))) (put 'pxref 'texinfo-format 'texinfo-format-pxref) (defun texinfo-format-pxref () (texinfo-format-xref) (or (save-excursion (forward-char -2) (looking-at "::")) (insert "."))) ;@inforef{NODE, FNAME, FILE} ;Like @xref{NODE, FNAME,,FILE} in texinfo. ;In Tex, generates "See Info file FILE, node NODE" (put 'inforef 'texinfo-format 'texinfo-format-inforef) (defun texinfo-format-inforef () (let ((args (texinfo-format-parse-args))) (texinfo-discard-command) (if (nth 1 args) (insert "*Note " (nth 1 args) ": (" (nth 2 args) ")" (car args)) (insert "*Note " "(" (nth 2 args) ")" (car args) "::")))) ;;; Section headings (put 'majorheading 'texinfo-format 'texinfo-format-chapter) (put 'chapheading 'texinfo-format 'texinfo-format-chapter) (put 'ichapter 'texinfo-format 'texinfo-format-chapter) (put 'chapter 'texinfo-format 'texinfo-format-chapter) (put 'iappendix 'texinfo-format 'texinfo-format-chapter) (put 'appendix 'texinfo-format 'texinfo-format-chapter) (put 'iunnumbered 'texinfo-format 'texinfo-format-chapter) (put 'top 'texinfo-format 'texinfo-format-chapter) (put 'unnumbered 'texinfo-format 'texinfo-format-chapter) (defun texinfo-format-chapter () (texinfo-format-chapter-1 ?*)) (put 'heading 'texinfo-format 'texinfo-format-section) (put 'isection 'texinfo-format 'texinfo-format-section) (put 'section 'texinfo-format 'texinfo-format-section) (put 'iappendixsection 'texinfo-format 'texinfo-format-section) (put 'appendixsection 'texinfo-format 'texinfo-format-section) (put 'iappendixsec 'texinfo-format 'texinfo-format-section) (put 'appendixsec 'texinfo-format 'texinfo-format-section) (put 'iunnumberedsec 'texinfo-format 'texinfo-format-section) (put 'unnumberedsec 'texinfo-format 'texinfo-format-section) (defun texinfo-format-section () (texinfo-format-chapter-1 ?=)) (put 'subheading 'texinfo-format 'texinfo-format-subsection) (put 'isubsection 'texinfo-format 'texinfo-format-subsection) (put 'subsection 'texinfo-format 'texinfo-format-subsection) (put 'iappendixsubsec 'texinfo-format 'texinfo-format-subsection) (put 'appendixsubsec 'texinfo-format 'texinfo-format-subsection) (put 'iunnumberedsubsec 'texinfo-format 'texinfo-format-subsection) (put 'unnumberedsubsec 'texinfo-format 'texinfo-format-subsection) (defun texinfo-format-subsection () (texinfo-format-chapter-1 ?-)) (put 'subsubheading 'texinfo-format 'texinfo-format-subsubsection) (put 'isubsubsection 'texinfo-format 'texinfo-format-subsubsection) (put 'subsubsection 'texinfo-format 'texinfo-format-subsubsection) (put 'iappendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection) (put 'appendixsubsubsec 'texinfo-format 'texinfo-format-subsubsection) (put 'iunnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection) (put 'unnumberedsubsubsec 'texinfo-format 'texinfo-format-subsubsection) (defun texinfo-format-subsubsection () (texinfo-format-chapter-1 ?.)) (defun texinfo-format-chapter-1 (belowchar) (let ((arg (texinfo-parse-arg-discard))) (message "Formatting: %s ... " arg) ; So we can see where we are. (insert ?\n arg ?\n "@SectionPAD " belowchar ?\n) (forward-line -2))) (put 'SectionPAD 'texinfo-format 'texinfo-format-sectionpad) (defun texinfo-format-sectionpad () (let ((str (texinfo-parse-arg-discard))) (forward-char -1) (let ((column (current-column))) (forward-char 1) (while (> column 0) (insert str) (setq column (1- column)))) (insert ?\n))) ;;; Space controling commands: @. and @: (put '\. 'texinfo-format 'texinfo-format-\.) (defun texinfo-format-\. () (texinfo-discard-command) (insert ".")) (put '\: 'texinfo-format 'texinfo-format-\:) (defun texinfo-format-\: () (texinfo-discard-command)) ;;; @center, @sp, and @br (put 'center 'texinfo-format 'texinfo-format-center) (defun texinfo-format-center () (let ((arg (texinfo-parse-expanded-arg))) (texinfo-discard-command) (insert arg) (insert ?\n) (save-restriction (goto-char (1- (point))) (let ((indent-tabs-mode nil)) (center-line))))) (put 'sp 'texinfo-format 'texinfo-format-sp) (defun texinfo-format-sp () (let* ((arg (texinfo-parse-arg-discard)) (num (read arg))) (insert-char ?\n num))) (put 'br 'texinfo-format 'texinfo-format-paragraph-break) (defun texinfo-format-paragraph-break () "Force a paragraph break. If used within a line, follow `@br' with braces." (texinfo-optional-braces-discard) ;; insert one return if at end of line; ;; else insert two returns, to generate a blank line. (if (= (following-char) ?\n) (insert ?\n) (insert-char ?\n 2))) ;;; @footnote and @footnotestyle ; In Texinfo, footnotes are created with the `@footnote' command. ; This command is followed immediately by a left brace, then by the text of ; the footnote, and then by a terminating right brace. The ; template for a footnote is: ; ; @footnote{TEXT} ; ; Info has two footnote styles: ; ; * In the End of node style, all the footnotes for a single node ; are placed at the end of that node. The footnotes are ; separated from the rest of the node by a line of dashes with ; the word `Footnotes' within it. ; ; * In the Separate node style, all the footnotes for a single node ; are placed in an automatically constructed node of their own. ; Footnote style is specified by the @footnotestyle command, either ; @footnotestyle separate ; or ; @footnotestyle end ; ; The default is separate (defvar texinfo-footnote-style "separate" "Footnote style, either separate or end.") (put 'footnotestyle 'texinfo-format 'texinfo-footnotestyle) (defun texinfo-footnotestyle () "Specify whether footnotes are at end of node or in separate nodes. Argument is either end or separate." (setq texinfo-footnote-style (texinfo-parse-arg-discard))) (defvar texinfo-footnote-number) (put 'footnote 'texinfo-format 'texinfo-format-footnote) (defun texinfo-format-footnote () "Format a footnote in either end of node or separate node style. The texinfo-footnote-style variable controls which style is used." (setq texinfo-footnote-number (1+ texinfo-footnote-number)) (cond ((string= texinfo-footnote-style "end") (texinfo-format-end-node)) ((string= texinfo-footnote-style "separate") (texinfo-format-separate-node)))) (defun texinfo-format-separate-node () "Format footnote in Separate node style, with notes in own node. The node is constructed automatically." (let* (start (arg (texinfo-parse-line-arg)) (node-name-beginning (save-excursion (re-search-backward "^File: \\w+\\(\\w\\|\\s_\\|\\.\\|,\\)*[ \t]+Node:") (match-end 0))) (node-name (save-excursion (buffer-substring (progn (goto-char node-name-beginning) ; skip over node command (skip-chars-forward " \t") ; and over spaces (point)) (if (search-forward "," (save-excursion (end-of-line) (point)) t) ; bound search (1- (point)) (end-of-line) (point)))))) (texinfo-discard-command) ; remove or insert whitespace, as needed (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) (insert (format " (%d) (*Note %s-Footnotes::)" texinfo-footnote-number node-name)) (fill-paragraph nil) (save-excursion (if (re-search-forward "^@node" nil 'move) (forward-line -1)) ;; two cases: for the first footnote, we must insert a node header; ;; for the second and subsequent footnotes, we need only insert ;; the text of the footnote. (if (save-excursion (re-search-backward (concat node-name "-Footnotes, Up: ") node-name-beginning t)) (progn ; already at least one footnote (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point))) ;; else not yet a footnote (insert "\n\^_\nFile: " texinfo-format-filename " Node: " node-name "-Footnotes, Up: " node-name "\n") (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point)))))) (defun texinfo-format-end-node () "Format footnote in the End of node style, with notes at end of node." (let (start (arg (texinfo-parse-line-arg))) (texinfo-discard-command) ; remove or insert whitespace, as needed (delete-region (save-excursion (skip-chars-backward " \t\n") (point)) (point)) (insert (format " (%d) " texinfo-footnote-number)) (fill-paragraph nil) (save-excursion (if (search-forward "\n--------- Footnotes ---------\n" nil t) (progn ; already have footnote, put new one before end of node (if (re-search-forward "^@node" nil 'move) (forward-line -1)) (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)) (fill-region start (point))) ;; else no prior footnote (if (re-search-forward "^@node" nil 'move) (forward-line -1)) (insert "\n--------- Footnotes ---------\n") (setq start (point)) (insert (format "\n(%d) %s\n" texinfo-footnote-number arg)))))) ;;; @itemize, @enumerate, and similar commands ;; @itemize pushes (itemize "COMMANDS" STARTPOS) on texinfo-stack. ;; @enumerate pushes (enumerate 0 STARTPOS). ;; @item dispatches to the texinfo-item prop of the first elt of the list. ;; For itemize, this puts in and rescans the COMMANDS. ;; For enumerate, this increments the number and puts it in. ;; In either case, it puts a Backspace at the front of the line ;; which marks it not to be indented later. ;; All other lines get indented by 5 when the @end is reached. (defvar texinfo-stack-depth 0 "Count of number of unpopped texinfo-push-stack calls. Used by @refill indenting command to avoid indenting within lists, etc.") (defun texinfo-push-stack (check arg) (setq texinfo-stack-depth (1+ texinfo-stack-depth)) (setq texinfo-stack (cons (list check arg texinfo-command-start) texinfo-stack))) (defun texinfo-pop-stack (check) (setq texinfo-stack-depth (1- texinfo-stack-depth)) (if (null texinfo-stack) (error "Unmatched @end %s" check)) (if (not (eq (car (car texinfo-stack)) check)) (error "@end %s matches @%s" check (car (car texinfo-stack)))) (prog1 (cdr (car texinfo-stack)) (setq texinfo-stack (cdr texinfo-stack)))) (put 'itemize 'texinfo-format 'texinfo-itemize) (defun texinfo-itemize () (texinfo-push-stack 'itemize (progn (skip-chars-forward " \t") (if (eolp) "@bullet" (texinfo-parse-line-arg)))) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5))) (put 'itemize 'texinfo-end 'texinfo-end-itemize) (defun texinfo-end-itemize () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'itemize))) (texinfo-do-itemize (nth 1 stacktop)))) (put 'enumerate 'texinfo-format 'texinfo-enumerate) (defun texinfo-enumerate () (texinfo-push-stack 'enumerate (progn (skip-chars-forward " \t") (if (eolp) 1 (read (current-buffer))))) (if (and (symbolp (car (cdr (car texinfo-stack)))) (> 1 (length (symbol-name (car (cdr (car texinfo-stack))))))) (error "@enumerate: Use a number or letter, eg: 1, A, a, 3, B, or d." )) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5))) (put 'enumerate 'texinfo-end 'texinfo-end-enumerate) (defun texinfo-end-enumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'enumerate))) (texinfo-do-itemize (nth 1 stacktop)))) ;; @alphaenumerate never became a standard part of Texinfo (put 'alphaenumerate 'texinfo-format 'texinfo-alphaenumerate) (defun texinfo-alphaenumerate () (texinfo-push-stack 'alphaenumerate (1- ?a)) (setq fill-column (- fill-column 5)) (texinfo-discard-line)) (put 'alphaenumerate 'texinfo-end 'texinfo-end-alphaenumerate) (defun texinfo-end-alphaenumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'alphaenumerate))) (texinfo-do-itemize (nth 1 stacktop)))) ;; @capsenumerate never became a standard part of Texinfo (put 'capsenumerate 'texinfo-format 'texinfo-capsenumerate) (defun texinfo-capsenumerate () (texinfo-push-stack 'capsenumerate (1- ?A)) (setq fill-column (- fill-column 5)) (texinfo-discard-line)) (put 'capsenumerate 'texinfo-end 'texinfo-end-capsenumerate) (defun texinfo-end-capsenumerate () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'capsenumerate))) (texinfo-do-itemize (nth 1 stacktop)))) ;; At the @end, indent all the lines within the construct ;; except those marked with backspace. FROM says where ;; construct started. (defun texinfo-do-itemize (from) (save-excursion (while (progn (forward-line -1) (>= (point) from)) (if (= (following-char) ?\b) (save-excursion (delete-char 1) (end-of-line) (delete-char 6)) (if (not (looking-at "[ \t]*$")) (save-excursion (insert " "))))))) (put 'item 'texinfo-format 'texinfo-item) (put 'itemx 'texinfo-format 'texinfo-item) (defun texinfo-item () (funcall (get (car (car texinfo-stack)) 'texinfo-item))) (put 'itemize 'texinfo-item 'texinfo-itemize-item) (defun texinfo-itemize-item () ;; (texinfo-discard-line) ; Did not handle text on same line as @item. (delete-region (1+ (point)) (save-excursion (beginning-of-line) (point))) (if (looking-at "[ \t]*[^ \t\n]+") ;; Text on same line as @item command. (insert "\b " (nth 1 (car texinfo-stack)) " \n") ;; Else text on next line. (insert "\b " (nth 1 (car texinfo-stack)) " ")) (forward-line -1)) (put 'enumerate 'texinfo-item 'texinfo-enumerate-item) (defun texinfo-enumerate-item () (texinfo-discard-line) (let (enumerating-symbol) (cond ((integerp (car (cdr (car texinfo-stack)))) (setq enumerating-symbol (car (cdr (car texinfo-stack)))) (insert ?\b (format "%3d. " enumerating-symbol) ?\n) (setcar (cdr (car texinfo-stack)) (1+ enumerating-symbol))) ((symbolp (car (cdr (car texinfo-stack)))) (setq enumerating-symbol (symbol-name (car (cdr (car texinfo-stack))))) (if (or (equal ?\[ (string-to-char enumerating-symbol)) (equal ?\{ (string-to-char enumerating-symbol))) (error "Too many items in enumerated list; alphabet ends at Z.")) (insert ?\b (format "%3s. " enumerating-symbol) ?\n) (setcar (cdr (car texinfo-stack)) (make-symbol (char-to-string (1+ (string-to-char enumerating-symbol)))))) (t (error "@enumerate: Use a number or letter, eg: 1, A, a, 3, B or d." ))) (forward-line -1))) (put 'alphaenumerate 'texinfo-item 'texinfo-alphaenumerate-item) (defun texinfo-alphaenumerate-item () (texinfo-discard-line) (let ((next (1+ (car (cdr (car texinfo-stack)))))) (if (> next ?z) (error "More than 26 items in @alphaenumerate; get a bigger alphabet.")) (setcar (cdr (car texinfo-stack)) next) (insert "\b " next ". \n")) (forward-line -1)) (put 'capsenumerate 'texinfo-item 'texinfo-capsenumerate-item) (defun texinfo-capsenumerate-item () (texinfo-discard-line) (let ((next (1+ (car (cdr (car texinfo-stack)))))) (if (> next ?Z) (error "More than 26 items in @capsenumerate; get a bigger alphabet.")) (setcar (cdr (car texinfo-stack)) next) (insert "\b " next ". \n")) (forward-line -1)) ;;; @table ; The `@table' command produces two-column tables. (put 'table 'texinfo-format 'texinfo-table) (defun texinfo-table () (texinfo-push-stack 'table (progn (skip-chars-forward " \t") (if (eolp) "@asis" (texinfo-parse-line-arg)))) (texinfo-discard-line-with-args) (setq fill-column (- fill-column 5))) (put 'table 'texinfo-item 'texinfo-table-item) (defun texinfo-table-item () (let ((arg (texinfo-parse-arg-discard)) (itemfont (car (cdr (car texinfo-stack))))) (insert ?\b itemfont ?\{ arg "}\n \n")) (forward-line -2)) (put 'table 'texinfo-end 'texinfo-end-table) (defun texinfo-end-table () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'table))) (texinfo-do-itemize (nth 1 stacktop)))) ;; @description appears to be an undocumented variant on @table that ;; does not require an arg. It fails in texinfo.tex 2.58 and is not ;; part of makeinfo.c The command appears to be a relic of the past. (put 'description 'texinfo-end 'texinfo-end-table) (put 'description 'texinfo-format 'texinfo-description) (defun texinfo-description () (texinfo-push-stack 'table "@asis") (setq fill-column (- fill-column 5)) (texinfo-discard-line)) ;;; @ftable, @vtable ; The `@ftable' and `@vtable' commands are like the `@table' command ; but they also insert each entry in the first column of the table ; into the function or variable index. ;; Handle the @ftable and @vtable commands: (put 'ftable 'texinfo-format 'texinfo-ftable) (put 'vtable 'texinfo-format 'texinfo-vtable) (defun texinfo-ftable () (texinfo-indextable 'ftable)) (defun texinfo-vtable () (texinfo-indextable 'vtable)) (defun texinfo-indextable (table-type) (texinfo-push-stack table-type (texinfo-parse-arg-discard)) (setq fill-column (- fill-column 5))) ;; Handle the @item commands within ftable and vtable: (put 'ftable 'texinfo-item 'texinfo-ftable-item) (put 'vtable 'texinfo-item 'texinfo-vtable-item) (defun texinfo-ftable-item () (texinfo-indextable-item 'texinfo-findex)) (defun texinfo-vtable-item () (texinfo-indextable-item 'texinfo-vindex)) (defun texinfo-indextable-item (index-type) (let ((item (texinfo-parse-arg-discard)) (itemfont (car (cdr (car texinfo-stack)))) (indexvar index-type)) (insert ?\b itemfont ?\{ item "}\n \n") (set indexvar (cons (list item texinfo-last-node) (symbol-value indexvar))) (forward-line -2))) ;; Handle @end ftable, @end vtable (put 'ftable 'texinfo-end 'texinfo-end-ftable) (put 'vtable 'texinfo-end 'texinfo-end-vtable) (defun texinfo-end-ftable () (texinfo-end-indextable 'ftable)) (defun texinfo-end-vtable () (texinfo-end-indextable 'vtable)) (defun texinfo-end-indextable (table-type) (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack table-type))) (texinfo-do-itemize (nth 1 stacktop)))) ;;; @ifinfo, @iftex, @tex (put 'ifinfo 'texinfo-format 'texinfo-discard-line) (put 'ifinfo 'texinfo-end 'texinfo-discard-command) (put 'iftex 'texinfo-format 'texinfo-format-iftex) (defun texinfo-format-iftex () (delete-region texinfo-command-start (progn (re-search-forward "@end iftex\n") (point)))) (put 'tex 'texinfo-format 'texinfo-format-tex) (defun texinfo-format-tex () (delete-region texinfo-command-start (progn (re-search-forward "@end tex\n") (point)))) ;;; @titlepage (put 'titlepage 'texinfo-format 'texinfo-format-titlepage) (defun texinfo-format-titlepage () (delete-region texinfo-command-start (progn (search-forward "@end titlepage\n") (point)))) (put 'endtitlepage 'texinfo-format 'texinfo-discard-line) ; @titlespec an alternative titling command; ignored by Info (put 'titlespec 'texinfo-format 'texinfo-format-titlespec) (defun texinfo-format-titlespec () (delete-region texinfo-command-start (progn (search-forward "@end titlespec\n") (point)))) (put 'endtitlespec 'texinfo-format 'texinfo-discard-line) ;;; @today (put 'today 'texinfo-format 'texinfo-format-today) ; Produces Day Month Year style of output. eg `1 Jan 1900' ; The `@today{}' command requires a pair of braces, like `@dots{}'. (defun texinfo-format-today () (texinfo-parse-arg-discard) (insert (format "%s %s %s" (substring (current-time-string) 8 10) (substring (current-time-string) 4 7) (substring (current-time-string) -4)))) ;;; @ignore (put 'ignore 'texinfo-format 'texinfo-format-ignore) (defun texinfo-format-ignore () (delete-region texinfo-command-start (progn (search-forward "@end ignore\n") (point)))) (put 'endignore 'texinfo-format 'texinfo-discard-line) ;;; Define the Info enclosure command: @definfoenclose ; A `@definfoenclose' command may be used to define a highlighting ; command for Info, but not for TeX. A command defined using ; `@definfoenclose' marks text by enclosing it in strings that precede ; and follow the text. ; ; Presumably, if you define a command with `@definfoenclose` for Info, ; you will also define the same command in the TeX definitions file, ; `texinfo.tex' in a manner appropriate for typesetting. ; ; Write a `@definfoenclose' command on a line and follow it with three ; arguments separated by commas (commas are used as separators in an ; `@node' line in the same way). The first argument to ; `@definfoenclose' is the @-command name \(without the `@'\); the ; second argument is the Info start delimiter string; and the third ; argument is the Info end delimiter string. The latter two arguments ; enclose the highlighted text in the Info file. A delimiter string ; may contain spaces. Neither the start nor end delimiter is ; required. However, if you do not provide a start delimiter, you ; must follow the command name with two commas in a row; otherwise, ; the Info formatting commands will misinterpret the end delimiter ; string as a start delimiter string. ; ; An enclosure command defined this way takes one argument in braces. ; ; For example, you can write: ; ; @definfoenclose phonetic, //, \\ ; ; near the beginning of a Texinfo file to define `@phonetic' as an ; Info formatting command that inserts `//' before and `\\' after the ; argument to '@phonetic'. You can then write `@phonetic{bar}' ; wherever you want `//bar\\' highlighted in Info. ; ; Similarly, you can write: ; ; @definfoenclose headword, , : ; ; near the beginning of the file, to define `@headword' as an Info ; formatting command that inserts nothing before and a colon after the ; argument to `@headword'. You can then write `@headword{foo}' ; wherever you want `foo:' highlighted in Info. (put 'definfoenclose 'texinfo-format 'texinfo-define-info-enclosure) (defun texinfo-define-info-enclosure () (let* ((args (texinfo-format-parse-line-args)) (command-name (nth 0 args)) (beginning-delimiter (or (nth 1 args) "")) (end-delimiter (or (nth 2 args) ""))) (texinfo-discard-command) (setq texinfo-enclosure-list (cons (list command-name (list beginning-delimiter end-delimiter)) texinfo-enclosure-list)))) ;;; @var, @code and the like (put 'var 'texinfo-format 'texinfo-format-var) ; @sc a small caps font for TeX; formatted as `var' in Info (put 'sc 'texinfo-format 'texinfo-format-var) (defun texinfo-format-var () (insert (upcase (texinfo-parse-arg-discard))) (goto-char texinfo-command-start)) ; various noops (put 'b 'texinfo-format 'texinfo-format-noop) (put 'i 'texinfo-format 'texinfo-format-noop) (put 'r 'texinfo-format 'texinfo-format-noop) (put 't 'texinfo-format 'texinfo-format-noop) (put 'w 'texinfo-format 'texinfo-format-noop) (put 'asis 'texinfo-format 'texinfo-format-noop) (put 'dmn 'texinfo-format 'texinfo-format-noop) (put 'key 'texinfo-format 'texinfo-format-noop) (put 'math 'texinfo-format 'texinfo-format-noop) (put 'titlefont 'texinfo-format 'texinfo-format-noop) (defun texinfo-format-noop () (insert (texinfo-parse-arg-discard)) (goto-char texinfo-command-start)) (put 'cite 'texinfo-format 'texinfo-format-code) (put 'code 'texinfo-format 'texinfo-format-code) (put 'file 'texinfo-format 'texinfo-format-code) (put 'kbd 'texinfo-format 'texinfo-format-code) (put 'samp 'texinfo-format 'texinfo-format-code) (defun texinfo-format-code () (insert "`" (texinfo-parse-arg-discard) "'") (goto-char texinfo-command-start)) (put 'emph 'texinfo-format 'texinfo-format-emph) (put 'strong 'texinfo-format 'texinfo-format-emph) (defun texinfo-format-emph () (insert "*" (texinfo-parse-arg-discard) "*") (goto-char texinfo-command-start)) (put 'dfn 'texinfo-format 'texinfo-format-defn) (put 'defn 'texinfo-format 'texinfo-format-defn) (defun texinfo-format-defn () (insert "\"" (texinfo-parse-arg-discard) "\"") (goto-char texinfo-command-start)) (put 'bullet 'texinfo-format 'texinfo-format-bullet) (defun texinfo-format-bullet () "Insert an asterisk. If used within a line, follow `@bullet' with braces." (texinfo-optional-braces-discard) (insert "*")) ;;; @example, @lisp, @quotation, @display, @smalllisp, @smallexample (put 'display 'texinfo-format 'texinfo-format-example) (put 'example 'texinfo-format 'texinfo-format-example) (put 'lisp 'texinfo-format 'texinfo-format-example) (put 'quotation 'texinfo-format 'texinfo-format-example) (put 'smallexample 'texinfo-format 'texinfo-format-example) (put 'smalllisp 'texinfo-format 'texinfo-format-example) (defun texinfo-format-example () (texinfo-push-stack 'example nil) (setq fill-column (- fill-column 5)) (texinfo-discard-line)) (put 'example 'texinfo-end 'texinfo-end-example) (put 'display 'texinfo-end 'texinfo-end-example) (put 'lisp 'texinfo-end 'texinfo-end-example) (put 'quotation 'texinfo-end 'texinfo-end-example) (put 'smallexample 'texinfo-end 'texinfo-end-example) (put 'smalllisp 'texinfo-end 'texinfo-end-example) (defun texinfo-end-example () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'example))) (texinfo-do-itemize (nth 1 stacktop)))) (put 'exdent 'texinfo-format 'texinfo-format-exdent) (defun texinfo-format-exdent () (texinfo-discard-command) (delete-region (point) (progn (skip-chars-forward " ") (point))) (insert ?\b) ;; Cancel out the deletion that texinfo-do-itemize ;; is going to do at the end of this line. (save-excursion (end-of-line) (insert "\n "))) ;;; @cartouche ; The @cartouche command is a noop in Info; in a printed manual, ; it makes a box with rounded corners. (put 'cartouche 'texinfo-format 'texinfo-discard-line) (put 'cartouche 'texinfo-end 'texinfo-discard-command) ;;; @flushleft and @format ; The @flushleft command left justifies every line but leaves the ; right end ragged. As far as Info is concerned, @flushleft is a ; `do-nothing' command ; The @format command is similar to @example except that it does not ; indent; this means that in Info, @format is similar to @flushleft. (put 'format 'texinfo-format 'texinfo-format-flushleft) (put 'flushleft 'texinfo-format 'texinfo-format-flushleft) (defun texinfo-format-flushleft () (texinfo-discard-line)) (put 'format 'texinfo-end 'texinfo-end-flushleft) (put 'flushleft 'texinfo-end 'texinfo-end-flushleft) (defun texinfo-end-flushleft () (texinfo-discard-command)) ;;; @flushright ; The @flushright command right justifies every line but leaves the ; left end ragged. Spaces and tabs at the right ends of lines are ; removed so that visible text lines up on the right side. (put 'flushright 'texinfo-format 'texinfo-format-flushright) (defun texinfo-format-flushright () (texinfo-push-stack 'flushright nil) (texinfo-discard-line)) (put 'flushright 'texinfo-end 'texinfo-end-flushright) (defun texinfo-end-flushright () (texinfo-discard-command) (let ((stacktop (texinfo-pop-stack 'flushright))) (texinfo-do-flushright (nth 1 stacktop)))) (defun texinfo-do-flushright (from) (save-excursion (while (progn (forward-line -1) (>= (point) from)) (beginning-of-line) (insert (make-string (- fill-column (save-excursion (end-of-line) (skip-chars-backward " \t") (delete-region (point) (progn (end-of-line) (point))) (current-column))) ? ))))) ;;; @ctrl, @TeX, @copyright, @minus, @dots (put 'ctrl 'texinfo-format 'texinfo-format-ctrl) (defun texinfo-format-ctrl () (let ((str (texinfo-parse-arg-discard))) (insert (logand 31 (aref str 0))))) (put 'TeX 'texinfo-format 'texinfo-format-TeX) (defun texinfo-format-TeX () (texinfo-parse-arg-discard) (insert "TeX")) (put 'copyright 'texinfo-format 'texinfo-format-copyright) (defun texinfo-format-copyright () (texinfo-parse-arg-discard) (insert "(C)")) (put 'minus 'texinfo-format 'texinfo-format-minus) (defun texinfo-format-minus () "Insert a minus sign. If used within a line, follow `@minus' with braces." (texinfo-optional-braces-discard) (insert "-")) (put 'dots 'texinfo-format 'texinfo-format-dots) (defun texinfo-format-dots () (texinfo-parse-arg-discard) (insert "...")) ;;; Refilling and indenting: @refill, @paragraphindent, @noindent ;;; Indent only those paragraphs that are refilled as a result of an ;;; @refill command. ; * If the value is `asis', do not change the existing indentation at ; the starts of paragraphs. ; * If the value zero, delete any existing indentation. ; * If the value is greater than zero, indent each paragraph by that ; number of spaces. ;;; But do not refill paragraphs with an @refill command that are ;;; preceded by @noindent or are part of a table, list, or deffn. (defvar texinfo-paragraph-indent "asis" "Number of spaces for @refill to indent a paragraph; else to leave as is.") (put 'paragraphindent 'texinfo-format 'texinfo-paragraphindent) (defun texinfo-paragraphindent () "Specify the number of spaces for @refill to indent a paragraph. Default is to leave the number of spaces as is." (let ((arg (texinfo-parse-arg-discard))) (if (string= "asis" arg) (setq texinfo-paragraph-indent "asis") (setq texinfo-paragraph-indent (string-to-int arg))))) (put 'refill 'texinfo-format 'texinfo-format-refill) (defun texinfo-format-refill () "Refill paragraph. Also, indent first line as set by @paragraphindent. Default is to leave paragraph indentation as is." (texinfo-discard-command) (forward-paragraph -1) (if (looking-at "[ \t\n]*$") (forward-line 1)) ;; Do not indent if an entry in a list, table, or deffn, ;; or if paragraph is preceded by @noindent. ;; Otherwise, indent (cond ;; delete a @noindent line and do not indent paragraph ((save-excursion (forward-line -1) (looking-at "^@noindent")) (forward-line -1) (delete-region (point) (progn (forward-line 1) (point)))) ;; do nothing if "asis" ((equal texinfo-paragraph-indent "asis")) ;; do no indenting in list, etc. ((> texinfo-stack-depth 0)) ;; otherwise delete existing whitespace and indent (t (delete-region (point) (progn (skip-chars-forward " \t") (point))) (insert (make-string texinfo-paragraph-indent ? )))) (forward-paragraph 1) (forward-line -1) (end-of-line) (fill-paragraph nil)) (put 'noindent 'texinfo-format 'texinfo-noindent) (defun texinfo-noindent () (save-excursion (forward-paragraph 1) (if (search-backward "@refill" (save-excursion (forward-line -1) (point)) t) () ; leave @noindent command so @refill command knows not to indent ;; else (texinfo-discard-line)))) ;;; Index generation (put 'vindex 'texinfo-format 'texinfo-format-vindex) (defun texinfo-format-vindex () (texinfo-index 'texinfo-vindex)) (put 'cindex 'texinfo-format 'texinfo-format-cindex) (defun texinfo-format-cindex () (texinfo-index 'texinfo-cindex)) (put 'findex 'texinfo-format 'texinfo-format-findex) (defun texinfo-format-findex () (texinfo-index 'texinfo-findex)) (put 'pindex 'texinfo-format 'texinfo-format-pindex) (defun texinfo-format-pindex () (texinfo-index 'texinfo-pindex)) (put 'tindex 'texinfo-format 'texinfo-format-tindex) (defun texinfo-format-tindex () (texinfo-index 'texinfo-tindex)) (put 'kindex 'texinfo-format 'texinfo-format-kindex) (defun texinfo-format-kindex () (texinfo-index 'texinfo-kindex)) (defun texinfo-index (indexvar) (let ((arg (texinfo-parse-expanded-arg))) (texinfo-discard-command) (set indexvar (cons (list arg texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value indexvar))))) (defconst texinfo-indexvar-alist '(("cp" . texinfo-cindex) ("fn" . texinfo-findex) ("vr" . texinfo-vindex) ("tp" . texinfo-tindex) ("pg" . texinfo-pindex) ("ky" . texinfo-kindex))) ;;; @defindex @defcodeindex (put 'defindex 'texinfo-format 'texinfo-format-defindex) (put 'defcodeindex 'texinfo-format 'texinfo-format-defindex) (defun texinfo-format-defindex () (let* ((index-name (texinfo-parse-arg-discard)) ; eg: `aa' (indexing-command (intern (concat index-name "index"))) (index-formatting-command ; eg: `texinfo-format-aaindex' (intern (concat "texinfo-format-" index-name "index"))) (index-alist-name ; eg: `texinfo-aaindex' (intern (concat "texinfo-" index-name "index")))) (set index-alist-name nil) (put indexing-command ; eg, aaindex 'texinfo-format index-formatting-command) ; eg, texinfo-format-aaindex ;; eg: "aa" . texinfo-aaindex (or (assoc index-name texinfo-indexvar-alist) (setq texinfo-indexvar-alist (cons (cons index-name index-alist-name) texinfo-indexvar-alist))) (fset index-formatting-command (list 'lambda 'nil (list 'texinfo-index (list 'quote index-alist-name)))))) ;;; @synindex @syncodeindex (put 'synindex 'texinfo-format 'texinfo-format-synindex) (put 'syncodeindex 'texinfo-format 'texinfo-format-synindex) (defun texinfo-format-synindex () (let* ((args (texinfo-parse-arg-discard)) (second (cdr (read-from-string args))) (joiner (symbol-name (car (read-from-string args)))) (joined (symbol-name (car (read-from-string args second))))) (if (assoc joiner texinfo-short-index-cmds-alist) (put (cdr (assoc joiner texinfo-short-index-cmds-alist)) 'texinfo-format (or (cdr (assoc joined texinfo-short-index-format-cmds-alist)) (intern (concat "texinfo-format-" joined "index")))) (put (intern (concat joiner "index")) 'texinfo-format (or (cdr(assoc joined texinfo-short-index-format-cmds-alist)) (intern (concat "texinfo-format-" joined "index"))))))) (defconst texinfo-short-index-cmds-alist '(("cp" . cindex) ("fn" . findex) ("vr" . vindex) ("tp" . tindex) ("pg" . pindex) ("ky" . kindex))) (defconst texinfo-short-index-format-cmds-alist '(("cp" . texinfo-format-cindex) ("fn" . texinfo-format-findex) ("vr" . texinfo-format-vindex) ("tp" . texinfo-format-tindex) ("pg" . texinfo-format-pindex) ("ky" . texinfo-format-kindex))) ;;; Sort and index (for VMS) ;; Sort an index which is in the current buffer between START and END. ;; Used on VMS, where the `sort' utility is not available. (defun texinfo-sort-region (start end) (require 'sort) (save-restriction (narrow-to-region start end) (sort-subr nil 'forward-line 'end-of-line 'texinfo-sort-startkeyfun))) ;; Subroutine for sorting an index. ;; At start of a line, return a string to sort the line under. (defun texinfo-sort-startkeyfun () (let ((line (buffer-substring (point) (save-excursion (end-of-line) (point))))) ;; Canonicalize whitespace and eliminate funny chars. (while (string-match "[ \t][ \t]+\\|[^a-z0-9 ]+" line) (setq line (concat (substring line 0 (match-beginning 0)) " " (substring line (match-end 0) (length line))))) line)) ;;; @printindex (put 'printindex 'texinfo-format 'texinfo-format-printindex) (defun texinfo-format-printindex () (let ((indexelts (symbol-value (cdr (assoc (texinfo-parse-arg-discard) texinfo-indexvar-alist)))) opoint) (insert "\n* Menu:\n\n") (setq opoint (point)) (texinfo-print-index nil indexelts) (if (eq system-type 'vax-vms) (texinfo-sort-region opoint (point)) (shell-command-on-region opoint (point) "sort -fd" 1)))) (defun texinfo-print-index (file indexelts) (while indexelts (if (stringp (car (car indexelts))) (progn (insert "* " (car (car indexelts)) ": " ) (indent-to 32) (insert (if file (concat "(" file ")") "") (nth 1 (car indexelts)) ".") (indent-to 54) (insert (if (nth 2 (car indexelts)) (format " %d." (nth 2 (car indexelts))) "") "\n")) ;; index entries from @include'd file (texinfo-print-index (nth 1 (car indexelts)) (nth 2 (car indexelts)))) (setq indexelts (cdr indexelts)))) ;;; Glyphs: @equiv, @error, etc ;; @equiv to show that two expressions are equivalent ;; @error to show an error message ;; @expansion to show what a macro expands to ;; @point to show the location of point in an example ;; @print to show what an evaluated expression prints ;; @result to indicate the value returned by an expression (put 'equiv 'texinfo-format 'texinfo-format-equiv) (defun texinfo-format-equiv () (texinfo-parse-arg-discard) (insert "==")) (put 'error 'texinfo-format 'texinfo-format-error) (defun texinfo-format-error () (texinfo-parse-arg-discard) (insert "error-->")) (put 'expansion 'texinfo-format 'texinfo-format-expansion) (defun texinfo-format-expansion () (texinfo-parse-arg-discard) (insert "==>")) (put 'point 'texinfo-format 'texinfo-format-point) (defun texinfo-format-point () (texinfo-parse-arg-discard) (insert "-!-")) (put 'print 'texinfo-format 'texinfo-format-print) (defun texinfo-format-print () (texinfo-parse-arg-discard) (insert "-|")) (put 'result 'texinfo-format 'texinfo-format-result) (defun texinfo-format-result () (texinfo-parse-arg-discard) (insert "=>")) ;;; Definition formatting: @deffn, @defun, etc ;; What definition formatting produces: ;; ;; @deffn category name args... ;; In Info, `Category: name ARGS' ;; In index: name: node. line#. ;; ;; @defvr category name ;; In Info, `Category: name' ;; In index: name: node. line#. ;; ;; @deftp category name attributes... ;; `category name attributes...' Note: @deftp args in lower case. ;; In index: name: node. line#. ;; ;; Specialized function-like or variable-like entity: ;; ;; @defun, @defmac, @defspec, @defvar, @defopt ;; ;; @defun name args In Info, `Function: name ARGS' ;; @defmac name args In Info, `Macro: name ARGS' ;; @defvar name In Info, `Variable: name' ;; etc. ;; In index: name: node. line#. ;; ;; Generalized typed-function-like or typed-variable-like entity: ;; @deftypefn category data-type name args... ;; In Info, `Category: data-type name args...' ;; @deftypevr category data-type name ;; In Info, `Category: data-type name' ;; In index: name: node. line#. ;; ;; Specialized typed-function-like or typed-variable-like entity: ;; @deftypefun data-type name args... ;; In Info, `Function: data-type name ARGS' ;; In index: name: node. line#. ;; ;; @deftypevar data-type name ;; In Info, `Variable: data-type name' ;; In index: name: node. line#. but include args after name!? ;; ;; Generalized object oriented entity: ;; @defop category class name args... ;; In Info, `Category on class: name ARG' ;; In index: name on class: node. line#. ;; ;; @defcv category class name ;; In Info, `Category of class: name' ;; In index: name of class: node. line#. ;; ;; Specialized object oriented entity: ;; @defmethod class name args... ;; In Info, `Method on class: name ARGS' ;; In index: name on class: node. line#. ;; ;; @defivar class name ;; In Info, `Instance variable of class: name' ;; In index: name of class: node. line#. ;;; The definition formatting functions (defun texinfo-format-defun () (texinfo-push-stack 'defun nil) (setq fill-column (- fill-column 5)) (texinfo-format-defun-1 t)) (defun texinfo-end-defun () (setq fill-column (+ fill-column 5)) (texinfo-discard-command) (let ((start (nth 1 (texinfo-pop-stack 'defun)))) (texinfo-do-itemize start) ;; Delete extra newline inserted after header. (save-excursion (goto-char start) (delete-char -1)))) (defun texinfo-format-defunx () (texinfo-format-defun-1 nil)) (defun texinfo-format-defun-1 (first-p) (let ((parse-args (texinfo-format-parse-defun-args)) (command-type (get texinfo-command-name 'texinfo-defun-type))) (texinfo-discard-command) ;; Delete extra newline inserted after previous header line. (if (not first-p) (delete-char -1)) (funcall (get texinfo-command-name 'texinfo-deffn-formatting-property) parse-args) ;; Insert extra newline so that paragraph filling does not mess ;; with header line. (insert "\n\n") (rplaca (cdr (cdr (car texinfo-stack))) (point)) (funcall (get texinfo-command-name 'texinfo-defun-indexing-property) parse-args))) ;;; Formatting the first line of a definition ;; @deffn, @defvr, @deftp (put 'deffn 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (put 'deffnx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (put 'defvr 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (put 'defvrx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (put 'deftp 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (put 'deftpx 'texinfo-deffn-formatting-property 'texinfo-format-deffn) (defun texinfo-format-deffn (parsed-args) ;; Generalized function-like, variable-like, or generic data-type entity: ;; @deffn category name args... ;; In Info, `Category: name ARGS' ;; @deftp category name attributes... ;; `category name attributes...' Note: @deftp args in lower case. (let ((category (car parsed-args)) (name (car (cdr parsed-args))) (args (cdr (cdr parsed-args)))) (insert " -- " category ": " name) (while args (insert " " (if (or (= ?& (aref (car args) 0)) (eq (eval (car command-type)) 'deftp-type)) (car args) (upcase (car args)))) (setq args (cdr args))))) ;; @defun, @defmac, @defspec, @defvar, @defopt: Specialized, simple (put 'defun 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defunx 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defmac 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defmacx 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defspec 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defspecx 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defvar 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defvarx 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defopt 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (put 'defoptx 'texinfo-deffn-formatting-property 'texinfo-format-specialized-defun) (defun texinfo-format-specialized-defun (parsed-args) ;; Specialized function-like or variable-like entity: ;; @defun name args In Info, `Function: Name ARGS' ;; @defmac name args In Info, `Macro: Name ARGS' ;; @defvar name In Info, `Variable: Name' ;; Use cdr of command-type to determine category: (let ((category (car (cdr command-type))) (name (car parsed-args)) (args (cdr parsed-args))) (insert " -- " category ": " name) (while args (insert " " (if (= ?& (aref (car args) 0)) (car args) (upcase (car args)))) (setq args (cdr args))))) ;; @deftypefn, @deftypevr: Generalized typed (put 'deftypefn 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) (put 'deftypefnx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) (put 'deftypevr 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) (put 'deftypevrx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefn) (defun texinfo-format-deftypefn (parsed-args) ;; Generalized typed-function-like or typed-variable-like entity: ;; @deftypefn category data-type name args... ;; In Info, `Category: data-type name args...' ;; @deftypevr category data-type name ;; In Info, `Category: data-type name' ;; Note: args in lower case, unless modified in command line. (let ((category (car parsed-args)) (data-type (car (cdr parsed-args))) (name (car (cdr (cdr parsed-args)))) (args (cdr (cdr (cdr parsed-args))))) (insert " -- " category ": " data-type " " name) (while args (insert " " (car args)) (setq args (cdr args))))) ;; @deftypefun, @deftypevar: Specialized typed (put 'deftypefun 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) (put 'deftypefunx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) (put 'deftypevar 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) (put 'deftypevarx 'texinfo-deffn-formatting-property 'texinfo-format-deftypefun) (defun texinfo-format-deftypefun (parsed-args) ;; Specialized typed-function-like or typed-variable-like entity: ;; @deftypefun data-type name args... ;; In Info, `Function: data-type name ARGS' ;; @deftypevar data-type name ;; In Info, `Variable: data-type name' ;; Note: args in lower case, unless modified in command line. ;; Use cdr of command-type to determine category: (let ((category (car (cdr command-type))) (data-type (car parsed-args)) (name (car (cdr parsed-args))) (args (cdr (cdr parsed-args)))) (insert " -- " category ": " data-type " " name) (while args (insert " " (car args)) (setq args (cdr args))))) ;; @defop: Generalized object-oriented (put 'defop 'texinfo-deffn-formatting-property 'texinfo-format-defop) (put 'defopx 'texinfo-deffn-formatting-property 'texinfo-format-defop) (defun texinfo-format-defop (parsed-args) ;; Generalized object oriented entity: ;; @defop category class name args... ;; In Info, `Category on class: name ARG' ;; Note: args in upper case; use of `on' (let ((category (car parsed-args)) (class (car (cdr parsed-args))) (name (car (cdr (cdr parsed-args)))) (args (cdr (cdr (cdr parsed-args))))) (insert " -- " category " on " class ": " name) (while args (insert " " (upcase (car args))) (setq args (cdr args))))) ;; @defcv: Generalized object-oriented (put 'defcv 'texinfo-deffn-formatting-property 'texinfo-format-defcv) (put 'defcvx 'texinfo-deffn-formatting-property 'texinfo-format-defcv) (defun texinfo-format-defcv (parsed-args) ;; Generalized object oriented entity: ;; @defcv category class name ;; In Info, `Category of class: name' ;; Note: args in upper case; use of `of' (let ((category (car parsed-args)) (class (car (cdr parsed-args))) (name (car (cdr (cdr parsed-args)))) (args (cdr (cdr (cdr parsed-args))))) (insert " -- " category " of " class ": " name) (while args (insert " " (upcase (car args))) (setq args (cdr args))))) ;; @defmethod: Specialized object-oriented (put 'defmethod 'texinfo-deffn-formatting-property 'texinfo-format-defmethod) (put 'defmethodx 'texinfo-deffn-formatting-property 'texinfo-format-defmethod) (defun texinfo-format-defmethod (parsed-args) ;; Specialized object oriented entity: ;; @defmethod class name args... ;; In Info, `Method on class: name ARGS' ;; Note: args in upper case; use of `on' ;; Use cdr of command-type to determine category: (let ((category (car (cdr command-type))) (class (car parsed-args)) (name (car (cdr parsed-args))) (args (cdr (cdr parsed-args)))) (insert " -- " category " on " class ": " name) (while args (insert " " (upcase (car args))) (setq args (cdr args))))) ;; @defivar: Specialized object-oriented (put 'defivar 'texinfo-deffn-formatting-property 'texinfo-format-defivar) (put 'defivarx 'texinfo-deffn-formatting-property 'texinfo-format-defivar) (defun texinfo-format-defivar (parsed-args) ;; Specialized object oriented entity: ;; @defivar class name ;; In Info, `Instance variable of class: name' ;; Note: args in upper case; use of `of' ;; Use cdr of command-type to determine category: (let ((category (car (cdr command-type))) (class (car parsed-args)) (name (car (cdr parsed-args))) (args (cdr (cdr parsed-args)))) (insert " -- " category " of " class ": " name) (while args (insert " " (upcase (car args))) (setq args (cdr args))))) ;;; Indexing for definitions ;; An index entry has three parts: the `entry proper', the node name, and the ;; line number. Depending on the which command is used, the entry is ;; formatted differently: ;; ;; @defun, ;; @defmac, ;; @defspec, ;; @defvar, ;; @defopt all use their 1st argument as the entry-proper ;; ;; @deffn, ;; @defvr, ;; @deftp ;; @deftypefun ;; @deftypevar all use their 2nd argument as the entry-proper ;; ;; @deftypefn, ;; @deftypevr both use their 3rd argument as the entry-proper ;; ;; @defmethod uses its 2nd and 1st arguments as an entry-proper ;; formatted: NAME on CLASS ;; @defop uses its 3rd and 2nd arguments as an entry-proper ;; formatted: NAME on CLASS ;; ;; @defivar uses its 2nd and 1st arguments as an entry-proper ;; formatted: NAME of CLASS ;; ;; @defcv uses its 3rd and 2nd argument as an entry-proper ;; formatted: NAME of CLASS (put 'defun 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defunx 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defmac 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defmacx 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defspec 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defspecx 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defvar 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defvarx 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defopt 'texinfo-defun-indexing-property 'texinfo-index-defun) (put 'defoptx 'texinfo-defun-indexing-property 'texinfo-index-defun) (defun texinfo-index-defun (parsed-args) ;; use 1st parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (car parsed-args) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'deffn 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deffnx 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'defvr 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'defvrx 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftp 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftpx 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftypefun 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftypefunx 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftypevar 'texinfo-defun-indexing-property 'texinfo-index-deffn) (put 'deftypevarx 'texinfo-defun-indexing-property 'texinfo-index-deffn) (defun texinfo-index-deffn (parsed-args) ;; use 2nd parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (car (cdr parsed-args)) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'deftypefn 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) (put 'deftypefnx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) (put 'deftypevr 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) (put 'deftypevrx 'texinfo-defun-indexing-property 'texinfo-index-deftypefn) (defun texinfo-index-deftypefn (parsed-args) ;; use 3rd parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (car (cdr (cdr parsed-args))) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'defmethod 'texinfo-defun-indexing-property 'texinfo-index-defmethod) (put 'defmethodx 'texinfo-defun-indexing-property 'texinfo-index-defmethod) (defun texinfo-index-defmethod (parsed-args) ;; use 2nd on 1st parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (format "%s on %s" (car (cdr parsed-args)) (car parsed-args)) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'defop 'texinfo-defun-indexing-property 'texinfo-index-defop) (put 'defopx 'texinfo-defun-indexing-property 'texinfo-index-defop) (defun texinfo-index-defop (parsed-args) ;; use 3rd on 2nd parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (format "%s on %s" (car (cdr (cdr parsed-args))) (car (cdr parsed-args))) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'defivar 'texinfo-defun-indexing-property 'texinfo-index-defivar) (put 'defivarx 'texinfo-defun-indexing-property 'texinfo-index-defivar) (defun texinfo-index-defivar (parsed-args) ;; use 2nd of 1st parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (format "%s of %s" (car (cdr parsed-args)) (car parsed-args)) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) (put 'defcv 'texinfo-defun-indexing-property 'texinfo-index-defcv) (put 'defcvx 'texinfo-defun-indexing-property 'texinfo-index-defcv) (defun texinfo-index-defcv (parsed-args) ;; use 3rd of 2nd parsed-arg as entry-proper ;; `index-list' will be texinfo-findex or the like (let ((index-list (get texinfo-command-name 'texinfo-defun-index))) (set index-list (cons ;; Three elements: entry-proper, node-name, line-number (list (format "%s of %s" (car (cdr (cdr parsed-args))) (car (cdr parsed-args))) texinfo-last-node ;; Region formatting may not provide last node position. (if texinfo-last-node-pos (1+ (count-lines texinfo-last-node-pos (point))) 1)) (symbol-value index-list))))) ;;; Properties for definitions ;; Each definition command has six properties: ;; ;; 1. texinfo-deffn-formatting-property to format definition line ;; 2. texinfo-defun-indexing-property to create index entry ;; 3. texinfo-format formatting command ;; 4. texinfo-end end formatting command ;; 5. texinfo-defun-type type of deffn to format ;; 6. texinfo-defun-index type of index to use ;; ;; The `x' forms of each definition command are used for the second ;; and subsequent header lines. ;; The texinfo-deffn-formatting-property and texinfo-defun-indexing-property ;; are listed just before the appropriate formatting and indexing commands. (put 'deffn 'texinfo-format 'texinfo-format-defun) (put 'deffnx 'texinfo-format 'texinfo-format-defunx) (put 'deffn 'texinfo-end 'texinfo-end-defun) (put 'deffn 'texinfo-defun-type '('deffn-type nil)) (put 'deffnx 'texinfo-defun-type '('deffn-type nil)) (put 'deffn 'texinfo-defun-index 'texinfo-findex) (put 'deffnx 'texinfo-defun-index 'texinfo-findex) (put 'defun 'texinfo-format 'texinfo-format-defun) (put 'defunx 'texinfo-format 'texinfo-format-defunx) (put 'defun 'texinfo-end 'texinfo-end-defun) (put 'defun 'texinfo-defun-type '('defun-type "Function")) (put 'defunx 'texinfo-defun-type '('defun-type "Function")) (put 'defun 'texinfo-defun-index 'texinfo-findex) (put 'defunx 'texinfo-defun-index 'texinfo-findex) (put 'defmac 'texinfo-format 'texinfo-format-defun) (put 'defmacx 'texinfo-format 'texinfo-format-defunx) (put 'defmac 'texinfo-end 'texinfo-end-defun) (put 'defmac 'texinfo-defun-type '('defun-type "Macro")) (put 'defmacx 'texinfo-defun-type '('defun-type "Macro")) (put 'defmac 'texinfo-defun-index 'texinfo-findex) (put 'defmacx 'texinfo-defun-index 'texinfo-findex) (put 'defspec 'texinfo-format 'texinfo-format-defun) (put 'defspecx 'texinfo-format 'texinfo-format-defunx) (put 'defspec 'texinfo-end 'texinfo-end-defun) (put 'defspec 'texinfo-defun-type '('defun-type "Special form")) (put 'defspecx 'texinfo-defun-type '('defun-type "Special form")) (put 'defspec 'texinfo-defun-index 'texinfo-findex) (put 'defspecx 'texinfo-defun-index 'texinfo-findex) (put 'defvr 'texinfo-format 'texinfo-format-defun) (put 'defvrx 'texinfo-format 'texinfo-format-defunx) (put 'defvr 'texinfo-end 'texinfo-end-defun) (put 'defvr 'texinfo-defun-type '('deffn-type nil)) (put 'defvrx 'texinfo-defun-type '('deffn-type nil)) (put 'defvr 'texinfo-defun-index 'texinfo-vindex) (put 'defvrx 'texinfo-defun-index 'texinfo-vindex) (put 'defvar 'texinfo-format 'texinfo-format-defun) (put 'defvarx 'texinfo-format 'texinfo-format-defunx) (put 'defvar 'texinfo-end 'texinfo-end-defun) (put 'defvar 'texinfo-defun-type '('defun-type "Variable")) (put 'defvarx 'texinfo-defun-type '('defun-type "Variable")) (put 'defvar 'texinfo-defun-index 'texinfo-vindex) (put 'defvarx 'texinfo-defun-index 'texinfo-vindex) (put 'defconst 'texinfo-format 'texinfo-format-defun) (put 'defconstx 'texinfo-format 'texinfo-format-defunx) (put 'defconst 'texinfo-end 'texinfo-end-defun) (put 'defconst 'texinfo-defun-type '('defun-type "Constant")) (put 'defconstx 'texinfo-defun-type '('defun-type "Constant")) (put 'defconst 'texinfo-defun-index 'texinfo-vindex) (put 'defconstx 'texinfo-defun-index 'texinfo-vindex) (put 'defcmd 'texinfo-format 'texinfo-format-defun) (put 'defcmdx 'texinfo-format 'texinfo-format-defunx) (put 'defcmd 'texinfo-end 'texinfo-end-defun) (put 'defcmd 'texinfo-defun-type '('defun-type "Command")) (put 'defcmdx 'texinfo-defun-type '('defun-type "Command")) (put 'defcmd 'texinfo-defun-index 'texinfo-findex) (put 'defcmdx 'texinfo-defun-index 'texinfo-findex) (put 'defopt 'texinfo-format 'texinfo-format-defun) (put 'defoptx 'texinfo-format 'texinfo-format-defunx) (put 'defopt 'texinfo-end 'texinfo-end-defun) (put 'defopt 'texinfo-defun-type '('defun-type "User Option")) (put 'defoptx 'texinfo-defun-type '('defun-type "User Option")) (put 'defopt 'texinfo-defun-index 'texinfo-vindex) (put 'defoptx 'texinfo-defun-index 'texinfo-vindex) (put 'deftp 'texinfo-format 'texinfo-format-defun) (put 'deftpx 'texinfo-format 'texinfo-format-defunx) (put 'deftp 'texinfo-end 'texinfo-end-defun) (put 'deftp 'texinfo-defun-type '('deftp-type nil)) (put 'deftpx 'texinfo-defun-type '('deftp-type nil)) (put 'deftp 'texinfo-defun-index 'texinfo-tindex) (put 'deftpx 'texinfo-defun-index 'texinfo-tindex) ;;; Object-oriented stuff is a little hairier. (put 'defop 'texinfo-format 'texinfo-format-defun) (put 'defopx 'texinfo-format 'texinfo-format-defunx) (put 'defop 'texinfo-end 'texinfo-end-defun) (put 'defop 'texinfo-defun-type '('defop-type nil)) (put 'defopx 'texinfo-defun-type '('defop-type nil)) (put 'defop 'texinfo-defun-index 'texinfo-findex) (put 'defopx 'texinfo-defun-index 'texinfo-findex) (put 'defmethod 'texinfo-format 'texinfo-format-defun) (put 'defmethodx 'texinfo-format 'texinfo-format-defunx) (put 'defmethod 'texinfo-end 'texinfo-end-defun) (put 'defmethod 'texinfo-defun-type '('defmethod-type "Method")) (put 'defmethodx 'texinfo-defun-type '('defmethod-type "Method")) (put 'defmethod 'texinfo-defun-index 'texinfo-findex) (put 'defmethodx 'texinfo-defun-index 'texinfo-findex) (put 'defcv 'texinfo-format 'texinfo-format-defun) (put 'defcvx 'texinfo-format 'texinfo-format-defunx) (put 'defcv 'texinfo-end 'texinfo-end-defun) (put 'defcv 'texinfo-defun-type '('defop-type nil)) (put 'defcvx 'texinfo-defun-type '('defop-type nil)) (put 'defcv 'texinfo-defun-index 'texinfo-vindex) (put 'defcvx 'texinfo-defun-index 'texinfo-vindex) (put 'defivar 'texinfo-format 'texinfo-format-defun) (put 'defivarx 'texinfo-format 'texinfo-format-defunx) (put 'defivar 'texinfo-end 'texinfo-end-defun) (put 'defivar 'texinfo-defun-type '('defmethod-type "Instance variable")) (put 'defivarx 'texinfo-defun-type '('defmethod-type "Instance variable")) (put 'defivar 'texinfo-defun-index 'texinfo-vindex) (put 'defivarx 'texinfo-defun-index 'texinfo-vindex) ;;; Typed functions and variables (put 'deftypefn 'texinfo-format 'texinfo-format-defun) (put 'deftypefnx 'texinfo-format 'texinfo-format-defunx) (put 'deftypefn 'texinfo-end 'texinfo-end-defun) (put 'deftypefn 'texinfo-defun-type '('deftypefn-type nil)) (put 'deftypefnx 'texinfo-defun-type '('deftypefn-type nil)) (put 'deftypefn 'texinfo-defun-index 'texinfo-findex) (put 'deftypefnx 'texinfo-defun-index 'texinfo-findex) (put 'deftypefun 'texinfo-format 'texinfo-format-defun) (put 'deftypefunx 'texinfo-format 'texinfo-format-defunx) (put 'deftypefun 'texinfo-end 'texinfo-end-defun) (put 'deftypefun 'texinfo-defun-type '('deftypefun-type "Function")) (put 'deftypefunx 'texinfo-defun-type '('deftypefun-type "Function")) (put 'deftypefun 'texinfo-defun-index 'texinfo-findex) (put 'deftypefunx 'texinfo-defun-index 'texinfo-findex) (put 'deftypevr 'texinfo-format 'texinfo-format-defun) (put 'deftypevrx 'texinfo-format 'texinfo-format-defunx) (put 'deftypevr 'texinfo-end 'texinfo-end-defun) (put 'deftypevr 'texinfo-defun-type '('deftypefn-type nil)) (put 'deftypevrx 'texinfo-defun-type '('deftypefn-type nil)) (put 'deftypevr 'texinfo-defun-index 'texinfo-vindex) (put 'deftypevrx 'texinfo-defun-index 'texinfo-vindex) (put 'deftypevar 'texinfo-format 'texinfo-format-defun) (put 'deftypevarx 'texinfo-format 'texinfo-format-defunx) (put 'deftypevar 'texinfo-end 'texinfo-end-defun) (put 'deftypevar 'texinfo-defun-type '('deftypevar-type "Variable")) (put 'deftypevarx 'texinfo-defun-type '('deftypevar-type "Variable")) (put 'deftypevar 'texinfo-defun-index 'texinfo-vindex) (put 'deftypevarx 'texinfo-defun-index 'texinfo-vindex) ;;; @set, @clear, @ifset, @ifclear ;; If a flag is set with @set FLAG, then text between @ifset and @end ;; ifset is formatted normally, but if the flag is is cleared with ;; @clear FLAG, then the text is not formatted; it is ignored. ;; If a flag is cleared with @clear FLAG, then text between @ifclear ;; and @end ifclear is formatted normally, but if the flag is is set with ;; @set FLAG, then the text is not formatted; it is ignored. @ifclear ;; is the opposite of @ifset. (put 'clear 'texinfo-format 'texinfo-clear) (defun texinfo-clear () "Clear the value of the flag." (let ((arg (texinfo-parse-arg-discard))) (make-local-variable (intern arg)) (set (intern arg) nil))) (put 'set 'texinfo-format 'texinfo-set) (defun texinfo-set () "Set the value of the flag." (let ((arg (texinfo-parse-arg-discard))) (make-local-variable (intern arg)) (set (intern arg) t))) (put 'ifset 'texinfo-end 'texinfo-discard-command) (put 'ifset 'texinfo-format 'texinfo-if-set) (defun texinfo-if-set () "If set, continue formatting; else do not format region up to @end ifset" (let ((arg (texinfo-parse-line-arg))) (if (not (boundp (intern arg))) (error "@ifset flag `%s' is not defined by @set." arg)) (texinfo-discard-command) (if (symbol-value (intern arg)) ;; (message "%s is true." arg) () ;; (message "%s is false." arg) (delete-region texinfo-command-start (progn (re-search-forward "@end ifset[ \t]*\n") (point)))))) (put 'ifclear 'texinfo-end 'texinfo-discard-command) (put 'ifclear 'texinfo-format 'texinfo-if-clear) (defun texinfo-if-clear () "If clear, do not format up to @end ifclear; else continue formatting." (let ((arg (texinfo-parse-line-arg))) (if (not (boundp (intern arg))) (error "@ifclear flag `%s' is not defined by @clear or @set." arg)) (texinfo-discard-command) (if (symbol-value (intern arg)) (delete-region texinfo-command-start (progn (re-search-forward "@end ifclear[ \t]*\n") (point)))))) ;;; Process included files: `@include' command ;; Updated 19 October 1990 ;; In the original version, include files were ignored by Info but ;; incorporated in to the printed manual. To make references to the ;; included file, the Texinfo source file has to refer to the included ;; files using the `(filename)nodename' format for refering to other ;; Info files. Also, the included files had to be formatted on their ;; own. It was just like they were another file. ;; Currently, include files are inserted into the buffer that is ;; formatted for Info. If large, the resulting info file is split and ;; tagified. For current include files to work, the master menu must ;; refer to all the nodes, and the highest level nodes in the include ;; files must have the correct next, prev, and up pointers. ;; The included file may have an @setfilename and even an @settitle, ;; but not an /input texinfo ; Original definition: ; (defun texinfo-format-include () ; (let ((filename (texinfo-parse-arg-discard)) ; (default-directory input-directory) ; subindex) ; (setq subindex ; (save-excursion ; (progn (find-file ; (cond ((file-readable-p (concat filename ".texinfo")) ; (concat filename ".texinfo")) ; ((file-readable-p (concat filename ".texi")) ; (concat filename ".texi")) ; ((file-readable-p (concat filename ".tex")) ; (concat filename ".tex")) ; ((file-readable-p filename) ; filename) ; (t (error "@include'd file %s not found" ; filename)))) ; (texinfo-format-buffer-1)))) ; (texinfo-subindex 'texinfo-vindex (car subindex) (nth 1 subindex)) ; (texinfo-subindex 'texinfo-findex (car subindex) (nth 2 subindex)) ; (texinfo-subindex 'texinfo-cindex (car subindex) (nth 3 subindex)) ; (texinfo-subindex 'texinfo-pindex (car subindex) (nth 4 subindex)) ; (texinfo-subindex 'texinfo-tindex (car subindex) (nth 5 subindex)) ; (texinfo-subindex 'texinfo-kindex (car subindex) (nth 6 subindex)))) (defun texinfo-subindex (indexvar file content) (set indexvar (cons (list 'recurse file content) (symbol-value indexvar)))) (put 'include 'texinfo-format 'texinfo-format-include) (defun texinfo-format-include () (let ((filename (concat input-directory (texinfo-parse-arg-discard))) (default-directory input-directory)) (message "Reading: %s" filename) (save-excursion (save-restriction (narrow-to-region (point) (+ (point) (car (cdr (insert-file-contents filename))))) (goto-char (point-min)) (texinfo-append-refill) (texinfo-format-convert (point-min) (point-max)))) (setq last-input-buffer input-buffer) ; to bypass setfilename )) ;;; Numerous commands do nothing in Texinfo ;; These commands are defined in texinfo.tex for printed output. (put 'bye 'texinfo-format 'texinfo-discard-line) (put 'c 'texinfo-format 'texinfo-discard-line-with-args) (put 'comment 'texinfo-format 'texinfo-discard-line-with-args) (put 'contents 'texinfo-format 'texinfo-discard-line-with-args) (put 'finalout 'texinfo-format 'texinfo-discard-line) (put 'group 'texinfo-end 'texinfo-discard-line-with-args) (put 'group 'texinfo-format 'texinfo-discard-line-with-args) (put 'headings 'texinfo-format 'texinfo-discard-line-with-args) (put 'hsize 'texinfo-format 'texinfo-discard-line-with-args) (put 'itemindent 'texinfo-format 'texinfo-discard-line-with-args) (put 'lispnarrowing 'texinfo-format 'texinfo-discard-line-with-args) (put 'need 'texinfo-format 'texinfo-discard-line-with-args) (put 'nopara 'texinfo-format 'texinfo-discard-line-with-args) (put 'page 'texinfo-format 'texinfo-discard-line-with-args) (put 'parindent 'texinfo-format 'texinfo-discard-line-with-args) (put 'setchapternewpage 'texinfo-format 'texinfo-discard-line-with-args) (put 'setq 'texinfo-format 'texinfo-discard-line-with-args) (put 'settitle 'texinfo-format 'texinfo-discard-line-with-args) (put 'setx 'texinfo-format 'texinfo-discard-line-with-args) (put 'shortcontents 'texinfo-format 'texinfo-discard-line-with-args) (put 'smallbook 'texinfo-format 'texinfo-discard-line) (put 'summarycontents 'texinfo-format 'texinfo-discard-line-with-args) ;;; Some commands cannot be handled (defun texinfo-unsupported () (error "%s is not handled by texinfo" (buffer-substring texinfo-command-start texinfo-command-end))) ;;; Batch formatting (defun batch-texinfo-format () "Runs texinfo-format-buffer on the files remaining on the command line. Must be used only with -batch, and kills emacs on completion. Each file will be processed even if an error occurred previously. For example, invoke \"emacs -batch -funcall batch-texinfo-format $docs/ ~/*.texinfo\"." (if (not noninteractive) (error "batch-texinfo-format may only be used -batch.")) (let ((version-control t) (auto-save-default nil) (find-file-run-dired nil) (kept-old-versions 259259) (kept-new-versions 259259)) (let ((error 0) file (files ())) (while command-line-args-left (setq file (expand-file-name (car command-line-args-left))) (cond ((not (file-exists-p file)) (message ">> %s does not exist!" file) (setq error 1 command-line-args-left (cdr command-line-args-left))) ((file-directory-p file) (setq command-line-args-left (nconc (directory-files file) (cdr command-line-args-left)))) (t (setq files (cons file files) command-line-args-left (cdr command-line-args-left))))) (while files (setq file (car files) files (cdr files)) (condition-case err (progn (if buffer-file-name (kill-buffer (current-buffer))) (find-file file) (buffer-flush-undo (current-buffer)) (set-buffer-modified-p nil) (texinfo-mode) (message "texinfo formatting %s..." file) (texinfo-format-buffer nil) (if (buffer-modified-p) (progn (message "Saving modified %s" (buffer-file-name)) (save-buffer)))) (error (message ">> Error: %s" (prin1-to-string err)) (message ">> point at") (let ((s (buffer-substring (point) (min (+ (point) 100) (point-max)))) (tem 0)) (while (setq tem (string-match "\n+" s tem)) (setq s (concat (substring s 0 (match-beginning 0)) "\n>> " (substring s (match-end 0))) tem (1+ tem))) (message ">> %s" s)) (setq error 1)))) (kill-emacs error)))) ;;; Place `provide' at end of file. (provide 'texinfmt) ;;;;;;;;;;;;;;;; end texinfmt.el ;;;;;;;;;;;;;;;; texinfo-2.15/elisp/texnfo-upd.el0000644000175000017500000021253712415567332014124 0ustar gg;;;; texnfo-upd.el ;;; Texinfo mode utilities for updating nodes and menus in Texinfo files. ;;; Version 2.12 8 June 1992 ;;; Robert J. Chassell ;;; Please send bug reports to: bob@gnu.ai.mit.edu ;;; Copyright 1989, 1990, 1991, 1992 Free Software Foundation ;;; Known bug: update commands fail to ignore @ignore. ;;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; Summary: how to use the updating commands ; The node and menu updating functions automatically ; * insert missing `@node' lines, ; * insert the `Next', `Previous' and `Up' pointers of a node, ; * insert or update the menu for a section, ; * create a master menu for a Texinfo source file. ; ; Passed an argument, the `texinfo-update-node' and ; `texinfo-make-menu' functions do their jobs in the region. ; ; In brief, the functions for creating or updating nodes and menus, are: ; ; texinfo-update-node (&optional region-p) ; texinfo-every-node-update () ; texinfo-sequential-node-update (&optional region-p) ; ; texinfo-make-menu (&optional region-p) ; texinfo-all-menus-update () ; texinfo-master-menu () ; ; texinfo-insert-node-lines (&optional title-p) ; ; texinfo-indent-menu-description (column &optional region-p) ; The `texinfo-column-for-description' variable specifies the column to ; which menu descriptions are indented. ; Texinfo file structure ; ---------------------- ; To use the updating commands, you must structure your Texinfo file ; hierarchically. Each `@node' line, with the exception of the top ; node, must be accompanied by some kind of section line, such as an ; `@chapter' or `@section' line. Each node-line/section-line ; combination must look like this: ; @node Lists and Tables, Cross References, Structuring, Top ; @comment node-name, next, previous, up ; @chapter Making Lists and Tables ; or like this (without the `@comment' line): ; @node Lists and Tables, Cross References, Structuring, Top ; @chapter Making Lists and Tables ; If the file has a `top' node, it must be called `top' or `Top' and ; be the first node in the file. ;;; The update node functions described in detail ; The `texinfo-update-node' function without an argument inserts ; the correct next, previous and up pointers for the node in which ; point is located (i.e., for the node preceding point). ; With an argument, the `texinfo-update-node' function inserts the ; correct next, previous and up pointers for the nodes inside the ; region. ; It does not matter whether the `@node' line has pre-existing ; `Next', `Previous', or `Up' pointers in it. They are removed. ; The `texinfo-every-node-update' function runs `texinfo-update-node' ; on the whole buffer. ; The `texinfo-update-node' function inserts the immediately following ; and preceding node into the `Next' or `Previous' pointers regardless ; of their hierarchical level. This is only useful for certain kinds ; of text, like a novel, which you go through sequentially. ;;; The menu making functions described in detail ; The `texinfo-make-menu' function without an argument creates or ; updates a menu for the section encompassing the node that follows ; point. With an argument, it makes or updates menus for the nodes ; within or part of the marked region. ; Whenever an existing menu is updated, the descriptions from ; that menu are incorporated into the new menu. This is done by copying ; descriptions from the existing menu to the entries in the new menu ; that have the same node names. If the node names are different, the ; descriptions are not copied to the new menu. ; Menu entries that refer to other Info files are removed since they ; are not a node within current buffer. This is a deficiency. ; The `texinfo-all-menus-update' function runs `texinfo-make-menu' ; on the whole buffer. ; The `texinfo-master-menu' function creates an extended menu located ; after the top node. (The file must have a top node.) The function ; first updates all the regular menus in the buffer (incorporating the ; descriptions from pre-existing menus), and then constructs a master ; menu that includes every entry from every other menu. (However, the ; function cannot update an already existing master menu; if one ; exists, it must be removed before calling the function.) ; The `texinfo-indent-menu-description' function indents every ; description in the menu following point, to the specified column. ; Non-nil argument (prefix, if interactive) means indent every ; description in every menu in the region. This function does not ; indent second and subsequent lines of a multi-line description. ; The `texinfo-insert-node-lines' function inserts `@node' before the ; `@chapter', `@section', and such like lines of a region in a Texinfo ; file where the `@node' lines are missing. ; ; With a non-nil argument (prefix, if interactive), the function not ; only inserts `@node' lines but also inserts the chapter or section ; titles as the names of the corresponding nodes; and inserts titles ; as node names in pre-existing `@node' lines that lack names. ; ; Since node names should be more concise than section or chapter ; titles, node names so inserted will need to be edited manually. ;;; The menu making functions (defun texinfo-make-menu (&optional region-p) "Without any prefix argument, make or update a menu. Make the menu for the section enclosing the node found following point. Non-nil argument (prefix, if interactive) means make or update menus for nodes within or part of the marked region. Whenever a menu exists, and is being updated, the descriptions that are associated with node names in the pre-existing menu are incorporated into the new menu. Otherwise, the nodes' section titles are inserted as descriptions." (interactive "P") (if (not region-p) (let ((level (texinfo-hierarchic-level))) (texinfo-make-one-menu level) (message "Done...updated the menu. You may save the buffer.")) ;; else (message "Making or updating menus in %s... " (buffer-name)) (let ((beginning (region-beginning)) (region-end (region-end)) (level (progn ; find section type following point (goto-char (region-beginning)) (texinfo-hierarchic-level)))) (if (= region-end beginning) (error "Please mark a region!")) (save-excursion (save-restriction (widen) (while (texinfo-find-lower-level-node level region-end) (setq level (texinfo-hierarchic-level)) ; new, lower level (texinfo-make-one-menu level)) (while (and (< (point) region-end) (texinfo-find-higher-level-node level region-end)) (setq level (texinfo-hierarchic-level)) (while (texinfo-find-lower-level-node level region-end) (setq level (texinfo-hierarchic-level)) ; new, lower level (texinfo-make-one-menu level)))))) (message "Done...updated menus. You may save the buffer."))) (defun texinfo-make-one-menu (level) "Make a menu of all the appropriate nodes in this section. `Appropriate nodes' are those associated with sections that are at the level specified by LEVEL. Point is left at the end of menu." (let* ((case-fold-search t) (beginning (save-excursion (goto-char (texinfo-update-menu-region-beginning level)) (end-of-line) (point))) (end (texinfo-update-menu-region-end level)) (first (texinfo-menu-first-node beginning end)) (node-name (progn (goto-char beginning) (beginning-of-line) (texinfo-copy-node-name))) (new-menu-list (texinfo-make-menu-list beginning end level))) (if (texinfo-old-menu-p beginning first) (progn (texinfo-incorporate-descriptions new-menu-list) (texinfo-delete-old-menu beginning first))) (texinfo-insert-menu new-menu-list node-name))) (defun texinfo-all-menus-update (&optional update-all-nodes-p) "Update every regular menu in a Texinfo file. Update pre-existing master menu, if there is one. If called with a non-nil argument, this function first updates all the nodes in the buffer before updating the menus." (interactive "P") (let ((case-fold-search t) master-menu-p) (save-excursion (push-mark (point-max) t) (goto-char (point-min)) (message "Checking for a master menu in %s ... "(buffer-name)) (save-excursion (if (re-search-forward texinfo-master-menu-header nil t) ;; Remove detailed master menu listing (progn (setq master-menu-p t) (goto-char (match-beginning 0)) (let ((end-of-detailed-menu-descriptions (save-excursion ; beginning of end menu line (goto-char (texinfo-menu-end)) (beginning-of-line) (forward-char -1) (point)))) (delete-region (point) end-of-detailed-menu-descriptions))))) (if update-all-nodes-p (progn (message "Updating all nodes in %s ... " (buffer-name)) (sleep-for 2) (push-mark (point-max) t) (goto-char (point-min)) (texinfo-update-node t))) (message "Updating all menus in %s ... " (buffer-name)) (sleep-for 2) (push-mark (point-max) t) (goto-char (point-min)) (texinfo-make-menu t) (if master-menu-p (progn (message "Updating the master menu in %s... " (buffer-name)) (sleep-for 2) (texinfo-master-menu nil)))) (message "Done...updated all the menus. You may save the buffer."))) (defun texinfo-find-lower-level-node (level region-end) "Search forward from point for node at any level lower than LEVEL. Search is limited to the end of the marked region, REGION-END, and to the end of the menu region for the level. Return t if the node is found, else nil. Leave point at the beginning of the node if one is found; else do not move point." (let ((case-fold-search t)) (if (and (< (point) region-end) (re-search-forward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval (cdr (assoc level texinfo-update-menu-lower-regexps)))) ;; the next higher level node marks the end of this ;; section, and no lower level node will be found beyond ;; this position even if region-end is farther off (texinfo-update-menu-region-end level) t)) (goto-char (match-beginning 1))))) (defun texinfo-find-higher-level-node (level region-end) "Search forward from point for node at any higher level than argument LEVEL. Search is limited to the end of the marked region, REGION-END. Return t if the node is found, else nil. Leave point at the beginning of the node if one is found; else do not move point." (let ((case-fold-search t)) (cond ((or (string-equal "top" level) (string-equal "chapter" level)) (if (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" region-end t) (progn (beginning-of-line) t))) (t (if (re-search-forward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) region-end t) (progn (beginning-of-line) t)))))) ;;; Making the list of new menu entries (defun texinfo-make-menu-list (beginning end level) "Make a list of node names and their descriptions. Point is left at the end of the menu region, but the menu is not inserted. First argument is position from which to start making menu list; second argument is end of region in which to try to locate entries; third argument is the level of the nodes that are the entries. Node names and descriptions are dotted pairs of strings. Each pair is an element of the list. If the description does not exist, the element consists only of the node name." (goto-char beginning) (let (new-menu-list) (while (texinfo-menu-locate-entry-p level end) (setq new-menu-list (cons (cons (texinfo-copy-node-name) ;; Use following if you don't want section title. ;; (prog1 "" (forward-line 1))) (texinfo-copy-section-title)) new-menu-list))) (reverse new-menu-list))) (defun texinfo-menu-locate-entry-p (level search-end) "Find a node that will be part of menu for this section. First argument is a string such as \"section\" specifying the general hierarchical level of the menu; second argument is a postion specifying the end of the search. The function returns t if the node is found, else nil. It searches forward from point, and leaves point at the beginning of the node. The function finds entries of the same type. Thus `subsections' and `unnumberedsubsecs' will appear in the same menu." (let ((case-fold-search t)) (if (re-search-forward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval (cdr (assoc level texinfo-update-menu-same-level-regexps)))) search-end t) (goto-char (match-beginning 1))))) (defun texinfo-copy-node-name () "Return the node name as a string. Start with point at the beginning of the node line; copy the text after the node command up to the first comma on the line, if any, and return the text as a string. Leaves point at the beginning of the line. If there is no node name, returns an empty string." (save-excursion (buffer-substring (progn (forward-word 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (point)) (if (search-forward "," (save-excursion (end-of-line) (point)) t) ; bound search (1- (point)) (end-of-line) (point))))) (defun texinfo-copy-section-title () "Return the title of the section as a string. The title is used as a description line in the menu when one does not already exist. Move point to the beginning of the appropriate section line by going to the start of the text matched by last regexp searched for, which must have been done by `texinfo-menu-locate-entry-p'." ;; could use the same re-search as in `texinfo-menu-locate-entry-p' ;; instead of using `match-beginning'; such a variation would be ;; more general, but would waste information already collected (goto-char (match-beginning 7)) ; match section name (buffer-substring (progn (forward-word 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (point)) (progn (end-of-line) (point)))) ;;; Handling the old menu (defun texinfo-old-menu-p (beginning first) "Move point to the beginning of the menu for this section, if any. Otherwise move point to the end of the first node of this section. Return t if a menu is found, nil otherwise. First argument is the position of the beginning of the section in which the menu will be located; second argument is the position of the first node within the section. If no menu is found, the function inserts two newlines just before the end of the section, and leaves point there where a menu ought to be." (goto-char beginning) (if (not (re-search-forward "^@menu" first 'goto-end)) (progn (insert "\n\n") (forward-line -2) nil) t)) (defun texinfo-incorporate-descriptions (new-menu-list) "Copy the old menu line descriptions that exist to the new menu. Point must be at beginning of old menu. If the node-name of the new menu entry cannot be found in the old menu, use the new section title for the description, but if the node-name of the new menu is found in the old menu, replace the section title with the old description, whatever it may be. For this function, the new menu is a list made up of lists of dotted pairs in which the first element of the pair is the node name and the second element the description. The new menu is changed destructively. The old menu is the menu as it appears in the texinfo file." (let ((new-menu-list-pointer new-menu-list) (end-of-menu (texinfo-menu-end))) (while new-menu-list (save-excursion ; keep point at beginning of menu (if (search-forward (concat "\* " ; so only menu entries are found (car (car new-menu-list)) ":") ; so only complete entries are found end-of-menu t) (setcdr (car new-menu-list) (texinfo-menu-copy-old-description end-of-menu)))) (setq new-menu-list (cdr new-menu-list))) (setq new-menu-list new-menu-list-pointer))) (defun texinfo-menu-copy-old-description (end-of-menu) "Return description field of old menu line as string. Point must be located just after the node name. Point left before description. Single argument, END-OF-MENU, is position limiting search." (skip-chars-forward "[:.,\t\n ]+") ;; don't copy a carriage return at line beginning with asterisk! ;; do copy a description that begins with an `@'! ;; !! Known bug: does not copy descriptions starting with ^|\{?* etc. (if (and (looking-at "\\(\\w+\\|@\\)") (not (looking-at "\\(^\\* \\|^@end menu\\)"))) (buffer-substring (point) (save-excursion (re-search-forward "\\(^\\* \\|^@end menu\\)" end-of-menu t) (forward-line -1) (end-of-line) ; go to end of last description line (point))) "")) (defun texinfo-menu-end () "Return position of end of menu. Does not change location of point. Signal an error if not end of menu." (save-excursion (if (re-search-forward "^@end menu" nil t) (point) (error "Menu does not have an end.")))) (defun texinfo-delete-old-menu (beginning first) "Delete the old menu. Point must be in or after menu. First argument is position of the beginning of the section in which the menu will be located; second argument is the position of the first node within the section." ;; No third arg to search, so error if search fails. (re-search-backward "^@menu" beginning) (delete-region (point) (save-excursion (re-search-forward "^@end menu" first) (point)))) ;;; Inserting new menu ;; try 32, but perhaps 24 is better (defvar texinfo-column-for-description 32 "*Column at which descriptions start in a Texinfo menu.") (defun texinfo-insert-menu (menu-list node-name) "Insert formatted menu at point. Indents the first line of the description, if any, to the value of texinfo-column-for-description. MENU-LIST has form: \(\(\"node-name1\" . \"description\"\) \(\"node-name\" . \"description\"\) ... \) However, there does not need to be a description field." (insert "@menu\n") (while menu-list (if (cdr (car menu-list)) ; menu-list has description entry (progn (insert (format "* %s::" (car (car menu-list)))) ; node-name entry (indent-to texinfo-column-for-description 2) (insert (format "%s\n" (cdr (car menu-list))))) ; description entry ;; else menu-list lacks description entry (insert (format "* %s::\n" (car (car menu-list))))) ; node-name entry (setq menu-list (cdr menu-list))) (insert "@end menu") (message "Updated \"%s\" level menu following node: %s ... " level node-name)) ;;; Handling description indentation ; Since the make-menu functions indent descriptions, these functions ; are useful primarily for indenting a single menu specially. (defun texinfo-indent-menu-description (column &optional region-p) "Indent every description in menu following point to COLUMN. Non-nil argument (prefix, if interactive) means indent every description in every menu in the region. Does not indent second and subsequent lines of a multi-line description." (interactive "nIndent menu descriptions to (column number): \nP") (save-excursion (save-restriction (widen) (if (not region-p) (progn (re-search-forward "^@menu") (texinfo-menu-indent-description column) (message "Indented descriptions in menu. You may save the buffer.")) ;;else (message "Indenting every menu description in region... ") (goto-char (region-beginning)) (while (and (< (point) (region-end)) (texinfo-locate-menu-p)) (forward-line 1) (texinfo-menu-indent-description column)) (message "Indenting done. You may save the buffer."))))) (defun texinfo-menu-indent-description (to-column-number) "Indent the Texinfo file menu description to TO-COLUMN-NUMBER. Start with point just after the word `menu' in the `@menu' line and leave point on the line before the `@end menu' line. Does not indent second and subsequent lines of a multi-line description." (let* ((beginning-of-next-line (point))) (while (< beginning-of-next-line (save-excursion ; beginning of end menu line (goto-char (texinfo-menu-end)) (beginning-of-line) (point))) (if (search-forward "::" (texinfo-menu-end) t) (progn (let ((beginning-white-space (point))) (skip-chars-forward " \t") ; skip over spaces (if (looking-at "\\(@\\|\\w\\)+") ; if there is text (progn ;; remove pre-existing indentation (delete-region beginning-white-space (point)) (indent-to-column to-column-number)))))) ;; position point at beginning of next line (forward-line 1) (setq beginning-of-next-line (point))))) ;;; Making the master menu (defun texinfo-master-menu (update-all-nodes-menus-p) "Make a master menu for a whole Texinfo file. Non-nil argument (prefix, if interactive) means first update all existing nodes and menus. Remove pre-existing master menu, if there is one. This function creates a master menu that follows the top node. The master menu includes every entry from all the other menus. It replaces any existing ordinary menu that follows the top node. If called with a non-nil argument, this function first updates all the menus in the buffer (incorporating descriptions from pre-existing menus) before it constructs the master menu. The function removes the detailed part of an already existing master menu. This action depends on the pre-exisitng master menu using the standard `texinfo-master-menu-header'. The master menu has the following format, which is adapted from the recommendation in the Texinfo Manual: * The first part contains the major nodes in the Texinfo file: the nodes for the chapters, chapter-like sections, and the major appendices. This includes the indices, so long as they are in chapter-like sections, such as unnumbered sections. * The second and subsequent parts contain a listing of the other, lower level menus, in order. This way, an inquirer can go directly to a particular node if he or she is searching for specific information. Each of the menus in the detailed node listing is introduced by the title of the section containing the menu." (interactive "P") (let ((case-fold-search t)) (widen) (goto-char (point-min)) ;; Move point to location after `top'. (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) (error "This buffer needs a Top node!")) (let ((first-chapter (save-excursion (re-search-forward "^@node") (point)))) (if (re-search-forward texinfo-master-menu-header first-chapter t) ;; Remove detailed master menu listing (progn (goto-char (match-beginning 0)) (let ((end-of-detailed-menu-descriptions (save-excursion ; beginning of end menu line (goto-char (texinfo-menu-end)) (beginning-of-line) (forward-char -1) (point)))) (delete-region (point) end-of-detailed-menu-descriptions))))) (if update-all-nodes-menus-p (progn (message "Making a master menu in %s ...first updating all nodes... " (buffer-name)) (sleep-for 2) (push-mark (point-max) t) (goto-char (point-min)) (texinfo-update-node t) (message "Updating all menus in %s ... " (buffer-name)) (sleep-for 2) (push-mark (point-max) t) (goto-char (point-min)) (texinfo-make-menu t))) (message "Now making the master menu in %s... " (buffer-name)) (sleep-for 2) (goto-char (point-min)) (texinfo-insert-master-menu-list (texinfo-master-menu-list)) ;; Remove extra newlines that texinfo-insert-master-menu-list ;; may have inserted. (save-excursion (goto-char (point-min)) (re-search-forward texinfo-master-menu-header) (goto-char (match-beginning 0)) (insert "\n") (delete-blank-lines) (re-search-backward "^@menu") (forward-line -1) (delete-blank-lines) (re-search-forward "^@end menu") (forward-line 1) (delete-blank-lines)) (message "Done...completed making master menu. You may save the buffer."))) (defun texinfo-master-menu-list () "Return a list of menu entries and header lines for the master menu. Start with the menu for chapters and indices and then find each following menu and the title of the node preceding that menu. The master menu list has this form: \(\(\(... \"entry-1-2\" \"entry-1\"\) \"title-1\"\) \(\(... \"entry-2-2\" \"entry-2-1\"\) \"title-2\"\) ...\) However, there does not need to be a title field." (let (master-menu-list) (while (texinfo-locate-menu-p) (setq master-menu-list (cons (list (texinfo-copy-menu) (texinfo-copy-menu-title)) master-menu-list))) (reverse master-menu-list))) (defun texinfo-insert-master-menu-list (master-menu-list) "Format and insert the master menu in the current buffer." (goto-char (point-min)) ;; Insert a master menu only after `Top' node and before next node ;; \(or include file if there is no next node\). (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) (error "This buffer needs a Top node!")) (let ((first-chapter (save-excursion (re-search-forward "^@node\\|^@include") (point)))) (if (not (re-search-forward "^@menu" first-chapter t)) (error "Buffer lacks ordinary `Top' menu in which to insert master."))) (beginning-of-line) (delete-region ; buffer must have ordinary top menu (point) (save-excursion (re-search-forward "^@end menu") (point))) (save-excursion ; leave point at beginning of menu ;; Handle top of menu (insert "\n@menu\n") ;; Insert chapter menu entries (setq this-very-menu-list (reverse (car (car master-menu-list)))) ;; Tell user what is going on. (message "Inserting chapter menu entry: %s ... " this-very-menu-list) (while this-very-menu-list (insert "* " (car this-very-menu-list) "\n") (setq this-very-menu-list (cdr this-very-menu-list))) (setq master-menu-list (cdr master-menu-list)) (insert texinfo-master-menu-header) ;; Now, insert all the other menus ;; The menu master-menu-list has a form like this: ;; ((("beta" "alpha") "title-A") ;; (("delta" "gamma") "title-B")) (while master-menu-list (message "Inserting menu for %s .... " (car (cdr (car master-menu-list)))) ;; insert title of menu section (insert "\n" (car (cdr (car master-menu-list))) "\n\n") ;; insert each menu entry (setq this-very-menu-list (reverse (car (car master-menu-list)))) (while this-very-menu-list (insert "* " (car this-very-menu-list) "\n") (setq this-very-menu-list (cdr this-very-menu-list))) (setq master-menu-list (cdr master-menu-list))) ;; Finish menu (insert "@end menu\n\n"))) (defvar texinfo-master-menu-header "\n --- The Detailed Node Listing ---\n" "String inserted before lower level entries in Texinfo master menu. It comes after the chapter-level menu entries.") (defun texinfo-locate-menu-p () "Find the next menu in the texinfo file. If found, leave point after word `menu' on the `@menu' line, and return t. If a menu is not found, do not move point and return nil." (re-search-forward "\\(^@menu\\)" nil t)) (defun texinfo-copy-menu-title () "Return the title of the section preceding the menu as a string. If such a title cannot be found, return an empty string. Do not move point." (let ((case-fold-search t)) (save-excursion (if (re-search-backward (concat "\\(^@top" "\\|" ; or texinfo-section-types-regexp ; all other section types "\\)") nil t) (progn (beginning-of-line) (forward-word 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (buffer-substring (point) (progn (end-of-line) (point)))) "")))) (defun texinfo-copy-menu () "Return the entries of an existing menu as a list. Start with point just after the word `menu' in the `@menu' line and leave point on the line before the `@end menu' line." (let* (this-menu-list (end-of-menu (texinfo-menu-end)) ; position of end of `@end menu' (last-entry (save-excursion ; position of beginning of ; last `* ' entry (goto-char end-of-menu) ;; handle multi-line description (if (not (re-search-backward "^\* " nil t)) (error "No entries in menu.")) (point)))) (while (< (point) last-entry) (if (re-search-forward "^\* " end-of-menu t) (progn (setq this-menu-list (cons (buffer-substring (point) ;; copy multi-line descriptions (save-excursion (re-search-forward "\\(^\* \\|^@e\\)" nil t) (- (point) 3))) this-menu-list))))) this-menu-list)) ;;; Determining the hierarchical level in the texinfo file (defun texinfo-specific-section-type () "Return the specific type of next section, as a string. For example, \"unnumberedsubsec\". Return \"top\" for top node. Searches forward for a section. Hence, point must be before the section whose type will be found. Does not move point. Signal an error if the node is not the top node and a section is not found." (let ((case-fold-search t)) (save-excursion (cond ((re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" ;;; Following search limit by cph but causes a bug ;;; (save-excursion ;;; (end-of-line) ;;; (point)) nil t) "top") ((re-search-forward texinfo-section-types-regexp nil t) (buffer-substring (progn (beginning-of-line) ; copy its name (1+ (point))) (progn (forward-word 1) (point)))) (t (error "texinfo-specific-section-type: Chapter or section not found.")))))) (defun texinfo-hierarchic-level () "Return the general hierarchal level of the next node in a texinfo file. Thus, a subheading or appendixsubsec is of type subsection." (let ((case-fold-search t)) (cdr (assoc (texinfo-specific-section-type) texinfo-section-to-generic-alist)))) ;;; Locating the major positions (defun texinfo-update-menu-region-beginning (level) "Locate beginning of higher level section this section is within. Return position of the beginning of the node line; do not move point. Thus, if this level is subsection, searches backwards for section node. Only argument is a string of the general type of section." (let ((case-fold-search t)) ;; !! Known bug: if section immediately follows top node, this ;; returns the beginning of the buffer as the beginning of the ;; higher level section. (cond ((or (string-equal "top" level) (string-equal "chapter" level)) (save-excursion (goto-char (point-min)) (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t) (beginning-of-line) (point))) (t (save-excursion (re-search-backward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval (cdr (assoc level texinfo-update-menu-higher-regexps)))) nil 'goto-beginning) (point)))))) (defun texinfo-update-menu-region-end (level) "Locate end of higher level section this section is within. Return position; do not move point. Thus, if this level is a subsection, find the node for the section this subsection is within. If level is top or chapter, returns end of file. Only argument is a string of the general type of section." (let ((case-fold-search t)) (save-excursion (if (re-search-forward (concat "\\(^@node\\).*\n" ; match node line "\\(\\(\\(^@c\\).*\n\\)" ; match comment line, if any "\\|" ; or "\\(^@ifinfo[ ]*\n\\)\\)?" ; ifinfo line, if any (eval ;; Never finds end of level above chapter so goes to end. (cdr (assoc level texinfo-update-menu-higher-regexps)))) nil 'goto-end) (match-beginning 1) (point-max))))) (defun texinfo-menu-first-node (beginning end) "Locate first node of the section the menu will be placed in. Return position; do not move point. The menu will be located just before this position. First argument is the position of the beginning of the section in which the menu will be located; second argument is the position of the end of that region; it limits the search." (save-excursion (goto-char beginning) (forward-line 1) (re-search-forward "^@node" end t) (beginning-of-line) (point))) ;;; Alists and regular expressions for defining hierarchical levels (defvar texinfo-section-to-generic-alist '(("top" . "top") ("chapter" . "chapter") ("unnumbered" . "chapter") ("majorheading" . "chapter") ("chapheading" . "chapter") ("appendix" . "chapter") ("section" . "section") ("unnumberedsec" . "section") ("heading" . "section") ("appendixsec" . "section") ("subsection" . "subsection") ("unnumberedsubsec" . "subsection") ("subheading" . "subsection") ("appendixsubsec" . "subsection") ("subsubsection" . "subsubsection") ("unnumberedsubsubsec" . "subsubsection") ("subsubheading" . "subsubsection") ("appendixsubsubsec" . "subsubsection")) "*An alist of specific and corresponding generic Texinfo section types. The keys are strings specifying specific types of section; the values are strings of their corresponding general types.") (defvar texinfo-section-types-regexp "^@\\(chapter \\|sect\\|subs\\|subh\\|unnum\\|major\\|chapheading \\|heading \\|appendix\\)" "Regexp matching chapter, section, other headings (but not the top node).") (defvar texinfo-chapter-level-regexp "chapter\\|unnumbered \\|appendix \\|majorheading\\|chapheading" "Regular expression matching just the Texinfo chapter level headings.") (defvar texinfo-section-level-regexp "section\\|unnumberedsec\\|heading \\|appendixsec" "Regular expression matching just the Texinfo section level headings.") (defvar texinfo-subsection-level-regexp "subsection\\|unnumberedsubsec\\|subheading\\|appendixsubsec" "Regular expression matching just the Texinfo subsection level headings.") (defvar texinfo-subsubsection-level-regexp "subsubsection\\|unnumberedsubsubsec\\|subsubheading\\|appendixsubsubsec" "Regular expression matching just the Texinfo subsubsection level headings.") (defvar texinfo-update-menu-same-level-regexps '(("top" . "top[ \t]+") ("chapter" . (concat "\\(^@\\)\\(" texinfo-chapter-level-regexp "\\)[ \t]*")) ("section" . (concat "\\(^@\\)\\(" texinfo-section-level-regexp "\\)[ \t]*")) ("subsection" . (concat "\\(^@\\)\\(" texinfo-subsection-level-regexp "\\)[ \t]+")) ("subsubsection" . (concat "\\(^@\\)\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+"))) "*Regexps for searching for same level sections in a Texinfo file. The keys are strings specifying the general hierarchical level in the document; the values are regular expressions.") (defvar texinfo-update-menu-higher-regexps '(("top" . "^@node [ \t]*DIR") ("chapter" . "^@node [ \t]*top[ \t]*\\(,\\|$\\)") ("section" . (concat "\\(^@\\(" texinfo-chapter-level-regexp "\\)[ \t]*\\)")) ("subsection" . (concat "\\(^@\\(" texinfo-section-level-regexp "\\|" texinfo-chapter-level-regexp "\\)[ \t]*\\)")) ("subsubsection" . (concat "\\(^@\\(" texinfo-subsection-level-regexp "\\|" texinfo-section-level-regexp "\\|" texinfo-chapter-level-regexp "\\)[ \t]*\\)"))) "*Regexps for searching for higher level sections in a Texinfo file. The keys are strings specifying the general hierarchical level in the document; the values are regular expressions.") (defvar texinfo-update-menu-lower-regexps '(("top" . (concat "\\(^@\\(" texinfo-chapter-level-regexp "\\|" texinfo-section-level-regexp "\\|" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]*\\)")) ("chapter" . (concat "\\(^@\\(" texinfo-section-level-regexp "\\|" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]*\\)")) ("section" . (concat "\\(^@\\(" texinfo-subsection-level-regexp "\\|" texinfo-subsubsection-level-regexp "\\)[ \t]+\\)")) ("subsection" . (concat "\\(^@\\(" texinfo-subsubsection-level-regexp "\\)[ \t]+\\)")) ("subsubsection" . "nothing lower")) "*Regexps for searching for lower level sections in a Texinfo file. The keys are strings specifying the general hierarchical level in the document; the values are regular expressions.") ;;; Updating a node (defun texinfo-update-node (&optional region-p) "Without any prefix argument, update the node in which point is located. Non-nil argument (prefix, if interactive) means update the nodes in the marked region. The functions for creating or updating nodes and menus, and their keybindings, are: texinfo-update-node (&optional region-p) \\[texinfo-update-node] texinfo-every-node-update () \\[texinfo-every-node-update] texinfo-sequential-node-update (&optional region-p) texinfo-make-menu (&optional region-p) \\[texinfo-make-menu] texinfo-all-menus-update () \\[texinfo-all-menus-update] texinfo-master-menu () texinfo-indent-menu-description (column &optional region-p) The `texinfo-column-for-description' variable specifies the column to which menu descriptions are indented. Its default value is 32." (interactive "P") (if (not region-p) (let ((auto-fill-hook nil)) ; update a single node (if (not (re-search-backward "^@node" (point-min) t)) (error "Node line not found before this position.")) (texinfo-update-the-node) (message "Done...updated the node. You may save the buffer.")) ;; else (let ((auto-fill-hook nil) (beginning (region-beginning)) (end (region-end))) (if (= end beginning) (error "Please mark a region!")) (save-restriction (narrow-to-region beginning end) (goto-char beginning) (push-mark (point) t) (while (re-search-forward "^@node" (point-max) t) (beginning-of-line) (texinfo-update-the-node)) (message "Done...updated nodes in region. You may save the buffer."))))) (defun texinfo-every-node-update () "Update every node in a Texinfo file." (interactive) (save-excursion (push-mark (point-max) t) (goto-char (point-min)) (texinfo-update-node t) (message "Done...updated every node. You may save the buffer."))) (defun texinfo-update-the-node () "Update one node. Point must be at the beginning of node line. Leave point at the end of the node line." (texinfo-check-for-node-name) (texinfo-delete-existing-pointers) (message "Updating node: %s ... " (texinfo-copy-node-name)) (save-restriction (widen) (let* ((case-fold-search t) (level (texinfo-hierarchic-level)) (beginning (texinfo-update-menu-region-beginning level)) (end (texinfo-update-menu-region-end level))) (if (string-equal level "top") (texinfo-top-pointer-case) ;; else (texinfo-insert-pointer beginning end level 'next) (texinfo-insert-pointer beginning end level 'previous) (texinfo-insert-pointer beginning end level 'up) (texinfo-clean-up-node-line))))) (defun texinfo-top-pointer-case () "Insert pointers in the Top node. This is a special case. The `Next' pointer is a pointer to a chapter or section at a lower hierarchical level in the file. The `Previous' and `Up' pointers are to `(dir)'. Point must be at the beginning of the node line, and is left at the end of the node line." (texinfo-clean-up-node-line) (insert ", " (save-excursion ;; There may be an @chapter or other such command between ;; the top node line and the next node line, as a title ;; for an `ifinfo' section. This @chapter command must ;; must be skipped. So the procedure is to search for ;; the next `@node' line, and then copy its name. (if (re-search-forward "^@node" nil t) (progn (beginning-of-line) (texinfo-copy-node-name)) " ")) ", (dir), (dir)")) (defun texinfo-check-for-node-name () "Determine whether the node has a node name. Prompt for one if not. Point must be at beginning of node line. Does not move point." (save-excursion (let ((initial (texinfo-copy-next-section-title))) (forward-word 1) ; skip over node command (skip-chars-forward " \t") ; and over spaces (if (not (looking-at "[^,\t\n ]+")) ; regexp based on what Info looks for ; alternatively, use "[a-zA-Z]+" (let ((node-name (read-from-minibuffer "Node name (use no @, commas, colons, or apostrophes): " initial))) (insert " " node-name)))))) (defun texinfo-delete-existing-pointers () "Delete `Next', `Previous', and `Up' pointers. Starts from the current position of the cursor, and searches forward on the line for a comma and if one is found, deletes the rest of the line, including the comma. Leaves point at beginning of line." (if (search-forward "," (save-excursion (end-of-line) (point)) t) (progn (goto-char (1- (point))) (kill-line nil))) (beginning-of-line)) (defun texinfo-find-pointer (beginning end level direction) "Move point to section associated with next, previous, or up pointer. Return type of pointer (either 'normal or 'no-pointer). The first and second arguments bound the search for a pointer to the beginning and end, respectively, of the enclosing higher level section. The third argument is a string specifying the general kind of section such as \"chapter\ or \"section\". When looking for the `Next' pointer, the section found will be at the same hierarchical level in the Texinfo file; when looking for the `Previous' pointer, the section found will be at the same or higher hierarchical level in the Texinfo file; when looking for the `Up' pointer, the section found will be at some level higher in the Texinfo file. The fourth argument \(one of 'next, 'previous, or 'up\) specifies whether to find the `Next', `Previous', or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) (forward-line 3) ; skip over current node ;; Search for section commands accompanied by node lines; ;; ignore section commands in the middle of nodes. (if (re-search-forward ;; A `Top' node is never a next pointer, so won't find it. (concat ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-same-level-regexps)))) end t) 'normal 'no-pointer)) ((eq direction 'previous) (if (re-search-backward (concat "\\(" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-same-level-regexps))) "\\|" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) "\\|" ;; Handle `Top' node specially. "^@node [ \t]*top[ \t]*\\(,\\|$\\)" "\\)") beginning t) 'normal 'no-pointer)) ((eq direction 'up) (if (re-search-backward (concat "\\(" ;; Match node line. "\\(^@node\\).*\n" ;; Match comment or ifinfo line, if any "\\(\\(\\(^@c\\).*\n\\)\\|\\(^@ifinfo[ ]*\n\\)\\)?" (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) "\\|" ;; Handle `Top' node specially. "^@node [ \t]*top[ \t]*\\(,\\|$\\)" "\\)") (save-excursion (goto-char beginning) (beginning-of-line) (point)) t) 'normal 'no-pointer)) (t (error "texinfo-find-pointer: lack proper arguments"))))) (defun texinfo-pointer-name (kind) "Return the node name preceding the section command. The argument is the kind of section, either normal or no-pointer." (let (name) (cond ((eq kind 'normal) (end-of-line) ; this handles prev node top case (re-search-backward ; when point is already "^@node" ; at the beginning of @node line (save-excursion (forward-line -3)) t) (setq name (texinfo-copy-node-name))) ((eq kind 'no-pointer) (setq name " "))) ; put a blank in the pointer slot name)) (defun texinfo-insert-pointer (beginning end level direction) "Insert the `Next', `Previous' or `Up' node name at point. Move point forward. The first and second arguments bound the search for a pointer to the beginning and end, respectively, of the enclosing higher level section. The third argument is the hierarchical level of the Texinfo file, a string such as \"section\". The fourth argument is direction towards which the pointer is directed, one of `next, `previous, or 'up." (end-of-line) (insert ", " (save-excursion (texinfo-pointer-name (texinfo-find-pointer beginning end level direction))))) (defun texinfo-clean-up-node-line () "Remove extra commas, if any, at end of node line." (end-of-line) (skip-chars-backward ", ") (delete-region (point) (save-excursion (end-of-line) (point)))) ;;; Updating nodes sequentially ; These sequential update functions insert `Next' or `Previous' ; pointers that point to the following or preceding nodes even if they ; are at higher or lower hierarchical levels. This means that if a ; section contains one or more subsections, the section's `Next' ; pointer will point to the subsection and not the following section. ; (The subsection to which `Next' points will most likely be the first ; item on the section's menu.) (defun texinfo-sequential-node-update (&optional region-p) "Update one node (or many) in a Texinfo file with sequential pointers. This function causes the `Next' or `Previous' pointer to point to the immediately preceding or following node, even if it is at a higher or lower hierarchical level in the document. Continually pressing `n' or `p' takes you straight through the file. Without any prefix argument, update the node in which point is located. Non-nil argument (prefix, if interactive) means update the nodes in the marked region. This command makes it awkward to navigate among sections and subsections; it should be used only for those documents that are meant to be read like a novel rather than a reference, and for which the Info `g*' command is inadequate." (interactive "P") (if (not region-p) (let ((auto-fill-hook nil)) ; update a single node (if (not (re-search-backward "^@node" (point-min) t)) (error "Node line not found before this position.")) (texinfo-sequentially-update-the-node) (message "Done...sequentially updated the node . You may save the buffer.")) ;; else (let ((auto-fill-hook nil) (beginning (region-beginning)) (end (region-end))) (if (= end beginning) (error "Please mark a region!")) (save-restriction (narrow-to-region beginning end) (goto-char beginning) (push-mark (point) t) (while (re-search-forward "^@node" (point-max) t) (beginning-of-line) (texinfo-sequentially-update-the-node)) (message "Done...updated the nodes in sequence. You may save the buffer."))))) (defun texinfo-sequentially-update-the-node () "Update one node such that the pointers are sequential. A `Next' or `Previous' pointer points to any preceding or following node, regardless of its hierarchical level." (texinfo-check-for-node-name) (texinfo-delete-existing-pointers) (message "Sequentially updating node: %s ... " (texinfo-copy-node-name)) (save-restriction (widen) (let* ((case-fold-search t) (level (texinfo-hierarchic-level))) (if (string-equal level "top") (texinfo-top-pointer-case) ;; else (texinfo-sequentially-insert-pointer level 'next) (texinfo-sequentially-insert-pointer level 'previous) (texinfo-sequentially-insert-pointer level 'up) (texinfo-clean-up-node-line))))) (defun texinfo-sequentially-find-pointer (level direction) "Find next or previous pointer sequentially in Texinfo file, or up pointer. Move point to section associated with the pointer. Find point even if it is in a different section. Return type of pointer (either 'normal or 'no-pointer). The first argument is a string specifying the general kind of section such as \"chapter\ or \"section\". The section found will be at the same hierarchical level in the Texinfo file, or, in the case of the up pointer, some level higher. The second argument (one of 'next, 'previous, or 'up) specifies whether to find the `Next', `Previous', or `Up' pointer." (let ((case-fold-search t)) (cond ((eq direction 'next) (forward-line 3) ; skip over current node (if (re-search-forward texinfo-section-types-regexp (point-max) t) 'normal 'no-pointer)) ((eq direction 'previous) (if (re-search-backward texinfo-section-types-regexp (point-min) t) 'normal 'no-pointer)) ((eq direction 'up) (if (re-search-backward (eval (cdr (assoc level texinfo-update-menu-higher-regexps))) beginning t) 'normal 'no-pointer)) (t (error "texinfo-sequential-find-pointer: lack proper arguments"))))) (defun texinfo-sequentially-insert-pointer (level direction) "Insert the `Next', `Previous' or `Up' node name at point. Move point forward. The first argument is the hierarchical level of the Texinfo file, a string such as \"section\". The second argument is direction, one of `next, `previous, or 'up." (end-of-line) (insert ", " (save-excursion (texinfo-pointer-name (texinfo-sequentially-find-pointer level direction))))) ;;; Inserting `@node' lines ; The `texinfo-insert-node-lines' function inserts `@node' lines as needed ; before the `@chapter', `@section', and such like lines of a region ; in a Texinfo file. (defun texinfo-insert-node-lines (beginning end &optional title-p) "Insert missing `@node' lines in region of Texinfo file. Non-nil argument (prefix, if interactive) means also to insert the section titles as node names; and also to insert the section titles as node names in pre-existing @node lines that lack names." (interactive "r\nP") ;; Use marker; after inserting node lines, leave point at end of ;; region and mark at beginning. (let (beginning-marker end-marker title last-section-position) ;; Save current position on mark ring and set mark to end. (push-mark end t) (setq end-marker (mark-marker)) (goto-char beginning) (while (re-search-forward texinfo-section-types-regexp end-marker 'end) ;; Copy title if desired. (if title-p (progn (beginning-of-line) (forward-word 1) (skip-chars-forward " \t") (setq title (buffer-substring (point) (save-excursion (end-of-line) (point)))))) ;; Insert node line if necessary. (if (re-search-backward "^@node" ;; Avoid finding previous node line if node lines are close. (or last-section-position (save-excursion (forward-line -2) (point))) t) ;; @node is present, and point at beginning of that line (forward-word 1) ; Leave point just after @node. ;; Else @node missing; insert one. (beginning-of-line) ; Beginning of `@section' line. (insert "@node\n") (backward-char 1)) ; Leave point just after `@node'. ;; Insert title if desired. (if title-p (progn (skip-chars-forward " \t") ;; Use regexp based on what info looks for ;; (alternatively, use "[a-zA-Z]+"); ;; this means we only insert a title if none exists. (if (not (looking-at "[^,\t\n ]+")) (progn (beginning-of-line) (forward-word 1) (insert " " title) (message "Inserted title %s ... " title))))) ;; Go forward beyond current section title. (re-search-forward texinfo-section-types-regexp (save-excursion (forward-line 3) (point)) t) (setq last-section-position (point)) (forward-line 1)) ;; Leave point at end of region, mark at beginning. (set-mark beginning) (if title-p (message "Done inserting node lines and titles. You may save the buffer.") (message "Done inserting node lines. You may save the buffer.")))) ;;; Update and create menus for multi-file Texinfo sources ;; 1. M-x texinfo-multiple-files-update ;; ;; Read the include file list of an outer Texinfo file and ;; update all highest level nodes in the files listed and insert a ;; main menu in the outer file after its top node. ;; 2. C-u M-x texinfo-multiple-files-update ;; ;; Same as 1, but insert a master menu. (Saves reupdating lower ;; level menus and nodes.) This command simply reads every menu, ;; so if the menus are wrong, the master menu will be wrong. ;; Similarly, if the lower level node pointers are wrong, they ;; will stay wrong. ;; 3. C-u 2 M-x texinfo-multiple-files-update ;; ;; Read the include file list of an outer Texinfo file and ;; update all nodes and menus in the files listed and insert a ;; master menu in the outer file after its top node. ;;; Note: these functions: ;;; ;;; * Do not save or delete any buffers. You may fill up your memory. ;;; * Do not handle any pre-existing nodes in outer file. ;;; Hence, you may need a file for indices. ;;; Auxiliary functions for multiple file updating (defun texinfo-multi-file-included-list (outer-file) "Return a list of the included files in OUTER-FILE." (let ((included-file-list (list outer-file)) start) (save-excursion (switch-to-buffer (find-file-noselect outer-file)) (widen) (goto-char (point-min)) (while (re-search-forward "^@include" nil t) (skip-chars-forward " \t") (setq start (point)) (end-of-line) (skip-chars-backward " \t") (setq included-file-list (cons (buffer-substring start (point)) included-file-list))) (nreverse included-file-list)))) (defun texinfo-copy-next-section-title () "Return the name of the immediately following section as a string. Start with point at the beginning of the node line. Leave point at the same place. If there is no title, returns an empty string." (save-excursion (end-of-line) (let ((section-end (or (save-excursion (if (re-search-forward "\\(^@node\\)" nil t) (match-beginning 0))) (point-max)))) (if (re-search-forward texinfo-section-types-regexp section-end t) (progn (beginning-of-line) ;; copy title (let ((title (buffer-substring (progn (forward-word 1) ; skip over section type (skip-chars-forward " \t") ; and over spaces (point)) (progn (end-of-line) (point))))) title)) "")))) (defun texinfo-multi-file-update (files &optional update-everything) "Update first node pointers in each file in FILES. Return a list of the node names and the title immediate following them. The first file in the list is an outer file; the remaining are files included in the outer file with `@include' commands. If optional arg UPDATE-EVERYTHING non-nil, update every menu and pointer in each of the included files. Also update the `Top' level node pointers of the outer file. Requirements: * the first file in the FILES list must be the outer file, * each of the included files must contain exactly one highest hierarchical level node, * this node must be the first node in the included file, * each highest hierarchical level node must be of the same type. Thus, normally, each included file contains one, and only one, chapter. The menu-list has the form: \(\(\"node-name1\" . \"title1\"\) \(\"node-name2\" . \"title2\"\) ... \) However, there does not need to be a title field." (let ((case-fold-search t) menu-list) ;; Find the name of the first node of the first included file. (switch-to-buffer (find-file-noselect (car (cdr files)))) (widen) (goto-char (point-min)) (if (not (re-search-forward "^@node" nil t)) (error "No `@node' line found in %s !" (buffer-name))) (beginning-of-line) (texinfo-check-for-node-name) (setq next-node-name (texinfo-copy-node-name)) (setq menu-list (cons (cons next-node-name (texinfo-copy-next-section-title)) menu-list)) ;; Go to outer file (switch-to-buffer (find-file-noselect (car files))) (goto-char (point-min)) (if (not (re-search-forward "^@node [ \t]*top[ \t]*\\(,\\|$\\)" nil t)) (error "This buffer needs a Top node!")) (beginning-of-line) (texinfo-delete-existing-pointers) (end-of-line) (insert ", " next-node-name ", (dir), (dir)") (beginning-of-line) (setq previous-node-name "Top") (setq files (cdr files)) (while files (if (not (cdr files)) ;; No next file (setq next-node-name "") ;; Else, ;; find the name of the first node in the next file. (switch-to-buffer (find-file-noselect (car (cdr files)))) (widen) (goto-char (point-min)) (if (not (re-search-forward "^@node" nil t)) (error "No `@node' line found in %s !" (buffer-name))) (beginning-of-line) (texinfo-check-for-node-name) (setq next-node-name (texinfo-copy-node-name)) (setq menu-list (cons (cons next-node-name (texinfo-copy-next-section-title)) menu-list))) ;; Go to node to be updated. (switch-to-buffer (find-file-noselect (car files))) (goto-char (point-min)) (if (not (re-search-forward "^@node" nil t)) (error "No `@node' line found in %s !" (buffer-name))) (beginning-of-line) ;; Update other menus and nodes if requested. (if update-everything (texinfo-all-menus-update t)) (beginning-of-line) (texinfo-delete-existing-pointers) (end-of-line) (insert ", " next-node-name ", " previous-node-name ", " up-node-name) (beginning-of-line) (setq previous-node-name (texinfo-copy-node-name)) (setq files (cdr files))) (nreverse menu-list))) (defun texinfo-multi-files-insert-main-menu (menu-list) "Insert formatted main menu at point. Indents the first line of the description, if any, to the value of texinfo-column-for-description." (insert "@menu\n") (while menu-list (if (cdr (car menu-list)) ; menu-list has description entry (progn (insert (format "* %s::" (car (car menu-list)))) ; node-name entry (indent-to texinfo-column-for-description 2) (insert (format "%s\n" (cdr (car menu-list))))) ; description entry ;; else menu-list lacks description entry (insert (format "* %s::\n" (car (car menu-list))))) ; node-name entry (setq menu-list (cdr menu-list))) (insert "@end menu")) (defun texinfo-multi-file-master-menu-list (files-list) "Return master menu list from files in FILES-LIST. Menu entries in each file collected using `texinfo-master-menu-list'. The first file in FILES-LIST must be the outer file; the others must be the files included within it. A main menu must already exist." (save-excursion (let (master-menu-list) (while files-list (switch-to-buffer (find-file-noselect (car files-list))) (message "Working on: %s " (current-buffer)) (goto-char (point-min)) (setq master-menu-list (append master-menu-list (texinfo-master-menu-list))) (setq files-list (cdr files-list))) master-menu-list))) ;;; The multiple-file update function (defun texinfo-multiple-files-update (outer-file &optional update-everything make-master-menu) "Update first node pointers in each file included in OUTER-FILE; create or update the `Top' level node pointers and the main menu in the outer file that refers to such nodes. This does not create or update menus or pointers within the included files. With optional MAKE-MASTER-MENU argument (prefix arg, if interactive), insert a master menu in OUTER-FILE in addition to creating or updating pointers in the first @node line in each included file and creating or updating the `Top' level node pointers of the outer file. This does not create or update other menus and pointers within the included files. With optional UPDATE-EVERYTHING argument (numeric prefix arg, if interactive), update all the menus and all the `Next', `Previous', and `Up' pointers of all the files included in OUTER-FILE before inserting a master menu in OUTER-FILE. Also, update the `Top' level node pointers of OUTER-FILE. Notes: * this command does NOT save any files--you must save the outer file and any modified, included files. * except for the `Top' node, this command does NOT handle any pre-existing nodes in the outer file; hence, indices must be enclosed in an included file. Requirements: * each of the included files must contain exactly one highest hierarchical level node, * this highest node must be the first node in the included file, * each highest hierarchical level node must be of the same type. Thus, normally, each included file contains one, and only one, chapter." (interactive (cons (read-string "Name of outer `include' file: " (buffer-file-name)) (cond ((not current-prefix-arg) '(nil nil)) ((listp current-prefix-arg) '(t nil)) ; make-master-menu ((numberp current-prefix-arg) '(t t)) ; update-everything ))) (let* ((included-file-list (texinfo-multi-file-included-list outer-file)) (files included-file-list) main-menu-list next-node-name previous-node-name (up-node-name "Top")) ;;; Update the pointers ;;; and collect the names of the nodes and titles (setq main-menu-list (texinfo-multi-file-update files update-everything)) ;;; Insert main menu ;; Go to outer file (switch-to-buffer (find-file-noselect (car included-file-list))) (if (texinfo-old-menu-p (point-min) (save-excursion (re-search-forward "^@include") (beginning-of-line) (point))) ;; If found, leave point after word `menu' on the `@menu' line. (progn (texinfo-incorporate-descriptions main-menu-list) ;; Delete existing menu. (beginning-of-line) (delete-region (point) (save-excursion (re-search-forward "^@end menu") (point))) ;; Insert main menu (texinfo-multi-files-insert-main-menu main-menu-list)) ;; Else no current menu; insert it before `@include' (texinfo-multi-files-insert-main-menu main-menu-list)) ;;; Insert master menu (if make-master-menu (progn ;; First, removing detailed part of any pre-existing master menu (goto-char (point-min)) (if (re-search-forward texinfo-master-menu-header nil t) ;; Remove detailed master menu listing (progn (goto-char (match-beginning 0)) (let ((end-of-detailed-menu-descriptions (save-excursion ; beginning of end menu line (goto-char (texinfo-menu-end)) (beginning-of-line) (forward-char -1) (point)))) (delete-region (point) end-of-detailed-menu-descriptions)))) ;; Create a master menu and insert it (texinfo-insert-master-menu-list (texinfo-multi-file-master-menu-list included-file-list))))) (message "Multiple files updated.")) ;;; Place `provide' at end of file. (provide 'texnfo-upd) ;;;;;;;;;;;;;;;; end texnfo-upd.el ;;;;;;;;;;;;;;;; texinfo-2.15/elisp/makeinfo.el0000644000175000017500000002714012415567307013620 0ustar gg;;;; makeinfo.el ;;; Texinfo mode interface to the `makeinfo' command ;;; for converting part or all of a Texinfo file to an Info file. ;;; Version 2.04 12 February 1992 ;;; Robert J. Chassell ;;; Copyright (C) 1991 Free Software Foundation, Inc. ;;; This file is part of GNU Emacs. ;; GNU Emacs is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation; either version 1, or (at your option) ;; any later version. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with GNU Emacs; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. ;;; The Texinfo mode `makeinfo' related commands are: ;; makeinfo-region to run makeinfo on the current region. ;; makeinfo-buffer to run makeinfo on the current buffer, or ;; with optional prefix arg, on current region ;; kill-compilation to kill currently running makeinfo job ;; makeinfo-recenter-makeinfo-buffer to redisplay *compilation* buffer ;;; Keybindings (defined in `texinfo.el') ;; makeinfo bindings ; (define-key texinfo-mode-map "\C-c\C-m\C-r" 'makeinfo-region) ; (define-key texinfo-mode-map "\C-c\C-m\C-b" 'makeinfo-buffer) ; (define-key texinfo-mode-map "\C-c\C-m\C-k" 'kill-compilation) ; (define-key texinfo-mode-map "\C-c\C-m\C-l" ; 'makeinfo-recenter-compilation-buffer) ;;; Variables used by `makeinfo' (require 'compile) (defvar makeinfo-run-command "makeinfo" "*Command used to run makeinfo subjob. The name of the file will be appended to this string, separated by a space.") (defvar makeinfo-options "+fill-column=70" "*String containing flags for makeinfo. Do not include footnote-style or paragraph-indent, which are specified by @footnotestyle and @paragraphindent.") (require 'texinfo) (require 'texinfmt) (defvar makeinfo-compilation-process nil "Process that runs makeinfo. Should start out nil.") (defvar makeinfo-temp-file nil "Temporary file name used for text being sent as input to makeinfo.") (defvar makeinfo-output-file-name nil "Info file name used for text output by makeinfo.") ;;; The `makeinfo' function definitions (autoload 'compile1 "compile") (defun makeinfo-region (region-beginning region-end) "Make Info file from region of current Texinfo file, and switch to it. This command does not offer the `next-error' feature since it would apply to a temporary file, not the original; use the `makeinfo-buffer' command to gain use of `next-error'." (interactive "r") (let (filename-or-header filename-or-header-beginning filename-or-header-end) ;; Cannot use `let' for makeinfo-temp-file or ;; makeinfo-output-file-name since `makeinfo-compilation-sentinel' ;; needs them. (setq makeinfo-temp-file (concat (make-temp-name (substring (buffer-file-name) 0 (or (string-match "\\.tex" (buffer-file-name)) (length (buffer-file-name))))) ".texinfo")) (save-excursion (save-restriction (widen) (goto-char (point-min)) (let ((search-end (save-excursion (forward-line 100) (point)))) ;; Find and record the Info filename, ;; or else explain that a filename is needed. (if (re-search-forward "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" search-end t) (setq makeinfo-output-file-name (buffer-substring (match-beginning 1) (match-end 1))) (error "The texinfo file needs a line saying: @setfilename ")) ;; Find header and specify its beginning and end. (goto-char (point-min)) (if (and (prog1 (search-forward texinfo-start-of-header search-end t) (beginning-of-line) ;; Mark beginning of header. (setq filename-or-header-beginning (point))) (prog1 (search-forward texinfo-end-of-header nil t) (beginning-of-line) ;; Mark end of header (setq filename-or-header-end (point)))) ;; Insert the header into the temporary file. (write-region (min filename-or-header-beginning region-beginning) filename-or-header-end makeinfo-temp-file nil nil) ;; Else no header; insert @filename line into temporary file. (goto-char (point-min)) (search-forward "@setfilename" search-end t) (beginning-of-line) (setq filename-or-header-beginning (point)) (forward-line 1) (setq filename-or-header-end (point)) (write-region (min filename-or-header-beginning region-beginning) filename-or-header-end makeinfo-temp-file nil nil)) ;; Insert the region into the file. (write-region (max region-beginning filename-or-header-end) region-end makeinfo-temp-file t nil) ;; Run the `makeinfo-compile' command in the *compilation* buffer (save-excursion (makeinfo-compile (concat makeinfo-run-command " " makeinfo-options " " makeinfo-temp-file) "Use `makeinfo-buffer' to gain use of the `next-error' command."))))))) ;; Based on `compile1' in compile.el; changed so to make it possible ;; to delete temporary file. (defun makeinfo-compile (command error-message &optional name-of-mode) ;(save-some-buffers) ; Don't need to save other buffers. (if makeinfo-compilation-process (if (or (not (eq (process-status makeinfo-compilation-process) 'run)) (yes-or-no-p "A `makeinfo' compilation process is running; kill it? ")) (condition-case () (let ((comp-proc makeinfo-compilation-process)) (interrupt-process comp-proc) (sit-for 1) (delete-process comp-proc)) (error nil)) (error "Cannot have two makeinfo processes"))) (setq makeinfo-compilation-process nil) (compilation-forget-errors) (setq compilation-error-list t) (setq compilation-error-message error-message) (setq makeinfo-compilation-process (start-process "makeinfo" "*compilation*" shell-file-name "-c" (concat "exec " command))) (with-output-to-temp-buffer "*compilation*" (princ "cd ") (princ default-directory) (terpri) (princ command) (terpri)) (let ((regexp compilation-error-regexp)) (save-excursion (set-buffer "*compilation*") (make-local-variable 'compilation-error-regexp) (setq compilation-error-regexp regexp))) (set-process-sentinel makeinfo-compilation-process 'makeinfo-compilation-sentinel) (let* ((thisdir default-directory) (outbuf (process-buffer makeinfo-compilation-process)) (outwin (get-buffer-window outbuf))) (if (eq outbuf (current-buffer)) (goto-char (point-max))) (save-excursion (set-buffer outbuf) (buffer-flush-undo outbuf) (let ((start (save-excursion (set-buffer outbuf) (point-min)))) (set-window-start outwin start) (or (eq outwin (selected-window)) (set-window-point outwin start))) (setq default-directory thisdir) (fundamental-mode) (setq mode-name (or name-of-mode "compilation")) ;; Make log buffer's mode line show process state (setq mode-line-process '(": %s"))))) ;; Delete makeinfo-temp-file after proccessing is finished, ;; and visit Info file. ;; This function is called when the compilation process changes state. ;; Based on `compilation-sentinel' in compile.el (defun makeinfo-compilation-sentinel (proc msg) (cond ((null (buffer-name (process-buffer proc))) ;; buffer killed (set-process-buffer proc nil)) ((memq (process-status proc) '(signal exit)) (let* ((obuf (current-buffer)) omax opoint) ;; save-excursion isn't the right thing if ;; process-buffer is current-buffer (unwind-protect (progn ;; Write something in *compilation* and hack ;; its mode line, (set-buffer (process-buffer proc)) (setq omax (point-max) opoint (point)) (goto-char (point-max)) (insert ?\n mode-name " " msg) (forward-char -1) (insert " at " (substring (current-time-string) 0 -5)) (forward-char 1) (setq mode-line-process (concat ": " (symbol-name (process-status proc)))) ;; If buffer and mode line will show that the process ;; is dead, we can delete it now. Otherwise it ;; will stay around until M-x list-processes. (delete-process proc)) (setq makeinfo-compilation-process nil) ;; Force mode line redisplay soon (set-buffer-modified-p (buffer-modified-p))) (if (and opoint (< opoint omax)) (goto-char opoint)) (set-buffer obuf)) (if (and makeinfo-temp-file (file-exists-p makeinfo-temp-file)) (delete-file makeinfo-temp-file)) ;; Always use the version on disk. (if (get-file-buffer makeinfo-output-file-name) (progn (set-buffer makeinfo-output-file-name) (revert-buffer t t))) (find-file makeinfo-output-file-name) (goto-char (point-min))))) (defun makeinfo-buffer (buffer) "Make Info file from current buffer. The \\[next-error] command can be used to move to the next error \(if any are found\)." (interactive "bRun `makeinfo' on: ") (cond ((null buffer-file-name) (error "Buffer not visiting any file!")) ((buffer-modified-p) (if (y-or-n-p "Buffer modified; do you want to save it? ") (save-buffer)))) ;; Find and record the Info filename, ;; or else explain that a filename is needed. (save-excursion (goto-char (point-min)) (let ((search-end (save-excursion (forward-line 100) (point)))) (if (re-search-forward "^@setfilename[ \t]+\\([^ \t\n]+\\)[ \t]*" search-end t) (setq makeinfo-output-file-name (buffer-substring (match-beginning 1) (match-end 1))) (error "The texinfo file needs a line saying: @setfilename ")))) (save-excursion (makeinfo-compile (concat makeinfo-run-command " " makeinfo-options " " "+footnote-style=" texinfo-footnote-style " " (buffer-file-name (get-buffer buffer))) "No more errors."))) (defun makeinfo-recenter-compilation-buffer (linenum) "Redisplay *compilation* buffer so that most recent output can be seen. The last line of the buffer is displayed on line LINE of the window, or centered if LINE is nil." (interactive "P") (let ((makeinfo-buffer (get-buffer "*compilation*")) (old-buffer (current-buffer))) (if (null makeinfo-buffer) (message "No *compilation* buffer") (pop-to-buffer makeinfo-buffer) (bury-buffer makeinfo-buffer) (goto-char (point-max)) (recenter (if linenum (prefix-numeric-value linenum) (/ (window-height) 2))) (pop-to-buffer old-buffer) ))) ;;; Place `provide' at end of file. (provide 'makeinfo) ;;;;;;;;;;;;;;;; end makeinfo.el ;;;;;;;;;;;;;;;; texinfo-2.15/ORIGIN0000644000175000017500000000026713751577001011300 0ustar ggThe contents of this package were retrieved from http://www.oldlinux.org/Linux.old/Linux-0.98/Yggdrasil-0.98.3/usr/src/usr.bin/texinfo-2.15/ The tar.gz file itself is not original. texinfo-2.15/texinfo.tex0000644000175000017500000032451012415566476012576 0ustar gg%% TeX macros to handle texinfo files % Copyright (C) 1985, 1986, 1988, 1990, 1991 Free Software Foundation, Inc. %This texinfo.tex file is free software; you can redistribute it and/or %modify it under the terms of the GNU General Public License as %published by the Free Software Foundation; either version 2, or (at %your option) any later version. %This texinfo.tex file is distributed in the hope that it will be %useful, but WITHOUT ANY WARRANTY; without even the implied warranty %of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU %General Public License for more details. %You should have received a copy of the GNU General Public License %along with this texinfo.tex file; see the file COPYING. If not, write %to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, %USA. %In other words, you are welcome to use, share and improve this program. %You are forbidden to forbid anyone else to use, share and improve %what you give them. Help stamp out software-hoarding! \def\texinfoversion{2.72} \message{Loading texinfo package [Version \texinfoversion]:} \message{} % Print the version number if in a .fmt file. \everyjob{\message{[Texinfo version \texinfoversion]}\message{}} % Save some parts of plain tex whose names we will redefine. \let\ptexlbrace=\{ \let\ptexrbrace=\} \let\ptexdots=\dots \let\ptexdot=\. \let\ptexstar=\* \let\ptexend=\end \let\ptexbullet=\bullet \let\ptexb=\b \let\ptexc=\c \let\ptexi=\i \let\ptext=\t \let\ptexl=\l \let\ptexL=\L \def\tie{\penalty 10000\ } % Save plain tex definition of ~. \message{Basics,} \chardef\other=12 % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J \hyphenation{ap-pen-dix} \hyphenation{mini-buf-fer mini-buf-fers} \hyphenation{eshell} % Margin to add to right of even pages, to left of odd pages. \newdimen \bindingoffset \bindingoffset=0pt \newdimen \normaloffset \normaloffset=\hoffset \newdimen\pagewidth \newdimen\pageheight \pagewidth=\hsize \pageheight=\vsize % Sometimes it is convenient to have everything in the transcript file % and nothing on the terminal. We don't just call \tracingall here, % since that produces some useless output on the terminal. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \def\loggingall{\tracingcommands2 \tracingstats2 \tracingpages1 \tracingoutput1 \tracinglostchars1 \tracingmacros2 \tracingparagraphs1 \tracingrestores1 \showboxbreadth\maxdimen\showboxdepth\maxdimen }% %---------------------Begin change----------------------- % %%%% For @cropmarks command. % Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\cornerlong \newdimen\cornerthick \newdimen \topandbottommargin \newdimen \outerhsize \newdimen \outervsize \cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks \outerhsize=7in %\outervsize=9.5in % Alternative @smallbook page size is 9.25in \outervsize=9.25in \topandbottommargin=.75in % %---------------------End change----------------------- % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions itself, but you have to call it yourself. \chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} \def\onepageout#1{\hoffset=\normaloffset \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi {\escapechar=`\\\relax % makes sure backslash is used in output files. \shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% {\let\hsize=\pagewidth \makefootline}}}% \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} %%%% For @cropmarks command %%%% % Here is a modification of the main output routine for Near East Publications % This provides right-angle cropmarks at all four corners. % The contents of the page are centerlined into the cropmarks, % and any desired binding offset is added as an \hskip on either % site of the centerlined box. (P. A. MacKay, 12 November, 1986) % \def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up \shipout \vbox to \outervsize{\hsize=\outerhsize \vbox{\line{\ewtop\hfill\ewtop}} \nointerlineskip \line{\vbox{\moveleft\cornerthick\nstop} \hfill \vbox{\moveright\cornerthick\nstop}} \vskip \topandbottommargin \centerline{\ifodd\pageno\hskip\bindingoffset\fi \vbox{ {\let\hsize=\pagewidth \makeheadline} \pagebody{#1} {\let\hsize=\pagewidth \makefootline}} \ifodd\pageno\else\hskip\bindingoffset\fi} \vskip \topandbottommargin plus1fill minus1fill \boxmaxdepth\cornerthick \line{\vbox{\moveleft\cornerthick\nsbot} \hfill \vbox{\moveright\cornerthick\nsbot}} \nointerlineskip \vbox{\line{\ewbot\hfill\ewbot}} } \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} % % Do @cropmarks to get crop marks \def\cropmarks{\let\onepageout=\croppageout } \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi \dimen@=\dp#1 \unvbox#1 \ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi \ifr@ggedbottom \kern-\dimen@ \vfil \fi} } % % Here are the rules for the cropmarks. Note that they are % offset so that the space between them is truly \outerhsize or \outervsize % (P. A. MacKay, 12 November, 1986) % \def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} \def\nstop{\vbox {\hrule height\cornerthick depth\cornerlong width\cornerthick}} \def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} \def\nsbot{\vbox {\hrule height\cornerlong depth\cornerthick width\cornerthick}} % Parse an argument, then pass it to #1. % The argument can be delimited with [...] or with "..." or braces % or it can be a whole line. % #1 should be a macro which expects % an ordinary undelimited TeX argument. \def\parsearg #1{\let\next=#1\begingroup\obeylines\futurelet\temp\parseargx} \def\parseargx{% \ifx \obeyedspace\temp \aftergroup\parseargdiscardspace \else% \aftergroup \parseargline % \fi \endgroup} {\obeyspaces % \gdef\parseargdiscardspace {\begingroup\obeylines\futurelet\temp\parseargx}} \gdef\obeyedspace{\ } \def\parseargline{\begingroup \obeylines \parsearglinex} {\obeylines % \gdef\parsearglinex #1^^M{\endgroup \next {#1}}} \def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} %% These are used to keep @begin/@end levels from running away %% Call \inENV within environments (after a \begingroup) \newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} \def\ENVcheck{% \ifENV\errmessage{Still within an environment. Type Return to continue.} \endgroup\fi} % This is not perfect, but it should reduce lossage % @begin foo is the same as @foo, for now. \newhelp\EMsimple{Type to continue} \outer\def\begin{\parsearg\beginxxx} \def\beginxxx #1{% \expandafter\ifx\csname #1\endcsname\relax {\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else \csname #1\endcsname\fi} %% @end foo executes the definition of \Efoo. %% foo can be delimited by doublequotes or brackets. \def\end{\parsearg\endxxx} \def\endxxx #1{% \expandafter\ifx\csname E#1\endcsname\relax \expandafter\ifx\csname #1\endcsname\relax \errmessage{Undefined command @end #1}\else \errorE{#1}\fi\fi \csname E#1\endcsname} \def\errorE#1{ {\errhelp=\EMsimple \errmessage{@end #1 not within #1 environment}}} % Single-spacing is done by various environments. \newskip\singlespaceskip \singlespaceskip = \baselineskip \def\singlespace{% {\advance \baselineskip by -\singlespaceskip \kern \baselineskip}% \baselineskip=\singlespaceskip } %% Simple single-character @ commands % @@ prints an @ % Kludge this until the fonts are right (grr). \def\@{{\tt \char '100}} % Define @` and @' to be the same as ` and ' % but suppressing ligatures. \def\`{{`}} \def\'{{'}} % Used to generate quoted braces. \def\mylbrace {{\tt \char '173}} \def\myrbrace {{\tt \char '175}} \let\{=\mylbrace \let\}=\myrbrace % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } % @w prevents a word break. Without the \leavevmode, @w at the % beginning of a paragraph, when TeX is still in vertical mode, would % produce a whole line of output instead of starting the paragraph. \def\w#1{\leavevmode\hbox{#1}} % @group ... @end group forces ... to be all on one page, by enclosing % it in a TeX vbox. We use \vtop instead of \vbox to construct the box % to keep its height that of a normal line. According to the rules for % \topskip (p.114 of the TeXbook), the glue inserted is % max (\topskip - \ht (first item), 0). If that height is large, % therefore, no glue is inserted, and the space between the headline and % the text is small, which looks bad. % \def\group{\begingroup \ifnum\catcode13=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi \def\Egroup{\egroup\endgroup}% \vtop\bgroup } % % TeX puts in an \escapechar (i.e., `@') at the beginning of the help % message, so this ends up printing `@group can only ...'. % \newhelp\groupinvalidhelp{% group can only be used in environments such as @example,^^J% where each line of input produces a line of output.} % @need space-in-mils % forces a page break if there is not space-in-mils remaining. \newdimen\mil \mil=0.001in \def\need{\parsearg\needx} % Old definition--didn't work. %\def\needx #1{\par % %% This method tries to make TeX break the page naturally %% if the depth of the box does not fit. %{\baselineskip=0pt% %\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 %\prevdepth=-1000pt %}} \def\needx#1{% % Go into vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % Don't add any leading before our big empty box, but allow a page % break, since the best break might be right here. \allowbreak \nointerlineskip \vtop to #1\mil{\vfil}% % % TeX does not even consider page breaks if a penalty added to the % main vertical list is 10000 or more. But in order to see if the % empty box we just added fits on the page, we must make it consider % page breaks. On the other hand, we don't want to actually break the % page after the empty box. So we use a penalty of 9999. % % There is an extremely small chance that TeX will actually break the % page at this \penalty, if there are no other feasible breakpoints in % sight. (If the user is using lots of big @group commands, which % almost-but-not-quite fill up a page, TeX will have a hard time doing % good page breaking, for example.) However, I could not construct an % example where a page broke at this \penalty; if it happens in a real % document, then we can reconsider our strategy. \penalty9999 % % Back up by the size of the box, whether we did a page break or not. \kern -#1\mil % % Do not allow a page break right after this kern. \nobreak } % @br forces paragraph break \let\br = \par % @dots{} output some dots \def\dots{$\ldots$} % @page forces the start of a new page \def\page{\par\vfill\supereject} % @exdent text.... % outputs text on separate line in roman font, starting at standard page margin % This records the amount of indent in the innermost environment. % That's how much \exdent should take out. \newskip\exdentamount % This defn is used inside fill environments such as @defun. \def\exdent{\parsearg\exdentyyy} \def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} % This defn is used inside nofill environments such as @example. \def\nofillexdent{\parsearg\nofillexdentyyy} \def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount \leftline{\hskip\leftskip{\rm#1}}}} %\hbox{{\rm#1}}\hfil\break}} % @include file insert text of that file as input. \def\include{\parsearg\includezzz} \def\includezzz #1{{\def\thisfile{#1}\input #1 }} \def\thisfile{} % @center line outputs that line, centered \def\center{\parsearg\centerzzz} \def\centerzzz #1{{\advance\hsize by -\leftskip \advance\hsize by -\rightskip \centerline{#1}}} % @sp n outputs n lines of vertical space \def\sp{\parsearg\spxxx} \def\spxxx #1{\par \vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment \def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% \parsearg \commentxxx} \def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } \let\c=\comment % Prevent errors for section commands. % Used in @ignore and in failing conditionals. \def\ignoresections{% \let\chapter=\relax \let\unnumbered=\relax \let\top=\relax \let\unnumberedsec=\relax \let\unnumberedsection=\relax \let\unnumberedsubsec=\relax \let\unnumberedsubsection=\relax \let\unnumberedsubsubsec=\relax \let\unnumberedsubsubsection=\relax \let\section=\relax \let\subsec=\relax \let\subsubsec=\relax \let\subsection=\relax \let\subsubsection=\relax \let\appendix=\relax \let\appendixsec=\relax \let\appendixsection=\relax \let\appendixsubsec=\relax \let\appendixsubsection=\relax \let\appendixsubsubsec=\relax \let\appendixsubsubsection=\relax \let\contents=\relax \let\smallbook=\relax \let\titlepage=\relax } \def\ignore{\begingroup\ignoresections % Make sure that spaces turn into tokens that match what \ignorexxx wants. \catcode32=10 \ignorexxx} \long\def\ignorexxx #1\end ignore{\endgroup\ignorespaces} \def\direntry{\begingroup\direntryxxx} \long\def\direntryxxx #1\end direntry{\endgroup\ignorespaces} % Conditionals to test whether a flag is set. \def\ifset{\begingroup\ignoresections\parsearg\ifsetxxx} \def\ifsetxxx #1{\endgroup \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\ifsetfail \else \let\temp=\relax \fi \temp} \def\Eifset{} \def\ifsetfail{\begingroup\ignoresections\ifsetfailxxx} \long\def\ifsetfailxxx #1\end ifset{\endgroup\ignorespaces} \def\ifclear{\begingroup\ignoresections\parsearg\ifclearxxx} \def\ifclearxxx #1{\endgroup \expandafter\ifx\csname IF#1\endcsname\relax \let\temp=\relax \else \let\temp=\ifclearfail \fi \temp} \def\Eifclear{} \def\ifclearfail{\begingroup\ignoresections\ifclearfailxxx} \long\def\ifclearfailxxx #1\end ifclear{\endgroup\ignorespaces} % @set foo to set the flag named foo. % @clear foo to clear the flag named foo. \def\set{\parsearg\setxxx} \def\setxxx #1{ \expandafter\let\csname IF#1\endcsname=\set} \def\clear{\parsearg\clearxxx} \def\clearxxx #1{ \expandafter\let\csname IF#1\endcsname=\relax} % Some texinfo constructs that are trivial in tex \def\iftex{} \def\Eiftex{} \def\ifinfo{\begingroup\ignoresections\ifinfoxxx} \long\def\ifinfoxxx #1\end ifinfo{\endgroup\ignorespaces} \long\def\menu #1\end menu{} \def\asis#1{#1} % @math means output in math mode. % We don't use $'s directly in the definition of \math because control % sequences like \math are expanded when the toc file is written. Then, % we read the toc file back, the $'s will be normal characters (as they % should be, according to the definition of Texinfo). So we must use a % control sequence to switch into and out of math mode. % % This isn't quite enough for @math to work properly in indices, but it % seems unlikely it will ever be needed there. % \let\implicitmath = $ \def\math#1{\implicitmath #1\implicitmath} \def\node{\ENVcheck\parsearg\nodezzz} \def\nodezzz#1{\nodexxx [#1,]} \def\nodexxx[#1,#2]{\gdef\lastnode{#1}} \let\lastnode=\relax \def\donoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}\fi \let\lastnode=\relax} \def\unnumbnoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi \let\lastnode=\relax} \def\appendixnoderef{\ifx\lastnode\relax\else \expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi \let\lastnode=\relax} \let\refill=\relax % @setfilename is done at the beginning of every texinfo file. % So open here the files we need to have open while reading the input. % This makes it possible to make a .fmt file for texinfo. \def\setfilename{% \readauxfile \opencontents \openindices \fixbackslash % Turn off hack to swallow `\input texinfo'. \global\let\setfilename=\comment % Ignore extra @setfilename cmds. \comment % Ignore the actual filename. } \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{See Info file \file{\losespace#3{}}, node \samp{\losespace#1{}}} \def\losespace #1{#1} \message{fonts,} % Font-change commands. % Texinfo supports the sans serif font style, which plain TeX does not. % So we set up a \sf analogous to plain's \rm, etc. \newfam\sffam \def\sf{\fam=\sffam \tensf} \let\li = \sf % Sometimes we call it \li, not \sf. %% Try out Computer Modern fonts at \magstephalf \let\mainmagstep=\magstephalf \ifx\bigger\relax \let\mainmagstep=\magstep1 \font\textrm=cmr12 \font\texttt=cmtt12 \else \font\textrm=cmr10 scaled \mainmagstep \font\texttt=cmtt10 scaled \mainmagstep \fi % Instead of cmb10, you many want to use cmbx10. % cmbx10 is a prettier font on its own, but cmb10 % looks better when embedded in a line with cmr10. \font\textbf=cmb10 scaled \mainmagstep \font\textit=cmti10 scaled \mainmagstep \font\textsl=cmsl10 scaled \mainmagstep \font\textsf=cmss10 scaled \mainmagstep \font\textsc=cmcsc10 scaled \mainmagstep \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep % A few fonts for @defun, etc. \font\defbf=cmbx10 scaled \magstep1 %was 1314 \font\deftt=cmtt10 scaled \magstep1 \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} % Fonts for indices and small examples. % We actually use the slanted font rather than the italic, % because texinfo normally uses the slanted fonts for that. % Do not make many font distinctions in general in the index, since they % aren't very useful. \font\ninett=cmtt9 \font\indrm=cmr9 \font\indit=cmsl9 \let\indsl=\indit \let\indtt=\ninett \let\indsf=\indrm \let\indbf=\indrm \let\indsc=\indrm \font\indi=cmmi9 \font\indsy=cmsy9 % Fonts for headings \font\chaprm=cmbx12 scaled \magstep2 \font\chapit=cmti12 scaled \magstep2 \font\chapsl=cmsl12 scaled \magstep2 \font\chaptt=cmtt12 scaled \magstep2 \font\chapsf=cmss12 scaled \magstep2 \let\chapbf=\chaprm \font\chapsc=cmcsc10 scaled\magstep3 \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 \font\secrm=cmbx12 scaled \magstep1 \font\secit=cmti12 scaled \magstep1 \font\secsl=cmsl12 scaled \magstep1 \font\sectt=cmtt12 scaled \magstep1 \font\secsf=cmss12 scaled \magstep1 \font\secbf=cmbx12 scaled \magstep1 \font\secsc=cmcsc10 scaled\magstep2 \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 % \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. % \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. % \font\ssecsl=cmsl10 scaled \magstep1 % \font\ssectt=cmtt10 scaled \magstep1 % \font\ssecsf=cmss10 scaled \magstep1 %\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. %\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than %\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. %\font\ssectt=cmtt10 scaled 1315 %\font\ssecsf=cmss10 scaled 1315 %\let\ssecbf=\ssecrm \font\ssecrm=cmbx12 scaled \magstephalf \font\ssecit=cmti12 scaled \magstephalf \font\ssecsl=cmsl12 scaled \magstephalf \font\ssectt=cmtt12 scaled \magstephalf \font\ssecsf=cmss12 scaled \magstephalf \font\ssecbf=cmbx12 scaled \magstephalf \font\ssecsc=cmcsc10 scaled \magstep1 \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled \magstep1 % The smallcaps and symbol fonts should actually be scaled \magstep1.5, % but that is not a standard magnification. % Fonts for title page: \font\titlerm = cmbx12 scaled \magstep3 \let\authorrm = \secrm % In order for the font changes to affect most math symbols and letters, % we have to define the \textfont of the standard families. Since % texinfo doesn't allow for producing subscripts and superscripts, we % don't bother to reset \scriptfont and \scriptscriptfont (which would % also require loading a lot more fonts). % \def\resetmathfonts{% \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf \textfont\ttfam = \tentt \textfont\sffam = \tensf } % The font-changing commands redefine the meanings of \tenSTYLE, instead % of just \STYLE. We do this so that font changes will continue to work % in math mode, where it is the current \fam that is relevant in most % cases, not the current. Plain TeX does, for example, % \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need % to redefine \bf itself. \def\textfonts{% \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy \resetmathfonts} \def\chapfonts{% \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy \resetmathfonts} \def\secfonts{% \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy \resetmathfonts} \def\subsecfonts{% \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy \resetmathfonts} \def\indexfonts{% \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy \resetmathfonts} % Set up the default fonts, so we can use them for creating boxes. % \textfonts % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 % Fonts for short table of contents. \font\shortcontrm=cmr12 \font\shortcontbf=cmbx12 \font\shortcontsl=cmsl12 %% Add scribe-like font environments, plus @l for inline lisp (usually sans %% serif) and @ii for TeX italic % \smartitalic{ARG} outputs arg in italics, followed by an italic correction % unless the following character is such as not to need one. \def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} \def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\var=\smartitalic \let\dfn=\smartitalic \let\emph=\smartitalic \let\cite=\smartitalic \def\b#1{{\bf #1}} \let\strong=\b \def\t#1{{\tt \exhyphenpenalty=10000\rawbackslash \frenchspacing #1}\null} \let\ttfont = \t %\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} \def\samp #1{`\tclose{#1}'\null} \def\key #1{{\tt \exhyphenpenalty=10000\uppercase{#1}}\null} \def\ctrl #1{{\tt \rawbackslash \hat}#1} \let\file=\samp % @code is a modification of @t, % which makes spaces the same size as normal in the surrounding text. \newdimen\tclosesave \newdimen\tcloserm \def\tclose#1{{\rm \tcloserm=\fontdimen2\font \tt \tclosesave=\fontdimen2\font \fontdimen2\font=\tcloserm % prevent breaking lines at hyphens. \exhyphenpenalty=10000 \def\ {{\fontdimen2\font=\tclosesave{} }}% \rawbackslash \frenchspacing #1\fontdimen2\font=\tclosesave}\null} \let\code=\tclose %\let\exp=\tclose %Was temporary % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. \def\xkey{\key} \def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% \ifx\one\xkey\ifx\threex\three \key{#2}% \else\tclose{\look}\fi \else\tclose{\look}\fi} % Typeset a dimension, e.g., `in' or `pt'. The only reason for the % argument is to make the input look right: @dmn{pt} instead of % @dmn{}pt. % \def\dmn#1{\thinspace #1} \def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} \def\l#1{{\li #1}\null} % \def\r#1{{\rm #1}} % roman font % Use of \lowercase was suggested. \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \def\titlefont#1{{\titlerm #1}} \newtoks\realeverypar \newif\ifseenauthor \newif\iffinishedtitlepage \def\titlepage{\begingroup \parindent=0pt \textfonts \let\subtitlerm=\tenrm % I deinstalled the following change because \cmr12 is undefined. % This change was not in the ChangeLog anyway. --rms. % \let\subtitlerm=\cmr12 \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% % \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% % % Leave some space at the very top of the page. \vglue\titlepagetopglue % % Now you can print the title using @title. \def\title{\parsearg\titlezzz}% \def\titlezzz##1{\leftline{\titlefont{##1}} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt \vskip4pt}% % No rule at page bottom unless we print one at the top with @title. \finishedtitlepagetrue % % Now you can put text using @subtitle. \def\subtitle{\parsearg\subtitlezzz}% \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% % % @author should come last, but may come many times. \def\author{\parsearg\authorzzz}% \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi {\authorfont \leftline{##1}}}% % % Most title ``pages'' are actually two pages long, with space % at the top of the second. We don't want the ragged left on the second. \let\oldpage = \page \def\page{% \iffinishedtitlepage\else \finishtitlepage \fi \oldpage \let\page = \oldpage \hbox{}}% % \def\page{\oldpage \hbox{}} } \def\Etitlepage{% \iffinishedtitlepage\else \finishtitlepage \fi % It is important to do the page break before ending the group, % because the headline and footline are only empty inside the group. % If we use the new definition of \page, we always get a blank page % after the title page, which we certainly don't want. \oldpage \endgroup \HEADINGSon } \def\finishtitlepage{% \vskip4pt \hrule height 2pt \vskip\titlepagebottomglue \finishedtitlepagetrue } %%% Set up page headings and footings. \let\thispage=\folio \newtoks \evenheadline % Token sequence for heading line of even pages \newtoks \oddheadline % Token sequence for heading line of odd pages \newtoks \evenfootline % Token sequence for footing line of even pages \newtoks \oddfootline % Token sequence for footing line of odd pages % Now make Tex use those variables \headline={{\textfonts\rm \ifodd\pageno \the\oddheadline \else \the\evenheadline \fi}} \footline={{\textfonts\rm \ifodd\pageno \the\oddfootline \else \the\evenfootline \fi}\HEADINGShook} \let\HEADINGShook=\relax % Commands to set those variables. % For example, this is what @headings on does % @evenheading @thistitle|@thispage|@thischapter % @oddheading @thischapter|@thispage|@thistitle % @evenfooting @thisfile|| % @oddfooting ||@thisfile \def\evenheading{\parsearg\evenheadingxxx} \def\oddheading{\parsearg\oddheadingxxx} \def\everyheading{\parsearg\everyheadingxxx} \def\evenfooting{\parsearg\evenfootingxxx} \def\oddfooting{\parsearg\oddfootingxxx} \def\everyfooting{\parsearg\everyfootingxxx} {\catcode`\@=0 % \gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} \gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} \gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} \gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% \global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} \global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} \gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} \gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} \gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} \gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% \global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} \global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} % }% unbind the catcode of @. % @headings double turns headings on for double-sided printing. % @headings single turns headings on for single-sided printing. % @headings off turns them off. % @headings on same as @headings double, retained for compatibility. % @headings after turns on double-sided headings after this page. % @headings doubleafter turns on double-sided headings after this page. % @headings singleafter turns on single-sided headings after this page. % By default, they are off. \def\headings #1 {\csname HEADINGS#1\endcsname} \def\HEADINGSoff{ \global\evenheadline={\hfil} \global\evenfootline={\hfil} \global\oddheadline={\hfil} \global\oddfootline={\hfil}} \HEADINGSoff % When we turn headings on, set the page number to 1. % For double-sided printing, put current file name in lower left corner, % chapter name on inside top of right hand pages, document % title on inside top of left hand pages, and page numbers on outside top % edge of all pages. \def\HEADINGSdouble{ %\pagealignmacro \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} } % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{ %\pagealignmacro \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} } \def\HEADINGSon{\HEADINGSdouble} \def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} \let\HEADINGSdoubleafter=\HEADINGSafter \def\HEADINGSdoublex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} } \def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} \def\HEADINGSsinglex{% \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} } % Subroutines used in generating headings % Produces Day Month Year style of output. \def\today{\number\day\space \ifcase\month\or January\or February\or March\or April\or May\or June\or July\or August\or September\or October\or November\or December\fi \space\number\year} % Use this if you want the Month Day, Year style of output. %\def\today{\ifcase\month\or %January\or February\or March\or April\or May\or June\or %July\or August\or September\or October\or November\or December\fi %\space\number\day, \number\year} % @settitle line... specifies the title of the document, for headings % It generates no output of its own \def\thistitle{No Title} \def\settitle{\parsearg\settitlezzz} \def\settitlezzz #1{\gdef\thistitle{#1}} \message{tables,} % @tabs -- simple alignment % These don't work. For one thing, \+ is defined as outer. % So these macros cannot even be defined. %\def\tabs{\parsearg\tabszzz} %\def\tabszzz #1{\settabs\+#1\cr} %\def\tabline{\parsearg\tablinezzz} %\def\tablinezzz #1{\+#1\cr} %\def\&{&} % Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). % default indentation of table text \newdimen\tableindent \tableindent=.8in % default indentation of @itemize and @enumerate text \newdimen\itemindent \itemindent=.3in % margin between end of table item and start of table text. \newdimen\itemmargin \itemmargin=.1in % used internally for \itemindent minus \itemmargin \newdimen\itemmax % Note @table, @vtable, and @vtable define @item, @itemx, etc., with % these defs. % They also define \itemindex % to index the item name in whatever manner is desired (perhaps none). \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\par \parsearg\itemzzz} \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \par \parsearg\xitemzzz} \def\internalBkitem{\smallbreak \parsearg\kitemzzz} \def\internalBkitemx{\par \parsearg\kitemzzz} \def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% \itemzzz {#1}} \def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% \itemzzz {#1}} \def\itemzzz #1{\begingroup % \advance\hsize by -\rightskip \advance\hsize by -\tableindent \setbox0=\hbox{\itemfont{#1}}% \itemindex{#1}% \nobreak % This prevents a break before @itemx. % % Be sure we are not still in the middle of a paragraph. \parskip=0in \par % % If the item text does not fit in the space we have, put it on a line % by itself, and do not allow a page break either before or after that % line. We do not start a paragraph here because then if the next % command is, e.g., @kindex, the whatsit would get put into the % horizontal list on a line by itself, resulting in extra blank space. \ifdim \wd0>\itemmax \setbox0=\hbox{\hskip \leftskip \hskip -\tableindent \unhbox0}\box0 \nobreak \else % The item text fits into the space. Start a paragraph, so that the % following text (if any) will end up on the same line. Since that % text will be indented by \tableindent, we make the item text be in % a zero-width box. \noindent \rlap{\hskip -\tableindent\box0}% \fi \endgroup } \def\item{\errmessage{@item while not in a table}} \def\itemx{\errmessage{@itemx while not in a table}} \def\kitem{\errmessage{@kitem while not in a table}} \def\kitemx{\errmessage{@kitemx while not in a table}} \def\xitem{\errmessage{@xitem while not in a table}} \def\xitemx{\errmessage{@xitemx while not in a table}} %% Contains a kludge to get @end[description] to work \def\description{\tablez{\dontindex}{1}{}{}{}{}} \def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} {\obeylines\obeyspaces% \gdef\tablex #1^^M{% \tabley\dontindex#1 \endtabley}} \def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} {\obeylines\obeyspaces% \gdef\ftablex #1^^M{% \tabley\fnitemindex#1 \endtabley \def\Eftable{\endgraf\endgroup\afterenvbreak}% \let\Etable=\relax}} \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} {\obeylines\obeyspaces% \gdef\vtablex #1^^M{% \tabley\vritemindex#1 \endtabley \def\Evtable{\endgraf\endgroup\afterenvbreak}% \let\Etable=\relax}} \def\dontindex #1{} \def\fnitemindex #1{\doind {fn}{\code{#1}}}% \def\vritemindex #1{\doind {vr}{\code{#1}}}% {\obeyspaces % \gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% \tablez{#1}{#2}{#3}{#4}{#5}{#6}}} \def\tablez #1#2#3#4#5#6{% \aboveenvbreak % \begingroup % \def\Edescription{\Etable}% Neccessary kludge. \let\itemindex=#1% \ifnum 0#3>0 \advance \leftskip by #3\mil \fi % \ifnum 0#4>0 \tableindent=#4\mil \fi % \ifnum 0#5>0 \advance \rightskip by #5\mil \fi % \def\itemfont{#2}% \itemmax=\tableindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \tableindent % \exdentamount=\tableindent \parindent = 0pt \parskip = \smallskipamount \ifdim \parskip=0pt \parskip=2pt \fi% \def\Etable{\endgraf\endgroup\afterenvbreak}% \let\item = \internalBitem % \let\itemx = \internalBitemx % \let\kitem = \internalBkitem % \let\kitemx = \internalBkitemx % \let\xitem = \internalBxitem % \let\xitemx = \internalBxitemx % } % This is the counter used by @enumerate, which is really @itemize \newcount \itemno \def\itemize{\parsearg\itemizezzz} \def\itemizezzz #1{% \begingroup % ended by the @end itemsize \itemizey {#1}{\Eitemize} } \def\itemizey #1#2{% \aboveenvbreak % \itemmax=\itemindent % \advance \itemmax by -\itemmargin % \advance \leftskip by \itemindent % \exdentamount=\itemindent \parindent = 0pt % \parskip = \smallskipamount % \ifdim \parskip=0pt \parskip=2pt \fi% \def#2{\endgraf\endgroup\afterenvbreak}% \def\itemcontents{#1}% \let\item=\itemizeitem} \def\bullet{$\ptexbullet$} \def\minus{$-$} % Set sfcode to normal for the chars that usually have another value. % These are `.?!:;,' \def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } % \splitoff TOKENS\endmark defines \first to be the first token in % TOKENS, and \rest to be the remainder. % \def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% % Allow an optional argument of an uppercase letter, lowercase letter, % or number, to specify the first label in the enumerated list. No % argument is the same as `1'. % \def\enumerate{\parsearg\enumeratezzz} \def\enumeratezzz #1{\enumeratey #1 \endenumeratey} \def\enumeratey #1 #2\endenumeratey{% \begingroup % ended by the @end enumerate % % If we were given no argument, pretend we were given `1'. \def\thearg{#1}% \ifx\thearg\empty \def\thearg{1}\fi % % Detect if the argument is a single token. If so, it might be a % letter. Otherwise, the only valid thing it can be is a number. % (We will always have one token, because of the test we just made. % This is a good thing, since \splitoff doesn't work given nothing at % all -- the first parameter is undelimited.) \expandafter\splitoff\thearg\endmark \ifx\rest\empty % Only one token in the argument. It could still be anything. % A ``lowercase letter'' is one whose \lccode is nonzero. % An ``uppercase letter'' is one whose \lccode is both nonzero, and % not equal to itself. % Otherwise, we assume it's a number. % % We need the \relax at the end of the \ifnum lines to stop TeX from % continuing to look for a . % \ifnum\lccode\expandafter`\thearg=0\relax \numericenumerate % a number (we hope) \else % It's a letter. \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax \lowercaseenumerate % lowercase letter \else \uppercaseenumerate % uppercase letter \fi \fi \else % Multiple tokens in the argument. We hope it's a number. \numericenumerate \fi } % An @enumerate whose labels are integers. The starting integer is % given in \thearg. % \def\numericenumerate{% \itemno = \thearg \startenumeration{\the\itemno}% } % The starting (lowercase) letter is in \thearg. \def\lowercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more lowercase letters in @enumerate; get a bigger alphabet}% \fi \char\lccode\itemno }% } % The starting (uppercase) letter is in \thearg. \def\uppercaseenumerate{% \itemno = \expandafter`\thearg \startenumeration{% % Be sure we're not beyond the end of the alphabet. \ifnum\itemno=0 \errmessage{No more uppercase letters in @enumerate; get a bigger alphabet} \fi \char\uccode\itemno }% } % Call itemizey, adding a period to the first argument and supplying the % common last two arguments. Also subtract one from the initial value in % \itemno, since @item increments \itemno. % \def\startenumeration#1{% \advance\itemno by -1 \itemizey{#1.}\Eenumerate\flushcr } % @alphaenumerate and @capsenumerate are abbreviations for giving an arg % to @enumerate. % \def\alphaenumerate{\enumerate{a}} \def\capsenumerate{\enumerate{A}} \def\Ealphaenumerate{\Eenumerate} \def\Ecapsenumerate{\Eenumerate} % Definition of @item while inside @itemize. \def\itemizeitem{% \advance\itemno by 1 {\let\par=\endgraf \smallbreak}% \ifhmode \errmessage{\in hmode at itemizeitem}\fi {\parskip=0in \hskip 0pt \hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% \vadjust{\penalty 1200}}% \flushcr} \message{indexing,} % Index generation facilities % Define \newwrite to be identical to plain tex's \newwrite % except not \outer, so it can be used within \newindex. {\catcode`\@=11 \gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} % \newindex {foo} defines an index named foo. % It automatically defines \fooindex such that % \fooindex ...rest of line... puts an entry in the index foo. % It also defines \fooindfile to be the number of the output channel for % the file that accumulates this index. The file's extension is foo. % The name of an index should be no more than 2 characters long % for the sake of vms. \def\newindex #1{ \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex \noexpand\doindex {#1}} } % @defindex foo == \newindex{foo} \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. \def\newcodeindex #1{ \expandafter\newwrite \csname#1indfile\endcsname% Define number for output file \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex \noexpand\docodeindex {#1}} } \def\defcodeindex{\parsearg\newcodeindex} % @synindex foo bar makes index foo feed into index bar. % Do this instead of @defindex foo if you don't want it as a separate index. \def\synindex #1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex \noexpand\doindex {#2}}% } % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. \def\syncodeindex #1 #2 {% \expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname \expandafter\let\csname#1indfile\endcsname=\synindexfoo \expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex \noexpand\docodeindex {#2}}% } % Define \doindex, the driver for all \fooindex macros. % Argument #1 is generated by the calling \fooindex macro, % and it is "foo", the name of the index. % \doindex just uses \parsearg; it calls \doind for the actual work. % This is because \doind is more useful to call from other macros. % There is also \dosubind {index}{topic}{subtopic} % which makes an entry in a two-level index such as the operation index. \def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} \def\singleindexer #1{\doind{\indexname}{#1}} % like the previous two, but they put @code around the argument. \def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} \def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} \def\indexdummies{% \def\_{{\realbackslash _}}% \def\w{\realbackslash w }% \def\bf{\realbackslash bf }% \def\rm{\realbackslash rm }% \def\sl{\realbackslash sl }% \def\sf{\realbackslash sf}% \def\tt{\realbackslash tt}% \def\gtr{\realbackslash gtr}% \def\less{\realbackslash less}% \def\hat{\realbackslash hat}% \def\char{\realbackslash char}% \def\TeX{\realbackslash TeX}% \def\dots{\realbackslash dots }% \def\copyright{\realbackslash copyright }% \def\tclose##1{\realbackslash tclose {##1}}% \def\code##1{\realbackslash code {##1}}% \def\samp##1{\realbackslash samp {##1}}% \def\t##1{\realbackslash r {##1}}% \def\r##1{\realbackslash r {##1}}% \def\i##1{\realbackslash i {##1}}% \def\b##1{\realbackslash b {##1}}% \def\cite##1{\realbackslash cite {##1}}% \def\key##1{\realbackslash key {##1}}% \def\file##1{\realbackslash file {##1}}% \def\var##1{\realbackslash var {##1}}% \def\kbd##1{\realbackslash kbd {##1}}% } % \indexnofonts no-ops all font-change commands. % This is used when outputting the strings to sort the index by. \def\indexdummyfont#1{#1} \def\indexdummytex{TeX} \def\indexdummydots{...} \def\indexnofonts{% \let\w=\indexdummyfont \let\t=\indexdummyfont \let\r=\indexdummyfont \let\i=\indexdummyfont \let\b=\indexdummyfont \let\emph=\indexdummyfont \let\strong=\indexdummyfont \let\cite=\indexdummyfont \let\sc=\indexdummyfont %Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |... %\let\tt=\indexdummyfont \let\tclose=\indexdummyfont \let\code=\indexdummyfont \let\file=\indexdummyfont \let\samp=\indexdummyfont \let\kbd=\indexdummyfont \let\key=\indexdummyfont \let\var=\indexdummyfont \let\TeX=\indexdummytex \let\dots=\indexdummydots } % To define \realbackslash, we must make \ not be an escape. % We must first make another character (@) an escape % so we do not become unable to do a definition. {\catcode`\@=0 \catcode`\\=\other @gdef@realbackslash{\}} \let\indexbackslash=0 %overridden during \printindex. \def\doind #1#2{% {\count10=\lastpenalty % {\indexdummies % Must do this here, since \bf, etc expand at this stage \escapechar=`\\% {\let\folio=0% Expand all macros now EXCEPT \folio \def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now % so it will be output as is; and it will print as backslash in the indx. % % Now process the index-string once, with all font commands turned off, % to get the string to sort the index by. {\indexnofonts \xdef\temp1{#2}% }% % Now produce the complete index entry. We process the index-string again, % this time with font commands expanded, to get what to print in the index. \edef\temp{% \write \csname#1indfile\endcsname{% \realbackslash entry {\temp1}{\folio}{#2}}}% \temp }% }\penalty\count10}} \def\dosubind #1#2#3{% {\count10=\lastpenalty % {\indexdummies % Must do this here, since \bf, etc expand at this stage \escapechar=`\\% {\let\folio=0% \def\rawbackslashxx{\indexbackslash}% % % Now process the index-string once, with all font commands turned off, % to get the string to sort the index by. {\indexnofonts \xdef\temp1{#2 #3}% }% % Now produce the complete index entry. We process the index-string again, % this time with font commands expanded, to get what to print in the index. \edef\temp{% \write \csname#1indfile\endcsname{% \realbackslash entry {\temp1}{\folio}{#2}{#3}}}% \temp }% }\penalty\count10}} % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} % or % \entry {sortstring}{page}{topic}{subtopic} % The texindex program reads in these files and writes files % containing these kinds of lines: % \initial {c} % before the first topic whose initial is c % \entry {topic}{pagelist} % for a topic that is used without subtopics % \primary {topic} % for the beginning of a topic that is used with subtopics % \secondary {subtopic}{pagelist} % for each subtopic. % Define the user-accessible indexing commands % @findex, @vindex, @kindex, @cindex. \def\findex {\fnindex} \def\kindex {\kyindex} \def\cindex {\cpindex} \def\vindex {\vrindex} \def\tindex {\tpindex} \def\pindex {\pgindex} \def\cindexsub {\begingroup\obeylines\cindexsub} {\obeylines % \gdef\cindexsub "#1" #2^^M{\endgroup % \dosubind{cp}{#2}{#1}}} % Define the macros used in formatting output of the sorted index material. % This is what you call to cause a particular index to get printed. % Write % @unnumbered Function Index % @printindex fn \def\printindex{\parsearg\doprintindex} \def\doprintindex#1{% \tex \dobreak \chapheadingskip {10000} \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other \catcode`\$=\other\catcode`\_=\other \catcode`\~=\other % % The following don't help, since the chars were translated % when the raw index was written, and their fonts were discarded % due to \indexnofonts. %\catcode`\"=\active %\catcode`\^=\active %\catcode`\_=\active %\catcode`\|=\active %\catcode`\<=\active %\catcode`\>=\active % % \def\indexbackslash{\rawbackslashxx} \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt \begindoublecolumns % % See if the index file exists and is nonempty. \openin 1 \jobname.#1s \ifeof 1 % \enddoublecolumns gets confused if there is no text in the index, % and it loses the chapter title and the aux file entries for the % index. The easiest way to prevent this problem is to make sure % there is some text. (Index is nonexistent) \else % % If the index file exists but is empty, then \openin leaves \ifeof % false. We have to make TeX try to read something from the file, so % it can discover if there is anything in it. \read 1 to \temp \ifeof 1 (Index is empty) \else \input \jobname.#1s \fi \fi \closein 1 \enddoublecolumns \Etex } % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. % Same as \bigskipamount except no shrink. % \balancecolumns gets confused if there is any shrink. \newskip\initialskipamount \initialskipamount 12pt plus4pt \def\initial #1{% {\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt \ifdim\lastskip<\initialskipamount \removelastskip \penalty-200 \vskip \initialskipamount\fi \line{\secbf#1\hfill}\kern 2pt\penalty10000}} \def\entry #1#2{\begingroup \parfillskip=0in \parskip=0in \parindent=0in % % \hangindent is only relevant when the page number and the entry text % don't fit on one line. In that case, bob suggests starting the dots % pretty far over on the line. % \hangafter is reset to 1 at the start of each paragraph. \hangindent=.75\hsize \noindent % % Don't break the text of the index entry. \hbox{#1}% % % If we must, put the page number on a line of its own, and fill out % this line with blank space. (The \hfil is overwhelmed with the % fill leaders glue in \indexdotfill if the page number does fit.) \hfil\penalty50 \null\nobreak\indexdotfill % Have leaders before the page number. % % The `\ ' here is removed by the implicit \unskip that TeX does as % part of (the primitive) \par. Without, a spurious underfull \hbox ensues. \ #2% The page number ends the paragraph. \par \endgroup} % Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu . \mkern1.5mu$}\hskip 1em plus 1fill} \def\primary #1{\line{#1\hfil}} \newskip\secondaryindent \secondaryindent=0.5cm \def\secondary #1#2{ {\parfillskip=0in \parskip=0in \hangindent =1in \hangafter=1 \noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par }} %% Define two-column mode, which is used in indexes. %% Adapted from the TeXBook, page 416 \catcode `\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \doublecolumnhsize = 3.11in \newdimen\doublecolumnvsize \doublecolumnvsize = 19.1in \newdimen\availdimen@ \def\begindoublecolumns{\begingroup \output={\global\setbox\partialpage= \vbox{\unvbox255\kern -\topskip \kern \baselineskip}}\eject \output={\doublecolumnout}% \hsize=\doublecolumnhsize \vsize=\doublecolumnvsize} \def\enddoublecolumns{\output={\balancecolumns}\eject \endgroup \pagegoal=\vsize} \def\doublecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty} \def\pagesofar{\unvbox\partialpage % \hsize=\doublecolumnhsize % have to restore this since output routine % changes it to set cropmarks (P. A. MacKay, 12 Nov. 1986) \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} \def\balancecolumns{% % Unset the glue. \setbox255=\vbox{\unvbox255} \dimen@=\ht255 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by2 \availdimen@=\pageheight \advance\availdimen@ by-\ht\partialpage % If the remaining data is too big for one page, % output one page normally, then work with what remains. \ifdim \dimen@>\availdimen@ { \splittopskip=\topskip \splitmaxdepth=\maxdepth \dimen@=\pageheight \advance\dimen@ by-\ht\partialpage \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar } % Recompute size of what remains, in case we just output some of it. \dimen@=\ht255 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by2 \fi \setbox0=\vbox{\unvbox255} \splittopskip=\topskip {\vbadness=10000 \loop \global\setbox3=\copy0 \global\setbox1=\vsplit3 to\dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by1pt \repeat} \setbox0=\vbox to\dimen@{\unvbox1} \setbox2=\vbox to\dimen@{\unvbox3} \pagesofar} \catcode `\@=\other \message{sectioning,} % Define chapters, sections, etc. \newcount \chapno \newcount \secno \secno=0 \newcount \subsecno \subsecno=0 \newcount \subsubsecno \subsubsecno=0 % This counter is funny since it counts through charcodes of letters A, B, ... \newcount \appendixno \appendixno = `\@ \def\appendixletter{\char\the\appendixno} \newwrite \contentsfile % This is called from \setfilename. \def\opencontents{\openout \contentsfile = \jobname.toc} % Each @chapter defines this as the name of the chapter. % page headings and footings can use it. @section does likewise \def\thischapter{} \def\thissection{} \def\seccheck#1{\if \pageno<0 % \errmessage{@#1 not allowed after generating table of contents}\fi % } \def\chapternofonts{% \let\rawbackslash=\relax% \let\frenchspacing=\relax% \def\result{\realbackslash result} \def\equiv{\realbackslash equiv} \def\expansion{\realbackslash expansion} \def\print{\realbackslash print} \def\TeX{\realbackslash TeX} \def\dots{\realbackslash dots} \def\copyright{\realbackslash copyright} \def\tt{\realbackslash tt} \def\bf{\realbackslash bf } \def\w{\realbackslash w} \def\less{\realbackslash less} \def\gtr{\realbackslash gtr} \def\hat{\realbackslash hat} \def\char{\realbackslash char} \def\tclose##1{\realbackslash tclose {##1}} \def\code##1{\realbackslash code {##1}} \def\samp##1{\realbackslash samp {##1}} \def\r##1{\realbackslash r {##1}} \def\b##1{\realbackslash b {##1}} \def\key##1{\realbackslash key {##1}} \def\file##1{\realbackslash file {##1}} \def\kbd##1{\realbackslash kbd {##1}} % These are redefined because @smartitalic wouldn't work inside xdef. \def\i##1{\realbackslash i {##1}} \def\cite##1{\realbackslash cite {##1}} \def\var##1{\realbackslash var {##1}} \def\emph##1{\realbackslash emph {##1}} \def\dfn##1{\realbackslash dfn {##1}} } \def\thischaptername{No Chapter Title} \outer\def\chapter{\parsearg\chapterzzz} \def\chapterzzz #1{\seccheck{chapter}% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{Chapter \the\chapno}% \chapmacro {#1}{\the\chapno}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% % We don't substitute the actual chapter name into \thischapter % because we don't want its macros evaluated now. \xdef\thischapter{Chapter \the\chapno: \noexpand\thischaptername}% {\chapternofonts% \edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \donoderef % \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec }} \outer\def\appendix{\parsearg\appendixzzz} \def\appendixzzz #1{\seccheck{appendix}% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{Appendix \appendixletter}% \chapmacro {#1}{Appendix \appendixletter}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% \xdef\thischapter{Appendix \appendixletter: \noexpand\thischaptername}% {\chapternofonts% \edef\temp{{\realbackslash chapentry {#1}{Appendix \appendixletter}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \appendixnoderef % \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec }} \outer\def\top{\parsearg\unnumberedzzz} \outer\def\unnumbered{\parsearg\unnumberedzzz} \def\unnumberedzzz #1{\seccheck{unnumbered}% \secno=0 \subsecno=0 \subsubsecno=0 \message{(#1)} \unnumbchapmacro {#1}% \gdef\thischapter{#1}\gdef\thissection{#1}% {\chapternofonts% \edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \unnumbnoderef % \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec }} \outer\def\numberedsec{\parsearg\seczzz} \def\seczzz #1{\seccheck{section}% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% {\chapternofonts% \edef\temp{{\realbackslash secentry % {#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \donoderef % \penalty 10000 % }} \outer\def\appendixsection{\parsearg\appendixsectionzzz} \outer\def\appendixsec{\parsearg\appendixsectionzzz} \def\appendixsectionzzz #1{\seccheck{appendixsection}% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% {\chapternofonts% \edef\temp{{\realbackslash secentry % {#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \appendixnoderef % \penalty 10000 % }} \outer\def\unnumberedsec{\parsearg\unnumberedseczzz} \def\unnumberedseczzz #1{\seccheck{unnumberedsec}% \plainsecheading {#1}\gdef\thissection{#1}% {\chapternofonts% \edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \unnumbnoderef % \penalty 10000 % }} \outer\def\numberedsubsec{\parsearg\numberedsubseczzz} \def\numberedsubseczzz #1{\seccheck{subsection}% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% {\chapternofonts% \edef\temp{{\realbackslash subsecentry % {#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \donoderef % \penalty 10000 % }} \outer\def\appendixsubsec{\parsearg\appendixsubseczzz} \def\appendixsubseczzz #1{\seccheck{appendixsubsec}% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% {\chapternofonts% \edef\temp{{\realbackslash subsecentry % {#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \appendixnoderef % \penalty 10000 % }} \outer\def\unnumberedsubsec{\parsearg\unnumberedsubseczzz} \def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% \plainsecheading {#1}\gdef\thissection{#1}% {\chapternofonts% \edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \unnumbnoderef % \penalty 10000 % }} \outer\def\numberedsubsubsec{\parsearg\numberedsubsubseczzz} \def\numberedsubsubseczzz #1{\seccheck{subsubsection}% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% {\chapternofonts% \edef\temp{{\realbackslash subsubsecentry % {#1} {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} {\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \donoderef % \penalty 10000 % }} \outer\def\appendixsubsubsec{\parsearg\appendixsubsubseczzz} \def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% {\chapternofonts% \edef\temp{{\realbackslash subsubsecentry{#1}% {\appendixletter} {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \appendixnoderef % \penalty 10000 % }} \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} \def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% \plainsecheading {#1}\gdef\thissection{#1}% {\chapternofonts% \edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% \escapechar=`\\% \write \contentsfile \temp % \unnumbnoderef % \penalty 10000 % }} % These are variants which are not "outer", so they can appear in @ifinfo. % Actually, they should now be obsolete; ordinary section commands should work. \def\infotop{\parsearg\unnumberedzzz} \def\infounnumbered{\parsearg\unnumberedzzz} \def\infounnumberedsec{\parsearg\unnumberedseczzz} \def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} \def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} \def\infoappendix{\parsearg\appendixzzz} \def\infoappendixsec{\parsearg\appendixseczzz} \def\infoappendixsubsec{\parsearg\appendixsubseczzz} \def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} \def\infochapter{\parsearg\chapterzzz} \def\infosection{\parsearg\sectionzzz} \def\infosubsection{\parsearg\subsectionzzz} \def\infosubsubsection{\parsearg\subsubsectionzzz} % These macros control what the section commands do, according % to what kind of chapter we are in (ordinary, appendix, or unnumbered). % Define them by default for a numbered chapter. \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec % Define @majorheading, @heading and @subheading % NOTE on use of \vbox for chapter headings, section headings, and % such: % 1) We use \vbox rather than the earlier \line to permit % overlong headings to fold. % 2) \hyphenpenalty is set to 10000 because hyphenation in a % heading is obnoxious; this forbids it. % 3) Likewise, headings look best if no \parindent is used, and % if justification is not attempted. Hence \raggedright. \def\majorheading{\parsearg\majorheadingzzz} \def\majorheadingzzz #1{% {\advance\chapheadingskip by 10pt \chapbreak }% {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} \def\chapheading{\parsearg\chapheadingzzz} \def\chapheadingzzz #1{\chapbreak % {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 200} \def\heading{\parsearg\secheadingi} \def\subheading{\parsearg\subsecheadingi} \def\subsubheading{\parsearg\subsubsecheadingi} % These macros generate a chapter, section, etc. heading only % (including whitespace, linebreaking, etc. around it), % given all the information in convenient, parsed form. %%% Args are the skip and penalty (usually negative) \def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} %%% Define plain chapter starts, and page on/off switching for it % Parameter controlling skip before chapter headings (if needed) \newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt \def\chapbreak{\dobreak \chapheadingskip {-4000}} \def\chappager{\par\vfill\supereject} \def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} \def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} \def\CHAPPAGoff{ \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{ \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{ \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon \def\CHAPFplain{ \global\let\chapmacro=\chfplain \global\let\unnumbchapmacro=\unnchfplain} \def\chfplain #1#2{% \pchapsepmacro {% \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #2\enspace #1}% }% \bigskip \penalty5000 } \def\unnchfplain #1{% \pchapsepmacro % {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 10000 % } \CHAPFplain % The default \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\penalty 10000 % } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\CHAPFopen{ \global\let\chapmacro=\chfopen \global\let\unnumbchapmacro=\unnchfopen} % Parameter controlling skip before section headings. \newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} \newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt \def\secheadingbreak{\dobreak \secheadingskip {-1000}} % @paragraphindent is defined for the Info formatting commands only. \let\paragraphindent=\comment % Section fonts are the base font at magstep2, which produces % a size a bit more than 14 points in the default situation. \def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} \def\plainsecheading #1{\secheadingi {#1}} \def\secheadingi #1{{\advance \secheadingskip by \parskip % \secheadingbreak}% {\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}% \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } % Subsection fonts are the base font at magstep1, % which produces a size of 12 points. \def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} \def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % \subsecheadingbreak}% {\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}% \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } \def\subsubsecfonts{\subsecfonts} % Maybe this should change: % Perhaps make sssec fonts scaled % magstep half \def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} \def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % \subsecheadingbreak}% {\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}% \ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} \message{toc printing,} % Finish up the main text and prepare to read what we've written % to \contentsfile. \newskip\contentsrightmargin \contentsrightmargin=1in \def\startcontents#1{% \ifnum \pageno>0 \pageno = -1 % Request roman numbered pages. \fi \pagealignmacro \immediate\closeout \contentsfile % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \unnumbchapmacro{#1}\def\thischapter{}% \begingroup % Set up to handle contents files properly. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. } % Normal (long) toc. \outer\def\contents{% \startcontents{Table of Contents}% \input \jobname.toc \endgroup \vfill \eject } % And just the chapters. \outer\def\summarycontents{% \startcontents{Short Contents}% % \let\chapentry = \shortchapentry \let\unnumbchapentry = \shortunnumberedentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \rm \advance\baselineskip by 1pt % Open it up a little. \def\secentry ##1##2##3##4{} \def\unnumbsecentry ##1##2{} \def\subsecentry ##1##2##3##4##5{} \def\unnumbsubsecentry ##1##2{} \def\subsubsecentry ##1##2##3##4##5##6{} \def\unnumbsubsubsecentry ##1##2{} \input \jobname.toc \endgroup \vfill \eject } \let\shortcontents = \summarycontents % These macros generate individual entries in the table of contents. % The first argument is the chapter or section name. % The last argument is the page number. % The arguments in between are the chapter number, section number, ... % Chapter-level things, for both the long and short contents. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} % See comments in \dochapentry re vbox and related settings \def\shortchapentry#1#2#3{% \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\strut\raggedright {#2\labelspace #1}\dotfill\doshortpageno{#3}}% } \def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} \def\shortunnumberedentry#1#2{% \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\strut\raggedright #1\dotfill\doshortpageno{#2}}% } % Sections. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} \def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} % Subsections. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} \def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} % And subsubsections. \def\subsubsecentry#1#2#3#4#5#6{% \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} \def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} % This parameter controls the indentation of the various levels. \newdimen\tocindent \tocindent = 3pc % Now for the actual typesetting. In all these, #1 is the text and #2 is the % page number. % % If the toc has to be broken over pages, we would want to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip\baselineskip % This \vbox (and similar ones in dosecentry etc.) used to be a % \line; changed to permit linebreaks for long headings. See % comments above \majorheading. Here we also use \strut to % keep the top end of the vbox from jamming up against the previous % entry in the table of contents. \vbox{\chapentryfonts \hyphenpenalty=10000\tolerance=5000 % this line and next introduced \parindent=0pt\strut\raggedright % with \line -> \vbox change #1\dotfill \dopageno{#2}}% \nobreak\vskip .25\baselineskip } \def\dosecentry#1#2{% \vbox{\secentryfonts \leftskip=\tocindent \hyphenpenalty=10000\tolerance=5000 \parindent=0pt\strut\raggedright #1\dotfill \dopageno{#2}}% } \def\dosubsecentry#1#2{% \vbox{\subsecentryfonts \leftskip=2\tocindent \hyphenpenalty=10000\tolerance=5000 \parindent=0pt\strut\raggedright #1\dotfill \dopageno{#2}}% } \def\dosubsubsecentry#1#2{% \vbox{\subsubsecentryfonts \leftskip=3\tocindent \hyphenpenalty=10000\tolerance=5000 \parindent=0pt\strut\raggedright #1\dotfill \dopageno{#2}}% } % Space between chapter (or whatever) number and the title. \def\labelspace{\hskip1em \relax} \def\dopageno#1{{\rm #1}} \def\doshortpageno#1{{\rm #1}} \def\chapentryfonts{\secfonts \rm} \def\secentryfonts{\textfonts} \let\subsecentryfonts = \textfonts \let\subsubsecentryfonts = \textfonts \message{environments,} % Since these characters are used in examples, it should be an even number of % \tt widths. Each \tt character is 1en, so two makes it 1em. % Furthermore, these definitions must come after we define our fonts. \newbox\dblarrowbox \newbox\longdblarrowbox \newbox\pushcharbox \newbox\bullbox \newbox\equivbox \newbox\errorbox \let\ptexequiv = \equiv %{\tentt %\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} %\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} %\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} %\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} % Adapted from the manmac format (p.420 of TeXbook) %\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex % depth .1ex\hfil} %} \def\point{$\star$} \def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} \def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} \def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} \def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} % Adapted from the TeXbook's \boxit. {\tentt \global\dimen0 = 3em}% Width of the box. \dimen2 = .55pt % Thickness of rules % The text. (`r' is open on the right, `e' somewhat less so on the left.) \setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} \global\setbox\errorbox=\hbox to \dimen0{\hfil \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. \advance\hsize by -2\dimen2 % Rules. \vbox{ \hrule height\dimen2 \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. \kern3pt\vrule width\dimen2}% Space to right. \hrule height\dimen2} \hfil} % The @error{} command. \def\error{\leavevmode\lower.7ex\copy\errorbox} % @tex ... @end tex escapes into raw Tex temporarily. % One exception: @ is still an escape character, so that @end tex works. % But \@ or @@ will get a plain tex @ character. \def\tex{\begingroup \catcode `\\=0 \catcode `\{=1 \catcode `\}=2 \catcode `\$=3 \catcode `\&=4 \catcode `\#=6 \catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie \catcode `\%=14 \catcode 43=12 \catcode`\"=12 \catcode`\==12 \catcode`\|=12 \catcode`\<=12 \catcode`\>=12 \escapechar=`\\ % \let\{=\ptexlbrace \let\}=\ptexrbrace \let\.=\ptexdot \let\*=\ptexstar \let\dots=\ptexdots \def\@{@}% \let\bullet=\ptexbullet \let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl \let\L=\ptexL % \let\Etex=\endgroup} % Define @lisp ... @endlisp. % @lisp does a \begingroup so it can rebind things, % including the definition of @endlisp (which normally is erroneous). % Amount to narrow the margins by for @lisp. \newskip\lispnarrowing \lispnarrowing=0.4in % This is the definition that ^M gets inside @lisp % phr: changed space to \null, to avoid overfull hbox problems. {\obeyspaces% \gdef\lisppar{\null\endgraf}} % Cause \obeyspaces to make each Space cause a word-separation % rather than the default which is that it acts punctuation. % This is because space in tt font looks funny. {\obeyspaces % \gdef\sepspaces{\def {\ }}} \newskip\aboveenvskipamount \aboveenvskipamount= 0pt \def\aboveenvbreak{{\advance\aboveenvskipamount by \parskip \endgraf \ifdim\lastskip<\aboveenvskipamount \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi}} \def\afterenvbreak{\endgraf \ifdim\lastskip<\aboveenvskipamount \removelastskip \penalty-50 \vskip\aboveenvskipamount \fi} % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. \let\nonarrowing=\relax %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \cartouche: draw rectangle w/rounded corners around argument \font\circle=lcircle10 \newdimen\circthick \newdimen\cartouter\newdimen\cartinner \newskip\normbskip\newskip\normpskip\newskip\normlskip \circthick=\fontdimen8\circle % \def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth \def\ctr{{\hskip 6pt\circle\char'010}} \def\cbl{{\circle\char'012\hskip -6pt}} \def\cbr{{\hskip 6pt\circle\char'011}} \def\carttop{\hbox to \cartouter{\hskip\lskip \ctl\leaders\hrule height\circthick\hfil\ctr \hskip\rskip}} \def\cartbot{\hbox to \cartouter{\hskip\lskip \cbl\leaders\hrule height\circthick\hfil\cbr \hskip\rskip}} % \newskip\lskip\newskip\rskip \long\def\cartouche{% \begingroup \lskip=\leftskip \rskip=\rightskip \leftskip=0pt\rightskip=0pt %we want these *outside*. \cartinner=\hsize \advance\cartinner by-\lskip \advance\cartinner by-\rskip \cartouter=\hsize \advance\cartouter by 18pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip % Flag to tell @lisp, etc., not to narrow margin. \let\nonarrowing=\comment \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt \carttop \hbox\bgroup \hskip\lskip \vrule\kern3pt \vbox\bgroup \hsize=\cartinner \kern3pt \begingroup \baselineskip=\normbskip \lineskip=\normlskip \parskip=\normpskip \vskip -\parskip \def\Ecartouche{% \endgroup \kern3pt \egroup \kern3pt\vrule \hskip\rskip \egroup \cartbot \egroup \endgroup }} \def\lisp{\aboveenvbreak \begingroup\inENV % This group ends at the end of the @lisp body \hfuzz=12truept % Don't be fussy % Make spaces be word-separators rather than space tokens. \sepspaces % % Single space lines \singlespace % % The following causes blank lines not to be ignored % by adding a space to the end of each line. \let\par=\lisppar \def\Elisp{\endgroup\afterenvbreak}% \parskip=0pt % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \let\exdent=\nofillexdent \let\nonarrowing=\relax \fi \parindent=0pt \obeyspaces \obeylines \tt \rawbackslash \def\next##1{}\next} \let\example=\lisp \def\Eexample{\Elisp} \let\smallexample=\lisp \def\Esmallexample{\Elisp} % Macro for 9 pt. examples, necessary to print with 5" lines. % From Pavel@xerox. This is not really used unless the % @smallbook command is given. \def\smalllispx{\aboveenvbreak\begingroup\inENV % This group ends at the end of the @lisp body \hfuzz=12truept % Don't be fussy % Make spaces be word-separators rather than space tokens. \sepspaces % % Single space lines \singlespace % % The following causes blank lines not to be ignored % by adding a space to the end of each line. \let\par=\lisppar \def\Esmalllisp{\endgroup\afterenvbreak}% %%%% Smaller baseline skip for small examples. \baselineskip 10pt \parskip=0pt % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \let\exdent=\nofillexdent \let\nonarrowing=\relax \fi \parindent=0pt \obeyspaces \obeylines \ninett \indexfonts \rawbackslash \def\next##1{}\next} % This is @display; same as @lisp except use roman font. \def\display{\begingroup\inENV %This group ends at the end of the @display body \aboveenvbreak % Make spaces be word-separators rather than space tokens. \sepspaces % % Single space lines \singlespace % % The following causes blank lines not to be ignored % by adding a space to the end of each line. \let\par=\lisppar \def\Edisplay{\endgroup\afterenvbreak}% \parskip=0pt % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \exdentamount=\lispnarrowing \let\exdent=\nofillexdent \let\nonarrowing=\relax \fi \parindent=0pt \obeyspaces \obeylines \def\next##1{}\next} % This is @format; same as @lisp except use roman font and don't narrow margins \def\format{\begingroup\inENV %This group ends at the end of the @format body \aboveenvbreak % Make spaces be word-separators rather than space tokens. \sepspaces % \singlespace % % The following causes blank lines not to be ignored % by adding a space to the end of each line. \let\par=\lisppar \def\Eformat{\endgroup\afterenvbreak} \parskip=0pt \parindent=0pt \obeyspaces \obeylines \def\next##1{}\next} % @flushleft and @flushright \def\flushleft{% \begingroup\inENV %This group ends at the end of the @format body \aboveenvbreak % Make spaces be word-separators rather than space tokens. \sepspaces % % The following causes blank lines not to be ignored % by adding a space to the end of each line. % This also causes @ to work when the directive name % is terminated by end of line. \let\par=\lisppar \def\Eflushleft{\endgroup\afterenvbreak}% \parskip=0pt \parindent=0pt \obeyspaces \obeylines \def\next##1{}\next} \def\flushright{% \begingroup\inENV %This group ends at the end of the @format body \aboveenvbreak % Make spaces be word-separators rather than space tokens. \sepspaces % % The following causes blank lines not to be ignored % by adding a space to the end of each line. % This also causes @ to work when the directive name % is terminated by end of line. \let\par=\lisppar \def\Eflushright{\endgroup\afterenvbreak}% \parskip=0pt \parindent=0pt \advance \leftskip by 0pt plus 1fill \obeyspaces \obeylines \def\next##1{}\next} % @quotation - narrow the margins. \def\quotation{% \begingroup\inENV %This group ends at the end of the @quotation body {\parskip=0pt % because we will skip by \parskip too, later \aboveenvbreak}% \singlespace \parindent=0pt \def\Equotation{\par\endgroup\afterenvbreak}% % @cartouche defines \nonarrowing to inhibit narrowing % at next level down. \ifx\nonarrowing\relax \advance \leftskip by \lispnarrowing \advance \rightskip by \lispnarrowing \exdentamount=\lispnarrowing \let\nonarrowing=\relax \fi} \message{defuns,} % Define formatter for defuns % First, allow user to change definition object font (\df) internally \def\setdeffont #1 {\csname DEF#1\endcsname} \newskip\defbodyindent \defbodyindent=.4in \newskip\defargsindent \defargsindent=50pt \newskip\deftypemargin \deftypemargin=12pt \newskip\deflastargmargin \deflastargmargin=18pt \newcount\parencount % define \functionparens, which makes ( and ) and & do special things. % \functionparens affects the group it is contained in. \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active \catcode`\[=\active \catcode`\]=\active} {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} % Definitions of (, ) and & used in args for functions. % This is the definition of ( outside of all parentheses. \gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % \global\advance\parencount by 1 } % % This is the definition of ( when already inside a level of parens. \gdef\opnested{\char`\(\global\advance\parencount by 1 } % \gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. % also in that case restore the outer-level definition of (. \ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi \global\advance \parencount by -1 } % If we encounter &foo, then turn on ()-hacking afterwards \gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } % \gdef\normalparens{\boldbrax\let&=\ampnr} } % End of definition inside \activeparens %% These parens (in \boldbrax) actually are a little bolder than the %% contained text. This is especially needed for [ and ] \def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} % First, defname, which formats the header line itself. % #1 should be the function name. % #2 should be the type of definition, such as "Function". \def\defname #1#2{% % Get the values of \leftskip and \rightskip as they were % outside the @def... \dimen2=\leftskip \advance\dimen2 by -\defbodyindent \dimen3=\rightskip \advance\dimen3 by -\defbodyindent \noindent % \setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% \dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line \dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations \parshape 2 0in \dimen0 \defargsindent \dimen1 % % Now output arg 2 ("Function" or some such) % ending at \deftypemargin from the right margin, % but stuck inside a box of width 0 so it does not interfere with linebreaking {% Adjust \hsize to exclude the ambient margins, % so that \rightline will obey them. \advance \hsize by -\dimen2 \advance \hsize by -\dimen3 \rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% % Make all lines underfull and no complaints: \tolerance=10000 \hbadness=10000 \advance\leftskip by -\defbodyindent \exdentamount=\defbodyindent {\df #1}\enskip % Generate function name } % Actually process the body of a definition % #1 should be the terminating control sequence, such as \Edefun. % #2 should be the "another name" control sequence, such as \defunx. % #3 should be the control sequence that actually processes the header, % such as \defunheader. \def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\activeparens\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % \obeylines\activeparens\spacesplit#3} \def\defmethparsebody #1#2#3#4 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#4}}} \def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\activeparens\spacesplit{#3{#5}}} % These parsing functions are similar to the preceding ones % except that they do not make parens into active characters. % These are used for "variables" since they have no arguments. \def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2{\begingroup\obeylines\spacesplit#3}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup % \catcode 61=\active % \obeylines\spacesplit#3} \def\defvrparsebody #1#2#3#4 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\spacesplit{#3{#4}}} \def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % \medbreak % % Define the end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% \def#2##1 ##2 {\def#4{##1}% \begingroup\obeylines\spacesplit{#3{##2}}}% \parindent=0in \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent \exdentamount=\defbodyindent \begingroup\obeylines\spacesplit{#3{#5}}} % Split up #2 at the first space token. % call #1 with two arguments: % the first is all of #2 before the space token, % the second is all of #2 after that space token. % If #2 contains no space token, all of it is passed as the first arg % and the second is passed as empty. {\obeylines \gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% \long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% \ifx\relax #3% #1{#2}{}\else #1{#2}{#3#4}\fi}} % So much for the things common to all kinds of definitions. % Define @defun. % First, define the processing that is wanted for arguments of \defun % Use this to expand the args and terminate the paragraph they make up \def\defunargs #1{\functionparens \sl % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. \hyphenchar\tensl=0 #1% \hyphenchar\tensl=45 \ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\penalty 10000\vskip -\parskip\penalty 10000% } \def\deftypefunargs #1{% % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. \functionparens \code{#1}% \interlinepenalty=10000 \advance\rightskip by 0pt plus 1fil \endgraf\penalty 10000\vskip -\parskip\penalty 10000% } % Do complete processing of one @defun or @defunx line already parsed. % @deffn Command forward-char nchars \def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} \def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% \begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defun == @deffn Function \def\defun{\defparsebody\Edefun\defunx\defunheader} \def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Function}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefun int foobar (int @var{foo}, float @var{bar}) \def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} % #1 is the data type. #2 is the name and args. \def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} % #1 is the data type, #2 the name, #3 the args. \def\deftypefunheaderx #1#2 #3\relax{% \doind {fn}{\code{#2}}% Make entry in function index \begingroup\defname {\code{#1} #2}{Function}% \deftypefunargs {#3}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} % #1 is the classification. #2 is the data type. #3 is the name and args. \def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} % #1 is the classification, #2 the data type, #3 the name, #4 the args. \def\deftypefnheaderx #1#2#3 #4\relax{% \doind {fn}{\code{#3}}% Make entry in function index \begingroup\defname {\code{#2} #3}{#1}% \deftypefunargs {#4}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defmac == @deffn Macro \def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} \def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Macro}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % @defspec == @deffn Special Form \def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} \def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index \begingroup\defname {#1}{Special Form}% \defunargs {#2}\endgroup % \catcode 61=\other % Turn off change made in \defparsebody } % This definition is run if you use @defunx % anywhere other than immediately after a @defun or @defunx. \def\deffnx #1 {\errmessage{@deffnx in invalid context}} \def\defunx #1 {\errmessage{@defunx in invalid context}} \def\defmacx #1 {\errmessage{@defmacx in invalid context}} \def\defspecx #1 {\errmessage{@defspecx in invalid context}} \def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} \def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} % @defmethod, and so on % @defop {Funny Method} foo-class frobnicate argument \def\defop #1 {\def\defoptype{#1}% \defopparsebody\Edefop\defopx\defopheader\defoptype} \def\defopheader #1#2#3{% \dosubind {fn}{\code{#2}}{on #1}% Make entry in function index \begingroup\defname {#2}{\defoptype{} on #1}% \defunargs {#3}\endgroup % } % @defmethod == @defop Method \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} \def\defmethodheader #1#2#3{% \dosubind {fn}{\code{#2}}{on #1}% entry in function index \begingroup\defname {#2}{Method on #1}% \defunargs {#3}\endgroup % } % @defcv {Class Option} foo-class foo-flag \def\defcv #1 {\def\defcvtype{#1}% \defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} \def\defcvarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{\defcvtype{} of #1}% \defvarargs {#3}\endgroup % } % @defivar == @defcv {Instance Variable} \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} \def\defivarheader #1#2#3{% \dosubind {vr}{\code{#2}}{of #1}% Make entry in var index \begingroup\defname {#2}{Instance Variable of #1}% \defvarargs {#3}\endgroup % } % These definitions are run if you use @defmethodx, etc., % anywhere other than immediately after a @defmethod, etc. \def\defopx #1 {\errmessage{@defopx in invalid context}} \def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} \def\defcvx #1 {\errmessage{@defcvx in invalid context}} \def\defivarx #1 {\errmessage{@defivarx in invalid context}} % Now @defvar % First, define the processing that is wanted for arguments of @defvar. % This is actually simple: just print them in roman. % This must expand the args and terminate the paragraph they make up \def\defvarargs #1{\normalparens #1% \interlinepenalty=10000 \endgraf\penalty 10000\vskip -\parskip\penalty 10000} % @defvr Counter foo-count \def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} \def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% \begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} % @defvar == @defvr Variable \def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} \def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{Variable}% \defvarargs {#2}\endgroup % } % @defopt == @defvr {User Option} \def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} \def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index \begingroup\defname {#1}{User Option}% \defvarargs {#2}\endgroup % } % @deftypevar int foobar \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} % #1 is the data type. #2 is the name. \def\deftypevarheader #1#2{% \doind {vr}{\code{#2}}% Make entry in variables index \begingroup\defname {\code{#1} #2}{Variable}% \interlinepenalty=10000 \endgraf\penalty 10000\vskip -\parskip\penalty 10000 \endgroup} % @deftypevr {Global Flag} int enable \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} \def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% \begingroup\defname {\code{#2} #3}{#1} \interlinepenalty=10000 \endgraf\penalty 10000\vskip -\parskip\penalty 10000 \endgroup} % This definition is run if you use @defvarx % anywhere other than immediately after a @defvar or @defvarx. \def\defvrx #1 {\errmessage{@defvrx in invalid context}} \def\defvarx #1 {\errmessage{@defvarx in invalid context}} \def\defoptx #1 {\errmessage{@defoptx in invalid context}} \def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} \def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} % Now define @deftp % Args are printed in bold, a slight difference from @defvar. \def\deftpargs #1{\bf \defvarargs{#1}} % @deftp Class window height width ... \def\deftp{\defvrparsebody\Edeftp\deftpx\deftpheader} \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} % This definition is run if you use @deftpx, etc % anywhere other than immediately after a @deftp, etc. \def\deftpx #1 {\errmessage{@deftpx in invalid context}} \message{cross reference,} % Define cross-reference macros \newwrite \auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % \setref{foo} defines a cross-reference point named foo. \def\setref#1{% %\dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{Ysectionnumberandtype}} \def\unnumbsetref#1{% %\dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{Ynothing}} \def\appendixsetref#1{% %\dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{Yappendixletterandtype}} % \xref, \pxref, and \ref generate cross-references to specified points. % For \xrefX, #1 is the node name, #2 the name of the Info % cross-reference, #3 the printed node name, #4 the name of the Info % file, #5 the name of the printed manual. All but the node name can be % omitted. % \def\pxref#1{see \xrefX[#1,,,,,,,]} \def\xref#1{See \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup% \def\printedmanual{\ignorespaces #5}% \def\printednodename{\ignorespaces #3}% % \setbox1=\hbox{\printedmanual}% \setbox0=\hbox{\printednodename}% \ifdim \wd0=0pt% \def\printednodename{\ignorespaces #1}% %%% Uncommment the following line to make the actual chapter or section title %%% appear inside the square brackets. %\def\printednodename{#1-title}% \fi% % % % If we use \unhbox0 and \unhbox1 to print the node names, TeX does % not insert empty discretionaries after hyphens, which means that it % will not find a line break at a hyphen in a node names. Since some % manuals are best written with fairly long node names, containing % hyphens, this is a loss. Therefore, we simply give the text of % the node name again, so it is as if TeX is seeing it for the first % time. \ifdim \wd1>0pt section ``\printednodename'' in \cite{\printedmanual}% \else% \turnoffactive% \refx{#1-snt}{} [\printednodename], page\tie\refx{#1-pg}{}% \fi \endgroup} % \dosetq is the interface for calls from other macros % Use \turnoffactive so that punctuation chars such as underscore % work in node names. \def\dosetq #1#2{{\let\folio=0 \turnoffactive% \edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% \next}} % \internalsetq {foo}{page} expands into % CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} % When the aux file is read, ' is the escape character \def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} % Things to be expanded by \internalsetq \def\Ypagenumber{\folio} \def\Ytitle{\thischapter} \def\Ynothing{} \def\Ysectionnumberandtype{% \ifnum\secno=0 Chapter\xreftie\the\chapno % \else \ifnum \subsecno=0 Section\xreftie\the\chapno.\the\secno % \else \ifnum \subsubsecno=0 % Section\xreftie\the\chapno.\the\secno.\the\subsecno % \else % Section\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \def\Yappendixletterandtype{% \ifnum\secno=0 Appendix\xreftie'char\the\appendixno{}% \else \ifnum \subsecno=0 Section\xreftie'char\the\appendixno.\the\secno % \else \ifnum \subsubsecno=0 % Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno % \else % Section\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % \fi \fi \fi } \gdef\xreftie{'tie} % Use TeX 3.0's \inputlineno to get the line number, for better error % messages, but if we're using an old version of TeX, don't do anything. % \ifx\inputlineno\thisisundefined \let\linenumber = \empty % Non-3.0. \else \def\linenumber{\the\inputlineno:\space} \fi % Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. % If its value is nonempty, SUFFIX is output afterward. \def\refx#1#2{% \expandafter\ifx\csname X#1\endcsname\relax % If not defined, say something at least. $\langle$un\-de\-fined$\rangle$% \ifhavexrefs \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \else % It's defined, so just use it. \csname X#1\endcsname \fi #2% Output the suffix in any case. } % Read the last existing aux file, if any. No error if none exists. % This is the macro invoked by entries in the aux file. \def\xrdef #1#2{ {\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} \def\readauxfile{% \begingroup \catcode `\^^@=\other \catcode `\=\other \catcode `\=\other \catcode `\^^C=\other \catcode `\^^D=\other \catcode `\^^E=\other \catcode `\^^F=\other \catcode `\^^G=\other \catcode `\^^H=\other \catcode `\ =\other \catcode `\^^L=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode `\=\other \catcode 26=\other \catcode `\^^[=\other \catcode `\^^\=\other \catcode `\^^]=\other \catcode `\^^^=\other \catcode `\^^_=\other \catcode `\@=\other \catcode `\^=\other \catcode `\~=\other \catcode `\[=\other \catcode `\]=\other \catcode`\"=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode `\$=\other \catcode `\#=\other \catcode `\&=\other % the aux file uses ' as the escape. % Turn off \ as an escape so we do not lose on % entries which were dumped with control sequences in their names. % For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ % Reference to such entries still does not work the way one would wish, % but at least they do not bomb out when the aux file is read in. \catcode `\{=1 \catcode `\}=2 \catcode `\%=\other \catcode `\'=0 \catcode `\\=\other \openin 1 \jobname.aux \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue \fi % Open the new aux file. Tex will close it automatically at exit. \openout \auxfile=\jobname.aux \endgroup} % Footnotes. \newcount \footnoteno % The trailing space in the following definition for supereject is % vital for proper filling; pages come out unaligned when you do a % pagealignmacro call if that space before the closing brace is % removed. \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for info output only.. \let\footnotestyle=\comment \let\ptexfootnote=\footnote {\catcode `\@=11 \long\gdef\footnote #1{\global\advance \footnoteno by \@ne \unskip \edef\thisfootno{$^{\the\footnoteno}$}% \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi \thisfootno\@sf \footnotezzz{#1}} % \parsearg\footnotezzz} \long\gdef\footnotezzz #1{\insert\footins{ \interlinepenalty\interfootnotelinepenalty \splittopskip\ht\strutbox % top baseline for broken footnotes \splitmaxdepth\dp\strutbox \floatingpenalty\@MM \leftskip\z@skip \rightskip\z@skip \spaceskip\z@skip \xspaceskip\z@skip \footstrut\parindent=\defaultparindent\hang\textindent{\thisfootno}#1\strut}} }%end \catcode `\@=11 % End of control word definitions. \message{and turning on texinfo input format.} \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % Set some numeric style parameters, for 8.5 x 11 format. %\hsize = 6.5in \newdimen\defaultparindent \defaultparindent = 15pt \parindent = \defaultparindent \parskip 18pt plus 1pt \baselineskip 15pt \advance\topskip by 1.2cm % Prevent underfull vbox error messages. \vbadness=10000 % Following George Bush, just get rid of widows and orphans. \widowpenalty=10000 \clubpenalty=10000 % Use TeX 3.0's \emergencystretch to help line breaking, but if we're % using an old version of TeX, don't do anything. We want the amount of % stretch added to depend on the line length, hence the dependence on % \hsize. This makes it come to about 9pt for the 8.5x11 format. % \ifx\emergencystretch\thisisundefined \else \emergencystretch = \hsize \divide\emergencystretch by 45 \fi % Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) \def\smallbook{ \global\lispnarrowing = 0.3in \global\baselineskip 12pt \advance\topskip by -1cm \global\parskip 3pt plus 1pt \global\hsize = 5in \global\doublecolumnhsize=2.4in \global\doublecolumnvsize=15.0in \global\vsize=7.5in \global\tolerance=700 \global\hfuzz=1pt \global\contentsrightmargin=0pt \global\pagewidth=\hsize \global\pageheight=\vsize \global\let\smalllisp=\smalllispx \global\let\smallexample=\smalllispx \global\def\Esmallexample{\Esmalllisp} } % Use @afourpaper to print on European A4 paper. \def\afourpaper{ \global\tolerance=700 \global\hfuzz=1pt \global\baselineskip=12pt \global\parskip 15pt plus 1pt \global\vsize= 53\baselineskip \advance\vsize by \topskip %\global\hsize= 5.85in % A4 wide 10pt \global\hsize= 6.5in \global\outerhsize=\hsize \global\advance\outerhsize by 0.5in \global\outervsize=\vsize \global\advance\outervsize by 0.6in \global\doublecolumnhsize=\hsize \global\divide\doublecolumnhsize by 2 \global\advance\doublecolumnhsize by -0.1in \global\doublecolumnvsize=\vsize \global\multiply\doublecolumnvsize by 2 \global\advance\doublecolumnvsize by 0.1in \global\pagewidth=\hsize \global\pageheight=\vsize } %% For a final copy, take out the rectangles %% that mark overfull boxes (in case you have decided %% that the text looks ok even though it passes the margin). \def\finalout{\overfullrule=0pt} % Define macros to output various characters with catcode for normal text. \catcode`\"=\other \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \def\normaldoublequote{"} \def\normaltilde{~} \def\normalcaret{^} \def\normalunderscore{_} \def\normalverticalbar{|} \def\normalless{<} \def\normalgreater{>} \def\normalplus{+} % This macro is used to make a character print one way in ttfont % where it can probably just be output, and another way in other fonts, % where something hairier probably needs to be done. % % #1 is what to print if we are indeed using \tt; #2 is what to print % otherwise. Since all the Computer Modern typewriter fonts have zero % interword stretch (and shrink), and it is reasonable to expect all % typewriter fonts to have this, we can check that font parameter. % \def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} % Turn off all special characters except @ % (and those which the user can use as if they were ordinary). % Most of these we simply print from the \tt font, but for some, we can % use math or other variants that look better in normal text. \catcode`\"=\active \def\activedoublequote{{\tt \char '042}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt \char '176}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} % Subroutine for the previous macro. \def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} % \lvvmode is equivalent in function to \leavevmode. % Using \leavevmode runs into trouble when written out to % an index file due to the expansion of \leavevmode into ``\unhbox % \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our % magic tricks with @. \def\lvvmode{\vbox to 0pt{}} \catcode`\|=\active \def|{{\tt \char '174}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} %\catcode 27=\active %\def^^[{$\diamondsuit$} % Used sometimes to turn off (effectively) the active characters % even after parsing them. \def\turnoffactive{\let"=\normaldoublequote \let~=\normaltilde \let^=\normalcaret \let_=\normalunderscore \let|=\normalverticalbar \let<=\normalless \let>=\normalgreater \let+=\normalplus} % Set up an active definition for =, but don't enable it most of the time. {\catcode`\==\active \global\def={{\tt \char 61}}} \catcode`\@=0 % \rawbackslashxx output one backslash character in current font \global\chardef\rawbackslashxx=`\\ %{\catcode`\\=\other %@gdef@rawbackslashxx{\}} % \rawbackslash redefines \ as input to do \rawbackslashxx. {\catcode`\\=\active @gdef@rawbackslash{@let\=@rawbackslashxx }} % \normalbackslash outputs one backslash in fixed width font. \def\normalbackslash{{\tt\rawbackslashxx}} % Say @foo, not \foo, in error messages. \escapechar=`\@ % \catcode 17=0 % Define control-q \catcode`\\=\active % If a .fmt file is being used, we don't want the `\input texinfo' to show up. % That is what \eatinput is for; after that, the `\' should revert to printing % a backslash. % @gdef@eatinput input texinfo{@fixbackslash} @global@let\ = @eatinput % On the other hand, perhaps the file did not have a `\input texinfo'. Then % the first `\{ in the file would cause an error. This macro tries to fix % that, assuming it is called before the first `\' could plausibly occur. % @gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} %% These look ok in all fonts, so just make them not special. The @rm below %% makes sure that the current font starts out as the newly loaded cmr10 @catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other @textfonts @rm @c Local variables: @c page-delimiter: "^\\\\message" @c End: texinfo-2.15/texinfo2.texi0000644000175000017500000177275612415566511013043 0ustar gg\input texinfo @c -*-texinfo-*- @comment %**start of header @setfilename texinfo @settitle Texinfo 2.15 @syncodeindex vr fn @c footnotestyle separate @c paragraphindent 2 @smallbook @comment %**end of header @iftex @finalout @end iftex @c Note: Please update the edition number, month, and year @c Edition number is set at: settitle, subtitle and top node @c Month or date is set at: subtitle and top node; @c Search for: !!set @c Note: for smallbook printed manual, illustrate smallbook with true @c smallbook example, show cartouche, consider vtable. @ifinfo This file documents Texinfo, a documentation system that uses a single source file to produce both on-line information and a printed manual. Copyright (C) 1988, 1990, 1991, 1992 Free Software Foundation, Inc. This is the second edition of the Texinfo documentation,@* and is consistent with version 2 of @file{texinfo.tex}. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @end ifinfo @setchapternewpage odd @titlepage @c use the new format for titles @c !!set month and edition here @title Texinfo @subtitle The GNU Documentation Format @subtitle Edition 2.15, for Texinfo Version Two @subtitle June 1992 @author by Robert J. Chassell and Richard M. Stallman @comment Include the Distribution inside the titlepage so @c that headings are turned off. @page @vskip 0pt plus 1filll Copyright @copyright{} 1988, 1990, 1991, 1992 Free Software Foundation, Inc. @sp 2 This is the second edition of the Texinfo documentation,@* and is consistent with version 2 of @file{texinfo.tex}. @sp 2 Published by the Free Software Foundation @* 675 Massachusetts Avenue, @* Cambridge, MA 02139 USA @* Printed copies are available for $15 each.@* ISBN-1882114-12-4 Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @sp 2 Cover art by Etienne Suvasa. @end titlepage @ifinfo @node Top, Copying, (dir), (dir) @top Texinfo Texinfo is a documentation system that uses a single source file to produce both on-line information and printed output.@refill The first part of this master menu lists the major nodes in this Info document, including the @@-command and concept indices. The rest of the menu lists all the lower level nodes in the document.@refill @c !!set date and edition here This is Edition 2.15 of the Texinfo documentation, @w{12 June 1992,} for Texinfo Version 2. @end ifinfo @c Here is a spare copy of the chapter menu entry descriptions, @c in case they are accidently deleted @ignore Your rights. Texinfo in brief. How to use Texinfo mode. What is at the beginning of a Texinfo file? What is at the end of a Texinfo file? How to create chapters, sections, subsections, appendices, and other parts. How to provide structure for a document. How to write nodes. How to write menus. How to write cross references. How to mark words and phrases as code, keyboard input, meta-syntactic variables, and the like. How to write quotations, examples, etc. How to write lists and tables. How to create indices. How to insert @@-signs, braces, etc. How to indicate results of evaluation, expansion of macros, errors, etc. How to force and prevent line and page breaks. How to describe functions and the like in a uniform manner. How to write footnotes. How to specify text for either @TeX{} or Info. How to print hardcopy. How to create an Info file. How to install an Info file A list of all the Texinfo @@-commands. Hints on how to write a Texinfo document. A sample Texinfo file to look at. Tell readers they have the right to copy and distribute. How to incorporate other Texinfo files. How to write page headings and footings. How to find formatting mistakes. All about paragraph refilling. A description of @@-Command syntax. Texinfo second edition features. A menu containing commands and variables. A menu covering many topics. @end ignore @menu * Copying:: Your rights. * Overview:: Texinfo in brief. * Texinfo Mode:: How to use Texinfo mode. * Beginning a File:: What is at the beginning of a Texinfo file? * Ending a File:: What is at the end of a Texinfo file? * Structuring:: How to create chapters, sections, subsections, appendices, and other parts. * Nodes:: How to write nodes. * Menus:: How to write menus. * Cross References:: How to write cross references. * Marking Text:: How to mark words and phrases as code, keyboard input, meta-syntactic variables, and the like. * Quotations and Examples:: How to write quotations, examples, etc. * Lists and Tables:: How to write lists and tables. * Indices:: How to create indices. * Insertions:: How to insert @@-signs, braces, etc. * Glyphs:: How to indicate results of evaluation, expansion of macros, errors, etc. * Breaks:: How to force and prevent line and page breaks. * Definition Commands:: How to describe functions and the like in a uniform manner. * Footnotes:: How to write footnotes. * Conditionals:: How to specify text for either @TeX{} or Info. * Format/Print Hardcopy:: How to convert a Texinfo file to a file for printing and how to print that file. * Create an Info File:: Convert a Texinfo file into an Info file. * Install an Info File:: Make an Info file accessible to users. * Command List:: All the Texinfo @@-commands. * Tips:: Hints on how to write a Texinfo document. * Sample Texinfo File:: A sample Texinfo file to look at. * Sample Permissions:: Tell readers they have the right to copy and distribute. * Include Files:: How to incorporate other Texinfo files. * Headings:: How to write page headings and footings. * Catching Mistakes:: How to find formatting mistakes. * Refilling Paragraphs:: All about paragraph refilling. * Command Syntax:: A description of @@-Command syntax. * Obtaining TeX:: How to Obtain @TeX{}. * New Features:: Texinfo second edition features. * Command and Variable Index:: A menu containing commands and variables. * Concept Index:: A menu covering many topics. --- The Detailed Node Listing --- Overview of Texinfo * Using Texinfo:: Create a conventional printed book or an Info file. * Info Files:: What is an Info file? * Printed Books:: Characteristics of a printed book or manual. * Formatting Commands:: @@-commands are used for formatting. * Conventions:: General rules for writing a Texinfo file. * Comments:: How to write comments and mark regions that the formatting commands will ignore. * Minimum:: What a Texinfo file must have. * Six Parts:: Usually, a Texinfo file has six parts. * Short Sample:: A short sample Texinfo file. Using Texinfo Mode * Texinfo Mode Overview:: How Texinfo mode can help you. * Emacs Editing:: Texinfo mode adds to GNU Emacs' general purpose editing features. * Inserting:: How to insert frequently used @@-commands. * Showing the Structure:: How to show the structure of a file. * Updating Nodes and Menus:: How to update or create new nodes and menus. * Info Formatting:: How to format for Info. * Printing:: How to format and print part or all of a file. * Texinfo Mode Summary:: Summary of all the Texinfo mode commands. Updating Nodes and Menus * Updating Commands:: Five major updating commands. * Updating Requirements:: How to structure a Texinfo file for using the updating command. * Other Updating Commands:: How to indent descriptions, insert missing nodes lines, and update nodes in sequence. Beginning a Texinfo File * Four Parts:: Four parts begin a Texinfo file. * Sample Beginning:: Here is a sample beginning for a Texinfo file. * Header:: The very beginning of a Texinfo file. * Info Summary and Permissions:: Summary and copying permissions for Info. * Titlepage & Copyright Page:: Creating the title and copyright pages. * The Top Node:: Creating the `Top' node and master menu. * Software Copying Conditions:: Ensure that you and others continue to have the right to use and share software. The Texinfo File Header * First Line:: The first line of a Texinfo file. * Start of Header:: Formatting a region requires this. * setfilename:: Tell Info the name of the Info file. * settitle:: Create a title for the printed work. * setchapternewpage:: Start chapters on right-hand pages. * paragraphindent:: An option to specify paragraph indentation. * End of Header:: Formatting a region requires this. The Title and Copyright Pages * titlepage:: Create a title for the printed document. * titlefont center sp:: The @code{@@titlefont}, @code{@@center}, and @code{@@sp} commands. * title subtitle author:: The @code{@@title}, @code{@@subtitle}, and @code{@@author} commands. * Copyright & Permissions:: How to write the copyright notice and include copying permissions. * end titlepage:: Turn on page headings after the title and copyright pages. * headings on off:: An option for turning headings on and off and double or single sided printing. The `Top' Node and Master Menu * Title of Top Node:: Sketch what the file is about. * Master Menu Parts:: A master menu has three or more parts. Ending a Texinfo File * Printing Indices & Menus:: How to print an index in hardcopy and generate index menus in Info. * Contents:: How to create a table of contents. * File End:: How to mark the end of a file. Chapter Structuring * Tree Structuring:: A manual is like an upside down tree @dots{} * Structuring Command Types:: How to divide a manual into parts. * makeinfo top:: The @code{@@top} command, part of the `Top' node. * chapter:: * unnumbered & appendix:: * majorheading & chapheading:: * section:: * unnumberedsec appendixsec heading:: * subsection:: * unnumberedsubsec appendixsubsec subheading:: * subsubsection:: Commands for the lowest level sections. Nodes * Two Paths:: Different commands to structure Info output and printed output. * Node Menu Illustration:: A diagram, and sample nodes and menus. * node:: How to write a node, in detail. * makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. The @code{@@node} Command * Node Names:: How to choose node and pointer names. * Writing a Node:: How to write an @code{@@node} line. * Node Line Tips:: Keep names short. * Node Line Requirements:: Keep names unique, without @@-commands. * First Node:: How to write a `Top' node. * makeinfo top command:: How to use the @code{@@top} command. * Top Node Summary:: Write a brief description for readers. Menus * Menu Location:: Put a menu in a short node. * Writing a Menu:: What is a menu? * Writing a Menu Entry:: How to write a menu entry. * Menu Example:: A menu example. * Other Info Files:: How to refer to a different Info file. Cross References * References:: What cross references are for. * Cross Reference Commands:: A summary of the different commands. * Cross Reference Parts:: A cross reference has several parts. * xref:: Begin a reference with `See' @dots{} * Top Node Naming:: How to refer to the beginning of another file. * ref:: A reference for the last part of a sentence. * pxref:: How to write a parenthetical cross reference. * inforef:: How to refer to an Info-only file. @code{@@xref} * Reference Syntax:: What a reference looks like and requires. * One Argument:: @code{@@xref} with one argument. * Two Arguments:: @code{@@xref} with two arguments. * Three Arguments:: @code{@@xref} with three arguments. * Four and Five Arguments:: @code{@@xref} with four and five arguments. Marking Words and Phrases * Indicating:: How to indicate definitions, files, etc. * Emphasis:: How to emphasize text. Indicating Definitions, Commands, etc. * Useful Highlighting:: Highlighting provides useful information. * code:: How to indicate code. * kbd:: How to show keyboard input. * key:: How to specify keys. * samp:: How to show a literal sequence of characters. * var:: How to indicate a metasyntactic variable. * file:: How to indicate the name of a file. * dfn:: How to specify a definition. * cite:: How to refer to a book that is not in Info. Emphasizing Text * emph & strong:: How to emphasize text in Texinfo. * Smallcaps:: How to use the small caps font. * Fonts:: Various font commands for printed output. Quotations and Examples * Block Enclosing Commands:: Use different constructs for different purposes. * quotation:: How to write a quotation. * example:: How to write an example in a fixed-width font. * noindent:: How to prevent paragraph indentation. * Lisp Example:: How to illustrate Lisp code. * smallexample & smalllisp:: Forms for the @code{@@smallbook} option. * display:: How to write an example in the current font. * format:: How to write an example that does not narrow the margins. * exdent:: How to undo the indentation of a line. * flushleft & flushright:: How to push text flushleft or flushright. * cartouche:: How to draw cartouches around examples. Making Lists and Tables * Introducing Lists:: Texinfo formats lists for you. * itemize:: How to construct a simple list. * enumerate:: How to construct a numbered list. * Two-column Tables:: How to construct a two-column table. Making a Two-column Table * table:: How to construct a two-column table. * ftable vtable:: How to construct a two-column table with automatic indexing. * itemx:: How to put more entries in the first column. Creating Indices * Index Entries:: Choose different words for index entries. * Predefined Indices:: Use different indices for different kinds of entry. * Indexing Commands:: How to make an index entry. * Combining Indices:: How to combine indices. * New Indices:: How to define your own indices. Combining Indices * syncodeindex:: How to merge two indices, using @code{@@code} font for the merged-from index. * synindex:: How to merge two indices, using the default font of the merged-to index. Special Insertions * Braces Atsigns Periods:: How to insert braces, @samp{@@} and periods. * dmn:: How to format a dimension. * Dots Bullets:: How to insert dots and bullets. * TeX and copyright:: How to insert the @TeX{} logo and the copyright symbol. * minus:: How to insert a minus sign. Inserting @samp{@@}, Braces, and Periods * Inserting An Atsign:: * Inserting Braces:: How to insert @samp{@{} and @samp{@}} * Controlling Spacing:: How to insert the right amount of space after punctuation within a sentence. Inserting Ellipsis, Dots, and Bullets * dots:: How to insert dots @dots{} * bullet:: How to insert a bullet. Inserting @TeX{} and the Copyright Symbol * tex:: How to insert the @TeX{} logo. * copyright symbol:: How to use @code{@@copyright}@{@}. Glyphs for Examples * Glyphs Summary:: * result:: How to show the result of expression. * expansion:: How to indicate an expansion. * Print Glyph:: How to indicate printed output. * Error Glyph:: How to indicate an error message. * Equivalence:: How to indicate equivalence. * Point Glyph:: How to indicate the location of point. Making and Preventing Breaks * Break Commands:: Cause and prevent splits. * Line Breaks:: How to force a single line to use two lines. * w:: How to prevent unwanted line breaks. * sp:: How to insert blank lines. * page:: How to force the start of a new page. * group:: How to prevent unwanted page breaks. * need:: Another way to prevent unwanted page breaks. Definition Commands: @code{@@deffn}, etc. * Def Cmd Template:: How to structure a description using a definition command. * Optional Arguments:: How to handle optional and repeated arguments. * deffnx:: How to group two or more `first' lines. * Def Cmds in Detail:: All the definition commands. * Def Cmd Conventions:: Conventions for writing definitions. * Sample Function Definition:: The Definition Commands * Functions Commands:: Commands for functions and similar entities. * Variables Commands:: Commands for variables and similar entities. * Typed Functions:: Commands for functions in typed languages. * Typed Variables:: Commands for variables in typed languages. * Abstract Objects:: Commands for object-oriented programming. * Data Types:: The definition command for data types. Conditionally Visible Text * Conditional Commands:: Specifying text for Info or @TeX{}. * Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. * set and clear:: Designating which text to format (for both Info and @TeX{}). Format and Print Hardcopy * Use TeX:: Use @TeX{} to format for hardcopy. * Shell Format & Print:: How to format and print a hardcopy manual with shell commands. * Within Emacs:: How to format and print from an Emacs shell. * Texinfo Mode Printing:: How to format and print in Texinfo mode. * Compile-Command:: How to print using Emacs's compile command. * Requirements Summary:: @TeX{} formatting requirements summary. * Preparing for TeX:: What you need to do to use @TeX{}. * Overfull hboxes:: What are and what to do with overfull hboxes. * smallbook:: Printing small format books and manuals. Creating an Info File * makeinfo advantages:: @code{makeinfo} provides better error checking. * Running makeinfo:: How to run @code{makeinfo} from a shell. * makeinfo options:: Specify fill-column and other options. * Pointer Validation:: How to check that pointers point somewhere. * makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. * texinfo-format commands:: Two Info formatting commands written in Emacs Lisp are an alternative to @code{makeinfo}. * Tag and Split Files:: How tagged and split files help Info to run better. Installing an Info File * Directory file:: The top level menu for all Info files. * New Info File:: Listing a new info file. * Other Info Directories:: How to specify Info files that are located in other directories. Sample Permissions * Inserting Permissions:: How to put permissions in your document. * ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. * Titlepage Permissions:: Sample Titlepage copying permissions. Include Files * Using Include Files:: How to use the @code{@@include} command. * texinfo-multiple-files-update:: How to create and update nodes and menus when using included files. * Include File Requirements:: What @code{texinfo-multiple-files-update} expects. * Sample Include File:: A sample outer file with included files within it; and a sample included file. * Include Files Evolution:: How use of the @code{@@include} command has changed over time. Page Headings * Headings Introduced:: Conventions for using page headings. * Heading Format:: Standard page heading formats. * Heading Choice:: How to specify the type of page heading. * Custom Headings:: How to create your own headings and footings. Formatting Mistakes * makeinfo preferred:: @code{makeinfo} finds errors. * Debugging with Info:: How to catch errors with Info formatting. * Debugging with TeX:: How to catch errors with @TeX{} formatting. * Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. * Using occur:: How to list all lines containing a pattern. * Running Info-Validate:: How to find badly referenced nodes. Finding Badly Referenced Nodes * Using Info-validate:: How to run @code{Info-validate}. * Unsplit:: How to create an unsplit file. * Tagifying:: How to tagify a file. * Splitting:: How to split a file manually. Second Edition Features * New Texinfo Mode Commands:: The updating commands are especially useful. * New Commands:: Many newly described @@-commands. @end menu @node Copying, Overview, Top, Top @comment node-name, next, previous, up @unnumbered Texinfo Copying Conditions @cindex Copying conditions @cindex Conditions for copying Texinfo The programs currently being distributed that relate to Texinfo include portions of GNU Emacs, plus other separate programs (including @code{makeinfo}, @code{info}, @code{texindex}, and @file{texinfo.tex}). These programs are @dfn{free}; this means that everyone is free to use them and free to redistribute them on a free basis. The Texinfo-related programs are not in the public domain; they are copyrighted and there are restrictions on their distribution, but these restrictions are designed to permit everything that a good cooperating citizen would want to do. What is not allowed is to try to prevent others from further sharing any version of these programs that they might get from you.@refill Specifically, we want to make sure that you have the right to give away copies of the programs that relate to Texinfo, that you receive source code or else can get it if you want it, that you can change these programs or use pieces of them in new free programs, and that you know you can do these things.@refill To make sure that everyone has such rights, we have to forbid you to deprive anyone else of these rights. For example, if you distribute copies of the Texinfo related programs, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights.@refill Also, for our own protection, we must make certain that everyone finds out that there is no warranty for the programs that relate to Texinfo. If these programs are modified by someone else and passed on, we want their recipients to know that what they have is not what we distributed, so that any problems introduced by others will not reflect on our reputation.@refill The precise conditions of the licenses for the programs currently being distributed that relate to Texinfo are found in the General Public Licenses that accompany them.@refill @node Overview, Texinfo Mode, Copying, Top @comment node-name, next, previous, up @chapter Overview of Texinfo @cindex Overview of Texinfo @cindex Texinfo overview @dfn{Texinfo}@footnote{Note that the first syllable of ``Texinfo'' is pronounced like ``speck'', not ``hex''. This odd pronunciation is derived from, but is not the same as, the pronunciation of @TeX{}. In the word @TeX{}, the @samp{X} is actually the Greek letter ``chi'' rather than the English letter ``ex''. Pronounce @TeX{} as if the @samp{X} were the last sound in the name `Bach'; but pronounce Texinfo as if the @samp{x} were a `k'. Spell ``Texinfo'' with a capital ``T'' and write the other letters in lower case.} is a documentation system that uses a single source file to produce both on-line information and printed output. This means that instead of writing two different documents, one for the on-line help or other on-line information and the other for a typeset manual or other printed work, you need write only one document. When the work is revised, you need revise only one document. (You can read the on-line information, known as an @dfn{Info file}, with an Info documentation-reading program.)@refill @c !!! should we use `file' in place of `document' three lines up? @menu * Using Texinfo:: Create a conventional printed book or an Info file. * Info Files:: What is an Info file? * Printed Books:: Characteristics of a printed book or manual. * Formatting Commands:: @@-commands are used for formatting. * Conventions:: General rules for writing a Texinfo file. * Comments:: How to write comments and mark regions that the formatting commands will ignore. * Minimum:: What a Texinfo file must have. * Six Parts:: Usually, a Texinfo file has six parts. * Short Sample:: A short sample Texinfo file. @end menu @node Using Texinfo, Info Files, , Overview @ifinfo @heading Using Texinfo @end ifinfo Using Texinfo, you can create a printed document with the normal features of a book, including chapters, sections, cross references, and indices. From the same Texinfo source file, you can create a menu-driven, on-line Info file with nodes, menus, cross references, and indices. You can, if you wish, make the chapters and sections of the printed document correspond to the nodes of the on-line information; and you use the same cross references and indices for both the Info file and the printed work. @cite{The GNU Emacs Manual} is a good example of a Texinfo file, as is this manual.@refill To make a printed document, you process a Texinfo source file with the @TeX{} typesetting program. This creates a @sc{dvi} file that you can typeset and print as a book or report. (Note that the Texinfo language is completely different from @TeX{}'s usual language, Plain@TeX{}, which Texinfo replaces.) If you do not have @TeX{}, but do have @code{troff} or @code{nroff}, you can use the @code{texi2roff} program instead.@refill To make an Info file, you process a Texinfo source file with the @code{makeinfo} utility or Emacs's @code{texinfo-format-buffer} command; this creates an Info file that you can install on-line.@refill @TeX{} and @code{texi2roff} work with many types of printer; similarly, Info works with almost every type of computer terminal. This power makes Texinfo a general purpose system, but brings with it a constraint, which is that a Texinfo file may contain only the customary ``typewriter'' characters (letters, numbers, spaces, and punctuation marks) but no special graphics.@refill A Texinfo file is a plain @sc{ascii} file containing text and @dfn{@@-commands} (words preceded by an @samp{@@}) that tell the typesetting and formatting programs what to do. You may edit a Texinfo file with any text editor; but it is especially convenient to use GNU Emacs since that editor has a special mode, called Texinfo mode, that provides various Texinfo-related features. (@xref{Texinfo Mode}.)@refill Before writing a Texinfo source file, you should become familiar with the Info documentation reading program and learn about nodes, menus, cross references, and the rest. (@inforef{Top, info, info}, for more information.)@refill You can use Texinfo to create both on-line help and printed manuals; moreover, Texinfo is freely redistributable. For these reasons, Texinfo is the format in which documentation for GNU utilities and libraries is written.@refill @node Info Files, Printed Books, Using Texinfo, Overview @comment node-name, next, previous, up @section Info files @cindex Info files An Info file is a Texinfo file formatted so that the Info documentation reading program can operate on it. (@code{makeinfo} and @code{texinfo-format-buffer} are two commands that convert a Texinfo file into an Info file.)@refill Info files are divided into pieces called @dfn{nodes}, each of which contains the discussion of one topic. Each node has a name, and contains both text for the user to read and pointers to other nodes, which are identified by their names. The Info program displays one node at a time, and provides commands with which the user can move to other related nodes.@refill @ifinfo @inforef{Top, info, info}, for more information about using Info.@refill @end ifinfo Each node of an Info file may have any number of child nodes that describe subtopics of the node's topic. The names of child nodes are listed in a @dfn{menu} within the parent node; this allows you to use certain Info commands to move to one of the child nodes. Generally, an Info file is organized like a book. If a node is at the logical level of a chapter, its child nodes are at the level of sections; likewise, the child nodes of sections are at the level of subsections.@refill All the children of any one parent are linked together in a bidirectional chain of `Next' and `Previous' pointers. This means that all the nodes that are at the level of sections within a chapter are linked together. Normally the order in this chain is the same as the order of the children in the parent's menu. Each child node records the parent node name as its `Up' pointer. The last child has no `Next' pointer, and the first child has the parent both as its `Previous' and as its `Up' pointer.@footnote{In some documents, the first child has no `Previous' pointer. Occasionally, the last child has the node name of the next following higher level node as its `Next' pointer.}@refill The book-like structuring of an Info file into nodes that correspond to chapters, sections, and the like is a matter of convention, not a requirement. The `Up', `Previous', and `Next' pointers of a node can point to any other nodes, and a menu can contain any other nodes. Thus, the node structure can be any directed graph. But it is usually more comprehensible to follow a structure that corresponds to the structure of chapters and sections in a printed book or report.@refill In addition to `Next', `Previous', and `Up' pointers and menus, Info provides pointers of another kind, called references, that can be sprinkled throughout the text. This is usually the best way to represent links that do not fit a hierarchical structure.@refill Usually, you will design a document so that its nodes match the structure of chapters and sections in the printed output. But there are times when this is not right for the material being discussed. Therefore, Texinfo uses separate commands to specify the node structure for the Info file and the section structure for the printed output.@refill Generally, you enter an Info file through a node that by convention is called @samp{Top}. This node normally contains just a brief summary of the file's purpose, and a large menu through which the rest of the file is reached. From this node, you can either traverse the file systematically by going from node to node, or you can go to a specific node listed in the main menu, or you can search the index menus and then go directly to the node that has the information you want.@refill @c !!! With the standalone Info system you may go to specific nodes directly.. If you want to read through an Info file in sequence, as if it were a printed manual, you can get the whole file with the advanced Info command @kbd{g* @key{RET}}. (@inforef{Expert, Advanced Info commands, info}.)@refill The @file{dir} file in the @file{@dots{}/emacs/info} directory serves as the departure point for the whole Info system. From it, you can reach the `Top' nodes of each of the documents in a complete Info system.@refill @node Printed Books, Formatting Commands, Info Files, Overview @comment node-name, next, previous, up @section Printed Books @cindex Printed book and manual characteristics @cindex Manual characteristics, printed @cindex Book characteristics, printed @cindex Texinfo printed book characteristics @cindex Characteristics, printed books or manuals A Texinfo file can be formatted and typeset as a printed book or manual. To do this, you need @TeX{}, a powerful, sophisticated typesetting program written by Donald Knuth.@footnote{You can also use the @code{texi2roff} program if you do not have @TeX{}; since Texinfo is designed for use with @TeX{}, @code{texi2roff} is not described here. @code{texi2roff} is part of the standard GNU distribution.}@refill A Texinfo-based book is similar to any other typeset, printed work: it can have a title page, copyright page, table of contents, and preface, as well as chapters, numbered or unnumbered sections and subsections, page headers, cross references, footnotes, and indices.@refill You can use Texinfo to write a book without ever having the intention of converting it into on-line information. You can use Texinfo for writing a printed novel, and even to write a printed memo, although this latter application is not recommended since electronic mail is so much easier.@refill @TeX{} is a general purpose typesetting program. Texinfo provides a file called @file{texinfo.tex} that contains information (definitions or @dfn{macros}) that @TeX{} uses when it typesets a Texinfo file. (@file{texinfo.tex} tells @TeX{} how to convert the Texinfo @@-commands to @TeX{} commands, which @TeX{} can then process to create the typeset document.) @file{texinfo.tex} contains the specifications for printing a document, either with 7 inch by 9.25 inch pages or with 8.5 inch by 11 inch pages. (This is 178 mm by 235 mm or else 216 mm by 280 mm.) By changing the parameters in @file{texinfo.tex}, you can change the size of the printed document. In addition, you can change the style in which the printed document is formatted; for example, you can change the sizes and fonts used, the amount of indentation for each paragraph, the degree to which words are hyphenated, and the like. By changing the specifications, you can make a book look dignified, old and serious, or light-hearted, young and cheery.@refill @TeX{} is freely distributable. It is written in a dialect of Pascal called WEB and can be compiled either in Pascal or (by using a conversion program that comes with the @TeX{} distribution) in C. (@xref{TeX Mode, ,@TeX{} Mode, emacs, The GNU Emacs Manual}, for information about @TeX{}.)@refill @TeX{} is very powerful and has a great many features. Because a Texinfo file must be able to present information both on a character-only terminal in Info form and in a typeset book, the formatting commands that Texinfo supports are necessarily limited.@refill @xref{Obtaining TeX, , How to Obtain @TeX{}}, for information on how to obtain @TeX{}. @node Formatting Commands, Conventions, Printed Books, Overview @comment node-name, next, previous, up @section @@-commands @cindex @@-commands @cindex Formatting commands In a Texinfo file, the commands that tell @TeX{} how to typeset the printed manual and tell @code{makeinfo} and @code{texinfo-format-buffer} how to create an Info file are preceded by @samp{@@}; they are called @dfn{@@-commands}. For example, @code{@@node} is the command to indicate a node and @code{@@chapter} is the command to indicate the start of a chapter.@refill @quotation @strong{Please note:} All the @@-commands, with the exception of the @code{@@TeX@{@}} command, must be written entirely in lower case.@refill @end quotation The Texinfo @@-commands are a strictly limited set of constructs. The strict limits make it possible for Texinfo files to be understood both by @TeX{} and by the code that converts them into Info files. You can display Info files on any terminal that displays alphabetic and numeric characters. Similarly, you can print the output generated by @TeX{} on a wide variety of printers.@refill Depending on what they do or what arguments@footnote{The word @dfn{argument} comes from the way it is used in mathematics and does not refer to a disputation between two people; it refers to the information presented to the command. According to the @cite{Oxford English Dictionary}, the word derives from the Latin for @dfn{to make clear, prove}; thus it came to mean `the evidence offered as proof', which is to say, `the information offered', which led to its mathematical meaning. In its other thread of derivation, the word came to mean `to assert in a manner against which others may make counter assertions', which led to the meaning of `argument' as a disputation.} they take, you need to write @@-commands on lines of their own or as part of sentences:@refill @itemize @bullet @item Write a command such as @code{@@noindent} at the beginning of a line as the only text on the line. (@code{@@noindent} prevents the beginning of the next line from being indented as the beginning of a paragraph.)@refill @item Write a command such as @code{@@chapter} at the beginning of a line followed by the command's arguments, in this case the chapter title, on the rest of the line. (@code{@@chapter} creates chapter titles.)@refill @item Write a command such as @code{@@dots@{@}} wherever you wish but usually within a sentence. (@code{@@dots@{@}} creates dots @dots{}.)@refill @item Write a command such as @code{@@code@{@var{sample-code}@}} wherever you wish (but usually within a sentence) with its argument, @var{sample-code} in this example, between the braces. (@code{@@code} marks text as being code.)@refill @item Write a command such as @code{@@example} at the beginning of a line of its own; write the body-text on following lines; and write the matching @code{@@end} command, @code{@@end example} in this case, at the beginning of a line of its own after the body-text. (@code{@@example} @dots{} @code{@@end example} indents and typesets body-text as an example.)@refill @end itemize @noindent @cindex Braces, when to use As a general rule, a command requires braces if it mingles among other text; but it does not need braces if it starts a line of its own. The non-alphabetic commands, such as @code{@@:}, are exceptions to the rule; they do not need braces.@refill As you gain experience with Texinfo, you will rapidly learn how to write the different commands: the different ways to write commands make it easier to write and read Texinfo files than if all commands followed exactly the same syntax. (For details about @@-command syntax, see @ref{Command Syntax, , @@-Command Syntax}.)@refill @node Conventions, Comments, Formatting Commands, Overview @comment node-name, next, previous, up @section General Syntactic Conventions @cindex General syntactic conventions @cindex Syntactic conventions @cindex Conventions, syntactic All @sc{ascii} printing characters except @samp{@@}, @samp{@{} and @samp{@}} can appear in a Texinfo file and stand for themselves. @samp{@@} is the escape character which introduces commands. @samp{@{} and @samp{@}} should be used only to surround arguments to certain commands. To put one of these special characters into the document, put an @samp{@@} character in front of it, like this: @samp{@@@@}, @samp{@@@{}, and @samp{@@@}}.@refill @ifinfo It is customary in @TeX{} to use doubled single-quote characters to begin and end quotations: ` ` and ' ' (but without a space between the two single-quote characters). This convention should be followed in Texinfo files. @TeX{} converts doubled single-quote characters to left- and right-hand doubled quotation marks and Info converts doubled single-quote characters to @sc{ascii} double-quotes: ` ` and ' ' to " .@refill @end ifinfo @iftex It is customary in @TeX{} to use doubled single-quote characters to begin and end quotations: @w{@tt{ `` }} and @w{@tt{ '' }}. This convention should be followed in Texinfo files. @TeX{} converts doubled single-quote characters to left- and right-hand doubled quotation marks, ``like this,'' and Info converts doubled single-quote characters to @sc{ascii} double-quotes: @w{@tt{ `` }} and @w{@tt{ '' }} to @w{@tt{ " }}.@refill @end iftex Use three hyphens in a row, @samp{---}, for a dash---like this. In @TeX{}, a single or even a double hyphen produces a printed dash that is shorter than the usual typeset dash. Info reduces three hyphens to two for display on the screen.@refill To prevent a paragraph from being indented in the printed manual, put the command @code{@@noindent} on a line by itself before the paragraph.@refill If you mark off a region of the Texinfo file with the @code{@@iftex} and @w{@code{@@end iftex}} commands, that region will appear only in the printed copy; in that region, you can use certain commands borrowed from Plain@TeX{} that you cannot use in Info. Likewise, if you mark off a region with the @code{@@ifinfo} and @code{@@end ifinfo} commands, that region will appear only in the Info file; in that region, you can use Info commands that you cannot use in @TeX{}. (@xref{Conditionals}.) @cindex Tabs; don't use! @quotation @strong{Caution:} Do not use tabs in a Texinfo file! @TeX{} has trouble with tabs: it treats them like single spaces, and that is not what they look like. This is a problem with @TeX{}.@refill To avoid putting tabs into your file, you can set the @code{indent-tabs-mode} variable in Emacs to @code{nil} so that Emacs inserts multiple spaces when you press the @key{TAB} key.@refill For example, you can include the following in your @file{.emacs} initialization file:@refill @example @group (setq texinfo-mode-hook '(lambda () (setq indent-tabs-mode nil))) @end group @end example @noindent Also, you can run @code{untabify} to convert tabs in a region to multiple spaces.@refill @end quotation @node Comments, Minimum, Conventions, Overview @comment node-name, next, previous, up @section Comments You can write comments in a Texinfo file that will not appear in either the Info file or the printed manual by using the @code{@@comment} command (which may be abbreviated to @code{@@c}). Such comments are for the person who reads the Texinfo file. All the text on a line that follows either @code{@@comment} or @code{@@c} is a comment; the rest of the line does not appear in either the Info file or the printed manual. (Often, you can write the @code{@@comment} or @code{@@c} in the middle of a line, and only the text that follows after the @code{@@comment} or @code{@@c} command does not appear; but some commands, such as @code{@@settitle} and @code{@@setfilename}, work on a whole line. You cannot use @code{@@comment} or @code{@@c} in a line beginning with such a command.)@refill @cindex Comments @findex comment @findex c @r{(comment)} You can write long stretches of text that will not appear in either the Info file or the printed manual by using the @code{@@ignore} and @code{@@end ignore} commands. Write each of these commands on a line of its own, starting each command at the beginning of the line. Text between these two commands does not appear in the processed output. You can use @code{@@ignore} and @code{@@end ignore} for writing comments. Often, @code{@@ignore} and @code{@@end ignore} is used to enclose a part of the copying permissions that applies to the Texinfo source file of a document, but not to the Info or printed version of the document.@refill @cindex Ignored text @cindex Unprocessed text @findex ignore @node Minimum, Six Parts, Comments, Overview @comment node-name, next, previous, up @section What a Texinfo File Must Have @cindex Minimal Texinfo file (requirements) @cindex Must have in Texinfo file @cindex Required in Texinfo file @cindex Texinfo file minimum By convention, the names of Texinfo files end with either of the three extensions @file{.texinfo}, @file{.texi}, or @file{.tex}. The longer extension is preferred since it describes more clearly to a human reader the nature of the file. The shorter extensions are for operating systems that cannot handle long file names.@refill In order to be made into a printed manual and an Info file, a Texinfo file @strong{must} begin with lines like this:@refill @example @group \input texinfo @@setfilename @var{info-file-name} @@settitle @var{name-of-manual} @end group @end example @noindent The contents of the file follow this beginning, and then you must end a Texinfo file with a line like this:@refill @example @@bye @end example @noindent The @samp{\input texinfo} line tells @TeX{} to use the @file{texinfo.tex} file, which tells @TeX{} how to translate the Texinfo @@-commands into @TeX{} typesetting commands. (Note the use of the backslash, @samp{\}; this is correct for @TeX{}.) The @samp{@@setfilename} line provides a name for the Info file and the @samp{@@settitle} line specifies a title for the page headers (or footers) of the printed manual.@refill The @code{@@bye} line at the end of the file on a line of its own tells the formatters that the file is ended and to stop formatting.@refill Usually, you will not use quite such a spare format, but will include mode setting and start-of-header and end-of-header lines at the beginning of a Texinfo file, like this:@refill @example \input texinfo @@c -*-texinfo-*- @@c %**start of header @@setfilename @var{info-file-name} @@settitle @var{name-of-manual} @@c %**end of header @end example @noindent In the first line, @samp{-*-texinfo-*-} causes Emacs to switch into Texinfo mode when you edit the file. The @code{@@c} lines which surround the @code{@@setfilename} and @code{@@settitle} lines are optional, but you need them in order to run @TeX{} or Info on just part of the file. (@xref{Start of Header}, for more information.)@refill Furthermore, you will usually provide a Texinfo file with a title page, indices, and the like. But the minimum, which can be useful for short documents, is just the three lines at the beginning and the one line at the end.@refill @node Six Parts, Short Sample, Minimum, Overview @comment node-name, next, previous, up @section Six Parts of a Texinfo File Generally, a Texinfo file contains more than the minimal beginning and end---it usually contains six parts:@refill @table @r @item 1. Header The @dfn{Header} names the file, tells @TeX{} which definitions' file to use, and performs other ``housekeeping'' tasks.@refill @item 2. Summary Description and Copyright The @dfn{Summary Description and Copyright} segment describes the document and contains the copyright notice and copying permissions for the Info file. The segment must be enclosed between @code{@@ifinfo} and @code{@@end ifinfo} commands so that the formatters place it only in the Info file.@refill @item 3. Title and Copyright The @dfn{Title and Copyright} segment contains the title and copyright pages and copying permissions for the printed manual. The segment must be enclosed between @code{@@titlepage} and @code{@@end titlepage} commands. The title and copyright page appear only in the printed @w{manual}.@refill @item 4. `Top' Node and Master Menu The @dfn{Master Menu} contains a complete menu of all the nodes in the whole Info file. It appears only in the Info file, in the `Top' node.@refill @item 5. Body The @dfn{Body} of the document may be structured like a traditional book or encyclopedia or it may be free form.@refill @item 6. End The @dfn{End} contains commands for printing indices and generating the table of contents, and the @code{@@bye} command on a line of its own.@refill @end table @node Short Sample, , Six Parts, Overview @comment node-name, next, previous, up @section A Short Sample Texinfo File @cindex Sample Texinfo file Here is a complete but very short Texinfo file, in 6 parts. The first three parts of the file, from @samp{\input texinfo} through to @samp{@@end titlepage}, look more intimidating than they are. Most of the material is standard boilerplate; when you write a manual, simply insert the names for your own manual in this segment. (@xref{Beginning a File}.)@refill @noindent In the following, the sample text is @emph{indented}; comments on it are not. The complete file, without any comments, is shown in an appendix. @xref{Sample Texinfo File}. @subheading Part 1: Header @noindent The header does not appear in either the Info file or the@* printed output. It sets various parameters, including the@* name of the Info file and the title used in the header. @example @group \input texinfo @@c -*-texinfo-*- @@c %**start of header @@setfilename sample.info @@settitle Sample Document @@c %**end of header @@setchapternewpage odd @end group @end example @subheading Part 2: Summary Description and Copyright @noindent The summary description and copyright segment does not@* appear in the printed document. @example @group @@ifinfo This is a short example of a complete Texinfo file. Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. @@end ifinfo @end group @end example @subheading Part 3: Titlepage and Copyright @noindent The titlepage segment does not appear in the Info file. @example @@titlepage @@sp 10 @@comment The title is printed in a large font. @@center @@titlefont@{Sample Title@} @@c The following two commands start the copyright page. @@page @@vskip 0pt plus 1filll Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. @@end titlepage @end example @subheading Part 4: `Top' Node and Master Menu @noindent The `Top' node contains the master menu for the Info file.@* Since a printed manual uses a table of contents rather than@* a menu, the master menu appears only in the Info file. @example @group @@node Top, First Chapter, (dir), (dir) @@comment node-name, next, previous, up @end group @end example @example @group @@menu * First Chapter:: The first chapter is the only chapter in this sample. * Concept Index:: This index has two entries. @@end menu @end group @end example @subheading Part 5: The Body of the Document @noindent The body segment contains all the text of the document, but not the indices or table of contents. This example illustrates a node and a chapter containing an enumerated list.@refill @example @group @@node First Chapter, Concept Index, Top, Top @@comment node-name, next, previous, up @@chapter First Chapter @@cindex Sample index entry @end group @group This is the contents of the first chapter. @@cindex Another sample index entry @end group @group Here is a numbered list. @@enumerate @@item This is the first item. @@item This is the second item. @@end enumerate @end group @group The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} commands transform a Texinfo file such as this into an Info file; and @@TeX@{@} typesets it for a printed manual. @end group @end example @subheading Part 6: The End of the Document @noindent The end segment contains commands both for generating an index in a node and unnumbered chapter of its own and for generating the table of contents; and it contains the @code{@@bye} command that marks the end of the document.@refill @example @group @@node Concept Index, , First Chapter, Top @@comment node-name, next, previous, up @@unnumbered Concept Index @end group @group @@printindex cp @@contents @@bye @end group @end example @subheading The Results Here is what the contents of the first chapter of the sample look like: @sp 1 @need 700 @quotation This is the contents of the first chapter. Here is a numbered list. @enumerate @item This is the first item. @item This is the second item. @end enumerate The @code{makeinfo} and @code{texinfo-format-buffer} commands transform a Texinfo file such as this into an Info file; and @TeX{} typesets it for a printed manual. @end quotation @node Texinfo Mode, Beginning a File, Overview, Top @comment node-name, next, previous, up @chapter Using Texinfo Mode @cindex Texinfo mode @cindex Mode, using Texinfo @cindex GNU Emacs @cindex Emacs You may edit a Texinfo file with any text editor you choose. A Texinfo file is no different from any other @sc{ascii} file. However, GNU Emacs comes with a special mode, called Texinfo mode, that provides Emacs commands and tools to help ease your work.@refill This chapter describes features of GNU Emacs' Texinfo mode but not any features of the Texinfo formatting language. If you are reading this manual straight through from the beginning, you may want to skim through this chapter briefly and come back to it after reading succeeding chapters which describe the Texinfo formatting language in detail.@refill @menu * Texinfo Mode Overview:: How Texinfo mode can help you. * Emacs Editing:: Texinfo mode adds to GNU Emacs' general purpose editing features. * Inserting:: How to insert frequently used @@-commands. * Showing the Structure:: How to show the structure of a file. * Updating Nodes and Menus:: How to update or create new nodes and menus. * Info Formatting:: How to format for Info. * Printing:: How to format and print part or all of a file. * Texinfo Mode Summary:: Summary of all the Texinfo mode commands. @end menu @node Texinfo Mode Overview, Emacs Editing, , Texinfo Mode @ifinfo @heading Texinfo Mode Overview @end ifinfo Texinfo mode provides special features for working with Texinfo files:@refill @itemize @bullet @item Insert frequently used @@commands. @refill @item Automatically create @code{@@node} lines. @item Show the structure of a Texinfo source file.@refill @item Automatically create or update the `Next',@* `Previous', and `Up' pointers of a node. @item Automatically create or update menus.@refill @item Automatically create a master menu.@refill @item Format a part or all of a file for Info.@refill @item Typeset and print part or all of a file.@refill @end itemize Perhaps the two most helpful features are those for inserting frequently used @@-commands and for creating node pointers and menus.@refill @node Emacs Editing, Inserting, Texinfo Mode Overview, Texinfo Mode @section The Usual GNU Emacs Editing Commands In most cases, the usual Text mode commands work the same in Texinfo mode as they do in Text mode. Texinfo mode adds new editing commands and tools to GNU Emacs' general purpose editing features. The major difference concerns filling. In Texinfo mode, the paragraph separation variable and syntax table are redefined so that Texinfo commands that should be on lines of their own are not inadvertently included in paragraphs. Thus, the @kbd{M-q} (@code{fill-paragraph}) command will refill a paragraph but not mix an indexing command on a line adjacent to it into the paragraph.@refill In addition, Texinfo mode sets the @code{page-delimiter} variable to the value of @code{texinfo-chapter-level-regexp}; by default, this is a regular expression matching the commands for chapters and their equivalents, such as appendices. With this value for the page delimiter, you can jump from chapter title to chapter title with the @kbd{C-x ]} (@code{forward-page}) and @kbd{C-x [} (@code{backward-page}) commands and narrow to a chapter with the @kbd{C-x p} (@code{narrow-to-page}) command. (@xref{Pages, , ,emacs, The GNU Emacs Manual}, for details about the page commands.)@refill You may name a Texinfo file however you wish, but the convention is to end a Texinfo file name with one of the three extensions @file{.texinfo}, @file{.texi}, or @file{.tex}. A longer extension is preferred, since it is explicit, but a shorter extension may be necessary for operating systems that limit the length of file names. GNU Emacs automatically enters Texinfo mode when you visit a file with a @file{.texinfo} or @file{.texi} extension. Also, Emacs switches to Texinfo mode when you visit a file that has @samp{-*-texinfo-*-} in its first line. If ever you are in another mode and wish to switch to Texinfo mode, type @code{M-x texinfo-mode}.@refill Like all other Emacs features, you can customize or enhance Texinfo mode as you wish. In particular, the keybindings are very easy to change. The keybindings described here are the default or standard ones.@refill @node Inserting, Showing the Structure, Emacs Editing, Texinfo Mode @comment node-name, next, previous, up @section Inserting Frequently Used Commands @cindex Inserting frequently used commands @cindex Frequently used commands, inserting @cindex Commands, inserting them Texinfo mode provides commands to insert various frequently used @@-commands into the buffer. You can use these commands to save keystrokes.@refill The insert commands are invoked by typing @kbd{C-c} twice and then the first letter of the @@-command:@refill @table @kbd @item C-c C-c c @itemx M-x texinfo-insert-@@code @findex texinfo-insert-@@code Insert @code{@@code@{@}} and put the cursor between the braces.@refill @item C-c C-c d @itemx M-x texinfo-insert-@@dfn @findex texinfo-insert-@@dfn Insert @code{@@dfn@{@}} and put the cursor between the braces.@refill @item C-c C-c e @itemx M-x texinfo-insert-@@end @findex texinfo-insert-@@end Insert @code{@@end} and attempt to insert the correct following word, such as @samp{example} or @samp{table}. (This command does not handle nested lists correctly, but inserts the word appropriate to the immediately preceding list.)@refill @item C-c C-c i @itemx M-x texinfo-insert-@@item @findex texinfo-insert-@@item Insert @code{@@item} and put the cursor at the beginning of the next line.@refill @item C-c C-c k @itemx M-x texinfo-insert-@@kbd @findex texinfo-insert-@@kbd Insert @code{@@kbd@{@}} and put the cursor between the braces.@refill @item C-c C-c n @itemx M-x texinfo-insert-@@node @findex texinfo-insert-@@node Insert @code{@@node} and a comment line listing the sequence for the `Next', `Previous', and `Up' nodes. Leave point after the @code{@@node}.@refill @item C-c C-c o @itemx M-x texinfo-insert-@@noindent @findex texinfo-insert-@@noindent Insert @code{@@noindent} and put the cursor at the beginning of the next line.@refill @item C-c C-c s @itemx M-x texinfo-insert-@@samp @findex texinfo-insert-@@samp Insert @code{@@samp@{@}} and put the cursor between the braces.@refill @item C-c C-c t @itemx M-x texinfo-insert-@@table @findex texinfo-insert-@@table Insert @code{@@table} followed by a @key{SPC} and leave the cursor after the @key{SPC}.@refill @item C-c C-c v @itemx M-x texinfo-insert-@@var @findex texinfo-insert-@@var Insert @code{@@var@{@}} and put the cursor between the braces.@refill @item C-c C-c x @itemx M-x texinfo-insert-@@example @findex texinfo-insert-@@example Insert @code{@@example} and put the cursor at the beginning of the next line.@refill @c M-@{ was the binding for texinfo-insert-braces; @c in Emacs 19, backward-paragraph will take this binding. @item C-c C-c @{ @itemx M-x texinfo-insert-braces @findex texinfo-insert-braces Insert @code{@{@}} and put the cursor between the braces.@refill @item C-c C-c @} @itemx C-c C-c ] @itemx M-x up-list @findex up-list Move from between a pair of braces forward past the closing brace. Typing @kbd{C-c C-c ]} is easier than typing @kbd{C-c C-c @}}, which is, however, more mnemonic; hence the two keybindings. (Also, you can move out from between braces by typing @kbd{C-f}.)@refill @end table To put a command such as @w{@code{@@code@{@dots{}@}}} around an @emph{existing} word, position the cursor in front of the word and type @kbd{C-u 1 C-c C-c c}. This makes it easy to edit existing plain text. The value of the prefix argument tells Emacs how many words following point to include between braces---1 for one word, 2 for two words, and so on. Use a negative argument to enclose the previous word or words. If you do not specify a prefix argument, Emacs inserts the @@-command string and positions the cursor between the braces. This feature works only for those @@-commands that operates on a word or words within one line, such as @code{@@kbd} and @code{@@var}.@refill This set of insert commands was created after analyzing the frequency with which different @@-commands are used in the @cite{GNU Emacs Manual} and the @cite{GDB Manual}. If you wish to add your own insert commands, you can bind a keyboard macro to a key, use abbreviations, or extend the code in @file{texinfo.el}.@refill @node Showing the Structure, Updating Nodes and Menus, Inserting, Texinfo Mode @comment node-name, next, previous, up @section Showing the Section Structure of a File @cindex Showing the section structure of a file @cindex Section structure of a file, showing it @cindex Structure of a file, showing it @cindex Outline of file structure, showing it @cindex Contents-like outline of file structure @cindex File section structure, showing it @cindex Texinfo file section structure, showing it You can show the section structure of a Texinfo file by using the @kbd{C-c C-s} command (@code{texinfo-show-structure}). This command shows the section structure of a Texinfo file by listing the lines that begin with the @@-commands for @code{@@chapter}, @code{@@section}, and the like. The command constructs what amounts to a table of contents. These lines are displayed in another buffer called the @samp{*Occur*} buffer. In that buffer, you can position the cursor over one of the lines and use the @kbd{C-c C-c} command (@code{occur-mode-goto-occurrence}), to jump to the corresponding spot in the Texinfo file.@refill @table @kbd @item C-c C-s @itemx M-x texinfo-show-structure @findex texinfo-show-structure Show the @code{@@chapter}, @code{@@section}, and such lines of a Texinfo file.@refill @item C-c C-c @itemx M-x occur-mode-goto-occurrence @findex occur-mode-goto-occurrence Go to the line in the Texinfo file corresponding to the line under the cursor in the @file{*Occur*} buffer.@refill @end table If you call @code{texinfo-show-structure} with a prefix argument by typing @w{@kbd{C-u C-c C-s}}, it will list not only those lines with the @@-commands for @code{@@chapter}, @code{@@section}, and the like, but also the @code{@@node} lines. (This is how the @code{texinfo-show-structure} command worked without an argument in the first version of Texinfo. It was changed because @code{@@node} lines clutter up the @samp{*Occur*} buffer and are usually not needed.) You can use @code{texinfo-show-structure} with a prefix argument to check whether the `Next', `Previous', and `Up' pointers of an @code{@@node} line are correct.@refill Often, when you are working on a manual, you will be interested only in the structure of the current chapter. In this case, you can mark off the region of the buffer that you are interested in with the @kbd{C-x n} (@code{narrow-to-region}) command and @code{texinfo-show-structure} will work on only that region. To see the whole buffer again, use @w{@kbd{C-x w}} (@code{widen}). (@xref{Narrowing, , , emacs, The GNU Emacs Manual}, for more information about the narrowing commands.)@refill @vindex page-delimiter @cindex Page delimiter in Texinfo mode In addition to providing the @code{texinfo-show-structure} command, Texinfo mode sets the value of the page delimiter variable to match the chapter-level @@-commands. This enables you to use the @kbd{C-x ]} (@code{forward-page}) and @kbd{C-x [} (@code{backward-page}) commands to move forward and backward by chapter, and to use the @kbd{C-x p} (@code{narrow-to-page}) command to narrow to a chapter. @xref{Pages, , , emacs, The GNU Emacs Manual}, for more information about the page commands.@refill @node Updating Nodes and Menus, Info Formatting, Showing the Structure, Texinfo Mode @comment node-name, next, previous, up @section Updating Nodes and Menus @cindex Updating nodes and menus @cindex Create nodes, menus automatically @cindex Insert nodes, menus automatically @cindex Automatically insert nodes, menus Texinfo mode provides commands for automatically creating or updating menus and node pointers. The commands are called ``update'' commands because their most frequent use is for updating a Texinfo file after you have worked on it; but you can use them to insert the `Next', `Previous', and `Up' pointers into an @code{@@node} line that has none and to create menus in a file that has none.@refill If you do not use the updating commands, you need to write menus and node pointers by hand, which is a tedious task.@refill @menu * Updating Commands:: Five major updating commands. * Updating Requirements:: How to structure a Texinfo file for using the updating command. * Other Updating Commands:: How to indent descriptions, insert missing nodes lines, and update nodes in sequence. @end menu @node Updating Commands, Updating Requirements, , Updating Nodes and Menus @ifinfo @subheading The Updating Commands @end ifinfo You can use the updating commands@refill @itemize @bullet @item to insert or update the `Next', `Previous', and `Up' pointers of a node,@refill @item to insert or update the menu for a section, and@refill @item to create a master menu for a Texinfo source file.@refill @end itemize You can also use the commands to update all the nodes and menus in a region or in a whole Texinfo file.@refill The updating commands work only with conventional Texinfo files, which are structured hierarchically like books. In such files, a structuring command line must follow closely after each @code{@@node} line, except for the `Top' @code{@@node} line. (A @dfn{structuring command line} is a line beginning with @code{@@chapter}, @code{@@section}, or other similar command.) You can write the structuring command line on the line that follows immediately after an @code{@@node} line or else on the line that follows after a single @code{@@comment} line or a single @code{@@ifinfo} line. You cannot interpose more than one line between the @code{@@node} line and the structuring command line; and you may interpose only an @code{@@comment} line or an @code{@@ifinfo} line. Commands which work on a whole buffer require that the `Top' node be followed by a node with an @code{@@chapter} or equivalent-level command. Note that the menu updating commands will not create a main or master menu for a Texinfo file that has only @code{@@chapter}-level nodes! The menu updating commands only create menus @emph{within} nodes for lower level nodes. To create a menu of chapters, you must provide a `Top' node.@refill The menu updating commands remove menu entries that refer to other Info files since they do not refer to nodes within the current buffer. This is a deficiency. Rather than use menu entries, you can use cross references to refer to other Info files. None of the updating commands affect cross references.@refill Texinfo mode has five updating commands that are used most often: two are for updating the node pointers or menu of a single node (or a region); two are for updating every node pointer and menu in a file; and one, the @code{texinfo-master-menu} command, is for creating a master menu for a complete file, and optionally, for updating every node and menu in the whole Texinfo file.@refill The @code{texinfo-master-menu} command is the primary command:@refill @table @kbd @item C-c C-u m @itemx M-x texinfo-master-menu @findex texinfo-master-menu Create or update a master menu that includes all the other menus (incorporating the descriptions from pre-existing menus, if any).@refill With an argument (prefix argument, @kbd{C-u,} if interactive), first create or update all the nodes and all the regular menus in the buffer before constructing the master menu. (@xref{The Top Node, , The Top Node and Master Menu}, for more about a master menu.)@refill For @code{texinfo-master-menu} to work, the Texinfo file must have a `Top' node and at least one subsequent node.@refill After extensively editing a Texinfo file, you can type the following: @example C-u M-x texinfo-master-menu @exdent or C-u C-c C-u m @end example @noindent This updates all the nodes and menus completely and all at once.@refill @end table The other major updating commands do smaller jobs and are designed for the person who updates nodes and menus as he or she writes a Texinfo file.@refill @need 1000 The commands are:@refill @table @kbd @item C-c C-u C-n @itemx M-x texinfo-update-node @findex texinfo-update-node Insert the `Next', `Previous', and `Up' pointers for the node that point is within (i.e., for the @code{@@node} line preceding point). If the @code{@@node} line has pre-existing `Next', `Previous', or `Up' pointers in it, the old pointers are removed and new ones inserted. With an argument (prefix argument, @kbd{C-u}, if interactive), this command updates all @code{@@node} lines in the region (which is the text between point and mark).@refill @item C-c C-u C-m @itemx M-x texinfo-make-menu @findex texinfo-make-menu Create or update the menu in the node that point is within. With an argument (@kbd{C-u} as prefix argument, if interactive), the command makes or updates menus for the nodes which are either within or a part of the region.@refill @c !!! texinfo-make-menu should offer user a buffer with descriptions @c !!! in it so the user can edit them. Whenever @code{texinfo-make-menu} updates an existing menu, the descriptions from that menu are incorporated into the new menu. This is done by copying descriptions from the existing menu to the entries in the new menu that have the same node names. If the node names are different, the descriptions are not copied to the new menu.@refill @item C-c C-u C-e @itemx M-x texinfo-every-node-update @findex texinfo-every-node-update Insert or update the `Next', `Previous', and `Up' pointers for every node in the buffer.@refill @item C-c C-u C-a @itemx M-x texinfo-all-menus-update @findex texinfo-all-menus-update Create or update all the menus in the buffer. With an argument (@kbd{C-u} as prefix argument, if interactive), first insert or update all the node pointers before working on the menus.@refill If a master menu exists, the @code{texinfo-all-menus-update} command updates it; but the command does not create a new master menu if none already exists. (Use the @code{texinfo-master-menu} command for that.)@refill When working on a document that does not merit a master menu, you can type the following: @example C-u C-c C-u C-a @exdent or C-u M-x texinfo-all-menus-update @end example @noindent This updates all the nodes and menus.@refill @end table The @code{texinfo-column-for-description} variable specifies the column to which menu descriptions are indented. By default, the value is 32 although it is often useful to reduce it to as low as 24. You can set the variable with the @kbd{M-x edit-options} command (@pxref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual}) or with the @kbd{M-x set-variable} command (@pxref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual}).@refill Also, the @code{texinfo-indent-menu-description} command may be used to indent existing menu descriptions to a specified column. Finally, if you wish, you can use the @code{texinfo-insert-node-lines} command to insert missing @code{@@node} lines into a file. (@xref{Other Updating Commands}, for more information.)@refill @node Updating Requirements, Other Updating Commands, Updating Commands, Updating Nodes and Menus @comment node-name, next, previous, up @subsection Updating Requirements @cindex Updating requirements @cindex Requirements for updating commands To use the updating commands, you must organize the Texinfo file hierarchically with chapters, sections, subsections, and the like. When you construct the hierarchy of the manual, do not `jump down' more than one level at a time: you can follow the `Top' node with a chapter, but not with a section; you can follow a chapter with a section, but not with a subsection. However, you may `jump up' any number of levels at one time---for example, from a subsection to a chapter.@refill Each @code{@@node} line, with the exception of the line for the `Top' node, must be followed by a line with a structuring command such as @code{@@chapter}, @code{@@section}, or @code{@@unnumberedsubsec}.@refill Each @code{@@node} line/structuring-command line combination must look either like this:@refill @example @group @@node Comments, Minimum, Conventions, Overview @@comment node-name, next, previous, up @@section Comments @end group @end example or like this (without the @code{@@comment} line): @example @group @@node Comments, Minimum, Conventions, Overview @@section Comments @end group @end example @noindent In this example, `Comments' is the name of both the node and the section. The next node is called `Minimum' and the previous node is called `Conventions'. The `Comments' section is within the `Overview' node, which is specified by the `Up' pointer. (Instead of an @code{@@comment} line, you can write an @code{@@ifinfo} line.)@refill If a file has a `Top' node, it must be called @samp{top} or @samp{Top} and be the first node in the file.@refill The menu updating commands create a menu of sections within a chapter, a menu of subsections within a section, and so on. This means that you must have a `Top' node if you want a menu of chapters.@refill Incidentally, the @code{makeinfo} command will create an Info file for a hierarchically organized Texinfo file that lacks `Next', `Previous' and `Up' pointers. Thus, if you can be sure that your Texinfo file will be formatted with @code{makeinfo}, you have no need for the `update node' commands. (@xref{Create an Info File, , Creating an Info File}, for more information about @code{makeinfo}.) However, both @code{makeinfo} and the @code{texinfo-format-@dots{}} commands require that you insert menus in the file.@refill @node Other Updating Commands, , Updating Requirements, Updating Nodes and Menus @comment node-name, next, previous, up @subsection Other Updating Commands In addition to the five major updating commands, Texinfo mode possesses several less frequently used updating commands:@refill @table @kbd @item M-x texinfo-insert-node-lines @findex texinfo-insert-node-lines Insert @code{@@node} lines before the @code{@@chapter}, @code{@@section}, and other sectioning commands wherever they are missing throughout a region in a Texinfo file.@refill With an argument (@kbd{C-u} as prefix argument, if interactive), the @code{texinfo-insert-node-lines} command not only inserts @code{@@node} lines but also inserts the chapter or section titles as the names of the corresponding nodes. In addition, it inserts the titles as node names in pre-existing @code{@@node} lines that lack names. Since node names should be more concise than section or chapter titles, you must manually edit node names so inserted.@refill For example, the following marks a whole buffer as a region and inserts @code{@@node} lines and titles throughout:@refill @example C-x h C-u M-x texinfo-insert-node-lines @end example @item M-x texinfo-multiple-files-update @findex texinfo-multiple-files-update Update nodes and menus in a document built from several separate files. With @kbd{C-u} as a prefix argument, create and insert a master menu in the outer file. With @kbd{C-u 2} as a numeric prefix argument, first update all the menus and all the `Next', `Previous', and `Up' pointers of all the included files before creating and inserting a master menu in the outer file. The @code{texinfo-multiple-files-update} command is described in the appendix on @code{@@include} files. @xref{texinfo-multiple-files-update, , @code{texinfo-multiple-files-update}}.@refill @item M-x texinfo-indent-menu-description @findex texinfo-indent-menu-description Indent every description in the menu following point to the specified column. You can use this command to give yourself more space for descriptions. With an argument (@kbd{C-u} as prefix argument, if interactive), the @code{texinfo-indent-menu-description} command indents every description in every menu in the region. However, this command does not indent the second and subsequent lines of a multi-line description.@refill @item M-x texinfo-sequential-node-update @findex texinfo-sequential-node-update Insert the names of the nodes immediately following and preceding the current node as the `Next' or `Previous' pointers regardless of those nodes' hierarchical level. This means that the `Next' node of a subsection may well be the next chapter. Sequentially ordered nodes are useful for novels and other documents that you read through sequentially. (However, in Info, the @code{g* @key{RET}} command lets you look through the file sequentially, so sequentially ordered nodes are not strictly necessary.) With an argument (prefix argument, if interactive), the @code{texinfo-sequential-node-update} command sequentially updates all the nodes in the region.@refill @end table @node Info Formatting, Printing, Updating Nodes and Menus, Texinfo Mode @comment node-name, next, previous, up @section Formatting for Info @cindex Formatting for Info @cindex Running an Info formatter @cindex Info formatting Texinfo mode provides several commands for formatting part or all of a Texinfo file for Info. Often, when you are writing a document, you want to format only part of a file---that is, a region.@refill You can use either the @code{texinfo-format-region} or the @code{makeinfo-region} command to format a region:@refill @table @kbd @findex texinfo-format-region @item C-c C-e C-r @itemx M-x texinfo-format-region @itemx C-c C-m C-r @itemx M-x makeinfo-region Format the current region for Info.@refill @end table You can use either the @code{texinfo-format-buffer} or the @code{makeinfo-buffer} command to format a whole buffer:@refill @table @kbd @findex texinfo-format-buffer @item C-c C-e C-b @itemx M-x texinfo-format-buffer @itemx C-c C-m C-b @itemx M-x makeinfo-buffer Format the current buffer for Info.@refill @end table @quotation For example, after writing a Texinfo file, you can type the following: @example C-u C-c C-u m @exdent or C-u M-x texinfo-master-menu @end example @noindent This updates all the nodes and menus. Then type the following to create an Info file: @example C-c C-m C-b @exdent or M-x makeinfo-buffer @end example @end quotation For the Info formatting commands to work, the file @emph{must} include a line that has @code{@@setfilename} in its header.@refill Not all systems support the @code{makeinfo}-based formatting commands.@refill @xref{Create an Info File}, for details about Info formatting.@refill @node Printing, Texinfo Mode Summary, Info Formatting, Texinfo Mode @comment node-name, next, previous, up @section Formatting and Printing @cindex Formatting for printing @cindex Printing a region or buffer @cindex Region formatting and printing @cindex Buffer formatting and printing @cindex Part of file formatting and printing Typesetting and printing a Texinfo file is a multi-step process in which you first create a file for printing (called a @sc{dvi} file), and then print the file. Optionally, you may also create indices. To do this, you must run the @code{texindex} command after first running the @code{tex} command; and then you must run the @code{tex} command again. @refill Often, when you are writing a document, you want to typeset and print only part of a file to see what it will look like. You can use the @code{texinfo-tex-region} and related commands for this purpose. Use the @code{texinfo-tex-buffer} command to format all of a buffer.@refill @table @kbd @item C-c C-t C-r @itemx M-x texinfo-tex-region @findex texinfo-tex-region Run @TeX{} on the region.@refill @item C-c C-t C-b @itemx M-x texinfo-tex-buffer @findex texinfo-tex-buffer Run @TeX{} on the buffer.@refill @item C-c C-t C-i @itemx M-x texinfo-texindex Run @code{texindex} to sort the indices of a Texinfo file formatted with @code{texinfo-tex-region} or @code{texinfo-tex-buffer}. You must run the @code{tex} command a second time after sorting the raw index files.@refill @item C-c C-t C-p @itemx M-x texinfo-tex-print @findex texinfo-tex-print Print the file (or the part of the file) previously formatted with @code{texinfo-tex-buffer} or @code{texinfo-tex-region}.@refill @end table @noindent For @code{texinfo-tex-region} or @code{texinfo-tex-buffer} to work, the file @emph{must} start with a @samp{\input texinfo} line and must include an @code{@@settitle} line. The file must end with @code{@@bye} on a line by itself. (When you use @code{texinfo-tex-region}, you must surround the @code{@@settitle} line with start-of-header and end-of-header lines.)@refill @xref{Format/Print Hardcopy}, for a description of the other @TeX{} related commands, such as @code{tex-show-print-queue}.@refill @node Texinfo Mode Summary, , Printing, Texinfo Mode @comment node-name, next, previous, up @section Texinfo Mode Summary In Texinfo mode, each set of commands has default keybindings that begin with the same keys. All the commands that are custom-created for Texinfo mode begin with @kbd{C-c}. The keys that follow are arranged mnemonically.@refill @subheading Insert Commands The insert commands are invoked by typing @kbd{C-c} twice and then the first letter of the @@-command to be inserted. (It might make more sense mnemonically to use @kbd{C-c C-i}, for `custom insert', but @kbd{C-c C-c} is quick to type.)@refill @example C-c C-c c @r{Insert} @samp{@@code}. C-c C-c d @r{Insert} @samp{@@dfn}. C-c C-c e @r{Insert} @samp{@@end}. C-c C-c i @r{Insert} @samp{@@item}. C-c C-c n @r{Insert} @samp{@@node}. C-c C-c s @r{Insert} @samp{@@samp}. C-c C-c v @r{Insert} @samp{@@var}. C-c C-c @{ @r{Insert braces.} C-c C-c ] C-c C-c @} @r{Move out of enclosing braces.} @end example @subheading Show Structure The @code{texinfo-show-structure} command is often used within a narrowed region.@refill @example C-c C-s @r{List all the headings.} @end example @subheading The Master Update Command The @code{texinfo-master-menu} command creates a master menu; and can be used to update every node and menu in a file as well.@refill @example @group C-c C-u m M-x texinfo-master-menu @r{Create or update a master menu.} @end group @group C-u C-c C-u m @r{With @kbd{C-u} as a prefix argument, first} @r{create or update all nodes and regular} @r{menus, and then create a master menu.} @end group @end example @subheading Update Pointers The update pointer commands are invoked by typing @kbd{C-c C-u} and then either @kbd{C-n} for @code{texinfo-update-node} or @kbd{C-e} for @code{texinfo-every-node-update}.@refill @example C-c C-u C-n @r{Update a node.} C-c C-u C-e @r{Update every node in the buffer.} @end example @subheading Update Menus Invoke the update menu commands by typing @kbd{C-c C-u} and then either @kbd{C-m} for @code{texinfo-make-menu} or @kbd{C-a} for @code{texinfo-all-menus-update}. To update both nodes and menus at the same time, precede @kbd{C-c C-u C-a} with @kbd{C-u}.@refill @example C-c C-u C-m @r{Make or update a menu.} @group C-c C-u C-a @r{Make or update all} @r{menus in a buffer.} @end group @group C-u C-c C-u C-a @r{With @kbd{C-u} as a prefix argument,} @r{first create or update all nodes and} @r{then create or update all menus.} @end group @end example @subheading Format for Info The Info formatting commands that are written in Emacs Lisp are invoked by typing @kbd{C-c C-e} and then either @kbd{C-r} for a region or @kbd{C-b} for the whole buffer.@refill The Info formatting commands that are written in C and based on the @code{makeinfo} program are invoked by typing @kbd{C-c C-m} and then either @kbd{C-r} for a region or @kbd{C-b} for the whole buffer.@refill @example @group @noindent @exdent @r{Use the @code{texinfo-format@dots{}} commands:} C-c C-e C-r @r{Format the region.} C-c C-e C-b @r{Format the buffer.} @end group @end example @noindent Use @code{makeinfo}: @example C-c C-m C-r @r{Format the region.} C-c C-m C-b @r{Format the buffer.} C-c C-m C-l @r{Recenter the @code{makeinfo} output buffer.} C-c C-m C-k @r{Kill the @code{makeinfo} formatting job.} @end example @subheading Typeset and Print The @TeX{} typesetting and printing commands are invoked by typing @kbd{C-c C-t} and then another control command: @kbd{C-r} for @code{texinfo-tex-region}, @kbd{C-b} for @code{texinfo-tex-buffer}, and so on.@refill @example C-c C-t C-r @r{Run @TeX{} on the region.} C-c C-t C-b @r{Run @TeX{} on the buffer.} C-c C-t C-i @r{Run} @code{texindex}. C-c C-t C-p @r{Print the @sc{dvi} file.} C-c C-t C-q @r{Show the print queue.} C-c C-t C-d @r{Delete a job from the print queue.} C-c C-t C-k @r{Kill the current @TeX{} formatting job.} C-c C-t C-x @r{Quit a currently stopped @TeX{} formatting job.} C-c C-t C-l @r{Recenter the output buffer.} @end example @subheading Other Updating Commands The `other updating commands' do not have standard keybindings because they are rarely used. @example @group M-x texinfo-insert-node-lines @r{Insert missing @code{@@node} lines in region.} @r{With @kbd{C-u} as a prefix argument,} @r{use section titles as node names.} @end group @group M-x texinfo-multiple-files-update @r{Update a multi-file document.} @r{With @kbd{C-u 2} as a prefix argument,} @r{create or update all nodes and menus} @r{in all included files first.} @end group @group M-x texinfo-indent-menu-description @r{Indent descriptions.} @end group @group M-x texinfo-sequential-node-update @r{Insert node pointers in strict sequence.} @end group @end example @node Beginning a File, Ending a File, Texinfo Mode, Top @comment node-name, next, previous, up @chapter Beginning a Texinfo File @cindex Beginning a Texinfo file @cindex Texinfo file beginning @cindex File beginning Certain pieces of information must be provided at the beginning of a Texinfo file, such as the name of the file and the title of the document.@refill @menu * Four Parts:: Four parts begin a Texinfo file. * Sample Beginning:: Here is a sample beginning for a Texinfo file. * Header:: The very beginning of a Texinfo file. * Info Summary and Permissions:: Summary and copying permissions for Info. * Titlepage & Copyright Page:: Creating the title and copyright pages. * The Top Node:: Creating the `Top' node and master menu. * Software Copying Conditions:: Ensure that you and others continue to have the right to use and share software. @end menu @node Four Parts, Sample Beginning, , Beginning a File @ifinfo @heading Four Parts Begin a File @end ifinfo Generally, the beginning of a Texinfo file has four parts:@refill @enumerate @item The header, delimited by special comment lines, that includes the commands for naming the Texinfo file and telling @TeX{} what definitions' file to use when processing the Texinfo file.@refill @item A short statement of what the file is about, with a copyright notice and copying permissions. This is enclosed in @code{@@ifinfo} and @code{@@end ifinfo} commands so that the formatters place it only in the Info file.@refill @item A title page and copyright page, with a copyright notice and copying permissions. This is enclosed between @code{@@titlepage} and @code{@@end titlepage} commands. The title and copyright page appear only in the printed @w{manual}.@refill @item The `Top' node that contains a menu for the whole Info file. The contents of this node appear only in the Info file.@refill @end enumerate Also, optionally, you may include the copying conditions for a program and a warranty disclaimer. The copying section will be followed by an introduction or else by the first chapter of the manual.@refill Since the copyright notice and copying permissions for the Texinfo document (in contrast to the copying permissions for a program) are in parts that appear only in the Info file or only in the printed manual, this information must be given twice.@refill @node Sample Beginning, Header, Four Parts, Beginning a File @comment node-name, next, previous, up @section Sample Texinfo File Beginning The following sample shows what is needed.@refill @example \input texinfo @@c -*-texinfo-*- @@c %**start of header @@setfilename @var{name-of-info-file} @@settitle @var{name-of-manual} @@setchapternewpage odd @@c %**end of header @@ifinfo This file documents @dots{} Copyright @@copyright@{@} @var{year} @var{copyright-owner} @group Permission is granted to @dots{} @@end ifinfo @end group @group @@c This title page illustrates only one of the @@c two methods of forming a title page. @end group @group @@titlepage @@title @var{name-of-manual-when-printed} @@subtitle @var{subtitle-if-any} @@subtitle @var{second-subtitle} @@author @var{author} @end group @group @@c The following two commands @@c start the copyright page. @@page @@vskip 0pt plus 1filll Copyright @@copyright@{@} @var{year} @var{copyright-owner} @end group Published by @dots{} Permission is granted to @dots{} @@end titlepage @@node Top, Overview, (dir), (dir) @@ifinfo This document describes @dots{} This document applies to version @dots{} of the program named @dots{} @@end ifinfo @group @@menu * Copying:: Your rights and freedoms. * First Chapter:: Getting started @dots{} * Second Chapter:: @dots{} @dots{} @dots{} @@end menu @end group @group @@node First Chapter, Second Chapter, top, top @@comment node-name, next, previous, up @@chapter First Chapter @@cindex Index entry for First Chapter @end group @end example @c !!! make sure there is no menu just before here! (Possible update bug) @node Header, Info Summary and Permissions, Sample Beginning, Beginning a File @comment node-name, next, previous, up @section The Texinfo File Header @cindex Header for Texinfo files @cindex Texinfo file header Texinfo files start with at least three lines that provide Info and @TeX{} with necessary information. These are the @code{\input texinfo} line, the @code{@@settitle} line, and the @code{@@setfilename} line. If you want to run @TeX{} on just a part of the Texinfo File, you must write the @code{@@settitle} and @code{@@setfilename} lines between start-of-header and end-of-header lines.@refill Thus, the beginning of a Texinfo file looks like this: @example @group \input texinfo @@c -*-texinfo-*- @@setfilename sample.info @@settitle Sample Document @end group @end example @noindent or else like this: @example @group \input texinfo @@c -*-texinfo-*- @@c %**start of header @@setfilename sample.info @@settitle Sample Document @@c %**end of header @end group @end example @menu * First Line:: The first line of a Texinfo file. * Start of Header:: Formatting a region requires this. * setfilename:: Tell Info the name of the Info file. * settitle:: Create a title for the printed work. * setchapternewpage:: Start chapters on right-hand pages. * paragraphindent:: An option to specify paragraph indentation. * End of Header:: Formatting a region requires this. @end menu @node First Line, Start of Header, , Header @comment node-name, next, previous, up @subsection The First Line of a Texinfo File @cindex First line of a Texinfo file @cindex Beginning line of a Texinfo file @cindex Header of a Texinfo file Every Texinfo file that is to be the top-level input to @TeX{} must begin with a line that looks like this:@refill @example \input texinfo @@c -*-texinfo-*- @end example @noindent This line serves two functions: @enumerate @item When the file is processed by @TeX{}, the @code{\input texinfo} command tells @TeX{} to load the macros needed for processing a Texinfo file. These are in a file called @file{texinfo.tex}, which is usually located in the @file{/usr/lib/tex/macros} directory. @TeX{} uses the backslash, @samp{\}, to mark the beginning of a command, just as Texinfo uses @code{@@}. The @file{texinfo.tex} file causes the switch from @samp{\} to @samp{@@}; before the switch occurs, @TeX{} requires @samp{\}, which is why it appears at the beginning of the file.@refill @item When the file is edited in GNU Emacs, the @samp{-*-texinfo-*-} mode specification tells Emacs to use Texinfo mode.@refill @end enumerate @node Start of Header, setfilename, First Line, Header @comment node-name, next, previous, up @subsection Start of Header @cindex Start of header line You should write a start-of-header line on the second line of a Texinfo file. Follow the start-of-header line with @code{@@setfilename} and @code{@@settitle} lines and, optionally, with other command lines, such as @code{@@smallbook} or @code{@@footnotestyle}; and then by an end-of-header line (@pxref{End of Header}).@refill With these lines, you can format part of a Texinfo file for Info or typeset part for printing.@refill A start-of-header line looks like this:@refill @example @@c %**start of header @end example The odd string of characters, @samp{%**}, is to ensure that no other comment is accidentally taken for a start-of-header line.@refill @node setfilename, settitle, Start of Header, Header @comment node-name, next, previous, up @subsection @code{@@setfilename} @cindex Info file requires @code{@@setfilename} @findex setfilename In order to be made into an Info file, a Texinfo file must contain a line that looks like this:@refill @example @@setfilename @var{info-file-name} @end example @noindent Write the @code{@@setfilename} command at the beginning of a line and follow it on the same line by the Info file name. Do not write anything else on the line; anything on the line after the command is considered part of the file name, including a comment.@refill The @code{@@setfilename} line specifies the name of the Info file to be generated. This name should be different from the name of the Texinfo file. The convention is to write a name with a @samp{.info} extension, to produce an Info file name such as @file{texinfo.info}.@refill Some operating systems cannot handle long file names. You can run into a problem even when the file name you specify is itself short enough. This occurs because the Info formatters split a long Info file into short indirect subfiles, and name them by appending `-1', `-2', @dots{}, `-10', `-11', and so on, to the original file name. (@xref{Tag and Split Files, , Tag Files and Split Files}.) The subfile name @file{texinfo.info-10}, for example, is too long for some systems; so the Info file name for this document is actually @file{texinfo} rather than @file{texinfo.info}.@refill The Info formatting commands ignore everything written before the @code{@@setfilename} line, which is why the very first line of the file (the @code{\input} line) does not need to be commented out. The @code{@@setfilename} line is ignored when you typeset a printed manual.@refill @node settitle, setchapternewpage, setfilename, Header @comment node-name, next, previous, up @subsection @code{@@settitle} @findex settitle In order to be made into a printed manual, a Texinfo file must contain a line that looks like this:@refill @example @@settitle @var{title} @end example @noindent Write the @code{@@settitle} command at the beginning of a line and follow it on the same line by the title. This tells @TeX{} the title to use in a header or footer. Do not write anything else on the line; anything on the line after the command is considered part of the title, including a comment.@refill Conventionally, @TeX{} formats a Texinfo file for double-sided output so as to print the title in the left-hand (even-numbered) page headings and the current chapter titles in the right-hand (odd-numbered) page headings. (@TeX{} learns the title of each chapter from each @code{@@chapter} command.) Page footers are not printed.@refill Even if you are printing in a single-sided style, @TeX{} looks for an @code{@@settitle} command line, in case you include the manual title in the heading. @refill The @code{@@settitle} command should precede everything that generates actual output in @TeX{}.@refill Although the title in the @code{@@settitle} command is usually the same as the title on the title page, it does not affect the title as it appears on the title page. Thus, the two do not need not match exactly; and the title in the @code{@@settitle} command can be a shortened or expanded version of the title as it appears on the title page (@pxref{titlepage, , @code{@@titlepage}}).@refill @TeX{} prints page headings only for that text that comes after the @code{@@end titlepage} command in the Texinfo file, or that comes after an @code{@@headings} command that turns on headings. (@xref{headings on off, , The @code{@@headings} Command}, for more information.)@refill You may, if you wish, create your own, customized headings and footings. @xref{Headings, , Page Headings}, for a detailed discussion of this process.@refill @node setchapternewpage, paragraphindent, settitle, Header @comment node-name, next, previous, up @subsection @code{@@setchapternewpage} @cindex Starting chapters @cindex Pages, starting odd @findex setchapternewpage In a book or a manual, text is usually printed on both sides of the paper, chapters start on right-hand pages, and right-hand pages have odd numbers. But in short reports, text often is printed only on one side of the paper. Also in short reports, chapters sometimes do not start on new pages, but are printed on the same page as the end of the preceding chapter, after a small amount of vertical whitespace.@refill You can use the @code{@@setchapternewpage} command with various arguments to specify how @TeX{} should start chapters and whether it should typeset pages for printing on one or both sides of the paper (single-sided or double-sided printing).@refill Write the @code{@@setchapternewpage} command at the beginning of a line followed by its argument.@refill For example, you would write the following to cause each chapter to start on a fresh odd-numbered page:@refill @example @@setchapternewpage odd @end example You can specify one of three alternatives with the @code{@@setchapternewpage} command:@refill @table @asis @ignore @item No @code{@@setchapternewpage} command If the Texinfo file does not contain an @code{@@setchapternewpage} command before the @code{@@titlepage} command, @TeX{} automatically begins chapters on new pages and prints headings in the standard format for single-sided printing. This is the conventional format for single-sided printing.@refill The result is exactly the same as when you write @code{@@setchapternewpage on}.@refill @end ignore @item @code{@@setchapternewpage off} Cause @TeX{} to typeset a new chapter on the same page as the last chapter, after skipping some vertical whitespace. Also, cause @TeX{} to format page headers for single-sided printing. (You can override the headers format with the @code{@@headings double} command; see @ref{headings on off, , The @code{@@headings} Command}.)@refill @item @code{@@setchapternewpage on} Cause @TeX{} to start new chapters on new pages and to typeset page headers for single-sided printing. This is the form most often used for short reports.@refill This alternative is the default.@refill @item @code{@@setchapternewpage odd} Cause @TeX{} to start new chapters on new, odd-numbered pages (right-handed pages) and to typeset for double-sided printing. This is the form most often used for books and manuals.@refill @end table @noindent Texinfo does not have an @code{@@setchapternewpage even} command.@refill @noindent (You can countermand or modify an @code{@@setchapternewpage} command with an @code{@@headings} command. @xref{headings on off, , The @code{@@headings} Command}.)@refill At the beginning of a manual or book, pages are not numbered---for example, the title and copyright pages of a book are not numbered. By convention, table of contents pages are numbered with roman numerals and not in sequence with the rest of the document.@refill Since an Info file does not have pages, the @code{@@setchapternewpage} command has no effect on it.@refill Usually, you do not write an @code{@@setchapternewpage} command for single-sided printing, but accept the default which is to typeset for single-sided printing and to start new chapters on new pages. Usually, you write an @code{@@setchapternewpage odd} command for double-sided printing.@refill @node paragraphindent, End of Header, setchapternewpage, Header @comment node-name, next, previous, up @subsection Paragraph Indenting @cindex Indenting paragraphs @cindex Paragraph indentation @findex paragraphindent The Info formatting commands may insert spaces at the beginning of the first line of each paragraph, thereby indenting that paragraph. You can use the @code{@@paragraphindent} command to specify the indentation. Write an @code{@@paragraphindent} command at the beginning of a line followed by either @samp{asis} or a number. The template is:@refill @example @@paragraphindent @var{indent} @end example The Info formatting commands indent according to the value of @var{indent}:@refill @itemize @bullet @item If the value of @var{indent} is @samp{asis}, the Info formatting commands do not change the existing indentation.@refill @item If the value of @var{indent} is 0, the Info formatting commands delete existing indentation.@refill @item If the value of @var{indent} is greater than 0, the Info formatting commands indent the paragraph by that number of spaces.@refill @end itemize The default value of @var{indent} is @samp{asis}.@refill Write the @code{@@paragraphindent} command before or shortly after the end-of-header line at the beginning of a Texinfo file. (If you write the command between the start-of-header and end-of-header lines, the region formatting commands indent paragraphs as specified.)@refill A peculiarity of the @code{texinfo-format-buffer} and @code{texinfo-format-region} commands is that they do not indent (nor fill) paragraphs that contain @code{@@w} or @code{@@*} commands. @xref{Refilling Paragraphs}, for a detailed description of what goes on.@refill @node End of Header, , paragraphindent, Header @comment node-name, next, previous, up @subsection End of Header @cindex End of header line Follow the header lines with an @w{end-of-header} line. An end-of-header line looks like this:@refill @example @@c %**end of header @end example If you include the @code{@@setchapternewpage} command between the start-of-header and end-of-header lines, @TeX{} will typeset a region as that command specifies. Similarly, if you include an @code{@@smallbook} command between the start-of-header and end-of-header lines, @TeX{} will typeset a region in the ``small'' book format.@refill @ifinfo The reason for the odd string of characters (@samp{%**}) is so that the @code{texinfo-tex-region} command does not accidentally find something that it should not when it is looking for the header.@refill The start-of-header line and the end-of-header line are Texinfo mode variables that you can change.@refill @end ifinfo @iftex @xref{Start of Header}. @end iftex @node Info Summary and Permissions, Titlepage & Copyright Page, Header, Beginning a File @comment node-name, next, previous, up @section Summary and Copying Permissions for Info The title page and the copyright page appear only in the printed copy of the manual; therefore, the same information must be inserted in a section that appears only in the Info file. This section usually contains a brief description of the contents of the Info file, a copyright notice, and copying permissions.@refill The copyright notice should read:@refill @example Copyright @var{year} @var{copyright-owner} @end example @noindent and be put on a line by itself.@refill Standard text for the copyright permissions is contained in an appendix to this manual; see @ref{ifinfo Permissions, , @samp{ifinfo} Copying Permissions}, for the complete text.@refill The permissions text appears in an Info file @emph{before} the first node. This mean that a reader does @emph{not} see this text when reading the file using Info, except when using the advanced Info command @kbd{g *}. @node Titlepage & Copyright Page, The Top Node, Info Summary and Permissions, Beginning a File @comment node-name, next, previous, up @section The Title and Copyright Pages A manual's name and author are usually printed on a title page. Sometimes copyright information is printed on the title page as well; more often, copyright information is printed on the back of the title page. The title and copyright pages appear in the printed manual, but not in the Info file. Because of this, it is possible to use several slightly obscure @TeX{} typesetting commands that cannot be used in an Info file. In addition, this part of the beginning of a Texinfo file contains the text of the copying permissions that will appear in the printed manual.@refill @xref{Titlepage Permissions, , Titlepage Copying Permissions}, for the standard text for the copyright permissions.@refill @menu * titlepage:: Create a title for the printed document. * titlefont center sp:: The @code{@@titlefont}, @code{@@center}, and @code{@@sp} commands. * title subtitle author:: The @code{@@title}, @code{@@subtitle}, and @code{@@author} commands. * Copyright & Permissions:: How to write the copyright notice and include copying permissions. * end titlepage:: Turn on page headings after the title and copyright pages. * headings on off:: An option for turning headings on and off and double or single sided printing. @end menu @node titlepage, titlefont center sp, , Titlepage & Copyright Page @comment node-name, next, previous, up @subsection @code{@@titlepage} @cindex Title page @findex titlepage Start the material for the title page and following copyright page with @code{@@titlepage} on a line by itself and end it with @code{@@end titlepage} on a line by itself.@refill The @code{@@end titlepage} command starts a new page and turns on page numbering. (@xref{Headings, , Page Headings}, for details about how to generate of page headings.) All the material that you want to appear on unnumbered pages should be put between the @code{@@titlepage} and @code{@@end titlepage} commands. By using the @code{@@page} command you can force a page break within the region delineated by the @code{@@titlepage} and @code{@@end titlepage} commands and thereby create more than one unnumbered page. This is how the copyright page is produced. (The @code{@@titlepage} command might perhaps have been better named the @code{@@titleandadditionalpages} command, but that would have been rather long!)@refill @c !!! append refill to footnote when makeinfo can handle it. When you write a manual about a computer program, you should write the version of the program to which the manual applies on the title page. If the manual changes more frequently than the program or is independent of it, you should also include an edition number@footnote{We have found that it is helpful to refer to versions of manuals as `editions' and versions of programs as `versions'; otherwise, we find we are liable to confuse each other in conversation by referring to both the documentation and the software with the same words.} for the manual. This helps readers keep track of which manual is for which version of the program. (The `Top' node should also contain this information; see @ref{makeinfo top, , @code{@@top}}.)@refill Texinfo provides two methods for creating a title page. One method uses the @code{@@titlefont}, @code{@@sp}, and @code{@@center} commands to generate a title page in which the words on the page are centered.@refill The second method uses the @code{@@title}, @code{@@subtitle}, and @code{@@author} commands to create a title page with black rules under the title and author lines and the subtitle text set flush to the right hand side of the page. With this method, you do not specify any of the actual formatting of the title page. You specify the text you want, and Texinfo does the formatting. You may use either method.@refill @node titlefont center sp, title subtitle author, titlepage, Titlepage & Copyright Page @comment node-name, next, previous, up @subsection @code{@@titlefont}, @code{@@center}, and @code{@@sp} @findex titlefont @findex center @findex sp @r{(titlepage line spacing)} You can use the @code{@@titlefont}, @code{@@sp}, and @code{@@center} commands to create a title page for a printed document. (This is the first of the two methods for creating a title page in Texinfo.)@refill Use the @code{@@titlefont} command to select a large font suitable for the title itself.@refill For example:@refill @example @@titlefont@{Texinfo@} @end example Use the @code{@@center} command at the beginning of a line to center the remaining text on that line. Thus,@refill @example @@center @@titlefont@{Texinfo@} @end example @noindent centers the title, which in this example is ``Texinfo'' printed in the title font.@refill Use the @code{@@sp} command to insert vertical space. For example:@refill @example @@sp 2 @end example @noindent This inserts two blank lines on the printed page. (@xref{sp, , @code{@@sp}}, for more information about the @code{@@sp} command.)@refill A template for this method looks like this:@refill @example @group @@titlepage @@sp 10 @@center @@titlefont@{@var{name-of-manual-when-printed}@} @@sp 2 @@center @var{subtitle-if-any} @@sp 2 @@center @var{author} @dots{} @@end titlepage @end group @end example The spacing of the example fits an 8 1/2 by 11 inch manual.@refill @node title subtitle author, Copyright & Permissions, titlefont center sp, Titlepage & Copyright Page @comment node-name, next, previous, up @subsection @code{@@title}, @code{@@subtitle}, and @code{@@author} @findex title @findex subtitle @findex author You can use the @code{@@title}, @code{@@subtitle}, and @code{@@author} commands to create a title page in which the vertical and horizontal spacing is done for you automatically. This contrasts with the method described in the previous section, in which the @code{@@sp} command is needed to adjust vertical spacing.@refill Write the @code{@@title}, @code{@@subtitle}, or @code{@@author} commands at the beginning of a line followed by the title, subtitle, or author.@refill The @code{@@title} command produces a line in which the title is set flush to the left-hand side of the page in a larger than normal font. The title is underlined with a black rule.@refill The @code{@@subtitle} command sets subtitles in a normal-sized font flush to the right-hand side of the page.@refill The @code{@@author} command sets the names of the author or authors in a middle-sized font flush to the left-hand side of the page on a line near the bottom of the title page. The names are underlined with a black rule that is thinner than the rule that underlines the title. (The black rule only occurs if the @code{@@author} command line is followed by an @code{@@page} command line.)@refill There are two ways to use the @code{@@author} command: you can write the name or names on the remaining part of the line that starts with an @code{@@author} command:@refill @example @@author by Jane Smith and John Doe @end example @noindent or you can write the names one above each other by using two (or more) @code{@@author} commands:@refill @example @group @@author Jane Smith @@author John Doe @end group @end example @noindent (Only the bottom name is underlined with a black rule.)@refill A template for this method looks like this:@refill @example @group @@titlepage @@title @var{name-of-manual-when-printed} @@subtitle @var{subtitle-if-any} @@subtitle @var{second-subtitle} @@author @var{author} @@page @dots{} @@end titlepage @end group @end example @ifinfo @noindent Contrast this form with the form of a title page written using the @code{@@sp}, @code{@@center}, and @code{@@titlefont} commands:@refill @example @@titlepage @@sp 10 @@center @@titlefont@{Name of Manual When Printed@} @@sp 2 @@center Subtitle, If Any @@sp 1 @@center Second subtitle @@sp 2 @@center Author @@page @dots{} @@end titlepage @end example @end ifinfo @node Copyright & Permissions, end titlepage, title subtitle author, Titlepage & Copyright Page @comment node-name, next, previous, up @subsection Copyright Page and Permissions @cindex Copyright page @cindex Printed permissions @cindex Permissions, printed By international treaty, the copyright notice for a book should be either on the title page or on the back of the title page. The copyright notice should include the year followed by the name of the organization or person who owns the copyright.@refill When the copyright notice is on the back of the title page, that page is customarily not numbered. Therefore, in Texinfo, the information on the copyright page should be within @code{@@titlepage} and @code{@@end titlepage} commands.@refill @findex vskip @findex filll @cindex Vertical whitespace (@samp{vskip}) Use the @code{@@page} command to cause a page break. To push the copyright notice and the other text on the copyright page towards the bottom of the page, you can write a somewhat mysterious line after the @code{@@page} command that reads like this:@refill @example @@vskip 0pt plus 1filll @end example @noindent This is a @TeX{} command that is not supported by the Info formatting commands. The @code{@@vskip} command inserts whitespace. The @samp{0pt plus 1filll} means to put in zero points of mandatory whitespace, and as much optional whitespace as needed to push the following text to the bottom of the page. Note the use of three @samp{l}s in the word @samp{filll}; this is the correct usage in @TeX{}.@refill @findex copyright In a printed manual, the @code{@@copyright@{@}} command generates a @samp{c} inside a circle. (In Info, it generates @samp{(C)}.) The copyright notice itself has the following legally defined sequence:@refill @example Copyright @copyright{} @var{year} @var{copyright-owner} @end example It is customary to put information on how to get a manual after the copyright notice, followed by the copying permissions for the manual.@refill Note that permissions must be given here as well as in the summary segment within @code{@@ifinfo} and @code{@@end ifinfo} that immediately follows the header since this text appears only in the printed manual and the @samp{ifinfo} text appears only in the Info file.@refill @xref{Sample Permissions}, for the standard text.@refill @node end titlepage, headings on off, Copyright & Permissions, Titlepage & Copyright Page @comment node-name, next, previous, up @subsection Heading Generation @findex end titlepage @cindex Headings, page, begin to appear @cindex Titlepage end starts headings @cindex End titlepage starts headings An @code{@@end titlepage} command on a line by itself not only marks the end of the title and copyright pages, but also causes @TeX{} to start generating page headings and page numbers. To repeat what is said elsewhere, Texinfo has two standard page heading formats, one for documents which are printed on one side of each sheet of paper (single-sided printing), and the other for documents which are printed on both sides of each sheet (double-sided printing). (@xref{setchapternewpage, ,@code{@@setchapternewpage}}.) You can specify these formats in different ways:@refill @itemize @bullet @item The conventional way is to write an @code{@@setchapternewpage} command before the title page commands, and then have the @code{@@end titlepage} command start generating page headings in the manner desired. (@xref{setchapternewpage, , @code{@@setchapternewpage}}.)@refill @item Alternatively, you can use the @code{@@headings} command to prevent page headings from being generated or to start them for either single or double-sided printing. (Write an @code{@@headings} command immediately after the @code{@@end titlepage} command. @xref{headings on off, , The @code{@@headings} Command}, for more information.)@refill @item Or, you may specify your own page heading and footing format. @xref{Headings, , Page Headings}, for detailed information about page headings and footings.@refill @end itemize Most documents are formatted with the standard single-sided or double-sided format, using @code{@@setchapternewpage odd} for double-sided printing and no @code{@@setchapternewpage} command for single-sided printing.@refill @node headings on off, , end titlepage, Titlepage & Copyright Page @comment node-name, next, previous, up @subsection The @code{@@headings} Command @findex headings The @code{@@headings} command is rarely used. It specifies what kind of page headings and footings to print on each page. Usually, this is controlled by the @code{@@setchapternewpage} command. You need the @code{@@headings} command only if the @code{@@setchapternewpage} command does not do what you want, or if you want to turn off pre-defined page headings prior to defining your own. Write an @code{@@headings} command immediately after the @code{@@end titlepage} command.@refill There are four ways to use the @code{@@headings} command:@refill @table @code @item @@headings off Turn off printing of page headings.@refill @item @@headings single Turn on page headings appropriate for single-sided printing. @refill @item @@headings double @itemx @@headings on Turn on page headings appropriate for double-sided printing. The two commands, @code{@@headings on} and @code{@@headings double}, are synonymous.@refill @end table For example, suppose you write @code{@@setchapternewpage off} before the @code{@@titlepage} command to tell @TeX{} to start a new chapter on the same page as the end of the last chapter. This command also causes @TeX{} to typeset page headers for single-sided printing. To cause @TeX{} to typeset for double sided printing, write @code{@@headings double} after the @code{@@end titlepage} command. You can stop @TeX{} from generating any page headings at all by writing @code{@@headings off} on a line of its own immediately after the line containing the @code{@@end titlepage} command, like this:@refill @example @@end titlepage @@headings off @end example @noindent The @code{@@headings off} command overrides the @code{@@end titlepage} command, which would otherwise cause @TeX{} to print page headings.@refill You can also specify your own style of page heading and footing. @xref{Headings, , Page Headings}, for more information.@refill @node The Top Node, Software Copying Conditions, Titlepage & Copyright Page, Beginning a File @comment node-name, next, previous, up @section The `Top' Node and Master Menu @cindex @samp{@r{Top}} node @cindex Master menu @cindex Node, `Top' The `Top' node is the node from which you enter an Info from outside.@refill A `Top' node should contain a brief description of the Info file and an extensive, master menu for the whole Info file. This helps the reader understand what the Info file is about. Also, you should write the version number of the program to which the Info file applies; or, at least, the edition number.@refill The contents of the `Top' node should appear only in the Info file; none of it should appear in printed output, so enclose it between @code{@@ifinfo} and @code{@@end ifinfo} commands. (@TeX{} does not print either an @code{@@node} line or a menu; they appear only in Info; strictly speaking, you are not required to enclose these parts between @code{@@ifinfo} and @code{@@end ifinfo}, but it is simplest to do so. @xref{Conditionals, , Conditionally Visible Text}.)@refill @menu * Title of Top Node:: Sketch what the file is about. * Master Menu Parts:: A master menu has three or more parts. @end menu @node Title of Top Node, Master Menu Parts, , The Top Node @ifinfo @subheading `Top' Node Title @end ifinfo Sometimes, you will want to place an @code{@@top} sectioning command line containing the title of the document immediately after the @code{@@node Top} line (@pxref{makeinfo top command, , The @code{@@top} Sectioning Command}, for more information).@refill For example, the beginning of the Top node of this manual contains an @code{@@top} sectioning command, a short description, and edition and version information. It looks like this:@refill @example @group @dots{} @@end titlepage @@ifinfo @@node Top, Copying, (dir), (dir) @@top Texinfo Texinfo is a documentation system@dots{} @end group @group This is edition@dots{} @dots{} @@end ifinfo @end group @group @@menu * Copying:: Texinfo is freely redistributable. * Overview:: What is Texinfo? @dots{} @end group @@end menu @end example In a `Top' node, the `Previous', and `Up' nodes usually refer to the top level directory of the whole Info system, which is called @samp{(dir)}.@refill @node Master Menu Parts, , Title of Top Node, The Top Node @subsection Parts of a Master Menu @cindex Master menu parts @cindex Parts of a master menu A @dfn{master menu} is a detailed main menu listing all the nodes in a file. A master menu is enclosed in @code{@@menu} and @code{@@end menu} commands and does not appear in the printed document.@refill Generally, a master menu is divided into parts.@refill @itemize @bullet @item The first part contains the major nodes in the Texinfo file: the nodes for the chapters, chapter-like sections, and the appendices.@refill @item The second part contains nodes for the indices.@refill @item The third and subsequent parts contain a listing of the other, lower level nodes, often ordered by chapter. This way, rather than go through an intermediary menu, an inquirer can go directly to a particular node when searching for specific information. These menu items are not required; add them if you think they are a convenience.@refill @end itemize Each section in the menu can be introduced by a descriptive line. So long as the line does not begin with an asterisk, it will not be treated as a menu entry. (@xref{Writing a Menu}, for more information.)@refill For example, the master menu for this manual looks like the following (but has many more entries):@refill @example @group @@menu * Copying:: Texinfo is freely redistributable. * Overview:: What is Texinfo? * Texinfo Mode:: Special features in GNU Emacs. @dots{} @dots{} @end group @group * Command and Variable Index:: An entry for each @@-command. * Concept Index:: An entry for each concept. @end group @group --- The Detailed Node Listing --- Overview of Texinfo * Info Files:: What is an Info file? * Printed Manuals:: Characteristics of a printed manual. @dots{} @dots{} @end group @group Using Texinfo Mode * Info on a Region:: Formatting part of a file for Info. @dots{} @dots{} @@end menu @end group @end example @node Software Copying Conditions, , The Top Node, Beginning a File @comment node-name, next, previous, up @section Software Copying Conditions @cindex Software copying conditions @cindex Copying software @cindex Distribution @cindex License agreement If the Texinfo file has a section containing the ``General Public License'' and the distribution information and a warranty disclaimer for the software that is documented, this section usually follows the `Top' node. The General Public License is very important to Project GNU software. It ensures that you and others will continue to have a right to use and share the software.@refill The copying and distribution information and the disclaimer are followed by an introduction or else by the first chapter of the manual.@refill @cindex Introduction, as part of file Although an introduction is not a required part of a Texinfo file, it is very helpful. Ideally, it should state clearly and concisely what the file is about and who would be interested in reading it. In general, an introduction would follow the licensing and distribution information, although sometimes people put it earlier in the document. Usually, an introduction is put in an @code{@@unnumbered} section. (@xref{unnumbered & appendix, , The @code{@@unnumbered} and @code{@@appendix} Commands}.)@refill @node Ending a File, Structuring, Beginning a File, Top @comment node-name, next, previous, up @chapter Ending a Texinfo File @cindex Ending a Texinfo file @cindex Texinfo file ending @cindex File ending @findex bye The end of a Texinfo file should include the commands that create indices and generate detailed and summary tables of contents. And it must include the @code{@@bye} command that marks the last line processed by @TeX{}.@refill For example:@refill @example @@node Concept Index, , Variables Index, Top @@comment node-name, next, previous, up @@unnumbered Concept Index @@printindex cp @@contents @@bye @end example @menu * Printing Indices & Menus:: How to print an index in hardcopy and generate index menus in Info. * Contents:: How to create a table of contents. * File End:: How to mark the end of a file. @end menu @node Printing Indices & Menus, Contents, , Ending a File @comment node-name, next, previous, up @section Index Menus and Printing an Index @findex printindex @cindex Printing an index @cindex Indices, printing and menus @cindex Generating menus with indices @cindex Menus generated with indices To print an index means to include it as part of a manual or Info file. This does not happen automatically just because you use @code{@@cindex} or other index-entry generating commands in the Texinfo file; those just cause the raw data for the index to be accumulated. To generate an index, you must include the @code{@@printindex} command at the place in the document where you want the index to appear. Also, as part of the process of creating a printed manual, you must run a program called @code{texindex} (@pxref{Format/Print Hardcopy}) to sort the raw data to produce a sorted index file. The sorted index file is what is actually used to print the index.@refill Texinfo offers six different types of predefined index: the concept index, the function index, the variables index, the keystroke index, the program index, and the data type index (@pxref{Predefined Indices}). Each index type has a two-letter name: @samp{cp}, @samp{fn}, @samp{vr}, @samp{ky}, @samp{pg}, and @samp{tp}. You may merge indices, or put them into separate sections (@pxref{Combining Indices}).@refill The @code{@@printindex} command takes a two-letter index name, reads the corresponding sorted index file and formats it appropriately into an index.@refill @ignore The two-letter index names are: @table @samp @item cp concept index @item fn function index @item vr variable index @item ky key index @item pg program index @item tp data type index @end table @end ignore The @code{@@printindex} command does not generate a chapter heading for the index. Consequently, you should precede the @code{@@printindex} command with a suitable section or chapter command (usually @code{@@unnumbered}) to supply the chapter heading and put the index into the table of contents. Precede the @code{@@unnumbered} command with an @code{@@node} line. For example:@refill @smallexample @group @@node Variables Index, Concept Index, Function Index, Top @@comment node-name, next, previous, up @@unnumbered Variable Index @@printindex vr @end group @group @@node Concept Index, , Variables Index, Top @@comment node-name, next, previous, up @@unnumbered Concept Index @@printindex cp @end group @group @@summarycontents @@contents @@bye @end group @end smallexample @noindent (Readers often prefer that the concept index come last in a book, since that makes it easiest to find.)@refill @ignore In @TeX{}, the @code{@@printindex} command needs a sorted index file to work from. @TeX{} does not know how to do sorting; this is a deficiency. @TeX{} writes output files of raw index data; use the @code{texindex} program to convert these files to sorted index files. (@xref{Format/Print Hardcopy}, for more information.)@refill @end ignore @node Contents, File End, Printing Indices & Menus, Ending a File @comment node-name, next, previous, up @section Generating a Table of Contents @cindex Table of contents @cindex Contents, Table of @findex contents @findex summarycontents @findex shortcontents The @code{@@chapter}, @code{@@section}, and other structuring commands supply the information to make up a table of contents, but they do not cause an actual table to appear in the manual. To do this, you must use the @code{@@contents} and @code{@@summarycontents} commands:@refill @table @code @item @@contents Generate a table of contents in a printed manual, including all chapters, sections, subsections, etc., as well as appendices and unnumbered chapters. (Headings generated by the @code{@@heading} series of commands do not appear in the table of contents.) The @code{@@contents} command should be written on a line by itself.@refill @item @@shortcontents @itemx @@summarycontents (@code{@@summarycontents} is a synonym for @code{@@shortcontents}; the two commands are exactly the same.)@refill Generate a short or summary table of contents that lists only the chapters (and appendices and unnumbered chapters). Omit sections, subsections and subsubsections. Only a long manual needs a short table of contents in addition to the full table of contents.@refill Write the @code{@@shortcontents} command on a line by itself right @emph{before} the @code{@@contents} command.@refill @end table The table of contents commands automatically generate a chapter-like heading at the top of the first table of contents page. Write the table of contents commands at the very end of a Texinfo file, just before the @code{@@bye} command, following any index sections---anything in the Texinfo file after the table of contents commands will be omitted from the table of contents. When you print a manual with a table of contents, the table of contents will be printed last and numbered with roman numerals. You need to place those pages in their proper place, after the title page, yourself. (This is the only collating you need to do for a printed manual. The table of contents is printed last because it is generated after the rest of the manual is typeset.)@refill Here is an example of where to write table of contents commands:@refill @example @group @var{indices}@dots{} @@shortcontents @@contents @@bye @end group @end example Since an Info file uses menus instead of tables of contents, the Info formatting commands ignore the @code{@@contents} and @code{@@shortcontents} commands.@refill @node File End, , Contents, Ending a File @comment node-name, next, previous, up @section @code{@@bye} File Ending @findex bye An @code{@@bye} command terminates @TeX{} or Info formatting. None of the formatting commands see any of the file following @code{@@bye}. The @code{@@bye} command should be on a line by itself.@refill If you wish, you may follow the @code{@@bye} line with notes. These notes will not be formatted and will not appear in either Info or a printed manual; it is as if text after @code{@@bye} were within @code{@@ignore} @dots{} @code{@@end ignore}. Also, you may follow the @code{@@bye} line with a local variables list. @xref{Compile-Command, , Using Local Variables and the Compile Command}, for more information.@refill @node Structuring, Nodes, Ending a File, Top @comment node-name, next, previous, up @chapter Chapter Structuring @cindex Chapter structuring @cindex Structuring of chapters The @dfn{chapter structuring} commands divide a document into a hierarchy of chapters, sections, subsections, and subsubsections. These commands generate large headings; they also provide information for the table of contents of a printed manual (@pxref{Contents, , Generating a Table of Contents}).@refill The chapter structuring commands do not create an Info node structure, so normally you should put an @code{@@node} command immediately before each chapter structuring command (@pxref{Nodes}). The only time you are likely to use the chapter structuring commands without using the node structuring commands is if you are writing a document that contains no cross references and will never be transformed into Info format.@refill It is unlikely that you will ever write a Texinfo file that is intended only as an Info file and not as a printable document. If you do, you might still use chapter structuring commands to create a heading at the top of each node---but you don't need to.@refill @menu * Tree Structuring:: A manual is like an upside down tree @dots{} * Structuring Command Types:: How to divide a manual into parts. * makeinfo top:: The @code{@@top} command, part of the `Top' node. * chapter:: * unnumbered & appendix:: * majorheading & chapheading:: * section:: * unnumberedsec appendixsec heading:: * subsection:: * unnumberedsubsec appendixsubsec subheading:: * subsubsection:: Commands for the lowest level sections. @end menu @node Tree Structuring, Structuring Command Types, , Structuring @comment node-name, next, previous, up @section Tree Structure of Sections @cindex Tree structuring A Texinfo file is usually structured like a book with chapters, sections, subsections, and the like. This structure can be visualized as a tree (or rather as an upside-down tree) with the root at the top and the levels corresponding to chapters, sections, subsection, and subsubsections.@refill Here is a diagram that shows a Texinfo file with three chapters, each of which has two sections.@refill @example @group Top | ------------------------------------- | | | Chapter 1 Chapter 2 Chapter 3 | | | -------- -------- -------- | | | | | | Section Section Section Section Section Section 1.1 1.2 2.1 2.2 3.1 3.2 @end group @end example In a Texinfo file that has this structure, the beginning of Chapter 2 looks like this:@refill @example @group @@node Chapter 2, Chapter 3, Chapter 1, top @@chapter Chapter 2 @end group @end example The chapter structuring commands are described in the sections that follow; the @code{@@node} and @code{@@menu} commands are described in following chapters. (@xref{Nodes}, and see @ref{Menus}.)@refill @node Structuring Command Types, makeinfo top, Tree Structuring, Structuring @comment node-name, next, previous, up @section Types of Structuring Command The chapter structuring commands fall into four groups or series, each of which contains structuring commands corresponding to the hierarchical levels of chapters, sections, subsections, and subsubsections.@refill The four groups are the @code{@@chapter} series, the @code{@@unnumbered} series, the @code{@@appendix} series, and the @code{@@heading} series.@refill Each command produces titles that have a different appearance on the printed page or Info file; only some of the commands produce titles that are listed in the table of contents of a printed book or manual.@refill @itemize @bullet @item The @code{@@chapter} and @code{@@appendix} series of commands produce numbered or lettered entries both in the body of a printed work and in its table of contents.@refill @item The @code{@@unnumbered} series of commands produce unnumbered entries both in the body of a printed work and in its table of contents. The @code{@@top} command, which has a special use, is a member of this series (@pxref{makeinfo top, , @code{@@top}}).@refill @item The @code{@@heading} series of commands produce unnumbered headings that do not appear in a table of contents. The heading commands never start a new page.@refill @item The @code{@@majorheading} command produces results similar to using the @code{@@chapheading} command but generates a larger vertical whitespace before the heading.@refill @item When an @code{@@setchapternewpage} command says to do so, the @code{@@chapter}, @code{@@unnumbered}, and @code{@@appendix} commands start new pages in the printed manual; the @code{@@heading} commands do not.@refill @end itemize Here are the four groups of chapter structuring commands:@refill @iftex @smallexample @group @r{No new pages} @r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} @r{In contents} @r{In contents} @r{In contents} @r{Not in contents} @@top @@majorheading @@chapter @@unnumbered @@appendix @@chapheading @@section @@unnumberedsec @@appendixsec @@heading @@subsection @@unnumberedsubsec @@appendixsubsec @@subheading @@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading @end group @end smallexample @end iftex @ifinfo @example @group @r{No new pages} @r{Numbered} @r{Unnumbered} @r{Lettered and numbered} @r{Unnumbered} @r{In contents} @r{In contents} @r{In contents} @r{Not in contents} @@top @@majorheading @@chapter @@unnumbered @@appendix @@chapheading @@section @@unnumberedsec @@appendixsec @@heading @@subsection @@unnumberedsubsec @@appendixsubsec @@subheading @@subsubsection @@unnumberedsubsubsec @@appendixsubsubsec @@subsubheading @end group @end example @end ifinfo @node makeinfo top, chapter, Structuring Command Types, Structuring @comment node-name, next, previous, up @section @code{@@top} The @code{@@top} command is a special sectioning command that you use only after an @code{@@node Top} line at the beginning of a Texinfo file. The @code{@@top} command tells the @code{makeinfo} formatter which node is the `Top' node. It has the same typesetting effect as @code{@@unnumbered} (@pxref{unnumbered & appendix, , @code{@@unnumbered}, @code{@@appendix}}). For detailed information, see @ref{makeinfo top command, , The @code{@@top} Command}.@refill @node chapter, unnumbered & appendix, makeinfo top, Structuring @comment node-name, next, previous, up @section @code{@@chapter} @findex chapter @code{@@chapter} identifies a chapter in the document. Write the command at the beginning of a line and follow it on the same line by the title of the chapter.@refill For example, this chapter in this manual is entitled ``Chapter Structuring''; the @code{@@chapter} line looks like this:@refill @example @@chapter Chapter Structuring @end example In @TeX{}, the @code{@@chapter} command creates a chapter in the document, specifying the chapter title. The chapter is numbered automatically.@refill In Info, the @code{@@chapter} command causes the title to appear on a line by itself, with a line of asterisks inserted underneath. Thus, in Info, the above example produces the following output:@refill @example Chapter Structuring ******************* @end example @c !!! spaces after a title underlined by asterisk: bug to fix @ignore An occasional mistake is to type blank spaces after the title, before the carriage return that marks the end of the line. The Info formatting commands will think the spaces are part of the title and insert asterisks under them.@refill @end ignore @node unnumbered & appendix, majorheading & chapheading, chapter, Structuring @comment node-name, next, previous, up @section @code{@@unnumbered}, @code{@@appendix} @findex unnumbered @findex appendix Use the @code{@@unnumbered} command to create a chapter that appears in a printed manual without chapter numbers of any kind. Use the @code{@@appendix} command to create an appendix in a printed manual that is labelled by letter instead of by number.@refill For Info file output, the @code{@@unnumbered} and @code{@@appendix} commands are equivalent to @code{@@chapter}: the title is printed on a line by itself with a line of asterisks underneath. (@xref{chapter, , @code{@@chapter}}.)@refill To create an appendix or an unnumbered chapter, write an @code{@@appendix} or @code{@@unnumbered} command at the beginning of a line and follow it on the same line by the title, as you would if you were creating a chapter.@refill @node majorheading & chapheading, section, unnumbered & appendix, Structuring @section @code{@@majorheading}, @code{@@chapheading} @findex majorheading @findex chapheading The @code{@@majorheading} and @code{@@chapheading} commands put chapter-like headings in the body of a document.@refill However, neither command causes @TeX{} to produce a numbered heading or an entry in the table of contents; and neither command causes @TeX{} to start a new page in a printed manual.@refill In @TeX{}, an @code{@@majorheading} command generates a larger vertical whitespace before the heading than an @code{@@chapheading} command but is otherwise the same.@refill In Info, the @code{@@majorheading} and @code{@@chapheading} commands are equivalent to @code{@@chapter}: the title is printed on a line by itself with a line of asterisks underneath. (@xref{chapter, , @code{@@chapter}}.)@refill @node section, unnumberedsec appendixsec heading, majorheading & chapheading, Structuring @comment node-name, next, previous, up @section @code{@@section} @findex section In a printed manual, an @code{@@section} command identifies a numbered section within a chapter. The section title appears in the table of contents. In Info, an @code{@@section} command provides a title for a segment of text, underlined with @samp{=}.@refill This section is headed with an @code{@@section} command and looks like this in the Texinfo file:@refill @example @@section @@code@{@@@@section@} @end example To create a section, write the @code{@@section} command at the beginning of a line and follow it on the same line by the section title.@refill Thus, @example @@section This is a section @end example @noindent produces @example @group This is a section ================= @end group @end example @noindent in Info. @node unnumberedsec appendixsec heading, subsection, section, Structuring @comment node-name, next, previous, up @section @code{@@unnumberedsec}, @code{@@appendixsec}, @code{@@heading} @findex unnumberedsec @findex appendixsec @findex heading The @code{@@unnumberedsec}, @code{@@appendixsec}, and @code{@@heading} commands are, respectively, the unnumbered, appendix-like, and heading-like equivalents of the @code{@@section} command. (@xref{section, , @code{@@section}}.)@refill @table @code @item @@unnumberedsec The @code{@@unnumberedsec} command may be used within an unnumbered chapter or within a regular chapter or appendix to provide an unnumbered section.@refill @item @@appendixsec @itemx @@appendixsection @code{@@appendixsection} is a longer spelling of the @code{@@appendixsec} command; the two are synonymous.@refill @findex appendixsection Conventionally, the @code{@@appendixsec} or @code{@@appendixsection} command is used only within appendices.@refill @item @@heading You may use the @code{@@heading} command anywhere you wish for a section-style heading that will not appear in the table of contents.@refill @end table @node subsection, unnumberedsubsec appendixsubsec subheading, unnumberedsec appendixsec heading, Structuring @comment node-name, next, previous, up @section The @code{@@subsection} Command @findex subsection Subsections are to sections as sections are to chapters. (@xref{section, , @code{@@section}}.) In Info, subsection titles are underlined with @samp{-}. For example,@refill @example @@subsection This is a subsection @end example @noindent produces @example @group This is a subsection -------------------- @end group @end example In a printed manual, subsections are listed in the table of contents and are numbered three levels deep.@refill @node unnumberedsubsec appendixsubsec subheading, subsubsection, subsection, Structuring @comment node-name, next, previous, up @section The @code{@@subsection}-like Commands @cindex Subsection-like commands @findex unnumberedsubsec @findex appendixsubsec @findex subheading The @code{@@unnumberedsubsec}, @code{@@appendixsubsec}, and @code{@@subheading} commands are, respectively, the unnumbered, appendix-like, and heading-like equivalents of the @code{@@subsection} command. (@xref{subsection, , @code{@@subsection}}.)@refill In Info, the @code{@@subsection}-like commands generate a title underlined with hyphens. In a printed manual, an @code{@@subheading} command produces a heading like that of a subsection except that it is not numbered and does not appear in the table of contents. Similarly, an @code{@@unnumberedsubsec} command produces an unnumbered heading like that of a subsection and an @code{@@appendixsubsec} command produces a subsection-like heading labelled with a letter and numbers; both of these commands produce headings that appear in the table of contents.@refill @node subsubsection, , unnumberedsubsec appendixsubsec subheading, Structuring @comment node-name, next, previous, up @section The `subsub' Commands @cindex Subsub commands @findex subsubsection @findex unnumberedsubsubsec @findex appendixsubsubsec @findex subsubheading The fourth and lowest level sectioning commands in Texinfo are the `subsub' commands. They are:@refill @table @code @item @@subsubsection Subsubsections are to subsections as subsections are to sections. (@xref{subsection, , @code{@@subsection}}.) In a printed manual, subsubsection titles appear in the table of contents and are numbered four levels deep.@refill @item @@unnumberedsubsubsec Unnumbered subsubsection titles appear in the table of contents of a printed manual, but lack numbers. Otherwise, unnumbered subsubsections are the same as subsubsections. In Info, unnumbered subsubsections look exactly like ordinary subsubsections.@refill @item @@appendixsubsubsec Conventionally, appendix commands are used only for appendices and are lettered and numbered appropriately in a printed manual. They also appear in the table of contents. In Info, appendix subsubsections look exactly like ordinary subsubsections.@refill @item @@subsubheading The @code{@@subsubheading} command may be used anywhere that you need a small heading that will not appear in the table of contents. In Info, subsubheadings look exactly like ordinary subsubsection headings.@refill @end table In Info, `subsub' titles are underlined with periods. For example,@refill @example @@subsubsection This is a subsubsection @end example @noindent produces @example @group This is a subsubsection ....................... @end group @end example @node Nodes, Menus, Structuring, Top @comment node-name, next, previous, up @chapter Nodes @dfn{Nodes} are the primary segments of a Texinfo file. They do not themselves impose a hierarchic or any other kind of structure on a file. Nodes contain @dfn{node pointers} that name other nodes, and can contain @dfn{menus} which are lists of nodes. In Info, the movement commands can carry you to a pointed-to node or to a node listed in a menu. Node pointers and menus provide structure for Info files just as chapters, sections, subsections, and the like, provide structure for printed books.@refill @menu * Two Paths:: Different commands to structure Info output and printed output. * Node Menu Illustration:: A diagram, and sample nodes and menus. * node:: How to write a node, in detail. * makeinfo Pointer Creation:: How to create node pointers with @code{makeinfo}. @end menu @node Two Paths, Node Menu Illustration, , Nodes @ifinfo @heading Two Paths @end ifinfo The node and menu commands and the chapter structuring commands are independent of each other: @itemize @bullet @item In Info, node and menu commands provide structure. The chapter structuring commands generate headings with different kinds of underlining---asterisks for chapters, hyphens for sections, and so on; they do nothing else.@refill @item In @TeX{}, the chapter structuring commands generate chapter and section numbers and tables of contents. The node and menu commands provide information for cross references; they do nothing else.@refill @end itemize You can use node pointers and menus to structure an Info file any way you want; and you can write a Texinfo file so that its Info output has a different structure than its printed output. However, most Texinfo files are written such that the structure for the Info output corresponds to the structure for the printed output. It is not convenient to do otherwise.@refill Generally, printed output is structured in a tree-like hierarchy in which the chapters are the major limbs from which the sections branch out. Similarly, node pointers and menus are organized to create a matching structure in the Info output.@refill @node Node Menu Illustration, node, Two Paths, Nodes @comment node-name, next, previous, up @section Node and Menu Illustration Here is a copy of the diagram shown earlier that illustrates a Texinfo file with three chapters, each of which contains two sections.@refill Note that the ``root'' is at the top of the diagram and the ``leaves'' are at the bottom. This is how such a diagram is drawn conventionally; it illustrates an upside-down tree. For this reason, the root node is called the `Top' node, and `Up' node pointers carry you closer to the root.@refill @example @group Top | ------------------------------------- | | | Chapter 1 Chapter 2 Chapter 3 | | | -------- -------- -------- | | | | | | Section Section Section Section Section Section 1.1 1.2 2.1 2.2 3.1 3.2 @end group @end example Write the beginning of the node for Chapter 2 like this:@refill @example @group @@node Chapter 2, Chapter 3, Chapter 1, top @@comment node-name, next, previous, up @end group @end example @noindent This @code{@@node} line says that the name of this node is ``Chapter 2'', the name of the `Next' node is ``Chapter 3'', the name of the `Previous' node is ``Chapter 1'', and the name of the `Up' node is ``Top''. @quotation @emph{Please Note:} `Next' refers to the next node at the same hierarchical level in the manual, not necessarily to the next node within the Texinfo file. In the Texinfo file, the subsequent node may be at a lower level---a section-level node may follow a chapter-level node, and a subsection-level node may follow a section-level node. `Next' and `Previous' refer to nodes at the @emph{same} hierarchical level. @end quotation To go to Sections 2.1 and 2.2 using Info, you need a menu inside Chapter 2. (@xref{Menus}.) You would write the menu just before the beginning of Section 2.1, like this:@refill @example @group @@menu * Sect. 2.1:: Description of this section. * Sect. 2.2:: @@end menu @end group @end example Write the node for Sect. 2.1 like this:@refill @example @group @@node Sect. 2.1, Sect. 2.2, Chapter 2, Chapter 2 @@comment node-name, next, previous, up @end group @end example In Info format, the `Next' and `Previous' pointers of a node usually lead to other nodes at the same level---from chapter to chapter or from section to section (sometimes, as shown, the `Previous' pointer points up); an `Up' pointer usually leads to a node at the level above (closer to the `Top' node); and a `Menu' leads to nodes at a level below (closer to `leaves'). (A cross reference can point to a node at any level; see @ref{Cross References}.)@refill Usually, an @code{@@node} command and a chapter structuring command are used in sequence, along with indexing commands. (You may follow the @code{@@node} line with a comment line that reminds you which pointer is which.)@refill Here is the beginning of the chapter in this manual called ``Ending a Texinfo File''. This shows an @code{@@node} line followed by a comment line, an @code{@@chapter} line, and then by indexing lines.@refill @smallexample @group @@node Ending a File, Structuring, Beginning a File, Top @@comment node-name, next, previous, up @@chapter Ending a Texinfo File @@cindex Ending a Texinfo file @@cindex Texinfo file ending @@cindex File ending @end group @end smallexample @node node, makeinfo Pointer Creation, Node Menu Illustration, Nodes @comment node-name, next, previous, up @section The @code{@@node} Command @cindex Node, defined A @dfn{node} is a segment of text that begins at an @code{@@node} command and continues until the next @code{@@node} command. The definition of node is different from that for chapter or section. A chapter may contain sections and a section may contain subsections; but a node cannot contain subnodes; the text of a node continues only until the next @code{@@node} command in the file. A node usually contains only one chapter structuring command, the one that follows the @code{@@node} line. On the other hand, in printed output nodes are used only for cross references, so a chapter or section may contain any number of nodes. Indeed, a chapter usually contains several nodes, one for each section, subsection, and subsubsection.@refill To create a node, write an @code{@@node} command at the beginning of a line, and follow it with four arguments, separated by commas, on the rest of the same line. These arguments are the name of the node, and the names of the `Next', `Previous', and `Up' pointers, in that order. You may insert spaces before each pointer if you wish; the spaces are ignored. You must write the name of the node, and the names of the `Next', `Previous', and `Up' pointers, all on the same line. Otherwise, the formatters fail. (@inforef{Top, info, info}, for more information about nodes in Info.)@refill Usually, you write one of the chapter-structuring command lines immediately after an @code{@@node} line---for example, an @code{@@section} or @code{@@subsection} line. (@xref{Structuring Command Types, , Types of Structuring Command}.)@refill @quotation @strong{Please note:} The GNU Emacs Texinfo mode updating commands work only with Texinfo files in which @code{@@node} lines are followed by chapter structuring lines. @xref{Updating Requirements}.@refill @end quotation @TeX{} uses @code{@@node} lines to identify the names to use for cross references. For this reason, you must write @code{@@node} lines in a Texinfo file that you intend to format for printing, even if you do not intend to format it for Info. (Cross references, such as the one at the end of this sentence, are made with @code{@@xref} and its related commands; see @ref{Cross References}.)@refill @menu * Node Names:: How to choose node and pointer names. * Writing a Node:: How to write an @code{@@node} line. * Node Line Tips:: Keep names short. * Node Line Requirements:: Keep names unique, without @@-commands. * First Node:: How to write a `Top' node. * makeinfo top command:: How to use the @code{@@top} command. * Top Node Summary:: Write a brief description for readers. @end menu @node Node Names, Writing a Node, , node @ifinfo @subheading Choosing Node and Pointer Names @end ifinfo The name of a node identifies the node. The pointers enable you to reach other nodes and consist of the names of those nodes.@refill Normally, a node's `Up' pointer contains the name of the node whose menu mentions that node. The node's `Next' pointer contains the name of the node that follows that node in that menu and its `Previous' pointer contains the name of the node that precedes it in that menu. When a node's `Previous' node is the same as its `Up' node, both node pointers name the same node.@refill Usually, the first node of a Texinfo file is the `Top' node, and its `Up' and `Previous' pointers point to the @file{dir} file, which contains the main menu for all of Info.@refill The `Top' node itself contains the main or master menu for the manual. Also, it is helpful to include a brief description of the manual in the `Top' node. @xref{First Node}, for information on how to write the first node of a Texinfo file.@refill @node Writing a Node, Node Line Tips, Node Names, node @comment node-name, next, previous, up @subsection How to Write an @code{@@node} Line @cindex Writing an @code{@@node} line @cindex @code{@@node} line writing @cindex Node line writing The easiest way to write an @code{@@node} line is to write @code{@@node} at the beginning of a line and then the name of the node, like this:@refill @example @@node @var{node-name} @end example If you are using GNU Emacs, you can use the update node commands provided by Texinfo mode to insert the names of the pointers; or you can leave the pointers out of the Texinfo file and let @code{makeinfo} insert node pointers into the Info file it creates. (@xref{Texinfo Mode}, and @ref{makeinfo Pointer Creation}.)@refill Alternatively, you can insert the `Next', `Previous', and `Up' pointers yourself. If you do this, you may find it helpful to use the Texinfo mode keyboard command @kbd{C-c C-c n}. This command inserts @samp{@@node} and a comment line listing the names of the pointers in their proper order. The comment line helps you keep track of which arguments are for which pointers. This comment line is especially useful if you are not familiar with Texinfo.@refill The template for a node line with `Next', `Previous', and `Up' pointers looks like this:@refill @example @@node @var{node-name}, @var{next}, @var{previous}, @var{up} @end example If you wish, you can ignore @code{@@node} lines altogether in your first draft and then use the @code{texinfo-insert-node-lines} command to create @code{@@node} lines for you. However, we do not recommend this practice. It is better to name the node itself at the same time that you write a segment so you can easily make cross references. A large number of cross references are an especially important feature of a good Info file.@refill After you have inserted an @code{@@node} line, you should immediately write an @@-command for the chapter or section and insert its name. Next (and this is important!), put in several index entries. Usually, you will find at least two and often as many as four or five ways of referring to the node in the index. Use them all. This will make it much easier for people to find the node.@refill @node Node Line Tips, Node Line Requirements, Writing a Node, node @comment node-name, next, previous, up @subsection @code{@@node} Line Tips Here are three suggestions: @itemize @bullet @item Try to pick node names that are informative but short.@refill In the Info file, the file name, node name, and pointer names are all inserted on one line, which may run into the right edge of the window. (This does not cause a problem with Info, but is ugly.)@refill @item Try to pick node names that differ from each other near the beginnings of their names. This way, it is easy to use automatic name completion in Info.@refill @item By convention, node names are capitalized just as they would be for section or chapter titles---initial and significant words are capitalized; others are not.@refill @end itemize @node Node Line Requirements, First Node, Node Line Tips, node @comment node-name, next, previous, up @subsection @code{@@node} Line Requirements Here are several requirements for @code{@@node} lines: @itemize @bullet @item All the node names for a single Info file must be unique.@refill Duplicates confuse the Info movement commands. This means, for example, that if you end every chapter with a summary, you must name each summary node differently. You cannot just call each one ``Summary''. You may, however, duplicate the titles of chapters, sections, and the like. Thus you can end each chapter in a book with a section called ``Summary'', so long as the node names for those sections are all different.@refill @item A pointer name must be the name of a node.@refill The node to which a pointer points may come before or after the node containing the pointer.@refill @item You cannot use any of the Texinfo @@-commands in a node name; @w{@@-commands} confuse Info.@refill Thus, the beginning of the section called @code{@@chapter} looks like this:@refill @smallexample @group @@node chapter, unnumbered & appendix, makeinfo top, Structuring @@comment node-name, next, previous, up @@section @@code@{@@@@chapter@} @@findex chapter @end group @end smallexample @item You cannot use commas, colons, or apostrophes within a node name; these confuse @TeX{} or the Info formatters.@refill For example, the following is a section title: @smallexample @@code@{@@@@unnumberedsec@}, @@code@{@@@@appendixsec@}, @@code@{@@@@heading@} @end smallexample @noindent The corresponding node name is: @smallexample unnumberedsec appendixsec heading @end smallexample @end itemize @node First Node, makeinfo top command, Node Line Requirements, node @comment node-name, next, previous, up @subsection The First Node @cindex @samp{@r{Top}} node is first @cindex First node The first node of a Texinfo file is the `Top' node, except in an included file (@pxref{Include Files}). The `Top' node (which must be named @samp{top} or @samp{Top}) should have as its `Up' and `Previous' nodes the name of a node in another file, where there is a menu that leads to this file. Specify the file name in parentheses. If the file is to be installed directly in the Info directory file, use @samp{(dir)} as the parent of the `Top' node; this is short for @samp{(dir)top}, and specifies the `Top' node in the @file{dir} file, which contains the main menu for Info. For example, the @code{@@node Top} line of this manual looks like this:@refill @example @@node Top, Overview, (dir), (dir) @end example @noindent (You may use the Texinfo updating commands or the @code{makeinfo} utility to insert these `Next' and @samp{(dir)} pointers automatically.)@refill @xref{Install an Info File}, for more information about installing an Info file in the @file{info} directory.@refill The `Top' node contains the main or master menu for the document. @node makeinfo top command, Top Node Summary, First Node, node @comment node-name, next, previous, up @subsection The @code{@@top} Sectioning Command @findex top @r{(@@-command)} A special sectioning command, @code{@@top}, has been created for use with the @code{@@node Top} line. The @code{@@top} sectioning command tells @code{makeinfo} that it marks the `Top' node in the file. It provides the information that @code{makeinfo} needs to insert node pointers automatically. Write the @code{@@top} command at the beginning of the line immediately following the @code{@@node Top} line. Write the title on the remaining part of the same line as the @code{@@top} command.@refill In Info, the @code{@@top} sectioning command causes the title to appear on a line by itself, with a line of asterisks inserted underneath.@refill In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} sectioning command is merely a synonym for @code{@@unnumbered}. Neither of these formatters require an @code{@@top} command, and do nothing special with it. You can use @code{@@chapter} or @code{@@unnumbered} after the @code{@@node Top} line when you use these formatters. Also, you can use @code{@@chapter} or @code{@@unnumbered} when you use the Texinfo updating commands to create or update pointers and menus.@refill Whatever sectioning command follows an @code{@@node Top} line, whether it be @code{@@top} or @code{@@chapter}, the @code{@@node Top} line and the immediately following line and any additional text must be enclosed between @code{@@ifinfo} and @code{@@end ifinfo} commands. (@xref{Conditionals}.) This prevents the title and the accompanying text from appearing in printed output. Write the @code{@@ifinfo} command before the @code{@@node} line and write the @code{@@end ifinfo} command after the @code{@@top} or other sectioning command and after any additional text. (You can write the @code{@@end ifinfo} command after the @code{@@end menu} command if you like.)@refill @node Top Node Summary, , makeinfo top command, node @subsection The `Top' Node Summary @cindex @samp{@r{Top}} node summary You can help readers by writing a summary in the `Top' node, after the @code{@@top} line, before the main or master menu. The summary should briefly describe the Info file. You should also write the version number of the program to which the manual applies in this section. This helps the reader keep track of which manual is for which version of the program. If the manual changes more frequently than the program or is independent of it, you should also include an edition number for the manual. (The title page should also contain this information: see @ref{titlepage, , @code{@@titlepage}}.)@refill Put the whole of the `Top' node, including the @code{@@top} sectioning command line if you have one, between @code{@@ifinfo} and @code{@@end ifinfo} so none of the text appears in the printed output (@pxref{Conditionals, , Conditionally Visible Text}). (You may want to repeat the brief description from the `Top' node within @code{@@iftex} @dots{} @code{@@end iftex} at the beginning of the first chapter, for those who read the printed manual.) @node makeinfo Pointer Creation, , node, Nodes @section Creating Pointers with @code{makeinfo} @cindex Creating pointers with @code{makeinfo} @cindex Pointer creation with @code{makeinfo} @cindex Automatic pointer creation with @code{makeinfo} The @code{makeinfo} program has a feature for automatically creating node pointers for a hierarchically organized file that lacks them.@refill When you take advantage of this feature, you do not need to write the `Next', `Previous', and `Up' pointers after the name of a node. However, you must write a sectioning command, such as @code{@@chapter} or @code{@@section}, on the line immediately following each truncated @code{@@node} line. You cannot write a comment line after a node line; the section line must follow it immediately.@refill In addition, you must follow the `Top' @code{@@node} line with a line beginning with @code{@@top} to mark the `Top' node in the file. @xref{makeinfo top, , @code{@@top}}. Finally, you must write the name of each node (except for the `Top' node) in a menu that is one or more hierarchical levels above the node's hierarchical level.@refill This node pointer insertion feature in @code{makeinfo} is an alternative to the menu and pointer creation and update commands in Texinfo mode. (@xref{Updating Nodes and Menus}.) It is especially helpful to people who do not use GNU Emacs for writing Texinfo documents.@refill @node Menus, Cross References, Nodes, Top @comment node-name, next, previous, up @chapter Menus @cindex Menus @findex menu @dfn{Menus} contain pointers to subordinate nodes.@footnote{Menus can carry you to any node, regardless of the hierarchical structure; even to nodes in a different Info file. However, the GNU Emacs Texinfo mode updating commands work only to create menus of subordinate nodes. Conventionally, cross references are used to refer to other nodes.} In Info, you use menus to go to such nodes. Menus have no effect in printed manuals and do not appear in them.@refill By convention, a menu is put at the end of a node. This way, it is easy for someone using Info to find the menu, using the @kbd{M->} (@code{end-of-buffer}) command.@refill @ifinfo A node that has a menu should @emph{not} contain much text. If you have a lot of text and a menu, move most of the text into a new subnode---all but a few lines.@refill @end ifinfo @iftex @emph{A node that has a menu should not contain much text.} If you have a lot of text and a menu, move most of the text into a new subnode---all but a few lines. Otherwise, a reader with a terminal that displays only a few lines may miss the menu and its associated text. As a practical matter, you should locate a menu within 20 lines of the beginning of the node.@refill @end iftex @menu * Menu Location:: Put a menu in a short node. * Writing a Menu:: What is a menu? * Writing a Menu Entry:: How to write a menu entry. * Menu Example:: A menu example. * Other Info Files:: How to refer to a different Info file. @end menu @node Menu Location, Writing a Menu, , Menus @ifinfo @heading Menus Need Short Nodes @end ifinfo @cindex Menu location @cindex Location of menus @cindex Nodes for menus are short @cindex Short nodes for menus @ifinfo A reader can easily see a menu that is close to the beginning of the node. The node should be short. As a practical matter, you should locate a menu within 20 lines of the beginning of the node. Otherwise, a reader with a terminal that displays only a few lines may miss the menu and its associated text.@refill @end ifinfo The short text before a menu may look awkward in a printed manual. To avoid this, you can write a menu near the beginning of its node and follow the menu by an @code{@@node} line, and then an @code{@@heading} line located within @code{@@ifinfo} and @code{@@end ifinfo}. This way, the menu, @code{@@node} line, and title appear only in the Info file, not the printed document.@refill For example, the preceding two paragraphs follow an Info-only menu, @code{@@node} line, and heading, and look like this:@refill @example @group @@menu * Menu Location:: Put a menu in a short node. * Menu Entry:: How to write a menu entry. * Menu Example:: A menu example. @@end menu @@node Menu Location @@ifinfo @@heading Menus Need Short Nodes @@end ifinfo @end group @end example The Texinfo file for this document contains more than a dozen other examples of this procedure. One is at the beginning of this chapter; another is at the beginning of the ``Cross References'' chapter.@refill @node Writing a Menu, Writing a Menu Entry, Menu Location, Menus @section Writing a Menu @cindex Writing a menu @cindex Menu writing A menu consists of an @code{@@menu} command on a line by itself followed by menu entry lines or menu comment lines and then by an @code{@@end menu} command on a line by itself.@refill A menu looks like this:@refill @example @group @@menu Larger Units of Text * Files:: All about handling files. * Multiples: Buffers. Multiple buffers; editing several files at once. @@end menu @end group @end example In a menu, every line that begins with an @w{@samp{* }} is a @dfn{menu entry}. (Note the space after the asterisk.) A line that does not start with an @w{@samp{* }} may also appear in a menu. Such a line is not a menu entry but is a menu comment line that appears in the Info file. In the example above, the line @samp{Larger Units of Text} is a menu comment line; the two lines starting with @w{@samp{* }} are menu entries. @node Writing a Menu Entry, Menu Example, Writing a Menu, Menus @section How to Write a Menu Entry @cindex Writing a menu entry @cindex Menu entry writing @cindex @code{@@menu} entry writing A menu entry has three parts, only the second of which is required:@refill @enumerate @item The menu entry name. @item The name of the node. @item A description of the item. @end enumerate The template for a menu entry looks like this:@refill @example * @var{menu-entry-name}: @var{node-name}. @var{description} @end example Follow the menu entry name with a single colon and follow the node name with tab, comma, period, or newline.@refill In Info, a user selects a node with the @kbd{m} (@code{Info-menu}) command. The menu entry name is what the user types after the @kbd{m} command.@refill If the menu entry name and the node name are the same, you can write the name immediately after the asterisk and space at the beginning of the line and follow the name with two colons.@refill @example @group @noindent @exdent @r{For example, write} * Name:: @noindent @exdent @r{instead of} * Name: Name. @end group @end example @noindent You should use the node name for the menu entry name whenever possible, since it reduces visual clutter in the menu.@refill The third part of a menu entry is a short descriptive phrase or sentence. Menu entry names and node names are often short; the description explains to the reader what the node is about. The description, which is optional, can spread over two or more lines. A useful description complements the node name rather than repeats it.@refill @node Menu Example, Other Info Files, Writing a Menu Entry, Menus @comment node-name, next, previous, up @section A Menu Example @cindex Menu example @cindex Example menu A menu looks like this in Texinfo:@refill @example @group @@menu * menu entry name: Node name. A short description. * Node name:: This form is preferred. @@end menu @end group @end example @example @group @exdent @r{This produces:} * menu: * menu entry name: Node name. A short description. * Node name:: This form is preferred. @end group @end example Here is an example as you might see it in a Texinfo file:@refill @example @group @@menu Larger Units of Text * Files:: All about handling files. * Multiples: Buffers. Multiple buffers; editing several files at once. @@end menu @end group @end example @example @group @noindent @exdent @r{This produces:} * menu: Larger Units of Text * Files:: All about handling files. * Multiples: Buffers. Multiple buffers; editing several files at once. @end group @end example In this example, the menu has two entries. @samp{Files} is both a menu entry name and the name of the node referred to by that name. In the other entry, @samp{Multiples} is the menu entry name, and it refers to the node named @samp{Buffers}.@refill Since no file name is specified with either @samp{Files} or @samp{Buffers}, they must be the names of nodes in the same Info file. (@xref{Other Info Files, , Referring to Other Info Files}.)@refill The line @samp{Larger Units of Text} is a comment; it appears as part of the menu in Info, but is not a menu entry.@refill @node Other Info Files, , Menu Example, Menus @comment node-name, next, previous, up @section Referring to Other Info Files @cindex Referring to other Info files @cindex Nodes in other Info files @cindex Other Info files' nodes @cindex Going to other Info files' nodes @cindex Info; other files' nodes You can create a menu entry that enables an reader in Info to go to a node in another Info file by writing the file name in parentheses just before the node name. In this case, you should use the three-part menu entry format, which saves the reader from having to type the file name.@refill The format looks like this:@refill @example @group @@menu * @var{first-entry-name}:(@var{filename})@var{nodename}. @var{description} * @var{second-entry-name}:(@var{filename})@var{second-node}. @var{description} @@end menu @end group @end example For example, to refer directly to the @samp{Outlining} and @samp{Rebinding} nodes in the @cite{Emacs Manual}, you would write a menu in a Texinfo file similar to the following:@refill @example @group @@menu * Outlining: (emacs)Outline Mode. The major mode for editing outlines. * Rebinding: (emacs)Rebinding. How to redefine the meaning of a key. @@end menu @end group @end example If you do not list the node name, but only name the file, then Info presumes that you are referring to the `Top' node.@refill The @file{dir} top level directory for the Info system has menu entries that take you directly to the `Top' nodes of each Info document. Only the file names are listed, not the `Top' nodes. (@xref{Install an Info File}.)@refill For example: @example @group @dots{} * Info: (info). Documentation browsing system. * Emacs: (emacs). The extensible, self-documenting text editor. @dots{} @end group @end example @noindent (The @file{dir} top level directory for the Info system is an Info file, not a Texinfo file, but a menu entry looks the same in both types of file.)@refill Note that the GNU Emacs Texinfo mode menu updating commands only work with nodes within the current buffer, so you cannot use them to create menus that refer to other files. You must write such menus by hand.@refill @node Cross References, Marking Text, Menus, Top @comment node-name, next, previous, up @chapter Cross References @cindex Making cross references @cindex Cross references @cindex References @dfn{Cross references} are used to refer the reader to other parts of the same or different Texinfo files. In Texinfo, nodes are the places to which cross references can refer.@refill @menu * References:: What cross references are for. * Cross Reference Commands:: A summary of the different commands. * Cross Reference Parts:: A cross reference has several parts. * xref:: Begin a reference with `See' @dots{} * Top Node Naming:: How to refer to the beginning of another file. * ref:: A reference for the last part of a sentence. * pxref:: How to write a parenthetical cross reference. * inforef:: How to refer to an Info-only file. @end menu @node References, Cross Reference Commands, , Cross References @ifinfo @heading What References Are For @end ifinfo Often, but not always, a printed document should be designed so that it can be read sequentially. People tire of flipping back and forth to find information that should be presented to them as they need it.@refill However, in any document, some information will be too detailed for the current context, or incidental to it; use cross references to provide access to such information. Also, an on-line help system or a reference manual is not like a novel; few read such documents in sequence from beginning to end. Instead, people look up what they need. For this reason, such creations should contain many cross references to help readers find other information that they may not have read.@refill In a printed manual, a cross reference results in a page reference, unless it is to another manual altogether, in which case the cross reference names that manual.@refill In Info, a cross reference results in an entry that you can follow using the Info @samp{f} command. (@inforef{Help-Adv, Some advanced Info commands, info}.)@refill The various cross reference commands use nodes to define cross reference locations. This is evident in Info, in which a cross reference takes you to the specified node. @TeX{} also uses nodes to define cross reference locations, but the action is less obvious. When @TeX{} generates a @sc{dvi} file, it records nodes' page numbers and uses the page numbers in making references. Thus, if you are writing a manual that will only be printed, and will not be used on-line, you must nonetheless write @code{@@node} lines to name the places to which you make cross references.@refill @need 800 @node Cross Reference Commands, Cross Reference Parts, References, Cross References @comment node-name, next, previous, up @section Different Cross Reference Commands @cindex Different cross reference commands There are four different cross reference commands:@refill @table @code @item @@xref Used to start a sentence in the printed manual saying @w{`See @dots{}'} or an entry in the Info file saying @samp{*Note @dots{}}. @item @@ref Used within or, more often, at the end of a sentence; produces just the reference in the printed manual without a preceding `See'.@refill @item @@pxref Used within parentheses to make a reference that starts with a lower case `see' within the printed manual. (@samp{p} is for `parenthesis'.)@refill @item @@inforef Used to make a reference to an Info file for which there is no printed manual.@refill @end table @noindent (The @code{@@cite} command is used to make references to books and manuals for which there is no corresponding Info file and, therefore, no node to which to point. @xref{cite, , @code{@@cite}}.)@refill @node Cross Reference Parts, xref, Cross Reference Commands, Cross References @comment node-name, next, previous, up @section Parts of a Cross Reference @cindex Cross reference parts @cindex Parts of a cross reference A cross reference command requires only one argument, which is the name of the node to which it refers. But a cross reference command may contain up to four additional arguments. By using these arguments, you can provide a cross reference name for Info, a topic description or section title for the printed output, the name of a different Info file, and the name of a different printed manual.@refill Here is a simple cross reference example:@refill @example @@xref@{Node name@}. @end example @noindent which produces @example *Note Node name::. @end example @noindent and @quotation See Section @var{nnn} [Node name], page @var{ppp}. @end quotation Here, however, is an example of a full five-part cross reference:@refill @example @group @@xref@{Node name, Cross Reference Name, Particular Topic, info-file-name, A Printed Manual@}, for details. @end group @end example @noindent which produces @example *Note Cross Reference Name: (info-file-name)Node name, for details. @end example @noindent and @quotation See Section Particular Topic of @i{A Printed Manual}, for details. @end quotation The five possible arguments for a cross reference are:@refill @enumerate @item The node name (required). This is the node to which the cross reference takes you. In a printed document, the location of the node provides the page reference only for references within the same document.@refill @item The cross reference name for the Info reference, if it is to be different from the node name. If you include this argument, it argument becomes the first part of the cross reference. It is usually omitted.@refill @item A topic description or section name. Often, this is the title of the section. This is used as the name of the reference in the printed manual. If omitted, the node name is used.@refill @item The name of the Info file in which the reference is located, if it is different from the current file.@refill @item The name of a printed manual from a different Texinfo file.@refill @end enumerate The template for a full five argument cross reference looks like this:@refill @example @group @@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, @var{info-file-name}, @var{printed-manual-title}@}. @end group @end example Cross references with one, two, three, four, and five arguments are described separately following the description of @code{@@xref}.@refill Write a node name in a cross reference in exactly the same way as in the @code{@@node} line, including the same capitalization; otherwise, the formatters may not find the reference.@refill You can write cross reference commands within a paragraph, but note how Info and @TeX{} format the output of each of the various commands: write @code{@@xref} at the beginning of a sentence; write @code{@@pxref} only within parentheses, and so on.@refill @node xref, Top Node Naming, Cross Reference Parts, Cross References @comment node-name, next, previous, up @section @code{@@xref} @findex xref @cindex Cross references using @code{@@xref} @cindex References using @code{@@xref} The @code{@@xref} command generates a cross reference for the beginning of a sentence. The Info formatting commands convert it into an Info cross reference, which the Info @samp{f} command can use to bring you directly to another node. The @TeX{} typesetting commands convert it into a page reference, or a reference to another book or manual.@refill @menu * Reference Syntax:: What a reference looks like and requires. * One Argument:: @code{@@xref} with one argument. * Two Arguments:: @code{@@xref} with two arguments. * Three Arguments:: @code{@@xref} with three arguments. * Four and Five Arguments:: @code{@@xref} with four and five arguments. @end menu @node Reference Syntax, One Argument, , xref @ifinfo @subheading What a Reference Looks Like and Requires @end ifinfo Most often, an Info cross reference looks like this:@refill @example *Note @var{node-name}::. @end example @noindent or like this @example *Note @var{cross-reference-name}: @var{node-name}. @end example @noindent In @TeX{}, a cross reference looks like this: @example See Section @var{section} [@var{node-name}], page @var{page}. @end example @noindent or like this @example See Section @var{section} [@var{title-or-topic}], page @var{page}. @end example The @code{@@xref} command does not generate a period or comma to end the cross reference in either the Info file or the printed output. You must write that period or comma yourself; otherwise, Info will not recognize the end of the reference. (The @code{@@pxref} command works differently. @xref{pxref, , @code{@@pxref}}.)@refill @quotation @emph{Please note:} A period or comma @strong{must} follow the closing brace of an @code{@@xref}. It is required to terminate the cross reference. This period or comma will appear in the output, both in the Info file and in the printed manual.@refill @end quotation @code{@@xref} must refer to an Info node by name. Use @code{@@node} to define the node (@pxref{Writing a Node}).@refill @code{@@xref} is followed by several arguments inside braces, separated by commas. Whitespace before and after these commas is ignored.@refill A cross reference requires only the name of a node; but it may contain up to four additional arguments. Each of these variations produces a cross reference that looks somewhat different.@refill @node One Argument, Two Arguments, Reference Syntax, xref @subsection @code{@@xref} with One Argument The simplest form of @code{@@xref} takes one argument, the name of another node in the same Info file. The Info formatters produce output that the Info readers can use to jump to the reference; @TeX{} produces output that specifies the page and section number for you.@refill @noindent For example, @example @@xref@{Tropical Storms@}. @end example @noindent produces @example *Note Tropical Storms::. @end example @noindent and @quotation See Section 3.1 [Tropical Storms], page 24. @end quotation @noindent (Note that in the preceding example the closing brace is followed by a period.)@refill You can write a clause after the cross reference, like this:@refill @example @@xref@{Tropical Storms@}, for more info. @end example @noindent which produces @example *Note Tropical Storms::, for more info. @end example @quotation See Section 3.1 [Tropical Storms], page 24, for more info. @end quotation @noindent (Note that in the preceding example the closing brace is followed by a comma, and then by the clause, which is followed by a period.)@refill @node Two Arguments, Three Arguments, One Argument, xref @subsection @code{@@xref} with Two Arguments With two arguments, the second one is used as the name of the Info cross reference, while the first argument is still the node that the cross reference points to.@refill @noindent The template is like this: @example @@xref@{@var{node-name}, @var{cross-reference-name}@}. @end example @noindent For example, @example @@xref@{Electrical Effects, Lightning@}. @end example @noindent produces: @example *Note Lightning: Electrical Effects. @end example @noindent and @quotation See Section 5.2 [Electrical Effects], page 57. @end quotation @noindent (Note that in the preceding example the closing brace is followed by a period; and that the node name is printed, not the cross reference name.)@refill You can write a clause after the cross reference, like this:@refill @example @@xref@{Electrical Effects, Lightning@}, for more info. @end example @noindent which produces @example *Note Lightning: Electrical Effects, for more info. @end example @noindent and @quotation See Section 5.2 [Electrical Effects], page 57, for more info. @end quotation @noindent (Note that in the preceding example the closing brace is followed by a comma, and then by the clause, which is followed by a period.)@refill @node Three Arguments, Four and Five Arguments, Two Arguments, xref @subsection @code{@@xref} with Three Arguments A third argument replaces the node name in the @TeX{} output. The third argument should be the name of the section in the printed output, or else state the topic discussed by that section. Often, you will want to use initial upper case letters so it will be easier to read when the reference is printed. Use a third argument when the node name is unsuitable because of syntax or meaning.@refill Remember that a comma or period must follow the closing brace of an @code{@@xref} command to terminate the cross reference. In the following examples, a clause follows a terminating comma.@refill @example @group @noindent @exdent @r{The template is like this:} @@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}@}. @end group @end example @noindent For example, @example @@xref@{Electrical Effects, Lightning, Thunder and Lightning@}, for details. @end example @noindent produces @example *Note Lightning: Electrical Effects, for details. @end example @noindent and @quotation See Section 5.2 [Thunder and Lightning], page 57, for details. @end quotation If a third argument is given and the second one is empty, then the third argument serves both. (Note how two commas, side by side, mark the empty second argument.)@refill @example @group @@xref@{Electrical Effects, , Thunder and Lightning@}, for details. @end group @end example @noindent produces @example *Note Thunder and Lightning: Electrical Effects, for details. @end example @noindent and @quotation See Section 5.2 [Thunder and Lightning], page 57, for details. @end quotation As a practical matter, it is often best to write cross references with just the first argument if the node name and the section title are the same, and with the first and third arguments if the node name and title are different.@refill Here are several examples from @cite{The GAWK Manual}:@refill @smallexample @@xref@{Sample Program@}. @@xref@{Glossary@}. @@xref@{Case-sensitivity, ,Case-sensitivity in Matching@}. @@xref@{Close Output, , Closing Output Files and Pipes@}, for more information. @@xref@{Regexp, , Regular Expressions as Patterns@}. @end smallexample @node Four and Five Arguments, , Three Arguments, xref @subsection @code{@@xref} with Four and Five Arguments In a cross reference, a fourth argument specifies the name of another Info file, different from the file in which the reference appears, and a fifth argument specifies its title as a printed manual.@refill Remember that a comma or period must follow the closing brace of an @code{@@xref} command to terminate the cross reference. In the following examples, a clause follows a terminating comma.@refill @example @group @noindent @exdent @r{The template is:} @@xref@{@var{node-name}, @var{cross-reference-name}, @var{title-or-topic}, @var{info-file-name}, @var{printed-manual-title}@}. @end group @end example @noindent For example, @example @@xref@{Electrical Effects, Lightning, Thunder and Lightning, weather, An Introduction to Meteorology@}, for details. @end example @noindent produces @example *Note Lightning: (weather)Electrical Effects, for details. @end example @noindent The name of the Info file is enclosed in parentheses and precedes the name of the node. @noindent In a printed manual, the reference looks like this:@refill @quotation See Section Thunder and Lightning of @i{An Introduction to Meteorology}, for details. @end quotation @noindent The title of the printed manual is typeset in italics; and the reference lacks a page number since @TeX{} cannot know to which page a reference refers when that reference is to another manual.@refill Often, you will leave out the second argument when you use the long version of @code{@@xref}. In this case, the third argument, the topic description, will be used as the cross reference name in Info.@refill @noindent The template looks like this: @example @@xref@{@var{node-name}, , @var{title-or-topic}, @var{info-file-name}, @var{printed-manual-title}@}, for details. @end example @noindent produces @example *Note @var{title-or-topic}: (@var{info-file-name})@var{node-name}, for details. @end example @noindent and @quotation See Section @var{title-or-topic} of @var{printed-manual-title}, for details. @end quotation @noindent For example, @example @@xref@{Electrical Effects, , Thunder and Lightning, weather, An Introduction to Meteorology@}, for details. @end example @noindent produces @example *Note Thunder and Lightning: (weather)Electrical Effects, for details. @end example @noindent and @quotation See Section Thunder and Lightning of @i{An Introduction to Meteorology}, for details. @end quotation On rare occasions, you may want to refer to another Info file that is within a single printed manual---when multiple Texinfo files are incorporated into the same @TeX{} run but make separate Info files. In this case, you need to specify only the fourth argument, and not the fifth.@refill @node Top Node Naming, ref, xref, Cross References @section Naming a `Top' Node @cindex Naming a `Top' Node in references @cindex @samp{@r{Top}} node naming for references In a cross reference, you must always name a node. This means that in order to refer to a whole manual, you must identify the `Top' node by writing it as the first argument to the @code{@@xref} command. (This is different from the way you write a menu entry; see @ref{Other Info Files, , Referring to Other Info Files}.) At the same time, to provide a meaningful section topic or title in the printed cross reference (instead of the word `Top'), you must write an appropriate entry for the third argument to the @code{@@xref} command. @refill @noindent Thus, to make a cross reference to @cite{The GNU Make Manual}, write:@refill @example @@xref@{Top, , Overview, make, The GNU Make Manual@}. @end example @noindent which produces @example *Note Overview: (make)Top. @end example @noindent and @quotation See Section Overview of @i{The GNU Make Manual}. @end quotation @noindent In this example, @samp{Top} is the name of the first node, and @samp{Overview} is the name of the first section of the manual.@refill @node ref, pxref, Top Node Naming, Cross References @comment node-name, next, previous, up @section @code{@@ref} @cindex Cross references using @code{@@ref} @cindex References using @code{@@ref} @findex ref @code{@@ref} is nearly the same as @code{@@xref} except that it does not generate a `See' in the printed output, just the reference itself. This makes it useful as the last part of a sentence.@refill @noindent For example, @example For more information, see @@ref@{Hurricanes@}. @end example @noindent produces @example For more information, see *Note Hurricanes. @end example @noindent and @quotation For more information, see Section 8.2 [Hurricanes], page 123. @end quotation The @code{@@ref} command sometimes leads writers to express themselves in a manner that is suitable for a printed manual but looks awkward in the Info format. Bear in mind that your audience will be using both the printed and the Info format.@refill @example @group @noindent @exdent @r{For example,} Sea surges are described in @@ref@{Hurricanes@}. @end group @end example @noindent produces @quotation Sea surges are described in Section 6.7 [Hurricanes], page 72. @end quotation @noindent in a printed document, but @example Sea surges are described in *Note Hurricanes::. @end example @noindent in Info. @quotation @strong{Caution:} You @emph{must} write a period or comma immediately after an @code{@@ref} command with two or more arguments. Otherwise, Info will not find the end of the cross reference entry and its attempt to follow the cross reference will fail. As a general rule, you should write a period or comma after every @code{@@ref} command. This looks best in both the printed and the Info output.@refill @end quotation @node pxref, inforef, ref, Cross References @comment node-name, next, previous, up @section @code{@@pxref} @cindex Cross references using @code{@@pxref} @cindex References using @code{@@pxref} @findex pxref The parenthetical reference command, @code{@@pxref}, is nearly the same as @code{@@xref}, but you use it @emph{only} inside parentheses and you do @emph{not} type a comma or period after the command's closing brace. The command differs from @code{@@xref} in two ways:@refill @enumerate @item @TeX{} typesets the reference for the printed manual with a lower case `see' rather than an upper case `See'.@refill @item The Info formatting commands automatically end the reference with a closing colon or period.@refill @end enumerate Because one type of formatting automatically inserts closing punctuation and the other does not, you should use @code{@@pxref} @emph{only} inside parentheses as part of another sentence. Also, you yourself should not insert punctuation after the reference, as you do with @code{@@xref}.@refill @code{@@pxref} is designed so that the output looks right and works right between parentheses both in printed output and in an Info file. In a printed manual, a closing comma or period should not follow a cross reference within parentheses; such punctuation is wrong. But in an Info file, suitable closing punctuation must follow the cross reference so Info can recognize its end. @code{@@pxref} spares you the need to use complicated methods to put a terminator into one form of the output and not the other.@refill @noindent With one argument, a parenthetical cross reference looks like this:@refill @example @dots{} storms cause flooding (@@pxref@{Hurricanes@}) @dots{} @end example @example @group @noindent @exdent @r{produces} @dots{} storms cause flooding (*Note Hurricanes::) @dots{} @end group @end example @noindent and @quotation @dots{} storms cause flooding (see Section 6.7 [Hurricanes], page 72) @dots{} @end quotation With two arguments, a parenthetical cross reference has this template:@refill @example @dots{} (@@pxref@{@var{node-name}, @var{cross-reference-name}@}) @dots{} @end example @noindent produces @example @dots{} (*Note @var{cross-reference-name}: @var{node-name}.) @dots{} @end example @noindent and @quotation @dots{} (see Section @var{nnn} [@var{node-name}], page @var{ppp}) @dots{} @end quotation @code{@@pxref} can be used with up to five arguments just like @code{@@xref} (@pxref{xref, , @code{@@xref}}).@refill @quotation @strong{Please note:} Use @code{@@pxref} only as a parenthetical reference. Do not try to use @code{@@pxref} as a clause in a sentence. It will look bad in either the Info file, the printed output, or both.@refill Also, parenthetical cross references look best at the ends of sentences. Although you may write them in the middle of a sentence, that location breaks up the flow of text.@refill @end quotation @node inforef, , pxref, Cross References @comment node-name, next, previous, up @section @code{@@inforef} @cindex Cross references using @code{@@inforef} @cindex References using @code{@@inforef} @findex inforef @code{@@inforef} is used for cross references to Info files for which there are no printed manuals. Even in a printed manual, @code{@@inforef} generates a reference directing the user to look in an Info file.@refill The command takes either two or three arguments, in the following order:@refill @enumerate @item The node name. @item The cross reference name (optional). @item The Info file name. @end enumerate @noindent Separate the arguments with commas, as with @code{@@xref}. Also, you must terminate the reference with a comma or period after the @samp{@}}, as you do with @code{@@xref}.@refill @noindent The template is: @example @@inforef@{@var{node-name}, @var{cross-reference-name}, @var{info-file-name}@}, @end example @example @group @noindent @exdent @r{Thus,} @@inforef@{Expert, Advanced Info commands, info@}, for more information. @end group @end example @noindent produces @example @group *Note Advanced Info commands: (info)Expert, for more information. @end group @end example @noindent and @quotation See Info file @file{info}, node @samp{Expert}, for more information. @end quotation @example @group @noindent @exdent @r{Similarly,} @@inforef@{Expert, , info@}, for more information. @end group @end example @noindent produces @example *Note (info)Expert::, for more information. @end example @noindent and @quotation See Info file @file{info}, node @samp{Expert}, for more information. @end quotation The converse of @code{@@inforef} is @code{@@cite}, which is used to refer to printed works for which no Info form exists. @xref{cite, , @code{@@cite}}.@refill @node Marking Text, Quotations and Examples, Cross References, Top @comment node-name, next, previous, up @chapter Marking Words and Phrases @cindex Paragraph, marking text within @cindex Marking words and phrases @cindex Words and phrases, marking them @cindex Marking text within a paragraph In Texinfo, you can mark words and phrases in a variety of ways. The Texinfo formatters use this information to determine how to highlight the text. You can specify, for example, whether a word or phrase is a defining occurrence, a metasyntactic variable, or a symbol used in a program. Also, you can emphasize text.@refill @menu * Indicating:: How to indicate definitions, files, etc. * Emphasis:: How to emphasize text. @end menu @node Indicating, Emphasis, , Marking Text @comment node-name, next, previous, up @section Indicating Definitions, Commands, etc. @cindex Highlighting text @cindex Indicating commands, definitions, etc. Texinfo has commands for indicating just what kind of object a piece of text refers to. For example, metasyntactic variables are marked by @code{@@var}, and code by @code{@@code}. Since the pieces of text are labelled by commands that tell what kind of object they are, it is easy to change the way the Texinfo formatters prepare such text. (Texinfo is an @emph{intentional} formatting language rather than a @emph{typesetting} formatting language.)@refill For example, in a printed manual, code is usually illustrated in a typewriter font; @code{@@code} tells @TeX{} to typeset this text in this font. But it would be easy to change the way @TeX{} highlights code to use another font, and this change would not effect how keystroke examples are highlighted. If straight typesetting commands were used in the body of the file and you wanted to make a change, you would need to check every single occurrence to make sure that you were changing code and not something else that should not be changed.@refill @menu * Useful Highlighting:: Highlighting provides useful information. * code:: How to indicate code. * kbd:: How to show keyboard input. * key:: How to specify keys. * samp:: How to show a literal sequence of characters. * var:: How to indicate a metasyntactic variable. * file:: How to indicate the name of a file. * dfn:: How to specify a definition. * cite:: How to refer to a book that is not in Info. @end menu @node Useful Highlighting, code, , Indicating @ifinfo @subheading Highlighting Commands are Useful @end ifinfo The highlighting commands can be used to generate useful information from the file, such as lists of functions or file names. It is possible, for example, to write a program in Emacs Lisp (or a keyboard macro) to insert an index entry after every paragraph that contains words or phrases marked by a specified command. You could do this to construct an index of functions if you had not already made the entries.@refill The commands serve a variety of purposes:@refill @table @code @item @@code@{@var{sample-code}@} Indicate text that is a literal example of a piece of a program.@refill @item @@kbd@{@var{keyboard-characters}@} Indicate keyboard input.@refill @item @@key@{@var{key-name}@} Indicate the conventional name for a key on a keyboard.@refill @item @@samp@{@var{text}@} Indicate text that is a literal example of a sequence of characters.@refill @item @@var@{@var{metasyntactic-variable}@} Indicate a metasyntactic variable.@refill @item @@file@{@var{file-name}@} Indicate the name of a file.@refill @item @@dfn@{@var{term}@} Indicate the introductory or defining use of a term.@refill @item @@cite@{@var{reference}@} Indicate the name of a book.@refill @ignore @item @@ctrl@{@var{ctrl-char}@} Use for an @sc{ascii} control character.@refill @end ignore @end table @node code, kbd, Useful Highlighting, Indicating @comment node-name, next, previous, up @subsection @code{@@code}@{@var{sample-code}@} @findex code Use the @code{@@code} command to indicate text that is a piece of a program and which consists of entire syntactic tokens. Enclose the text in braces.@refill Thus, you should use @code{@@code} for an expression in a program, for the name of a variable or function used in a program, or for a keyword. Also, you should use @code{@@code} for the name of a program, such as @code{diff}, that is a name used in the machine. (You should write the name of a program in the ordinary text font if you regard it as a new English word, such as `Emacs' or `Bison'.)@refill Use @code{@@code} for environment variables such as @code{TEXINPUTS}, and other variables.@refill Use @code{@@code} for command names in command languages that resemble programming languages, such as Texinfo or the shell. For example, @code{@@code} and @code{@@samp} are produced by writing @samp{@@code@{@@@@code@}} and @samp{@@code@{@@@@samp@}} in the Texinfo source, respectively.@refill Note, however, that you should not use @code{@@code} for shell options such as @samp{-c} when such options stand alone. (Use @code{@@samp}.) Also, an entire shell command often looks better if written using @code{@@samp} rather than @code{@@code}. In this case, the rule is to choose the more pleasing format.@refill It is incorrect to alter the case of a word inside an @code{@@code} command when it appears at the beginning of a sentence. Most computer languages are case sensitive. In C, for example, @code{Printf} is different from the identifier @code{printf}, and most likely is a misspelling of it. Even in languages which are not case sensitive, it is confusing to a human reader to see identifiers spelled in different ways. Pick one spelling and always use that. If you do not want to start a sentence with a command written all in lower case, you should rearrange the sentence.@refill Do not use the @code{@@code} command for a string of characters shorter than a syntactic token. If you are writing about @samp{TEXINPU}, which is just a part of the name for the @code{TEXINPUTS} environment variable, you should use @code{@@samp}.@refill In particular, you should not use the @code{@@code} command when writing about the characters used in a token; do not, for example, use @code{@@code} when you are explaining what letters or printable symbols can be used in the names of functions. (Use @code{@@samp}.) Also, you should not use @code{@@code} to mark text that is considered input to programs unless the input is written in a language that is like a programming language. For example, you should not use @code{@@code} for the keystroke commands of GNU Emacs (use @code{@@kbd} instead) although you may use @code{@@code} for the names of the Emacs Lisp functions that the keystroke commands invoke.@refill In the printed manual, @code{@@code} causes @TeX{} to typeset the argument in a typewriter face. In the Info file, it causes the Info formatting commands to use single quotation marks around the text. For example,@refill @example Use @@code@{diff@} to compare two files. @end example @noindent produces this in the printed manual:@refill @quotation Use @code{diff} to compare two files. @end quotation @iftex @noindent and this in the Info file:@refill @example Use `diff' to compare two files. @end example @end iftex @node kbd, key, code, Indicating @comment node-name, next, previous, up @subsection @code{@@kbd}@{@var{keyboard-characters}@} @findex kbd Use the @code{@@kbd} command for characters of input to be typed by users. For example, to refer to the characters @kbd{M-a}, write@refill @example @@kbd@{M-a@} @end example @noindent and to refer to the characters @kbd{M-x shell}, write@refill @example @@kbd@{M-x shell@} @end example The @code{@@kbd} command has the same effect as @code{@@code} in Info, but may produce a different font in a printed manual.@refill You can embed another @@-command inside the braces of an @code{@@kbd} command. Here, for example, is the way to describe a command that would be described more verbosely as ``press an @samp{r} and then press the @key{RET} key'':@refill @example @@kbd@{r @@key@{RET@}@} @end example @noindent This produces: @kbd{r @key{RET}} You also use the @code{@@kbd} command if you are spelling out the letters you type; for example:@refill @example To give the @@code@{logout@} command, type the characters @@kbd@{l o g o u t @@key@{RET@}@}. @end example @noindent This produces: @quotation To give the @code{logout} command, type the characters @kbd{l o g o u t @key{RET}}. @end quotation (Also, this example shows that you can add spaces for clarity. If you really want to mention a space character as one of the characters of input, write @kbd{@@key@{SPC@}} for it.)@refill @node key, samp, kbd, Indicating @comment node-name, next, previous, up @subsection @code{@@key}@{@var{key-name}@} @findex key Use the @code{@@key} command for the conventional name for a key on a keyboard, as in:@refill @example @@key@{RET@} @end example You can use the @code{@@key} command within the argument of an @code{@@kbd} command when the sequence of characters to be typed includes one or more keys that are described by name.@refill For example, to produce @kbd{C-x @key{ESC}} you would type:@refill @example @@kbd@{C-x @@key@{ESC@}@} @end example @c bob: this next sentence looks weird, having a semi-colon followed by @c a colon that ends the "sentence".. --mew Here is a list of the recommended names for keys; they are all in upper case:@refill @cindex Recommended names for keys @cindex Keys, recommended names @cindex Names recommended for keys @cindex Abbreviations for keys @quotation @table @t @item SPC Space @item RET Return @item LFD Linefeed @item TAB Tab @item BS Backspace @item ESC Escape @item DEL Delete @item SFT Shift @item CTL Control @item META Meta @end table @end quotation There are subtleties to handling words like `meta' or `ctl' that are names of shift keys. When mentioning a character in which the shift key is used, such as @kbd{Meta-a}, use the @code{@@kbd} command alone; do not use the @code{@@key} command; but when you are referring to the shift key in isolation, use the @code{@@key} command. For example, write @samp{@@kbd@{Meta-a@}} to produce @kbd{Meta-a} and @samp{@@key@{META@}} to produce @key{META}. This is because @kbd{Meta-a} refers to keys that you press on a keyboard, but @key{META} refers to a key without implying that you press it. In short, use @code{@@kbd} for what you do, and use @code{@@key} for what you talk about: ``Press @code{@@kbd@{M-a@}} to move point to the beginning of the sentence. The @code{@@key@{META@}} is often in the lower left of the keyboard.''@refill @cindex META key @node samp, var, key, Indicating @comment node-name, next, previous, up @subsection @code{@@samp}@{@var{text}@} @findex samp Use the @code{@@samp} command to indicate text that is a literal example or `sample' of a sequence of characters in a file, string, pattern, etc. Enclose the text in braces. The argument appears within single quotation marks in both the Info file and the printed manual; in addition, it is printed in a fixed-width font.@refill @example To match @@samp@{foo@} at the end of the line, use the regexp @@samp@{foo$@}. @end example @noindent produces @quotation To match @samp{foo} at the end of the line, use the regexp @samp{foo$}.@refill @end quotation Any time you are referring to single characters, you should use @code{@@samp} unless @code{@@kbd} is more appropriate. Use @code{@@samp} for the names of command-line options. Also, you may use @code{@@samp} for entire statements in C and for entire shell commands---in this case, @code{@@samp} often looks better than @code{@@code}. Basically, @code{@@samp} is a catchall for whatever is not covered by @code{@@code}, @code{@@kbd}, or @code{@@key}.@refill Only include punctuation marks within braces if they are part of the string you are specifying. Write punctuation marks outside the braces if those punctuation marks are part of the English text that surrounds the string. In the following sentence, for example, the commas and period are outside of the braces:@refill @example @group In English, the vowels are @@samp@{a@}, @@samp@{e@}, @@samp@{i@}, @@samp@{o@}, @@samp@{u@}, and sometimes @@samp@{y@}. @end group @end example @noindent This produces: @quotation In English, the vowels are @samp{a}, @samp{e}, @samp{i}, @samp{o}, @samp{u}, and sometimes @samp{y}. @end quotation @node var, file, samp, Indicating @comment node-name, next, previous, up @subsection @code{@@var}@{@var{metasyntactic-variable}@} @findex var Use the @code{@@var} command to indicate metasyntactic variables. A @dfn{metasyntactic variable} is something that stands for another piece of text. For example, you should use a metasyntactic variable in the documentation of a function to describe the arguments that are passed to that function.@refill Do not use @code{@@var} for the names of particular variables in programming languages. These are specific names from a program, so @code{@@code} is correct for them. For example, the Lisp variable @code{texinfo-tex-command} is not a metasyntactic variable; it is properly formatted using @code{@@code}.@refill The effect of @code{@@var} in the Info file is to upcase the argument; in the printed manual, to italicize it. For example,@refill @example To delete file @@var@{filename@}, type @@code@{rm @@var@{filename@}@}. @end example @noindent produces @quotation To delete file @var{filename}, type @code{rm @var{filename}}. @end quotation @noindent (Note that @code{@@var} may appear inside @code{@@code}, @code{@@samp}, @code{@@file}, etc.)@refill Write a metasyntactic variable all in lower case without spaces, and use hyphens to make it more readable. Thus, the illustration of how to begin a Texinfo manual looks like this:@refill @example @group \input texinfo @@setfilename @var{info-file-name} @@settitle @var{name-of-manual} @end group @end example In some documentation styles, metasyntactic variables are shown with angle brackets, for example:@refill @example @dots{}, type rm @end example @noindent However, that is not the style that Texinfo uses. (You can, of course, modify the sources to @TeX{} and the Info formatting commands to output the @code{<@dots{}>} format if you wish.)@refill @node file, dfn, var, Indicating @comment node-name, next, previous, up @subsection @code{@@file}@{@var{file-name}@} @findex file Use the @code{@@file} command to indicate text that is the name of a file, buffer, or directory, or is the name of a node in Info. You can also use the command for file name suffixes. Do not use @code{@@file} for symbols in a programming language; use @code{@@code}. Currently, @code{@@file} is equivalent to @code{@@samp} in its effects on the output. For example,@refill @example The @@file@{.el@} files are in the @@file@{/usr/local/emacs/lisp@} directory. @end example @noindent produces @quotation The @file{.el} files are in the @file{/usr/local/emacs/lisp} directory. @end quotation @node dfn, cite, file, Indicating @comment node-name, next, previous, up @subsection @code{@@dfn}@{@var{term}@} @findex dfn Use the @code{@@dfn} command to identify the introductory or defining use of a technical term. Use the command only in passages whose purpose is to introduce a term which will be used again or which the reader ought to know. Mere passing mention of a term for the first time does not deserve @code{@@dfn}. The command generates italics in the printed manual, and double quotation marks in the Info file. For example:@refill @example Getting rid of a file is called @@dfn@{deleting@} it. @end example @noindent produces @quotation Getting rid of a file is called @dfn{deleting} it. @end quotation As a general rule, a sentence containing the defining occurrence of a term should be a definition of the term. The sentence does not need to say explicitly that it is a definition, but it should contain the information of a definition---it should make the meaning clear. @node cite, , dfn, Indicating @comment node-name, next, previous, up @subsection @code{@@cite}@{@var{reference}@} @findex cite Use the @code{@@cite} command for the name of a book that lacks a companion Info file. The command produces italics in the printed manual, and quotation marks in the Info file.@refill (If a book is written in Texinfo, it is better to use a cross reference command since a reader can easily follow such a reference in Info. @xref{xref, , @code{@@xref}}.)@refill @ignore @c node ctrl, , cite, Indicating @comment node-name, next, previous, up @c subsection @code{@@ctrl}@{@var{ctrl-char}@} @findex ctrl The @code{@@ctrl} command is seldom used. It describes an @sc{ascii} control character by inserting the actual character into the Info file. Usually, in Texinfo, you talk what you type as keyboard entry by describing it with @code{@@kbd}: thus, @samp{@@kbd@{C-a@}} for @kbd{C-a}. Use @code{@@kbd} in this way when talking about a control character that is typed on the keyboard by the user. When talking about a control character appearing in a file or a string, do not use @code{@@kbd} since the control character is not typed. Also, do not use @samp{C-} but spell out @code{control-}, as in @samp{control-a}, to make it easier for a reader to understand.@refill @code{@@ctrl} is an idea from the beginnings of Texinfo which may not really fit in to the scheme of things. But there may be times when you want to use the command. The pattern is @code{@@ctrl@{@var{ch}@}}, where @var{ch} is an @sc{ascii} character whose control-equivalent is wanted. For example, to specify @samp{control-f}, you would enter@refill @example @@ctrl@{f@} @end example @noindent produces @quotation @ctrl{f} @end quotation In the Info file, this generates the specified control character, output literally into the file. This is done so a user can copy the specified control character (along with whatever else he or she wants) into another Emacs buffer and use it. Since the `control-h',`control-i', and `control-j' characters are formatting characters, they should not be indicated with @code{@@ctrl}.@refill In a printed manual, @code{@@ctrl} generates text to describe or identify that control character: an uparrow followed by the character @var{ch}.@refill @end ignore @node Emphasis, , Indicating, Marking Text @comment node-name, next, previous, up @section Emphasizing Text @cindex Emphasizing text Usually, Texinfo changes the font to mark words in the text according to what category the words belong to; an example is the @code{@@code} command. Most often, this is the best way to mark words. However, sometimes you will want to emphasize text without indicating a category. Texinfo has two commands to do this. Also, Texinfo has several commands that specify the font in which @TeX{} will typeset text. These commands have no affect on Info and only one of them, the @code{@@r} command, has any regular use.@refill @menu * emph & strong:: How to emphasize text in Texinfo. * Smallcaps:: How to use the small caps font. * Fonts:: Various font commands for printed output. @end menu @node emph & strong, Smallcaps, , Emphasis @comment node-name, next, previous, up @subsection @code{@@emph}@{@var{text}@} and @code{@@strong}@{@var{text}@} @cindex Emphasizing text, font for @findex emph @findex strong The @code{@@emph} and @code{@@strong} commands are for emphasis; @code{@@strong} is stronger. In printed output, @code{@@emph} produces @emph{italics} and @code{@@strong} produces @strong{bold}.@refill @example @group @exdent @r{For example,} @@quotation @@strong@{Caution:@} @@code@{rm * .[^.]*@} removes @@emph@{all@} files in the directory. @@end quotation @end group @end example @iftex @noindent produces the following in printed output: @quotation @strong{Caution}: @code{rm * .[^.]*} removes @emph{all} files in the directory. @end quotation @noindent and the following in Info: @end iftex @ifinfo @noindent produces: @end ifinfo @example *Caution*: `rm * .[^.]*' removes *all* files in the directory. @end example The @code{@@strong} command is seldom used except to mark what is, in effect, a typographical element, such as the word `Caution' in the preceding example.@footnote{Do not use @code{@@emph} or @code{@@strong} with the word @samp{Note}; Info will mistake the combination for a cross reference. Use a phrase such as @emph{Please note} or @emph{Caution} instead.}@refill In the Info file, both @code{@@emph} and @code{@@strong} put asterisks around the text.@refill @node Smallcaps, Fonts, emph & strong, Emphasis @subsection @code{@@sc}@{@var{text}@}: The Small Caps Font @cindex Small caps font @findex sc @r{(small caps font)} @iftex Use the @samp{@@sc} command to set text in the printed output in @sc{a small caps font} and set text in the Info file in upper case letters.@refill @end iftex @ifinfo Use the @samp{@@sc} command to set text in the printed output in a small caps font and set text in the Info file in upper case letters.@refill @end ifinfo Write the text between braces in lower case, like this:@refill @example The @@sc@{acm@} and @@sc@{ieee@} are technical societies. @end example @noindent This produces: @display The @sc{acm} and @sc{ieee} are technical societies. @end display @TeX{} typesets the small caps font in a manner that prevents the letters from `jumping out at you on the page'. This makes small caps text easier to read than text in all upper case.@refill @ifinfo If the text between the braces of an @code{@@sc} command is upper case, @TeX{} typesets the text in full-size capitals. Use full-size capitals sparingly.@refill @end ifinfo @iftex If the text between the braces of an @code{@@sc} command is upper case, @TeX{} typesets the text in @sc{FULL-SIZE CAPITALS}. Use full-size capitals sparingly.@refill @end iftex The Info formatting commands set all small caps text in upper case.@refill You may also use the small caps font for a jargon word such as @sc{ato} (a @sc{nasa} word meaning `abort to orbit').@refill There are subtleties to using the small caps font with a jargon word such as @sc{cdr}, a word used in Lisp programming. In this case, you should use the small caps font when the word refers to the second and subsequent elements of a list (the @sc{cdr} of the list), but you should use @samp{@@code} when the word refers to the Lisp function of the same spelling.@refill @node Fonts, , Smallcaps, Emphasis @comment node-name, next, previous, up @subsection Fonts for Printing, Not Info @cindex Fonts for printing, not for Info @findex i @r{(italic font)} @findex b @r{(bold font)} @findex t @r{(typewriter font)} @findex r @r{(Roman font)} Texinfo provides four font commands that specify font changes in the printed manual but have no effect in the Info file. @code{@@i} requests @i{italic} font (in some versions of @TeX{}, a slanted font is used), @code{@@b} requests @b{bold} face, @code{@@t} requests the @t{fixed-width}, typewriter-style font used by @code{@@code}, and @code{@@r} requests a @r{roman} font, which is the usual font in which text is printed. All four commands apply to an argument that follows, surrounded by braces.@refill Only the @code{@@r} command has much use: in example programs, you can use the @code{@@r} command to convert code comments from the fixed-width font to a roman font. This looks better in printed output.@refill For example, @example @group @@lisp (+ 2 2) ; @@r@{Add two plus two.@} @@end lisp @end group @end example @noindent produces @lisp (+ 2 2) ; @r{Add two plus two.} @end lisp If possible, you should avoid using the other three font commands. If you need to use one, it probably indicates a gap in the Texinfo language.@refill @node Quotations and Examples, Lists and Tables, Marking Text, Top @comment node-name, next, previous, up @chapter Quotations and Examples Quotations and examples are blocks of text consisting of one or more whole paragraphs that are set off from the bulk of the text and treated differently. They are usually indented.@refill In Texinfo, you always begin a quotation or example by writing an @@-command at the beginning of a line by itself, and end it by writing an @code{@@end} command that is also at the beginning of a line by itself. For instance, you begin an example by writing @code{@@example} by itself at the beginning of a line and end the example by writing @code{@@end example} on a line by itself, at the beginning of that line.@refill @findex end @menu * Block Enclosing Commands:: Use different constructs for different purposes. * quotation:: How to write a quotation. * example:: How to write an example in a fixed-width font. * noindent:: How to prevent paragraph indentation. * Lisp Example:: How to illustrate Lisp code. * smallexample & smalllisp:: Forms for the @code{@@smallbook} option. * display:: How to write an example in the current font. * format:: How to write an example that does not narrow the margins. * exdent:: How to undo the indentation of a line. * flushleft & flushright:: How to push text flushleft or flushright. * cartouche:: How to draw cartouches around examples. @end menu @node Block Enclosing Commands, quotation, , Quotations and Examples @section The Block Enclosing Commands There are a number of commands for quotations and examples:@refill @table @code @item @@quotation Indicate text that is quoted. The text is filled, indented, and printed in a roman font by default.@refill @item @@example Illustrate code, commands, and the like. The text is printed in a fixed-width font, and indented but not filled.@refill @item @@lisp Illustrate Lisp code. The text is printed in a fixed-width font, and indented but not filled.@refill @item @@smallexample Illustrate code, commands, and the like. Similar to @code{@@example}, except that in @TeX{} this command typesets text in a smaller font for the smaller @code{@@smallbook} format than for the 8.5 by 11 inch format.@refill @item @@smalllisp Illustrate Lisp code. Similar to @code{@@lisp}, except that in @TeX{} this command typesets text in a smaller font for the smaller @code{@@smallbook} format than for the 8.5 by 11 inch format.@refill @item @@display Display illustrative text. The text is indented but not filled, and no font is specified (so, by default, the font is roman).@refill @item @@format Print illustrative text. The text is not indented and not filled and no font is specified (so, by default, the font is roman).@refill @end table The @code{@@exdent} command is used within the above constructs to undo the indentation of a line. The @code{@@flushleft} and @code{@@flushright} commands are used to line up the left or right margins of unfilled text.@refill The @code{@@noindent} command may be used after one of the above constructs to prevent the following text from being indented as a new paragraph.@refill You can use the @code{@@cartouche} command within one of the above constructs to highlight the example or quotation by drawing a box with rounded corners around it. (The @code{@@cartouche} command affects only the printed manual; it has no effect in the Info file; see @ref{cartouche, , Drawing Cartouches Around Examples}.)@refill @node quotation, example, Block Enclosing Commands, Quotations and Examples @comment node-name, next, previous, up @section @code{@@quotation} @cindex Quotations @findex quotation The text of a quotation is processed normally except that@refill @itemize @bullet @item the margins are closer to the center of the page, so the whole of the quotation is indented;@refill @item the first lines of paragraphs are indented no more than other lines;@refill @item in the printed output, interline and interparagraph spacing is reduced.@refill @end itemize @quotation This is an example of text written between an @code{@@quotation} command and an @code{@@end quotation} command. An @code{@@quotation} command is most often used to indicate text that is excerpted from another (real or hypothetical) printed work.@refill @end quotation Write an @code{@@quotation} command as text on a line by itself. This line will disappear from the output. Mark the end of the quotation with a line beginning with and containing only @code{@@end quotation}. The @code{@@end quotation} line will likewise disappear from the output. Thus, the input@refill @example @@quotation This is a foo. @@end quotation @end example @noindent produces @quotation This is a foo. @end quotation @node example, noindent, quotation, Quotations and Examples @comment node-name, next, previous, up @section @code{@@example} @cindex Examples, formatting them @cindex Formatting examples @findex example The @code{@@example} command is used to indicate an example that is not part of the running text, such as computer input or output.@refill @example @group This is an example of text written between an @code{@@example} command and an @code{@@end example}command. The text is indented but not filled. @end group @group In the printed manual, the text is typeset in a fixed-width font, and extra spaces and blank lines are significant. In the Info file, an analogous result is obtained by indenting each line with five spaces. @end group @end example Write an @code{@@example} command at the beginning a line by itself. This line will disappear from the output. Mark the end of the example with an @code{@@end example} command, also written at the beginning a line by itself. The @code{@@end example} will disappear from the output.@refill For example,@refill @example @@example mv foo bar @@end example @end example @noindent produces @example mv foo bar @end example Since the lines containing @code{@@example} and @code{@@end example} will disappear, you should put a blank line before the @code{@@example} and another blank line after the @code{@@end example}. (Remember that blank lines between the beginning @code{@@example} and the ending @code{@@end example} will appear in the output.)@refill @quotation @strong{Caution:} Do not use tabs in lines of an example (or anywhere else in Texinfo, for that matter)! @TeX{} treats tabs like single spaces, and that is not what they look like. This is a problem with @TeX{}. (If necessary, in Emacs, you can use @kbd{M-x untabify} to convert tabs in a region to multiple spaces.)@refill @end quotation Examples are often, logically speaking, ``in the middle'' of a paragraph, and the text continues after an example should not be indented. The @code{@@noindent} command prevents a piece of text from being indented as if it were a new paragraph. @ifinfo (@xref{noindent}.) @end ifinfo (The @code{@@code} command is used for examples of code that are embedded within sentences, not set off from preceding and following text. @xref{code, , @code{@@code}}.) @node noindent, Lisp Example, example, Quotations and Examples @comment node-name, next, previous, up @section @code{@@noindent} @findex noindent If you have text following an @code{@@example} or other similar inclusion that reads as a continuation of the text before the @code{@@example}, it is good to prevent this text from being indented as a new paragraph. To accomplish this, write @code{@@noindent} at the beginning of a line by itself preceding the continuation text. For example:@refill @example @group @@example This is an example @@end example @@noindent This line is not indented. As you can see, the beginning of the line is fully flush left with the line that follows after it. (This whole example is between @@code@{@@@@display@} and @@code@{@@@@end display@}.) @end group @end example @noindent produces @display @example This is an example @end example @tex % Remove extra vskip; this is a kludge to counter the effect of display \vskip-3.5\baselineskip @end tex @noindent This line is not indented. As you can see, the beginning of the line is fully flush left with the line that follows after it. (This whole example is between @code{@@display} and @code{@@end display}.) @end display To adjust the number of blank lines properly in the Info file output, remember that the line containing @code{@@noindent} does not generate a blank line, and neither does the @code{@@end example} line.@refill In the Texinfo source file for this manual, each line that says `produces' is preceded by a line containing @code{@@noindent}.@refill Do not put braces after an @code{@@noindent} command; they are not necessary, since @code{@@noindent} is a command used outside of paragraphs (@pxref{Command Syntax}).@refill @node Lisp Example, smallexample & smalllisp, noindent, Quotations and Examples @comment node-name, next, previous, up @section @code{@@lisp} @cindex Lisp example @findex lisp The @code{@@lisp} command is used for Lisp code. It is synonymous with the @code{@@example} command. @lisp This is an example of text written between an @code{@@lisp} command and an @code{@@end lisp} command. @end lisp Use @code{@@lisp} instead of @code{@@example} so as to preserve information regarding the nature of the example. This is useful, for example, if you write a function that evaluates only and all the Lisp code in a Texinfo file. Then you can use the Texinfo file as a Lisp library.@footnote{It would be straightforward to extend Texinfo to work in a similar fashion for C, @sc{fortran}, or other languages.}@refill Mark the end of @code{@@lisp} with @code{@@end lisp} on a line by itself.@refill @node smallexample & smalllisp, display, Lisp Example, Quotations and Examples @comment node-name, next, previous, up @section @code{@@smallexample} and @code{@@smalllisp} @cindex Small book example @cindex Example for a small book @cindex Lisp example for a small book @findex smallexample @findex smalllisp In addition to the regular @code{@@example} and @code{@@lisp} commands, Texinfo has two other ``example-style'' commands. These are the @code{@@smallexample} and @code{@@smalllisp} commands. Both these commands are designed for use with the @code{@@smallbook} command that causes @TeX{} to produce a printed manual in a 7 by 9.25 inch format rather than the regular 8.5 by 11 inch format.@refill In @TeX{}, the @code{@@smallexample} and @code{@@smalllisp} commands typeset text in a smaller font for the smaller @code{@@smallbook} format than for the 8.5 by 11 inch format. Consequently, many examples containing long lines fit in a narrower, @code{@@smallbook} page without needing to be shortened. Both commands typeset in the normal font size when you format for the 8.5 by 11 inch size; indeed, in this situation, the @code{@@smallexample} and @code{@@smalllisp} commands are defined to be the @code{@@example} and @code{@@lisp} commands.@refill In Info, the @code{@@smallexample} and @code{@@smalllisp} commands are equivalent to the @code{@@example} and @code{@@lisp} commands, and work exactly the same.@refill Mark the end of @code{@@smallexample} or @code{@@smalllisp} with @code{@@end smallexample} or @code{@@end smalllisp}, respectively.@refill @iftex Here is an example written in the small font used by the @code{@@smallexample} and @code{@@smalllisp} commands: @display @tex % Remove extra vskip; this is a kludge to counter the effect of display \vskip-3\baselineskip {\ninett \dots{} to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things.} @end tex @end display @end iftex @ifinfo @smallexample This is an example of text written between @code{@@smallexample} and @code{@@end smallexample}. In Info and in an 8.5 by 11 inch manual, this text appears in its normal size; but in a 7 by 9.25 inch manual, this text appears in a smaller font. @end smallexample @end ifinfo The @code{@@smallexample} and @code{@@smalllisp} commands make it easier to prepare smaller format manuals without forcing you to edit examples by hand to fit them onto narrower pages.@refill @xref{smallbook, , Printing ``Small'' Books}, for more information about the @code{@@smallbook} command. @node display, format, smallexample & smalllisp, Quotations and Examples @comment node-name, next, previous, up @section @code{@@display} @cindex Display formatting @findex display The @code{@@display} command begins a kind of example. It is like the @code{@@example} command except that, in a printed manual, @code{@@display} does not select the fixed-width font. In fact, it does not specify the font at all, so that the text appears in the same font it would have appeared in without the @code{@@display} command.@refill @display This is an example of text written between an @code{@@display} command and an @code{@@end display} command. The @code{@@display} command indents the text, but does not fill it. @end display @node format, exdent, display, Quotations and Examples @comment node-name, next, previous, up @section @code{@@format} @findex format The @code{@@format} command is similar to @code{@@example} except that, in the printed manual, @code{@@format} does not select the fixed-width font and does not narrow the margins.@refill @format This is an example of text written between an @code{@@format} command and an @code{@@end format} command. As you can see from this example, the @code{@@format} command does not fill the text. @end format @node exdent, flushleft & flushright, format, Quotations and Examples @section @code{@@exdent}: Undoing a Line's Indentation @cindex Indentation undoing @findex exdent The @code{@@exdent} command removes any indentation a line might have. The command is written at the beginning of a line and applies only to the text that follows the command that is on the same line. Do not use braces around the text. In a printed manual, the text on an @code{@@exdent} line is printed in the roman font.@refill @code{@@exdent} is usually used within examples. Thus,@refill @example @group @@example This line follows an @@@@example command. @@exdent This line is exdented. This line follows the exdented line. The @@@@end example comes on the next line. @@end group @end group @end example @noindent produces @example @group This line follows an @@example command. @exdent This line is exdented. This line follows the exdented line. The @@end example comes on the next line. @end group @end example In practice, the @code{@@exdent} command is rarely used. Usually, you un-indent text by ending the example and returning the page to its normal width.@refill @node flushleft & flushright, cartouche, exdent, Quotations and Examples @section @code{@@flushleft} and @code{@@flushright} @findex flushleft @findex flushright The @code{@@flushleft} and @code{@@flushright} commands line up the ends of lines on the left and right margins of a page, but do not fill the text. The commands are written on lines of their own, without braces. The @code{@@flushleft} and @code{@@flushright} commands are ended by @code{@@end flushleft} and @code{@@end flushright} commands on lines of their own.@refill For example, @example @group @@flushleft This text is written flushleft. @@end flushleft @end group @end example @noindent produces @quotation @flushleft This text is written flushleft. @end flushleft @end quotation @noindent Flushright produces the type of indentation often used in the return address of letters.@refill @example @group @noindent @exdent @r{For example,} @@flushright Here is an example of text written flushright. The @@code@{@@flushright@} command right justifies every line but leaves the left end ragged. @@end flushright @end group @end example @noindent produces @flushright Here is an example of text written flushright. The @code{@@flushright} command right justifies every line but leaves the left end ragged. @end flushright @node cartouche, , flushleft & flushright, Quotations and Examples @section Drawing Cartouches Around Examples @findex cartouche @cindex Box with rounded corners In a printed manual, the @code{@@cartouche} command draws a box with rounded corners around its contents. You can use this command to further highlight an example or quotation. For instance, you could write a manual in which one type of example is surrounded by a cartouche for emphasis.@refill The @code{@@cartouche} command affects only the printed manual; it has no effect in the Info file.@refill For example, @example @group @@example @@cartouche % pwd /usr/local/lib/emacs/info @@end cartouche @@end group @end group @end example @noindent surrounds the two-line example with a box with rounded corners, in the printed manual. @node Lists and Tables, Indices, Quotations and Examples, Top @comment node-name, next, previous, up @chapter Making Lists and Tables @cindex Making lists and tables @cindex Lists and tables, making them @cindex Tables and lists, making them Texinfo has several ways of making lists and two-column tables. Lists can be bulleted or numbered, while two-column tables can highlight the items in the first column.@refill @menu * Introducing Lists:: Texinfo formats lists for you. * itemize:: How to construct a simple list. * enumerate:: How to construct a numbered list. * Two-column Tables:: How to construct a two-column table. @end menu @ifinfo @node Introducing Lists, itemize, , Lists and Tables @heading Introducing Lists @end ifinfo Texinfo automatically indents the text in lists or tables, and numbers an enumerated list. This last feature is useful if you modify the list, since you do not need to renumber it yourself.@refill Numbered lists and tables begin with the appropriate @@-command at the beginning of a line, and end with the corresponding @code{@@end} command on a line by itself. The table and itemized-list commands also require that you write formatting information on the same line as the beginning @@-command.@refill Begin an enumerated list, for example, with an @code{@@enumerate} command and end the list with an @code{@@end enumerate} command. Begin an itemized list with an @code{@@itemize} command, followed on the same line by a formatting command such as @code{@@bullet}, and end the list with an @code{@@end itemize} command.@refill @findex end Precede each element of a list with an @code{@@item} command.@refill @sp 1 @noindent Here is an itemized list of the different kinds of table and lists:@refill @itemize @bullet @item Itemized lists with and without bullets. @item Enumerated lists, using numbers or letters. @item Two-column tables with highlighting. @end itemize @sp 1 @noindent Here is an enumerated list with the same items:@refill @enumerate @item Itemized lists with and without bullets. @item Enumerated lists, using numbers or letters. @item Two-column tables with highlighting. @end enumerate @sp 1 @noindent And here is a two-column table with the same items and their @w{@@-commands}:@refill @table @code @item @@itemize Itemized lists with and without bullets. @item @@enumerate Enumerated lists, using numbers or letters. @item @@table @itemx @@ftable @itemx @@vtable Two-column tables with highlighting. @end table @node itemize, enumerate, Introducing Lists, Lists and Tables @comment node-name, next, previous, up @section Making an Itemized List @cindex Itemization @findex itemize The @code{@@itemize} command is used to produce sequences of indented paragraphs, with a bullet or other mark inside the left margin at the beginning of each paragraph for which such a mark is desired.@refill Begin an itemized list by writing @code{@@itemize} at the beginning of a line. Follow the command, on the same line, with a character or a Texinfo command that generates a mark. Usually, you will write @code{@@bullet} after @code{@@itemize}, but you can use @code{@@minus}, or any character or any special symbol that results in a single character in the Info file. (When you write @code{@@bullet} or @code{@@minus} after an @code{@@itemize} command, you may omit the @samp{@{@}}.)@refill Write the text of the indented paragraphs themselves after the @code{@@itemize}, up to another line that says @code{@@end itemize}.@refill Before each paragraph for which a mark in the margin is desired, write a line that says just @code{@@item}. Do not write any other text on this line.@refill @findex item Usually, you should put a blank line before an @code{@@item}. This puts a blank line in the Info file. (@TeX{} inserts the proper interline whitespace in either case.) Except when the entries are very brief, these blank lines make the list look better.@refill Here is an example of the use of @code{@@itemize}, followed by the output it produces. Note that @code{@@bullet} produces an @samp{*} in Info and a round dot in @TeX{}.@refill @example @group @@itemize @@bullet @@item Some text for foo. @@item Some text for bar. @@end itemize @end group @end example @noindent This produces: @quotation @itemize @bullet @item Some text for foo. @item Some text for bar. @end itemize @end quotation Itemized lists may be embedded within other itemized lists. Here is a list marked with dashes embedded in a list marked with bullets:@refill @example @group @@itemize @@bullet @@item First item. @@itemize @@minus @@item Inner item. @@item Second inner item. @@end itemize @@item Second outer item. @@end itemize @end group @end example @noindent This produces: @quotation @itemize @bullet @item First item. @itemize @minus @item Inner item. @item Second inner item. @end itemize @item Second outer item. @end itemize @end quotation @node enumerate, Two-column Tables, itemize, Lists and Tables @comment node-name, next, previous, up @section Making a Numbered or Lettered List @cindex Enumeration @findex enumerate @code{@@enumerate} is like @code{@@itemize} except that the marks in the left margin contain successive integers or letters. (@xref{itemize, , @code{@@itemize}}.)@refill Write the @code{@@enumerate} command at the beginning of a line. The command does not require an argument, but accepts either a number or a letter as an option. Without an argument, @code{@@enumerate} starts the list with the number 1. With a numeric argument, such as 3, the command starts the list with that number. With an upper or lower case letter, such as @kbd{a} or @kbd{A}, the command starts the list with that letter.@refill Write the text of the enumerated list in the same way you write an itemized list: put @code{@@item} on a line of its own before the start of each paragraph that you want enumerated. Do not write any other text on the line beginning with @code{@@item}.@refill You should put a blank line between entries in the list. This generally makes it easier to read the Info file.@refill Here is an example of @code{@@enumerate} without an argument:@refill @example @group @@enumerate @@item Underlying causes. @@item Proximate causes. @@end enumerate @end group @end example @noindent This produces: @enumerate @item Underlying causes. @item Proximate causes. @end enumerate @sp 1 Here is an example with an argument of @kbd{3}:@refill @sp 1 @example @group @@enumerate 3 @@item Predisposing causes. @@item Precipitating causes. @@item Perpetuating causes. @@end enumerate @end group @end example @noindent This produces: @enumerate 3 @item Predisposing causes. @item Precipitating causes. @item Perpetuating causes. @end enumerate @sp 1 Here is a brief summary of the alternatives. The summary is constructed using @code{@@enumerate} with an argument of @kbd{a}.@refill @sp 1 @enumerate a @item @code{@@enumerate} Without an argument, produce a numbered list, starting with the number 1.@refill @item @code{@@enumerate @var{positive-integer}} With a (positive) numeric argument, start a numbered list with that number. You can use this to continue a list that you interrupted with other text.@refill @item @code{@@enumerate @var{upper-case-letter}} With an upper case letter as argument, start a list in which each item is marked by a letter, beginning with that upper case letter.@refill @item @code{@@enumerate @var{lower-case-letter}} With a lower case letter as argument, start a list in which each item is marked by a letter, beginning with that lower case letter.@refill @end enumerate You can also nest enumerated lists, as in an outline.@refill @node Two-column Tables, , enumerate, Lists and Tables @comment node-name, next, previous, up @section Making a Two-column Table @cindex Tables, making two-column @findex table @code{@@table} is similar to @code{@@itemize}, but the command allows you to specify a name or heading line for each item. (@xref{itemize, , @code{@@itemize}}.) The @code{@@table} command is used to produce two-column tables, and is especially useful for glossaries and explanatory exhibits.@refill @menu * table:: How to construct a two-column table. * ftable vtable:: How to construct a two-column table with automatic indexing. * itemx:: How to put more entries in the first column. @end menu @ifinfo @node table, ftable vtable, , Two-column Tables @subheading Using the @code{@@table} Command Use the @code{@@table} command to produce two-column tables.@refill @end ifinfo Write the @code{@@table} command at the beginning of a line and follow it on the same line with an argument that is a Texinfo command such as @code{@@code}, @code{@@samp}, @code{@@var}, or @code{@@kbd}. Although these commands are usually followed by arguments in braces, in this case you use the command name without an argument because @code{@@item} will supply the argument. This command will be applied to the text that goes into the first column of each item and determines how it will be highlighted. For example, @code{@@samp} will cause the text in the first column to be highlighted with an @code{@@samp} command.@refill You may also choose to use the @code{@@asis} command as an argument to @code{@@table}. @code{@@asis} is a command that does nothing; if you use this command after @code{@@table}, @TeX{} and the Info formatting commands output the first column entries without added highlighting, (`as is').@refill (The @code{@@table} command may work with other commands besides those listed here. However, you can only use commands that normally take arguments in braces.)@refill Begin each table entry with an @code{@@item} command at the beginning of a line. Write the first column text on the same line as the @code{@@item} command. Write the second column text on the line following the @code{@@item} line and on subsequent lines. (You do not need to type anything for an empty second column entry.) You may write as many lines of supporting text as you wish, even several paragraphs. But only text on the same line as the @code{@@item} will be placed in the first column.@refill @findex item Normally, you should put a blank line before an @code{@@item} line. This puts a blank like in the Info file. Except when the entries are very brief, a blank line looks better.@refill The following table, for example, highlights the text in the first column with an @code{@@samp} command:@refill @example @group @@table @@samp @@item foo This is the text for @@samp@{foo@}. @@item bar Text for @@samp@{bar@}. @@end table @end group @end example @noindent This produces: @table @samp @item foo This is the text for @samp{foo}. @item bar Text for @samp{bar}. @end table If you want to list two or more named items with a single block of text, use the @code{@@itemx} command. (@xref{itemx, , @code{@@itemx}}.)@refill @node ftable vtable, itemx, table, Two-column Tables @comment node-name, next, previous, up @subsection @code{@@ftable} and @code{@@vtable} @cindex Tables with indexes @cindex Indexing table entries automatically @findex ftable @findex vtable The @code{@@ftable} and @code{@@vtable} commands are the same as the @code{@@table} command except that @code{@@ftable} automatically enters each of the items in the first column of the table into the index of functions and @code{@@vtable} automatically enters each of the items in the first column of the table into the index of variables. This simplifies the task of creating indices. Only the items on the same line as the @code{@@item} commands are indexed, and they are indexed in exactly the form that they appear on that line. @xref{Indices, , Creating Indices}, for more information about indices.@refill Begin a two-column table using @code{@@ftable} or @code{@@vtable} by writing the @@-command at the beginning of a line, followed on the same line by an argument that is a Texinfo command such as @code{@@code}, exactly as you would for an @code{@@table} command; and end the table with an @code{@@end ftable} or @code{@@end vtable} command on a line by itself. @node itemx, , ftable vtable, Two-column Tables @comment node-name, next, previous, up @subsection @code{@@itemx} @cindex Two named items for @code{@@table} @findex itemx Use the @code{@@itemx} command inside a table when you have two or more first column entries for the same item, each of which should appear on a line of its own. Use @code{@@itemx} for all but the first entry. The @code{@@itemx} command works exactly like @code{@@item} except that it does not generate extra vertical space above the first column text. For example,@refill @example @group @@table @@code @@item upcase @@itemx downcase These two functions accept a character or a string as argument, and return the corresponding upper case (lower case) character or string.@@refill @@end table @end group @end example @noindent produces @table @code @item upcase @itemx downcase These two functions accept a character or a string as argument, and return the corresponding upper case (lower case) character or string.@refill @end table @noindent (Note also that this example illustrates multi-line supporting text in a two-column table.)@refill @node Indices, Insertions, Lists and Tables, Top @comment node-name, next, previous, up @chapter Creating Indices @cindex Indices @cindex Creating indices Using Texinfo, you can generate indices without having to sort and collate entries manually. In an index, the entries are listed in alphabetical order, together with information on how to find the discussion of each entry. In a printed manual, this information consists of page numbers. In an Info file, this information is a menu entry leading to the first node referenced.@refill Texinfo provides several predefined kinds of index: an index for functions, an index for variables, an index for concepts, and so on. You can combine indices or use them for other than their canonical purpose. If you wish, you can define your own indices.@refill @menu * Index Entries:: Choose different words for index entries. * Predefined Indices:: Use different indices for different kinds of entry. * Indexing Commands:: How to make an index entry. * Combining Indices:: How to combine indices. * New Indices:: How to define your own indices. @end menu @node Index Entries, Predefined Indices, , Indices @comment node-name, next, previous, up @section Making Index Entries @cindex Index entries, making @cindex Entries, making index When you are making index entries, it is good practice to think of the different ways people may look for something. Different people @emph{do not} think of the same words when they look something up. A helpful index will have items indexed under all the different words that people may use. For example, one reader may think it obvious that the two-letter names for indices should be listed under ``Indices, two-letter names'', since the word ``Index'' is the general concept. But another reader may remember the specific concept of two-letter names and search for the entry listed as ``Two letter names for indices''. A good index will have both entries and will help both readers.@refill Like typesetting, the construction of an index is a highly skilled, professional art, the subtleties of which are not appreciated until you need to do it yourself.@refill @xref{Printing Indices & Menus}, for information about printing an index at the end of a book or creating an index menu in an Info file.@refill @node Predefined Indices, Indexing Commands, Index Entries, Indices @comment node-name, next, previous, up @section Predefined Indices Texinfo provides six predefined indices:@refill @itemize @bullet @item A @dfn{concept index} listing concepts that are discussed.@refill @item A @dfn{function index} listing functions (such as entry points of libraries).@refill @item A @dfn{variables index} listing variables (such as global variables of libraries).@refill @item A @dfn{keystroke index} listing keyboard commands.@refill @item A @dfn{program index} listing names of programs.@refill @item A @dfn{data type index} listing data types (such as structures defined in header files).@refill @end itemize @noindent Not every manual needs all of these, and most manuals use two or three of them. This manual has two indices: a concept index and an @@-command index (that is actually the function index but is called a command index in the chapter heading). Two or more indices can be combined into one using the @code{@@synindex} or @code{@@syncodeindex} commands. @xref{Combining Indices}.@refill @node Indexing Commands, Combining Indices, Predefined Indices, Indices @comment node-name, next, previous, up @section Defining the Entries of an Index @cindex Defining indexing entries @cindex Index entries @cindex Entries for an index @cindex Specifying index entries @cindex Creating index entries The data to make an index come from many individual indexing commands scattered throughout the Texinfo source file. Each command says to add one entry to a particular index; after formatting, the index will give the current page number or node name as the reference.@refill An index entry consists of an indexing command at the beginning of a line followed, on the rest of the line, by the entry.@refill For example, this section begins with the following five entries for the concept index:@refill @example @@cindex Defining indexing entries @@cindex Index entries @@cindex Entries for an index @@cindex Specifying index entries @@cindex Creating index entries @end example Each predefined index has its own indexing command---@code{@@cindex} for the concept index, @code{@@findex} for the function index, and so on.@refill @cindex Capitalizing index entries @cindex Index entry capitalization The usual convention is to capitalize the first word of each index entry, unless that word is the name of a function, variable, or other such entity that should not be capitalized. Thus, if you are documenting Emacs Lisp, you should usually capitalize entries in the concept index, but not those in the function index. However, if your concept index entries are consistently short (one or two words each) it may look better for each regular entry to start with a lower case letter. Whichever convention you adapt, please be consistent! By default, entries for a concept index are printed in a small roman font and entries for the other indices are printed in a small @code{@@code} font. You may change the way part of an entry is printed with the usual Texinfo commands, such as @code{@@file} for file names and @code{@@emph} for emphasis (@pxref{Marking Text}).@refill @cindex Index font types The six indexing commands for predefined indices are: @table @code @item @@cindex @var{concept} @findex cindex Make an entry in the concept index for @var{concept}.@refill @item @@findex @var{function} @findex findex Make an entry in the function index for @var{function}.@refill @item @@vindex @var{variable} @findex vindex Make an entry in the variable index for @var{variable}.@refill @item @@kindex @var{keystroke} @findex kindex Make an entry in the key index for @var{keystroke}.@refill @item @@pindex @var{program} @findex pindex Make an entry in the program index for @var{program}.@refill @item @@tindex @var{data type} @findex tindex Make an entry in the data type index for @var{data type}.@refill @end table @quotation @strong{Caution:} Do not use a colon in an index entry. In Info, a colon separates the menu entry name from the node name. An extra colon confuses Info. @xref{Writing a Menu Entry, , How to Write a Menu Entry}, for more information about the structure of a menu entry.@refill @end quotation If you write several identical index entries in different places in a Texinfo file, the index in the printed manual will list all the pages to which those entries refer. However, the index in the Info file will list @strong{only} the node that references the @strong{first} of those index entries. Therefore, it is best to write indices in which each entry refers to only one place in the Texinfo file. Fortunately, this constraint is a feature rather than a loss since it means that the index will be easy to use. Otherwise, you could create an index that lists several pages for one entry and your reader would not know to which page to turn. If you have two identical entries for one topic, change the topics slightly, or qualify them to indicate the difference.@refill You are not actually required to use the predefined indices for their canonical purposes. For example, suppose you wish to index some C preprocessor macros. You could put them in the function index along with actual functions, just by writing @code{@@findex} commands for them; then, when you print the ``Function Index'' as an unnumbered chapter, you could give it the title `Function and Macro Index' and all will be consistent for the reader. Or you could put the macros in with the data types by writing @code{@@tindex} commands for them, and give that index a suitable title so the reader will understand. (@xref{Printing Indices & Menus}.)@refill @node Combining Indices, New Indices, Indexing Commands, Indices @comment node-name, next, previous, up @section Combining Indices @cindex Combining indices @cindex Indices, combining them Sometimes you will want to combine two disparate indices such as functions and concepts, perhaps because you have few enough of one of them that a separate index for them would look silly.@refill You could put functions into the concept index by writing @code{@@cindex} commands for them instead of @code{@@findex} commands, and produce a consistent manual by printing the concept index with the title `Function and Concept Index' and not printing the `Function Index' at all; but this is not a robust procedure. It works only if your document is never included as part of another document that is designed to have a separate function index; if your document were to be included with such a document, the functions from your document and those from the other would not end up together. Also, to make your function names appear in the right font in the concept index, you would need to enclose every one of them between the braces of @code{@@code}.@refill @menu * syncodeindex:: How to merge two indices, using @code{@@code} font for the merged-from index. * synindex:: How to merge two indices, using the default font of the merged-to index. @end menu @node syncodeindex, synindex, , Combining Indices @subsubsection @code{@@syncodeindex} @findex syncodeindex When you want to combine functions and concepts into one index, you should index the functions with @code{@@findex} and index the concepts with @code{@@cindex}, and use the @code{@@syncodeindex} command to redirect the function index entries into the concept index.@refill @findex syncodeindex The @code{@@syncodeindex} command takes two arguments; they are the name of the index to redirect, and the name of the index to redirect it to. The template looks like this:@refill @example @@syncodeindex @var{from} @var{to} @end example For this purpose, the indices are given two-letter names:@refill @cindex Two letter names for indices @cindex Indices, two letter names @cindex Names for indices @table @samp @item cp concept index @item fn function index @item vr variable index @item ky key index @item pg program index @item tp data type index @end table Write an @code{@@syncodeindex} command before or shortly after the end-of-header line at the beginning of a Texinfo file. For example, to merge a function index with a concept index, write the following:@refill @example @@syncodeindex fn cp @end example @noindent This will cause all entries designated for the function index to merge in with the concept index instead.@refill To merge both a variables index and a function index into a concept index, write the following:@refill @example @group @@syncodeindex vr cp @@syncodeindex fn cp @end group @end example @cindex Fonts for indices The @code{@@syncodeindex} command puts all the entries from the `from' index (the redirected index) into the @code{@@code} font, overriding whatever default font is used by the index to which the entries are now directed. This way, if you direct function names from a function index into a concept index, all the function names are printed in the @code{@@code} font as you would expect.@refill @node synindex, , syncodeindex, Combining Indices @subsubsection @code{@@synindex} @findex synindex The @code{@@synindex} command is nearly the same as the @code{@@syncodeindex} command, except that it does not put the `from' index entries into the @code{@@code} font; rather it puts them in the roman font. Thus, you use @code{@@synindex} when you merge a concept index into a function index.@refill @xref{Printing Indices & Menus}, for information about printing an index at the end of a book or creating an index menu in an Info file.@refill @node New Indices, , Combining Indices, Indices @section Defining New Indices @cindex Defining new indices @cindex Indices, defining new @cindex New index defining @findex defindex @findex defcodeindex In addition to the predefined indices, you may use the @code{@@defindex} and @code{@@defcodeindex} commands to define new indices. These commands create new indexing @@-commands with which you mark index entries. The @code{@@defindex }command is used like this:@refill @example @@defindex @var{name} @end example The name of an index should be a two letter word, such as @samp{au}. For example:@refill @example @@defindex au @end example This defines a new index, called the @samp{au} index. At the same time, it creates a new indexing command, @code{@@auindex}, that you can use to make index entries. Use the new indexing command just as you would use a predefined indexing command.@refill For example, here is a section heading followed by a concept index entry and two @samp{au} index entries.@refill @example @@section Cognitive Semantics @@cindex kinesthetic image schemas @@auindex Johnson, Mark @@auindex Lakoff, George @end example @noindent (Evidently, @samp{au} serves here as an abbreviation for ``author''.) Texinfo constructs the new indexing command by concatenating the name of the index with @samp{index}; thus, defining an @samp{au} index leads to the automatic creation of an @code{@@auindex} command.@refill Use the @code{@@printindex} command to print the index, as you do with the predefined indices. For example:@refill @example @group @@node Author Index, Subject Index, , Top @@unnumbered Author Index @@printindex au @end group @end example The @code{@@defcodeindex} is like the @code{@@defindex} command, except that, in the printed output, it prints entries in an @code{@@code} font instead of a roman font. Thus, it parallels the @code{@@findex} command rather than the @code{@@cindex} command.@refill You should define new indices within or right after the end-of-header line of a Texinfo file, before any @code{@@synindex} or @code{@@syncodeindex} commands (@pxref{Header}).@refill @node Insertions, Glyphs, Indices, Top @comment node-name, next, previous, up @chapter Special Insertions @cindex Inserting special characters and symbols @cindex Special insertions Texinfo provides several commands for formatting dimensions, for inserting single characters that have special meaning in Texinfo, such as braces, and for inserting special graphic symbols that do not correspond to characters, such as dots and bullets.@refill @iftex These are: @itemize @bullet @item Braces, @samp{@@} and periods. @item Format a dimension, such as @samp{12@dmn{pt}}. @item Dots and bullets. @item The @TeX{} logo and the copyright symbol. @item A minus sign. @end itemize @end iftex @menu * Braces Atsigns Periods:: How to insert braces, @samp{@@} and periods. * dmn:: How to format a dimension. * Dots Bullets:: How to insert dots and bullets. * TeX and copyright:: How to insert the @TeX{} logo and the copyright symbol. * minus:: How to insert a minus sign. @end menu @node Braces Atsigns Periods, dmn, , Insertions @comment node-name, next, previous, up @section Inserting @samp{@@}, Braces, and Periods @cindex Inserting @@, braces, and periods @cindex Braces, inserting @cindex Periods, inserting @cindex Single characters, commands to insert @cindex Commands to insert single characters @samp{@@} and curly braces are special characters in Texinfo. To insert these characters so they appear in text, you must put an @samp{@@} in front of these characters to prevent Texinfo from misinterpreting them.@refill Periods are also special. Depending on whether the period is inside or at the end of a sentence, less or more space is inserted after a period in a typeset manual. Since it is not always possible for Texinfo to determine when a period ends a sentence and when it is used in an abbreviation, special commands are needed in some circumstances. (Usually, Texinfo can guess how to handle periods, so you do not need to use the special commands; you just enter a period as you would if you were using a typewriter, which means you put two spaces after the period, question mark, or exclamation mark that ends a sentence.)@refill Do not put braces after any of these commands; they are not necessary.@refill @menu * Inserting An Atsign:: * Inserting Braces:: How to insert @samp{@{} and @samp{@}} * Controlling Spacing:: How to insert the right amount of space after punctuation within a sentence. @end menu @node Inserting An Atsign, Inserting Braces, , Braces Atsigns Periods @comment node-name, next, previous, up @subsection Inserting @samp{@@} with @@@@ @findex @@ @r{(single @samp{@@})} @code{@@@@} stands for a single @samp{@@} in either printed or Info output.@refill Do not put braces after an @code{@@@@} command.@refill @node Inserting Braces, Controlling Spacing, Inserting An Atsign, Braces Atsigns Periods @comment node-name, next, previous, up @subsection Inserting @samp{@{} and @samp{@}}with @@@{ and @@@} @findex @{ @r{(single @samp{@{})} @findex @} @r{(single @samp{@}})} @code{@@@{} stands for a single @samp{@{} in either printed or Info output.@refill @code{@@@}} stands for a single @samp{@}} in either printed or Info output.@refill Do not put braces after either an @code{@@@{} or an @code{@@@}} command.@refill @node Controlling Spacing, , Inserting Braces, Braces Atsigns Periods @comment node-name, next, previous, up @subsection Spacing After Colons and Periods @findex : @r{(suppress widening)} Use the @code{@@:}@: command after a period, question mark, exclamation mark, or colon that should not be followed by extra space. For example, use @code{@@:}@: after periods that end abbreviations which are not at the ends of sentences. @code{@@:}@: has no effect on the Info file output.@refill For example,@refill @example The U.S.A.@@: is a continental nation. @end example @noindent produces @quotation The U.S.A.@: is a continental nation. @end quotation @findex . @r{(true end of sentence)} Use @code{@@.}@: instead of a period at the end of a sentence that ends with a single capital letter. Otherwise, @TeX{} will think the letter is an abbreviation and will not insert the correct end-of-sentence spacing. Here is an example:@refill @example Give it to X. and to Y@@. Give it to Z@@. Give it to X. and to Y. Give it to Z. @end example @noindent @ifinfo produces @end ifinfo @iftex If you look carefully at this printed output, you will see a little more whitespace after the Y in the first line than the Y in the second line.@refill @end iftex @quotation Give it to X. and to Y@. Give it to Z@.@* Give it to X. and to Y. Give it to Z. @end quotation In the Info file output, @code{@@.}@: is equivalent to a simple @samp{.}.@refill The meanings of @code{@@:}@: and @code{@@.}@: in Texinfo are designed to work well with the Emacs sentence motion commands. This made it necessary for them to be incompatible with some other formatting systems that use @@-commands.@refill Do not put braces after either an @code{@@:} or an @code{@@.} command.@refill @node dmn, Dots Bullets, Braces Atsigns Periods, Insertions @section @code{@@dmn}@{@var{dimension}@}: Format a Dimension @cindex Thin space between number, dimension @cindex Dimension formatting @cindex Format a dimension @findex dmn At times, you may want to write @samp{12@dmn{pt}} or @samp{8.5@dmn{in}} with little or no space between the number and the abbreviation for the dimension. You can use the @code{@@dmn} command to do this. On seeing the command, @TeX{} inserts just enough space for proper typesetting; the Info formatting commands insert no space at all, since the Info file does not require it.@refill To use the @code{@@dmn} command, write the number and then follow it immediately, with no intervening space, by @code{@@dmn}, and then by the dimension within braces.@refill @noindent For example,@refill @example A4 paper is 8.27@@dmn@{in@} wide. @end example @noindent produces @quotation A4 paper is 8.27@dmn{in} wide. @end quotation Not everyone uses this style. Instead of @w{@samp{8.27@dmn{in}}}, you may write @w{@samp{8.27 in.}} or @w{@samp{8.27 inches}}.@refill @node Dots Bullets, TeX and copyright, dmn, Insertions @comment node-name, next, previous, up @section Inserting Ellipsis, Dots, and Bullets @cindex Dots, inserting @cindex Bullets, inserting @cindex Ellipsis, inserting @cindex Inserting ellipsis @cindex Inserting dots @cindex Special typesetting commands @cindex Typesetting commands for dots, etc. An @dfn{ellipsis} (a line of dots) is not typeset as a string of periods, so a special command is used for ellipsis in Texinfo. The @code{@@bullet} command is special, too. Each of these commands is followed by a pair of braces, @samp{@{@}}, without any whitespace between the name of the command and the braces. (You need to use braces with these commands because you can use them next to other text; without the braces, the formatters would be confused. @xref{Command Syntax, , @@-Command Syntax}, for further information).@refill @menu * dots:: How to insert dots @dots{} * bullet:: How to insert a bullet. @end menu @node dots, bullet, , Dots Bullets @comment node-name, next, previous, up @subsection @code{@@dots}@{@} @findex dots @cindex Inserting dots @cindex Dots, inserting Use the @code{@@dots@{@}} command to generate an ellipsis, which is three dots in a row, appropriately spaced, like this: `@dots{}'. Do not simply write three periods in the input file; that would work for the Info file output, but would produce the wrong amount of space between the periods in the printed manual.@refill @iftex Here is an ellipsis: @dots{} Here are three periods in a row: ... In printed output, the three periods in a row are closer together than the dots in the ellipsis. @end iftex @node bullet, , dots, Dots Bullets @comment node-name, next, previous, up @subsection @code{@@bullet}@{@} @findex bullet Use the @code{@@bullet@{@}} command to generate a large round dot, or the closest possible thing to one. In Info, an asterisk is used.@refill Here is a bullet: @bullet{} When you use @code{@@bullet} in @code{@@itemize}, you do not need to type the braces, because @code{@@itemize} supplies them. @xref{itemize}.@refill @node TeX and copyright, minus, Dots Bullets, Insertions @comment node-name, next, previous, up @section Inserting @TeX{} and the Copyright Symbol The logo `@TeX{}' is typeset in a special fashion and it needs an @@-command. The copyright symbol, `@copyright{}', is also special. Each of these commands is followed by a pair of braces, @samp{@{@}}, without any whitespace between the name of the command and the braces.@refill @menu * tex:: How to insert the @TeX{} logo. * copyright symbol:: How to use @code{@@copyright}@{@}. @end menu @node tex, copyright symbol, , TeX and copyright @comment node-name, next, previous, up @subsection @code{@@TeX}@{@} @findex tex (command) Use the @code{@@TeX@{@}} command to generate `@TeX{}'. In a printed manual, this is a special logo that is different from three ordinary letters. In Info, it just looks like @samp{TeX}. The @code{@@TeX@{@}} command is unique among Texinfo commands in that the @key{T} and the @key{X} are in upper case.@refill @node copyright symbol, , tex, TeX and copyright @comment node-name, next, previous, up @subsection @code{@@copyright}@{@} @findex copyright Use the @code{@@copyright@{@}} command to generate `@copyright{}'. In a printed manual, this is a @samp{c} inside a circle, and in Info, this is @samp{(C)}.@refill @node minus, , TeX and copyright, Insertions @section @code{@@minus}@{@}: Inserting a Minus Sign @findex minus Use the @code{@@minus@{@}} command to generate a minus sign. In a fixed-width font, this is a single hyphen, but in a proportional font, the symbol is the customary length for a minus sign---a little longer than a hyphen.@refill You can compare the two forms: @display @samp{@minus{}} is a minus sign generated with @samp{@@minus@{@}}, `-' is a hyphen generated with the character @samp{-}. @end display @noindent In the fixed-width font used by Info, @code{@@minus@{@}} is the same as a hyphen.@refill You should not use @code{@@minus@{@}} inside @code{@@code} or @code{@@example} because the width distinction is not made in the fixed-width font they use.@refill When you use @code{@@minus} to specify the mark beginning each entry in an itemized list, you do not need to type the braces (@pxref{itemize}).@refill @node Glyphs, Breaks, Insertions, Top @comment node-name, next, previous, up @chapter Glyphs for Examples @cindex Glyphs In Texinfo, code is often illustrated in examples that are delimited by @code{@@example} and @code{@@end example}, or by @code{@@lisp} and @code{@@end lisp}. In such examples, you can indicate the results of evaluation or an expansion using @samp{@result{}} or @samp{@expansion{}}. Likewise, there are commands to insert glyphs to indicate printed output, error messages, equivalence of expressions, and the location of point.@refill The glyph-insertion commands do not need to be used within an example, but most often they are. Every glyph-insertion command is followed by a pair of left- and right-hand braces.@refill @menu * Glyphs Summary:: * result:: How to show the result of expression. * expansion:: How to indicate an expansion. * Print Glyph:: How to indicate printed output. * Error Glyph:: How to indicate an error message. * Equivalence:: How to indicate equivalence. * Point Glyph:: How to indicate the location of point. @end menu @node Glyphs Summary, result, , Glyphs @ifinfo @heading Glyphs Summary Here are the different glyph commands:@refill @end ifinfo @table @asis @item @result{} @code{@@result@{@}} points to the result of an expression.@refill @item @expansion{} @code{@@expansion@{@}} shows the results of a macro expansion.@refill @item @print{} @code{@@print@{@}} indicates printed output.@refill @item @error{} @code{@@error@{@}} indicates that the following text is an error message.@refill @item @equiv{} @code{@@equiv@{@}} indicates the exact equivalence of two forms.@refill @item @point{} @code{@@point@{@}} shows the location of point.@refill @end table @node result, expansion, Glyphs Summary, Glyphs @section @result{}: Indicating Evaluation @cindex Result of an expression @cindex Indicating evaluation @cindex Evaluation glyph @cindex Value of an expression, indicating Use the @code{@@result@{@}} command to indicate the result of evaluating an expression.@refill @iftex The @code{@@result@{@}} command is displayed as @samp{=>} in Info and as @samp{@result{}} in the printed output. @end iftex @ifinfo The @code{@@result@{@}} command is displayed as @samp{@result{}} in Info and as a double stemmed arrow in the printed output.@refill @end ifinfo Thus, the following, @lisp (cdr '(1 2 3)) @result{} (2 3) @end lisp @noindent may be read as ``@code{(cdr '(1 2 3))} evaluates to (2 3)''. @node expansion, Print Glyph, result, Glyphs @section @expansion{}: Indicating an Expansion @cindex Expansion, indicating it When an expression is a macro call, it expands into a new expression. You can indicate the result of the expansion with the @code{@@expansion@{@}} command.@refill @iftex The @code{@@expansion@{@}} command is displayed as @samp{==>} in Info and as @samp{@expansion{}} in the printed output. @end iftex @ifinfo The @code{@@expansion@{@}} command is displayed as @samp{@expansion{}} in Info and as a long arrow with a flat base in the printed output.@refill @end ifinfo For example, the following @example @group @@lisp (third '(a b c)) @@expansion@{@} (car (cdr (cdr '(a b c)))) @@result@{@} c @@end lisp @end group @end example @noindent produces @lisp @group (third '(a b c)) @expansion{} (car (cdr (cdr '(a b c)))) @result{} c @end group @end lisp @noindent which may be read as: @quotation @code{(third '(a b c))} expands to @code{(car (cdr (cdr '(a b c))))}; the result of evaluating the expression is @code{c}. @end quotation @noindent Often, as in this case, an example looks better if the @code{@@expansion@{@}} and @code{@@result@{@}} commands are indented five spaces.@refill @node Print Glyph, Error Glyph, expansion, Glyphs @section @print{}: Indicating Printed Output @cindex Printed output, indicating it Sometimes an expression will print output during its execution. You can indicate the printed output with the @code{@@print@{@}} command.@refill @iftex The @code{@@print@{@}} command is displayed as @samp{-|} in Info and as @samp{@print{}} in the printed output. @end iftex @ifinfo The @code{@@print@{@}} command is displayed as @samp{@print{}} in Info and similarly, as a horizontal dash butting against a vertical bar, in the printed output.@refill @end ifinfo In the following example, the printed text is indicated with @samp{@print{}}, and the value of the expression follows on the last line.@refill @lisp @group (progn (print 'foo) (print 'bar)) @print{} foo @print{} bar @result{} bar @end group @end lisp @noindent In a Texinfo source file, this example is written as follows: @lisp @group @@lisp (progn (print 'foo) (print 'bar)) @@print@{@} foo @@print@{@} bar @@result@{@} bar @@end lisp @end group @end lisp @node Error Glyph, Equivalence, Print Glyph, Glyphs @section @error{}: Indicating an Error Message @cindex Error message, indicating it A piece of code may cause an error when you evaluate it. You can designate the error message with the @code{@@error@{@}} command.@refill @iftex The @code{@@error@{@}} command is displayed as @samp{error-->} in Info and as @samp{@error{}} in the printed output. @end iftex @ifinfo The @code{@@error@{@}} command is displayed as @samp{@error{}} in Info and as the word `error' in a box in the printed output.@refill @end ifinfo Thus, @example @@lisp (+ 23 'x) @@error@{@} Wrong type argument: integer-or-marker-p, x @@end lisp @end example @noindent produces @lisp (+ 23 'x) @error{} Wrong type argument: integer-or-marker-p, x @end lisp @noindent This indicates that the following error message is printed when you evaluate the expression: @lisp Wrong type argument: integer-or-marker-p, x @end lisp Note that @samp{@error{}} itself is not part of the error message. @node Equivalence, Point Glyph, Error Glyph, Glyphs @section @equiv{}: Indicating Equivalence @cindex Equivalence, indicating it Sometimes two expressions produce identical results. You can indicate the exact equivalence of two forms with the @code{@@equiv@{@}} command.@refill @iftex The @code{@@equiv@{@}} command is displayed as @samp{==} in Info and as @samp{@equiv{}} in the printed output. @end iftex @ifinfo The @code{@@equiv@{@}} command is displayed as @samp{@equiv{}} in Info and as a three parallel horizontal lines in the printed output.@refill @end ifinfo Thus, @example @@lisp (make-sparse-keymap) @@equiv@{@} (list 'keymap) @@end lisp @end example @noindent produces @lisp (make-sparse-keymap) @equiv{} (list 'keymap) @end lisp @noindent This indicates that evaluating @code{(make-sparse-keymap)} produces identical results to evaluating @code{(list 'keymap)}. @node Point Glyph, , Equivalence, Glyphs @section Indicating Point in a Buffer @cindex Point, indicating it in a buffer Sometimes you need to show an example of text in an Emacs buffer. In such examples, the convention is to include the entire contents of the buffer in question between two lines of dashes containing the buffer name.@refill You can use the @samp{@@point@{@}} command to show the location of point in the text in the buffer. (The symbol for point, of course, is not part of the text in the buffer; it indicates the place @emph{between} two characters where point is located.)@refill @iftex The @code{@@point@{@}} command is displayed as @samp{-!-} in Info and as @samp{@point{}} in the printed output. @end iftex @ifinfo The @code{@@point@{@}} command is displayed as @samp{@point{}} in Info and as a small five pointed star in the printed output.@refill @end ifinfo The following example shows the contents of buffer @file{foo} before and after evaluating a Lisp command to insert the word @code{changed}.@refill @example @group ---------- Buffer: foo ---------- This is the @point{}contents of foo. ---------- Buffer: foo ---------- @end group @end example @example @group (insert "changed ") @result{} nil ---------- Buffer: foo ---------- This is the changed @point{}contents of foo. ---------- Buffer: foo ---------- @end group @end example In a Texinfo source file, the example is written like this:@refill @example @@example ---------- Buffer: foo ---------- This is the @@point@{@}contents of foo. ---------- Buffer: foo ---------- (insert "changed ") @@result@{@} nil ---------- Buffer: foo ---------- This is the changed @@point@{@}contents of foo. ---------- Buffer: foo ---------- @@end example @end example @node Breaks, Definition Commands, Glyphs, Top @comment node-name, next, previous, up @chapter Making and Preventing Breaks @cindex Making line and page breaks @cindex Preventing line and page breaks Usually, a Texinfo file is processed both by @TeX{} and by one of the Info formatting commands. Line, paragraph, or page breaks sometimes occur in the `wrong' place in one or other form of output. You must ensure that text looks right both in the printed manual and in the Info file.@refill For example, in a printed manual, page breaks may occur awkwardly in the middle of an example; to prevent this, you can hold text together using a grouping command that keeps the text from being split across two pages. Conversely, you may want to force a page break where none would occur normally. Fortunately, problems like these do not often arise. When they do, use the break, break prevention, or pagination commands.@refill @menu * Break Commands:: Cause and prevent splits. * Line Breaks:: How to force a single line to use two lines. * w:: How to prevent unwanted line breaks. * sp:: How to insert blank lines. * page:: How to force the start of a new page. * group:: How to prevent unwanted page breaks. * need:: Another way to prevent unwanted page breaks. @end menu @ifinfo @node Break Commands, Line Breaks, , Breaks @heading The Break Commands @end ifinfo @iftex @sp 1 @end iftex The break commands create line and paragraph breaks:@refill @table @code @item @@* Force a line break. @item @@sp @var{n} Skip @var{n} blank lines.@refill @end table @iftex @sp 1 @end iftex The line-break-prevention command holds text together all on one line:@refill @table @code @item @@w@{@var{text}@} Prevent @var{text} from being split and hyphenated across two lines.@refill @end table @iftex @sp 1 @end iftex The pagination commands apply only to printed output, since Info files do not have pages.@refill @table @code @item @@page Start a new page in the printed manual.@refill @item @@group Hold text together that must appear on one printed page.@refill @item @@need @var{mils} Start a new printed page if not enough space on this one.@refill @end table @node Line Breaks, w, Break Commands, Breaks @comment node-name, next, previous, up @section @code{@@*}: Generate Line Breaks @findex * @r{(force line break)} @cindex Line breaks @cindex Breaks in a line The @code{@@*} command forces a line break in both the printed manual and in Info.@refill For example, @example This line @@* is broken @@*in two places. @end example @noindent produces @example @group This line is broken in two places. @end group @end example @noindent (Note that the space after the first @code{@@*} command is faithfully carried down to the next line.)@refill The @code{@@*} command is often used in a file's copyright page:@refill @example @group This is version 2.0 of the Texinfo documentation,@@* and is for @dots{} @end group @end example @noindent In this case, the @code{@@*} command keeps @TeX{} from stretching the line across the whole page in an ugly manner.@refill Do not write braces after an @code{@@*} command; they are not needed.@refill Do not write an @code{@@refill} command at the end of a paragraph containing an @code{@@*} command; it will cause the paragraph to be refilled after the line break occurs, negating the effect of the line break.@refill @node w, sp, Line Breaks, Breaks @comment node-name, next, previous, up @section @code{@@w}@{@var{text}@}: Prevent Line Breaks @findex w @r{(prevent line break)} @cindex Line breaks, preventing @code{@@w@{@var{text}@}} outputs @var{text} and prohibits line breaks within @var{text}.@refill You can use the @code{@@w} command to prevent @TeX{} from automatically hyphenating a long name or phrase that accidentally falls near the end of a line.@refill @example You can copy GNU software from @@w@{@@file@{prep.ai.mit.edu@}@}. @end example @noindent produces @quotation You can copy GNU software from @w{@file{prep.ai.mit.edu}}. @end quotation In the Texinfo file, you must write the @code{@@w} command and its argument (all the affected text) all on one line.@refill Do not write an @code{@@refill} command at the end of a paragraph containing an @code{@@w} command; it will cause the paragraph to be refilled and may thereby negate the effect of the @code{@@w} command.@refill @node sp, page, w, Breaks @comment node-name, next, previous, up @section @code{@@sp} @var{n}: Insert Blank Lines @findex sp @r{(line spacing)} @cindex Spaces (blank lines) @cindex Blank lines @cindex Line spacing A line beginning with and containing only @code{@@sp @var{n}} generates @var{n} blank lines of space in both the printed manual and the Info file. @code{@@sp} also forces a paragraph break. For example,@refill @example @@sp 2 @end example @noindent generates two blank lines. The @code{@@sp} command is most often used in the title page.@refill @ignore @c node br, page, sp, Breaks @comment node-name, next, previous, up @c section @code{@@br}: Generate Paragraph Breaks @findex br @r{(paragraph breaks)} @cindex Paragraph breaks @cindex Breaks in a paragraph The @code{@@br} command forces a paragraph break. It inserts a blank line. You can use the command within or at the end of a line. If used within a line, the @code{@@br@{@}} command must be followed by left and right braces (as shown here) to mark the end of the command.@refill For example, @example @group This line @@br@{@}contains and is ended by paragraph breaks@@br and is followed by another line. @end group @end example @noindent produces @example @group This line contains and is ended by paragraph breaks and is followed by another line. @end group @end example The @code{@@br} command is seldom used. @end ignore @node page, group, sp, Breaks @comment node-name, next, previous, up @section @code{@@page}: Start a New Page @cindex Page breaks @findex page A line containing only @code{@@page} starts a new page in a printed manual. The command has no effect on Info files since they are not paginated. An @code{@@page} command is often used in the @code{@@titlepage} section of a Texinfo file to start the copyright page.@refill @node group, need, page, Breaks @comment node-name, next, previous, up @section @code{@@group}: Prevent Page Breaks @cindex Group (hold text together vertically) @cindex Holding text together vertically @cindex Vertically holding text together @findex group The @code{@@group} command (on a line by itself) is used inside an @code{@@example} or similar construct to begin an unsplittable vertical group, which will appear entirely on one page in the printed output. The group is terminated by a line containing only @code{@@end group}. These two lines produce no output of their own, and in the Info file output they have no effect at all.@refill @c Once said that these environments @c turn off vertical spacing between ``paragraphs''. @c Also, quotation used to work, but doesn't in texinfo2.72 Although @code{@@group} would make sense conceptually in a wide variety of contexts, its current implementation works reliably only within @code{@@example} and variants, and within @code{@@display}, @code{@@format}, @code{@@flushleft} and @code{@@flushright}. (What all these commands have in common is that each line of input produces a line of output.) In other contexts, @code{@@group} can cause anomalous vertical spacing. @xref{Quotations and Examples}.@refill @example @group @exdent @r{This formatting requirement means that you should write:} @@example @@group @dots{} @@end group @@end example @end group @end example @noindent with the @code{@@group} and @code{@@end group} command inside the @code{@@example} and @code{@@end example} commands. The @code{@@group} command is most often used to hold an example together on one page. In this Texinfo manual, more than 100 examples contain text that is enclosed between @code{@@group} and @code{@@end group}. If you forget to end a group, you may get strange and unfathomable error messages when you run @TeX{}. This is because @TeX{} keeps trying to put the rest of the Texinfo file onto the one page and does not start to generate error messages until it has processed considerable text. It is a good rule of thumb to look for a missing @code{@@end group} if you get incomprehensible error messages in @TeX{}.@refill @node need, , group, Breaks @comment node-name, next, previous, up @section @code{@@need @var{mils}}: Prevent Page Breaks @cindex Need space at page bottom @findex need A line containing only @code{@@need @var{n}} starts a new page in a printed manual if fewer than @var{n} mils (thousandths of an inch) remain on the current page. Do not use braces around the argument @var{n}. The @code{@@need} command has no effect on Info files since they are not paginated.@refill @need 300 This paragraph is preceded by an @code{@@need} command that tells @TeX{} to start a new page if fewer than 300 mils (three-tenths inch) remain on the page. It looks like this:@refill @example @group @@need 300 This paragraph is preceded by @dots{} @end group @end example The @code{@@need} command is useful for preventing orphans (single lines at the bottoms of printed pages).@refill @node Definition Commands, Footnotes, Breaks, Top @chapter Definition Commands: @code{@@deffn}, etc. @cindex Definition commands The @code{@@deffn} command and the other @dfn{definition commands} enable you to describe functions, variables, macros, commands, user options, special forms and other such artifacts in a uniform format.@refill In the Info file, a definition causes the entity category---`Function', `Variable', or whatever---to appear at the beginning of the first line of the definition, followed by the entity's name and arguments. In the printed manual, the command causes @TeX{} to print the entity's name and its arguments on the left margin and print the category next to the right margin. In both output formats, the body of the definition is indented. Also, the name of the entity is entered into the appropriate index: @code{@@deffn} enters the name into the index of functions, @code{@@defvr} enters it into the index of variables, and so on.@refill A manual need not and should not contain more than one definition for a given name. An appendix containing a summary should use @code{@@table} rather than the definition commands.@refill @menu * Def Cmd Template:: How to structure a description using a definition command. * Optional Arguments:: How to handle optional and repeated arguments. * deffnx:: How to group two or more `first' lines. * Def Cmds in Detail:: All the definition commands. * Def Cmd Conventions:: Conventions for writing definitions. * Sample Function Definition:: @end menu @node Def Cmd Template, Optional Arguments, , Definition Commands @section The Template for a Definition @cindex Definition template @cindex Template for a definition The @code{@@deffn} command is used for definitions of entities that resemble functions. To write a definition using the @code{@@deffn} command, write the @code{@@deffn} command at the beginning of a line and follow it on the same line by the category of the entity, the name of the entity itself, and its arguments (if any). Then write the body of the definition on succeeding lines. (You may embed examples in the body.) Finally, end the definition with an @code{@@end deffn} command written on a line of its own. (The other definition commands follow the same format.)@refill The template for a definition looks like this: @example @group @@deffn @var{category} @var{name} @var{arguments}@dots{} @var{body-of-definition} @@end deffn @end group @end example @noindent For example, @example @group @@deffn Command forward-word count This command moves point forward @@var@{count@} words (or backward if @@var@{count@} is negative). @dots{} @@end deffn @end group @end example @noindent produces @quotation @deffn Command forward-word count This function moves point forward @var{count} words (or backward if @var{count} is negative). @dots{} @end deffn @end quotation Capitalize the category name like a title. If the name of the category contains spaces, as in the phrase `Interactive Command', write braces around it. For example:@refill @example @group @@deffn @{Interactive Command@} isearch-forward @dots{} @@end deffn @end group @end example @noindent Otherwise, the second word will be mistaken for the name of the entity.@refill Some of the definition commands are more general than others. The @code{@@deffn} command, for example, is the general definition command for functions and the like---for entities that may take arguments. When you use this command, you specify the category to which the entity belongs. The @code{@@deffn} command possesses three predefined, specialized variations, @code{@@defun}, @code{@@defmac}, and @code{@@defspec}, that specify the category for you: ``Function'', ``Macro'', and ``Special Form'' respectively. The @code{@@defvr} command also is accompanied by several predefined, specialized variations for describing particular kinds of variables.@refill The template for a specialized definition, such as @code{@@defun}, is similar to the template for a generalized definition, except that you do not need to specify the category:@refill @example @group @@defun @var{name} @var{arguments}@dots{} @var{body-of-definition} @@end defun @end group @end example @noindent Thus, @example @group @@defun buffer-end flag This function returns @@code@{(point-min)@} if @@var@{flag@} is less than 1, @@code@{(point-max)@} otherwise. @dots{} @@end defun @end group @end example @noindent produces @quotation @defun buffer-end flag This function returns @code{(point-min)} if @var{flag} is less than 1, @code{(point-max)} otherwise. @dots{} @end defun @end quotation @noindent @xref{Sample Function Definition, Sample Function Definition, A Sample Function Definition}, for a more detailed example of a function definition, including the use of @code{@@example} inside the definition.@refill The other specialized commands work like @code{@@defun}.@refill @node Optional Arguments, deffnx, Def Cmd Template, Definition Commands @section Optional and Repeated Arguments @cindex Optional and repeated arguments @cindex Repeated and optional arguments @cindex Arguments, repeated and optional @cindex Syntax, optional & repeated arguments @cindex Meta-syntactic chars for arguments Some entities take optional or repeated arguments, which may be specified by a distinctive glyph that uses square brackets and ellipses. For example, a special form often breaks its argument list into separate arguments in more complicated ways than a straightforward function.@refill @iftex An argument enclosed within square brackets is optional. Thus, the phrase @samp{@code{@r{[}@var{optional-arg}@r{]}}} means that @var{optional-arg} is optional. An argument followed by an ellipsis is optional and may be repeated more than once. Thus, @samp{@var{repeated-args}@dots{}} stands for zero or more arguments. Parentheses are used when several arguments are grouped into additional levels of list structure in Lisp. @end iftex @c The following looks better in Info (no `r', `samp' and `code'): @ifinfo An argument enclosed within square brackets is optional. Thus, [@var{optional-arg}] means that @var{optional-arg} is optional. An argument followed by an ellipsis is optional and may be repeated more than once. Thus, @var{repeated-args}@dots{} stands for zero or more arguments. Parentheses are used when several arguments are grouped into additional levels of list structure in Lisp.@refill @end ifinfo Here is the @code{@@defspec} line of an example of an imaginary special form:@refill @quotation @defspec foobar (@var{var} [@var{from} @var{to} [@var{inc}]]) @var{body}@dots{} @end defspec @tex \vskip \parskip @end tex @end quotation @noindent In this example, the arguments @var{from} and @var{to} are optional, but must both be present or both absent. If they are present, @var{inc} may optionally be specified as well. These arguments are grouped with the argument @var{var} into a list, to distinguish them from @var{body}, which includes all remaining elements of the form.@refill In a Texinfo source file, this @code{@@defspec} line is written like this (except it would not be split over two lines, as it is in this example).@refill @example @group @@defspec foobar (@@var@{var@} [@@var@{from@} @@var@{to@} [@@var@{inc@}]]) @@var@{body@}@@dots@{@} @end group @end example @noindent The function is listed in the Command and Variable Index under @samp{foobar}.@refill @node deffnx, Def Cmds in Detail, Optional Arguments, Definition Commands @section Two or More `First' Lines @cindex Two `First' Lines for @code{@@deffn} @cindex Grouping two definitions together @cindex Definitions grouped together @findex deffnx To create two or more `first' or header lines for a definition, follow the first @code{@@deffn} line by a line beginning with @code{@@deffnx}. The @code{@@deffnx} command works exactly like @code{@@deffn} except that it does not generate extra vertical white space between it and the preceding line.@refill For example,@refill @example @group @@deffn @{Interactive Command@} isearch-forward @@deffnx @{Interactive Command@} isearch-backward These two search commands are similar except @dots{} @@end deffn @end group @end example @noindent produces @deffn {Interactive Command} isearch-forward @deffnx {Interactive Command} isearch-backward These two search commands are similar except @dots{} @end deffn Each of the other definition commands has an `x' form: @code{@@defunx}, @code{@@defvrx}, @code{@@deftypefunx}, etc. The `x' forms work just like @code{@@itemx}; see @ref{itemx, , @code{@@itemx}}. @node Def Cmds in Detail, Def Cmd Conventions, deffnx, Definition Commands @section The Definition Commands Texinfo provides more than a dozen definition commands, all of which are described in this section.@refill The definition commands automatically enter the name of the entity in the appropriate index: for example, @code{@@deffn}, @code{@@defun}, and @code{@@defmac} enter function names in the index of functions; @code{@@defvr} and @code{@@defvar} enter variable names in the index of variables.@refill Although the examples that follow mostly illustrate Lisp, the commands can be used for other programming languages.@refill @menu * Functions Commands:: Commands for functions and similar entities. * Variables Commands:: Commands for variables and similar entities. * Typed Functions:: Commands for functions in typed languages. * Typed Variables:: Commands for variables in typed languages. * Abstract Objects:: Commands for object-oriented programming. * Data Types:: The definition command for data types. @end menu @node Functions Commands, Variables Commands, , Def Cmds in Detail @subsection Functions and Similar Entities This section describes the commands for describing functions and similar entities:@refill @table @code @findex deffn @item @@deffn @var{category} @var{name} @var{arguments}@dots{} The @code{@@deffn} command is the general definition command for functions, interactive commands, and similar entities that may take arguments. You must choose a term to describe the category of entity being defined; for example, ``Function'' could be used if the entity is a function. The @code{@@deffn} command is written at the beginning of a line and is followed on the same line by the category of entity being described, the name of this particular entity, and its arguments, if any. Terminate the definition with @code{@@end deffn} on a line of its own.@refill For example, here is a definition: @example @group @@deffn Command forward-char nchars Move point forward @@var@{nchars@} characters. @@end deffn @end group @end example @noindent This shows a rather terse definition for a ``command'' named @code{forward-char} with one argument, @var{nchars}. @code{@@deffn} prints argument names such as @var{nchars} in italics or upper case, as if @code{@@var} had been used, because we think of these names as metasyntactic variables---they stand for the actual argument values. Within the text of the description, write an argument name explicitly with @code{@@var} to refer to the value of the argument. In the example above, we used @samp{@@var@{nchars@}} in this way. The template for @code{@@deffn} is: @example @group @@deffn @var{category} @var{name} @var{arguments}@dots{} @var{body-of-definition} @@end deffn @end group @end example @findex defun @item @@defun @var{name} @var{arguments}@dots{} The @code{@@defun} command is the definition command for functions. @code{@@defun} is equivalent to @samp{@@deffn Function @dots{}}.@refill @example @group @exdent @r{For example,} @@defun set symbol new-value Change the value of the symbol @@var@{symbol@} to @@var@{new-value@}. @@end defun @end group @end example @noindent shows a rather terse definition for a function @code{set} whose arguments are @var{symbol} and @var{new-value}. The argument names on the @code{@@defun} line automatically appear in italics or upper case as if they were enclosed in @code{@@var}. Terminate the definition with @code{@@end defun} on a line of its own.@refill The template is: @example @group @@defun @var{function-name} @var{arguments}@dots{} @var{body-of-definition} @@end defun @end group @end example @code{@@defun} creates an entry in the index of functions. @findex defmac @item @@defmac @var{name} @var{arguments}@dots{} The @code{@@defmac} command is the definition command for macros. @code{@@defmac} is equivalent to @samp{@@deffn Macro @dots{}} and works like @code{@@defun}.@refill @findex defspec @item @@defspec @var{name} @var{arguments}@dots{} The @code{@@defspec} command is the definition command for special forms. (In Lisp, a special form is an entity much like a function.) @code{@@defspec} is equivalent to @samp{@@deffn @{Special Form@} @dots{}} and works like @code{@@defun}.@refill @end table @node Variables Commands, Typed Functions, Functions Commands, Def Cmds in Detail @subsection Variables and Similar Entities Here are the commands for defining variables and similar entities:@refill @table @code @findex defvr @item @@defvr @var{category} @var{name} The @code{@@defvr} command is a general definition command for something like a variable---an entity that records a value. You must choose a term to describe the category of entity being defined; for example, ``Variable'' could be used if the entity is a variable. Write the @code{@@defvr} command at the beginning of a line and followed it on the same line by the category of the entity and the name of the entity.@refill Capitalize the category name like a title. If the name of the category contains spaces, as in the name `User Option', write braces around it. Otherwise, the second word will be mistaken for the name of the entity.@refill @example @group @exdent @r{For example:} @@defvr @{User Option@} fill-column This buffer-local variable specifies the maximum width of filled lines. @dots{} @@end defvr @end group @end example Terminate the definition with @code{@@end defvr} on a line of its own.@refill The template is: @example @group @@defvr @var{category} @var{name} @var{body-of-definition} @@end defvr @end group @end example @code{@@defvr} creates an entry in the index of variables for @var{name}. @findex defvar @item @@defvar @var{name} The @code{@@defvar} command is the definition command for variables. @code{@@defvar} is equivalent to @samp{@@defvr Variable @dots{}}.@refill For example: @example @group @@defvar kill-ring @dots{} @@end defvar @end group @end example The template is: @example @group @@defvar @var{name} @var{body-of-definition} @@end defvar @end group @end example @code{@@defvar} creates an entry in the index of variables for @var{name}.@refill @findex defopt @item @@defopt @var{name} The @code{@@defopt} command is the definition command for user options. @code{@@defopt} is equivalent to @samp{@@defvr @{User Option@} @dots{}} and works like @code{@@defvar}.@refill @end table @node Typed Functions, Typed Variables, Variables Commands, Def Cmds in Detail @subsection Functions in Typed Languages The @code{@@deftypefn} command and its variations are for describing functions in C or any other language in which you must declare types of variables and functions.@refill @table @code @findex deftypefn @item @@deftypefn @var{category} @var{data-type} @var{name} @var{arguments}@dots{} The @code{@@deftypefn} command is the general definition command for functions and similar entities that may take arguments and that are typed. The @code{@@deftypefn} command is written at the beginning of a line and is followed on the same line by the category of entity being described, the type of the returned value, the name of this particular entity, and its arguments, if any.@refill @example @group @exdent @r{For example,} @@deftypefn @{Library Function@} int foobar (int @@var@{foo@}, float @@var@{bar@}) @dots{} @@end deftypefn @end group @end example @noindent (where the text before the ``@dots{}'', shown above as two lines, would actually be a single line in a real Texinfo file) produces the following in Info: @smallexample @group -- Library Function: int foobar (int FOO, float BAR) @dots{} @end group @end smallexample @iftex In a printed manual, it produces: @quotation @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) @dots{} @end deftypefn @end quotation @end iftex This means that @code{foobar} is a ``library function'' that returns an @code{int}, and its arguments are @var{foo} (an @code{int}) and @var{bar} (a @code{float}).@refill The argument names that you write in @code{@@deftypefn} are not subject to an implicit @code{@@var}---since the actual names of the arguments in @code{@@deftypefn} are typically scattered among data type names and keywords, Texinfo cannot find them without help. Instead, you must write @code{@@var} explicitly around the argument names. In the example above, the argument names are @samp{foo} and @samp{bar}.@refill The template for @code{@@deftypefn} is:@refill @example @group @@deftypefn @var{category} @var{data-type} @var{name} @var{arguments} @dots{} @var{body-of-description} @@end deftypefn @end group @end example @noindent Note that if the @var{category} or @var{data type} is more than one word then it must be enclosed in braces to make it a single argument.@refill If you are describing a procedure in a language that has packages, such as Ada, you might consider using @code{@@deftypefn} in a manner somewhat contrary to the convention described in the preceding paragraphs.@refill @example @group @exdent @r{For example:} @@deftypefn stacks private push (@@var@{s@}:in out stack; @@var@{n@}:in integer) @dots{} @@end deftypefn @end group @end example @noindent (The @code{@@deftypefn} arguments are shown split into three lines, but would be a single line in a real Texinfo file.) In this instance, the procedure is classified as belonging to the package @code{stacks} rather than classified as a `procedure' and its data type is described as @code{private}. (The name of the procedure is @code{push}, and its arguments are @var{s} and @var{n}.)@refill @code{@@deftypefn} creates an entry in the index of functions for @var{name}.@refill @findex deftypefun @item @@deftypefun @var{data-type} @var{name} @var{arguments}@dots{} The @code{@@deftypefun} command is the specialized definition command for functions in typed languages. The command is equivalent to @samp{@@deftypefn Function @dots{}}.@refill @smallexample @group @@deftypefun int foobar (int @@var@{foo@}, float @@var@{bar@}) @dots{} @@end deftypefun @end group @end smallexample @noindent produces the following in Info: @example @group -- Function: int foobar (int FOO, float BAR) @dots{} @end group @end example @iftex @noindent and the following in a printed manual: @quotation @deftypefun int foobar (int @var{foo}, float @var{bar}) @dots{} @end deftypefun @end quotation @end iftex The template is: @example @group @@deftypefun @var{type} @var{name} @var{arguments}@dots{} @var{body-of-description} @@end deftypefun @end group @end example @code{@@deftypefun} creates an entry in the index of functions for @var{name}.@refill @end table @node Typed Variables, Abstract Objects, Typed Functions, Def Cmds in Detail @subsection Variables in Typed Languages Variables in typed languages are handled in a manner similar to functions in typed languages. @xref{Typed Functions}. The general definition command @code{@@deftypevr} corresponds to @code{@@deftypefn} and the specialized definition command @code{@@deftypevar} corresponds to @code{@@deftypefun}.@refill @table @code @findex deftypevr @item @@deftypevr @var{category} @var{data-type} @var{name} The @code{@@deftypevr} command is the general definition command for something like a variable in a typed language---an entity that records a value. You must choose a term to describe the category of the entity being defined; for example, ``Variable'' could be used if the entity is a variable.@refill The @code{@@deftypevr} command is written at the beginning of a line and is followed on the same line by the category of the entity being described, the data type, and the name of this particular entity.@refill @example @group @exdent @r{For example,} @@deftypevr @{Global Flag@} int enable @dots{} @@end deftypevr @end group @end example @noindent produces the following in Info: @example @group -- Global Flag: int enable @dots{} @end group @end example @iftex @noindent and the following in a printed manual: @quotation @deftypevr {Global Flag} int enable @dots{} @end deftypevr @end quotation @end iftex The template is: @example @@deftypevr @var{category} @var{data-type} @var{name} @var{body-of-description} @@end deftypevr @end example @code{@@deftypevr} creates an entry in the index of variables for @var{name}.@refill @findex deftypevar @item @@deftypevar @var{data-type} @var{name} The @code{@@deftypevar} command is the specialized definition command for variables in typed languages. @code{@@deftypevar} is equivalent to @samp{@@deftypevr Variable @dots{}}.@refill @example @group @exdent @r{For example,} @@deftypevar int fubar @dots{} @@end deftypevar @end group @end example @noindent produces the following in Info: @example @group -- Variable: int fubar @dots{} @end group @end example @iftex @noindent and the following in a printed manual: @quotation @deftypevar int fubar @dots{} @end deftypevar @end quotation @end iftex @example @group @exdent @r{The template is:} @@deftypevar @var{data-type} @var{name} @var{body-of-description} @@end deftypevar @end group @end example @code{@@deftypevar} creates an entry in the index of variables for @var{name}.@refill @end table @node Abstract Objects, Data Types, Typed Variables, Def Cmds in Detail @subsection Object-Oriented Programming Here are the commands for formatting descriptions about abstract objects, such as are used in object-oriented programming. A class is a defined type of abstract object. An instance of a class is a particular object that has the type of the class. An instance variable is a variable that belongs to the class but for which each instance has its own value.@refill In a definition, if the name of a class is truly a name defined in the programming system for a class, then you should write an @code{@@code} around it. Otherwise, it is printed in the usual text font.@refill @table @code @findex defcv @item @@defcv @var{category} @var{class} @var{name} The @code{@@defcv} command is the general definition command for variables associated with classes in object-oriented programming. The @code{@@defcv} command is followed by three arguments: the category of thing being defined, the class to which it belongs, and its name.@refill Thus, @example @group @@defcv @{Class Option@} Window border-pattern @dots{} @@end defcv @end group @end example @noindent illustrates how you would write the first line of a definition of the @code{border-pattern} class option of the class @code{Window}.@refill The template is @example @group @@defcv @var{category} @var{class} @var{name} @dots{} @@end defcv @end group @end example @code{@@defcv} creates an entry in the index of variables. @findex defivar @item @@defivar @var{class} @var{name} The @code{@@defivar} command is the definition command for instance variables in object-oriented programming. @code{@@defivar} is equivalent to @samp{@@defcv @{Instance Variable@} @dots{}}@refill The template is: @example @group @@defivar @var{class} @var{instance-variable-name} @var{body-of-definition} @@end defivar @end group @end example @code{@@defivar} creates an entry in the index of variables. @findex defop @item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} The @code{@@defop} command is the general definition command for entities that may resemble methods in object-oriented programming. These entities take arguments, as functions do, but are associated with particular classes of objects.@refill For example, some systems have constructs called @dfn{wrappers} that are associated with classes as methods are, but that act more like macros than like functions. You could use @code{@@defop Wrapper} to describe one of these.@refill Sometimes it is useful to distinguish methods and @dfn{operations}. You can think of an operation as the specification for a method. Thus, a window system might specify that all window classes have a method named @code{expose}; we would say that this window system defines an @code{expose} operation on windows in general. Typically, the operation has a name and also specifies the pattern of arguments; all methods that implement the operation must accept the same arguments, since applications that use the operation do so without knowing which method will implement it.@refill Often it makes more sense to document operations than methods. For example, window application developers need to know about the @code{expose} operation, but need not be concerned with whether a given class of windows has its own method to implement this operation. To describe this operation, you would write:@refill @example @@defop Operation windows expose @end example The @code{@@defop} command is written at the beginning of a line and is followed on the same line by the overall name of the category of operation, the name of the class of the operation, the name of the operation, and its arguments, if any.@refill @example @group @exdent @r{The template is:} @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} @var{body-of-definition} @@end defop @end group @end example @code{@@defop} creates an entry, such as `@code{expose} on @code{windows}', in the index of functions.@refill @findex defmethod @item @@defmethod @var{class} @var{name} @var{arguments}@dots{} The @code{@@defmethod} command is the definition command for methods in object-oriented programming. A method is a kind of function that implements an operation for a particular class of objects and its subclasses. In the Lisp Machine, methods actually were functions, but they were usually defined with @code{defmethod}. @code{@@defmethod} is equivalent to @samp{@@defop Method @dots{}}. The command is written at the beginning of a line and is followed by the name of the class of the method, the name of the method, and its arguments, if any.@refill @example @group @exdent @r{For example,} @@defmethod @code{bar-class} bar-method argument @dots{} @@end defmethod @end group @end example @noindent illustrates the definition for a method called @code{bar-method} of the class @code{bar-class}. The method takes an argument.@refill The template is: @example @group @@defmethod @var{class} @var{method-name} @var{arguments}@dots{} @var{body-of-definition} @@end defmethod @end group @end example @code{@@defmethod} creates an entry, such as `@code{bar-method} on @code{bar-class}', in the index of functions.@refill @end table @node Data Types, , Abstract Objects, Def Cmds in Detail @subsection Data Types Here is the command for data types:@refill @table @code @findex deftp @item @@deftp @var{category} @var{name} @var{attributes}@dots{} The @code{@@deftp} command is the generic definition command for data types. The command is written at the beginning of a line and is followed on the same line by the category, by the name of the type (which is a word like @code{int} or @code{float}), and then by names of attributes of objects of that type. Thus, you could use this command for describing @code{int} or @code{float}, in which case you could use @code{data type} as the category. (A data type is a category of certain objects for purposes of deciding which operations can be performed on them.)@refill In Lisp, for example, @dfn{pair} names a particular data type, and an object of that type has two slots called the @sc{car} and the @sc{cdr}. Here is how you would write the first line of a definition of @code{pair}.@refill @example @group @@deftp @{Data type@} pair car cdr @dots{} @@end deftp @end group @end example The template is: @example @group @@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} @var{body-of-definition} @@end deftp @end group @end example @code{@@deftp} creates an entry in the index of data types. @end table @node Def Cmd Conventions, Sample Function Definition, Def Cmds in Detail, Definition Commands @section Conventions for Writing Definitions @cindex Definition conventions @cindex Conventions for writing definitions When you write a definition using @code{@@deffn}, @code{@@defun}, or one of the other definition commands, please take care to use arguments that indicate the meaning, as with the @var{count} argument to the @code{forward-word} function. Also, if the name of an argument contains the name of a type, such as @var{integer}, take care that the argument actually is of that type.@refill @node Sample Function Definition, , Def Cmd Conventions, Definition Commands @section A Sample Function Definition @cindex Function definitions @cindex Command definitions @cindex Macro definitions @cindex Sample function definition A function definition uses the @code{@@defun} and @code{@@end defun} commands. The name of the function follows immediately after the @code{@@defun} command and it is followed, on the same line, by the parameter list.@refill Here is a definition from @cite{The GNU Emacs Lisp Reference Manual}. (@xref{Calling Functions, , Calling Functions, elisp, The GNU Emacs Lisp Reference Manual}.) @quotation @defun apply function &rest arguments @code{apply} calls @var{function} with @var{arguments}, just like @code{funcall} but with one difference: the last of @var{arguments} is a list of arguments to give to @var{function}, rather than a single argument. We also say that this list is @dfn{appended} to the other arguments. @code{apply} returns the result of calling @var{function}. As with @code{funcall}, @var{function} must either be a Lisp function or a primitive function; special forms and macros do not make sense in @code{apply}. @example (setq f 'list) @result{} list (apply f 'x 'y 'z) @error{} Wrong type argument: listp, z (apply '+ 1 2 '(3 4)) @result{} 10 (apply '+ '(1 2 3 4)) @result{} 10 (apply 'append '((a b c) nil (x y z) nil)) @result{} (a b c x y z) @end example An interesting example of using @code{apply} is found in the description of @code{mapcar}.@refill @end defun @end quotation In the Texinfo source file, this example looks like this: @example @@defun apply function &rest arguments @@code@{apply@} calls @@var@{function@} with @@var@{arguments@}, just like @@code@{funcall@} but with one difference: the last of @@var@{arguments@} is a list of arguments to give to @@var@{function@}, rather than a single argument. We also say that this list is @@dfn@{appended@} to the other arguments. @@code@{apply@} returns the result of calling @@var@{function@}. As with @@code@{funcall@}, @@var@{function@} must either be a Lisp function or a primitive function; special forms and macros do not make sense in @@code@{apply@}. @@example (setq f 'list) @@result@{@} list (apply f 'x 'y 'z) @@error@{@} Wrong type argument: listp, z (apply '+ 1 2 '(3 4)) @@result@{@} 10 (apply '+ '(1 2 3 4)) @@result@{@} 10 (apply 'append '((a b c) nil (x y z) nil)) @@result@{@} (a b c x y z) @@end example An interesting example of using @@code@{apply@} is found in the description of @@code@{mapcar@}.@@refill @@end defun @end example @noindent In this manual, this function is listed in the Command and Variable Index under @code{apply}.@refill Ordinary variables and user options are described using a format like that for functions except that variables do not take arguments. @node Footnotes, Conditionals, Definition Commands, Top @comment node-name, next, previous, up @chapter Footnotes @cindex Footnotes @findex footnote A @dfn{footnote} is for a reference that documents or elucidates the primary text.@footnote{A footnote should complement or expand upon the primary text, but a reader should not need to read a footnote to understand the primary text. For a thorough discussion of footnotes, see @cite{The Chicago Manual of Style}, which is published by the University of Chicago Press.}@refill In Texinfo, footnotes are created with the @code{@@footnote} command. This command is followed immediately by a left brace, then by the text of the footnote, and then by a terminating right brace. The template is: @example @@footnote@{@var{text}@} @end example Footnotes may be of any length, but are usually short.@refill For example, this clause is followed by a sample footnote@footnote{Here is the sample footnote.}; in the Texinfo source, it looks like this:@refill @example @dots{}a sample footnote @@footnote@{Here is the sample footnote.@}; in the Texinfo source@dots{} @end example In a printed manual or book, the reference mark for a footnote is a small, superscripted number; the text of the footnote is written at the bottom of the page, below a horizontal line.@refill In Info, the reference mark for a footnote is a pair of parentheses with the footnote number between them, like this: @samp{(1)}.@refill Info has two footnote styles, which determine where the text of the footnote is located:@refill @itemize @bullet @cindex @samp{@r{End}} node footnote style @item In the `End' node style, all the footnotes for a single node are placed at the end of that node. The footnotes are separated from the rest of the node by a line of dashes with the word @samp{Footnotes} within it. Each footnote begins with an @samp{(@var{n})} reference mark.@refill @noindent Here is an example of a single footnote in the end of node style:@refill @example @group --------- Footnotes --------- (1) Here is a sample footnote. @end group @end example @cindex @samp{@r{Separate}} footnote style @item In the `Separate' node style, all the footnotes for a single node are placed in an automatically constructed node of their own. In this style, a ``footnote reference'' follows each @samp{(@var{n})} reference mark in the body of the node. The footnote reference is actually a cross reference which you use to reach the footnote node.@refill The name of the node containing the footnotes is constructed by appending @w{@samp{-Footnotes}} to the name of the node that contains the footnotes. (Consequently, the footnotes' node for the @file{Footnotes} node is @w{@file{Footnotes-Footnotes}}!) The footnotes' node has an `Up' node pointer that leads back to its parent node.@refill @end itemize @noindent Here is how the first footnote in this manual looks after being formatted for Info in the separate node style:@refill @example File: texinfo.info Node: Overview-Footnotes, Up: Overview (1) Note that the first syllable of "Texinfo" is pronounced like "speck", not "hex". @dots{} @end example A Texinfo file may be formatted into an Info file with either footnote style.@refill @findex footnotestyle Use the @code{@@footnotestyle} command to specify an Info file's footnote style. Write this command at the beginning of a line followed by an argument, either @samp{end} for the end node style or @samp{separate} for the separate node style. For example:@refill @example @@footnotestyle end @end example @noindent or @example @@footnotestyle separate @end example Write an @code{@@footnotestyle} command before or shortly after the end-of-header line at the beginning of a Texinfo file. (If you include the @code{@@footnotestyle} command between the start-of-header and end-of-header lines, the region formatting commands will format footnotes as specified.)@refill If you do not specify a footnote style, the formatting commands use their default style. Currently, @code{texinfo-format-buffer} and @code{texinfo-format-region} use the `separate' style and @code{makeinfo} uses the `end' style.@refill @c !!! note: makeinfo's --footnote-style option overrides footnotestyle @ignore If you use @code{makeinfo} to create the Info file, the @samp{--footnote-style} option determines which style is used, @samp{end} for the end of node style or @samp{separate} for the separate node style. Thus, to format the Texinfo manual in the separate node style, you would use the following shell command:@refill @example makeinfo --footnote-style=separate texinfo.texi @end example @noindent To format the Texinfo manual in the end of node style, you would type:@refill @example makeinfo --footnote-style=end texinfo.texi @end example @end ignore @ignore If you use @code{texinfo-format-buffer} or @code{texinfo-format-region} to create the Info file, the value of the @code{texinfo-footnote-style} variable controls the footnote style. It can be either @samp{"separate"} for the separate node style or @samp{"end"} for the end of node style. (You can change the value of this variable with the @kbd{M-x edit-options} command (@pxref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual}), or with the @kbd{M-x set-variable} command (@pxref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual}).@refill The @code{texinfo-footnote-style} variable also controls the style if you use the @kbd{M-x makeinfo-region} or @kbd{M-x makeinfo-buffer} command in Emacs.@refill @end ignore This chapter contains two footnotes.@refill @node Conditionals, Format/Print Hardcopy, Footnotes, Top @comment node-name, next, previous, up @chapter Conditionally Visible Text @cindex Conditionally visible text @cindex Text, conditionally visible @cindex Visibility of conditional text @cindex If text conditionally visible @findex ifinfo @findex iftex Sometimes it is good to use different text for a printed manual and its corresponding Info file. In this case, you can use the @dfn{conditional commands} to specify which text is for the printed manual and which is for the Info file.@refill @menu * Conditional Commands:: Specifying text for Info or @TeX{}. * Using Ordinary TeX Commands:: You can use any and all @TeX{} commands. * set and clear:: Designating which text to format (for both Info and @TeX{}). @end menu @node Conditional Commands, Using Ordinary TeX Commands, , Conditionals @ifinfo @heading Using @code{@@ifinfo} and @code{@@iftex} @end ifinfo @code{@@ifinfo} begins segments of text that should be ignored by @TeX{} when it typesets the printed manual. The segment of text appears only in the Info file. The @code{@@ifinfo} command should appear on a line by itself; end the Info-only text with a line containing @code{@@end ifinfo} by itself. At the beginning of a Texinfo file, the Info permissions are contained within a region marked by @code{@@ifinfo} and @code{@@end ifinfo}. (@xref{Info Summary and Permissions}.)@refill The @code{@@iftex} and @code{@@end iftex} commands are similar to the @code{@@ifinfo} and @code{@@end ifinfo} commands, except that they specify text that will appear in the printed manual but not in the Info file.@refill For example: @example @@iftex This text will appear only in the printed manual. @@end iftex @@ifinfo However, this text will appear only in Info. @@end ifinfo @end example @noindent The preceding example produces the following line: @iftex This text will appear only in the printed manual. @end iftex @ifinfo However, this text will appear only in Info. @end ifinfo @noindent Note how you only see one of the two lines, depending on whether you are reading the Info version or the printed version of this manual.@refill The @code{@@titlepage} command is a special variant of @code{@@iftex} that is used for making the title and copyright pages of the printed manual. (@xref{titlepage, , @code{@@titlepage}}.) @refill @node Using Ordinary TeX Commands, set and clear, Conditional Commands, Conditionals @comment node-name, next, previous, up @section Using Ordinary @TeX{} Commands @cindex @TeX{} commands, using ordinary @cindex Ordinary @TeX{} commands, using @cindex Commands using ordinary @TeX{} @cindex Plain@TeX{} Inside a region delineated by @code{@@iftex} and @code{@@end iftex}, you can embed some Plain@TeX{} commands. Info will ignore these commands since they are only in that part of the file which is seen by @TeX{}. You can write the @TeX{} commands as you would write them in a normal @TeX{} file, except that you must replace the @samp{\} used by @TeX{} with an @samp{@@}. For example, in the @code{@@titlepage} section of a Texinfo file, you can use the @TeX{} command @code{@@vskip} to format the copyright page. (The @code{@@titlepage} command causes Info to ignore the region automatically, as it does with the @code{@@iftex} command.)@refill However, many features of Plain@TeX{} will not work, as they are overridden by features of Texinfo. You can enter Plain@TeX{} completely, and use @samp{\} in the @TeX{} commands, by delineating a region with the @code{@@tex} and @code{@@end tex} commands. (The @code{@@tex} command also causes Info to ignore the region, like the @code{@@iftex} command.)@refill For example, here is a mathematical expression written in Plain@TeX{}:@refill @example @@tex $$ \chi^2 = \sum_@{i=1@}^N \left (y_i - (a + b x_i) \over \sigma_i\right)^2 $$ @@end tex @end example @ifinfo @noindent The output of this example will appear only in a printed manual. If you are reading this in Info, you will not see anything after this paragraph.@refill @end ifinfo @iftex @noindent The output of this example will appear only in a printed manual. If you are reading this in Info, you will not see anything after this paragraph. In a printed manual, the above expression looks like this:@refill @tex $$ \chi^2 = \sum_{i=1}^N \left(y_i - (a + b x_i) \over \sigma_i\right)^2 $$ @end tex @end iftex @node set and clear, , Using Ordinary TeX Commands, Conditionals @comment node-name, next, previous, up @section @code{@@set} and @code{@@clear} You can direct the Texinfo formatting commands to format or ignore parts of a Texinfo file with the @code{@@set}, @code{@@clear}, and related commands. For example, you can use this option to create one document that has two variants, such as a guide book both for tourists and for natives of an area. The version for tourists could have extra information about how to `get around', while the version for natives would not.@refill To create such a document, write a Texinfo file that specifies some text for one version, some text for the other version, and some text for both versions. The Texinfo formatting commands will only affect the version you designate.@refill Use the @code{@@set @var{flag}} command to turn on, or @dfn{set}, a @var{flag}; a @dfn{flag} can be any word. The format for the command looks like this:@refill @findex set @example @@set @var{flag} @end example When a @var{flag} is set, the Texinfo formatting commands will format text between subsequent pairs of @code{@@ifset @var{flag}} and @code{@@end ifset} commands.@refill @findex ifset For example, here is an extract from a Texinfo file:@refill @example Unless you have good surge suppressors on your power line, you should turn off your computer before a thunderstorm. @@set enough-time-before-storm @@ifset enough-time-before-storm Save all your files, type @@kbd@{sync@} to ensure that the operating system copies all data in memory to the hard disk, type @@kbd@{halt@}, and then turn off the machine. @@end ifset Pull the electric plug from the wall. @end example @noindent In the example, the formatting commands will format the text between @code{@@ifset enough-time-before-storm} and @code{@@end ifset} because the @code{enough-time-before-storm} flag is set.@refill Use the @code{@@clear @var{flag}} command to turn off, or @dfn{clear}, a flag. Clearing a flag is the opposite of setting a flag. The command looks like this:@refill @example @@clear @var{flag} @end example When @var{flag} is cleared, then the Texinfo formatting commands do @emph{not} format the text between @code{@@ifset @var{flag}} and @code{@@end ifset}; that text is ignored and does not appear in either printed or Info output.@refill @findex clear @findex ifclear Thus, if you clear the @code{enough-time-before-storm} flag of the preceding example with @code{@@clear @var{flag}}, the Texinfo formatting commands ignore the text between the @code{@@ifset enough-time-before-storm} and @code{@@end ifset} commands. In the formatted output, that text does not appear; you see only the line that says, ``Pull the electric plug from the wall'', in both printed and Info output.@refill If a flag is cleared with an @code{@@clear @var{flag}} command, then the formatting commands format text between subsequent pairs of @code{@@ifclear} and @code{@@end ifclear} commands. But if the flag is set with @code{@@set @var{flag}}, then the formatting commands do @emph{not} format text between an @code{@@ifclear} and an @code{@@end ifclear} command; rather, they ignore that text. An @code{@@ifclear} command looks like this:@refill @example @@ifclear @var{flag} @end example In brief, the commands are:@refill @table @code @item @@set @var{flag} Tell the Texinfo formatting commands that @var{flag} is set.@refill @item @@clear @var{flag} Tell the Texinfo formatting commands that @var{flag} is cleared.@refill @item @@ifset @var{flag} If @var{flag} is set, tell the Texinfo formatting commands to format the text up to the following @code{@@end ifset} command.@refill If @var{flag} is cleared, tell the Texinfo formatting commands to ignore text up to the following @code{@@end ifset} command.@refill @item @@ifclear @var{flag} If @var{flag} is set, tell the Texinfo formatting commands to ignore the text up to the following @code{@@end ifclear} command.@refill If @var{flag} is cleared, tell the Texinfo formatting commands to format the text up to the following @code{@@end ifclear} command.@refill @end table Write each of these commands on a line of its own.@refill @node Format/Print Hardcopy, Create an Info File, Conditionals, Top @comment node-name, next, previous, up @chapter Format and Print Hardcopy @cindex Format and print hardcopy @cindex Hardcopy, printing it @cindex Making a printed manual @cindex Sorting indices @cindex Indices, sorting @cindex @TeX{} index sorting @findex texindex There are three major shell commands for making a printed manual from a Texinfo file: one for converting the Texinfo file into a file that will be printed, a second for sorting indices, and a third for printing the formatted document. When you use the shell commands, you can either work directly in the operating system shell or work within a shell inside GNU Emacs.@refill If you are using GNU Emacs, you can use commands provided by Texinfo mode instead of shell commands. In addition to the three commands to format a file, sort the indices, and print the result, Texinfo mode offers key bindings for commands to recenter the output buffer, show the print queue, and delete a job from the print queue.@refill @menu * Use TeX:: Use @TeX{} to format for hardcopy. * Shell Format & Print:: How to format and print a hardcopy manual with shell commands. * Within Emacs:: How to format and print from an Emacs shell. * Texinfo Mode Printing:: How to format and print in Texinfo mode. * Compile-Command:: How to print using Emacs's compile command. * Requirements Summary:: @TeX{} formatting requirements summary. * Preparing for TeX:: What you need to do to use @TeX{}. * Overfull hboxes:: What are and what to do with overfull hboxes. * smallbook:: Printing small format books and manuals. @end menu @node Use TeX, Shell Format & Print, , Format/Print Hardcopy @ifinfo @heading Use @TeX{} @end ifinfo The typesetting program called @TeX{} is used for formatting a Texinfo file.@footnote{If you do not have @TeX{}, you can use the @code{texi2roff} program for formatting.} @TeX{} is a very powerful typesetting program and, if used right, does an exceptionally good job. @xref{Obtaining TeX, , How to Obtain @TeX{}}, for information on how to obtain @TeX{}.@refill The @code{makeinfo}, @code{texinfo-format-region}, and @code{texinfo-format-buffer} commands read the very same @@-commands in the Texinfo file as does @TeX{}, but process them differently to make an Info file; see @ref{Create an Info File}.@refill @node Shell Format & Print, Within Emacs, Use TeX, Format/Print Hardcopy @comment node-name, next, previous, up @section How to Format and Print Using Shell Commands @cindex DVI file Format the Texinfo file with the shell command @code{tex} followed by the name of the Texinfo file. This produces a formatted @sc{dvi} file as well as several auxiliary files containing indices, cross references, etc. The @sc{dvi} file (for @dfn{DeVice Independent} file) can be printed on a wide variety of printers.@refill The @code{tex} formatting command itself does not sort the indices; it writes an output file of unsorted index data. This is a misfeature of @TeX{}. Hence, to generate a printed index, you first need a sorted index to work from. The @code{texindex} command sorts indices.@footnote{The source file @file{texindex.c} comes as part of the standard GNU distribution and is usually installed when Emacs is installed.}@refill @findex texindex @ignore Usage: texindex [-k] [-T tempdir] infile [-o outfile] ... Each infile arg can optionally be followed by a `-o outfile' arg; for each infile that is not followed by a -o arg, the infile name with `s' (for `sorted') appended is used for the outfile. -T dir is the directory to put temp files in, instead of /tmp. -k means `keep tempfiles', for debugging. @end ignore The @code{tex} formatting command outputs unsorted index files under names that obey a standard convention. These names are the name of your main input file to the @code{tex} formatting command, with everything after the first period thrown away, and the two letter names of indices added at the end. For example, the raw index output files for the input file @file{foo.texinfo} would be @file{foo.cp}, @file{foo.vr}, @file{foo.fn}, @file{foo.tp}, @file{foo.pg} and @file{foo.ky}. Those are exactly the arguments to give to @code{texindex}. Or else, you can use @samp{??} as ``wild-cards'' and give the command in this form:@refill @example texindex foo.?? @end example @noindent This command will run @code{texindex} on all the unsorted index files, including any that you have defined yourself using @code{@@defindex} or @code{@@defcodeindex}. (You may execute @samp{texindex foo.??} even if there are similarly named files with two letter extensions that are not index files, such as @samp{foo.el}. The @code{texindex} command reports but otherwise ignores such files.)@refill For each file specified, @code{texindex} generates a sorted index file whose name is made by appending @samp{s} to the input file name. The @code{@@printindex} command knows to look for a file of that name. @code{texindex} does not alter the raw index output file.@refill After you have sorted the indices, you need to rerun the @code{tex} formatting command on the Texinfo file. This regenerates a formatted @sc{dvi} file with up-to-date index entries.@footnote{If you use more than one index and have cross references to an index other than the first, you must run @code{tex} @emph{three times} to get correct output: once to generate raw index data; again (after @code{texindex}) to output the text of the indices and determine their true page numbers; and a third time to output correct page numbers in cross references to them. However, cross references to indices are rare.}@refill To summarize, this is a three step process: @enumerate @item Run the @code{tex} formatting command on the Texinfo file. This generates the formatted @sc{dvi} file as well as the raw index files with two letter extensions.@refill @item Run the shell command @code{texindex} on the raw index files to sort them. This creates the corresponding sorted index files.@refill @item Rerun the @code{tex} formatting command on the Texinfo file. This regenerates a formatted @sc{dvi} file with the index entries in the correct order. This second run also corrects the page numbers for the cross references. (The tables of contents are always correct.)@refill @end enumerate You need not run @code{texindex} each time after you run the @code{tex} formatting. If you do not, on the next run, the @code{tex} formatting command will use whatever sorted index files happen to exist from the previous use of @code{texindex}. This is usually @sc{ok} while you are debugging.@refill @findex texi2dvi @r{(shell script)} Rather than type the @code{tex} and @code{texindex} commands yourself, you can use @code{texi2dvi}. This shell script is designed to simplify the @code{tex}---@code{texindex}---@code{tex} sequence by figuring out whether index files and @sc{dvi} files are up-to-date. It runs @code{texindex} and @code{tex} only when necessary. The syntax for @code{texi2dvi} is like this (where @samp{%} is the shell prompt):@refill @example % texi2dvi @var{filename}@dots{} @end example @findex lpr @r{(@sc{dvi} print command)} Finally, you can print the @sc{dvi} file with the @sc{dvi} print command. The precise command to use depends on the system; @samp{lpr -d} is common. The @sc{dvi} print command may require a file name without any extension or with a @samp{.dvi} extension.@refill The following commands, for example, sort the indices, format, and print the @cite{Bison Manual} (where @samp{%} is the shell prompt):@refill @example % tex bison.texinfo % texindex bison.?? % tex bison.texinfo % lpr -d bison.dvi @end example @noindent (Remember that the shell commands may be different at your site; but these are commonly used versions.)@refill @node Within Emacs, Texinfo Mode Printing, Shell Format & Print, Format/Print Hardcopy @comment node-name, next, previous, up @section From an Emacs Shell @dots{} @cindex Print, format from Emacs shell @cindex Format, print from Emacs shell @cindex Shell, format, print from @cindex Emacs shell, format, print from @cindex GNU Emacs shell, format, print from You can give formatting and printing commands from a shell within GNU Emacs. To create a shell within Emacs, type @kbd{M-x shell}. In this shell, you can format and print the document. @xref{Shell Format & Print, , How to Format and Print Using Shell Commands}, for details.@refill You can switch to and from the shell buffer while @code{tex} is running and do other editing. If you are formatting a long document on a slow machine, this can be very convenient.@refill You can also use @code{texi2dvi} from an Emacs shell. For example, here is how to use @code{texi2dvi} to format and print the @cite{GCC Internals Manual} from a shell within Emacs (where @samp{%} is the shell prompt):@refill @example @group % texi2dvi gcc.texinfo % lpr -d gcc.dvi @end group @end example @ifinfo @xref{Texinfo Mode Printing}, for more information about formatting and printing in Texinfo mode.@refill @end ifinfo @node Texinfo Mode Printing, Compile-Command, Within Emacs, Format/Print Hardcopy @section Formatting and Printing in Texinfo Mode @cindex Region printing in Texinfo mode @cindex Format and print in Texinfo mode @cindex Print and format in Texinfo mode Texinfo mode provides several predefined key commands for @TeX{} formatting and printing. These include commands for sorting indices, looking at the printer queue, killing the formatting job, and recentering the display of the buffer in which the operations occur.@refill @table @kbd @item C-c C-t C-r @itemx M-x texinfo-tex-region Run @TeX{} on the current region.@refill @item C-c C-t C-b @itemx M-x texinfo-tex-buffer Run @TeX{} on the current buffer.@refill @item C-c C-t C-i @itemx M-x texinfo-texindex Sort the indices of a Texinfo file formatted with @code{texinfo-tex-region} or @code{texinfo-tex-buffer}.@refill @item C-c C-t C-p @itemx M-x texinfo-tex-print Print a @sc{dvi} file that was made with @code{texinfo-tex-region} or @code{texinfo-tex-buffer}.@refill @item C-c C-t C-q @itemx M-x texinfo-show-tex-print-queue Show the print queue.@refill @item C-c C-t C-d @itemx M-x texinfo-delete-from-tex-print-queue Delete a job from the print queue; you will be prompted for the job number shown by a preceding @kbd{C-c C-t C-q} command (@code{texinfo-show-tex-print-queue}).@refill @item C-c C-t C-k @itemx M-x texinfo-kill-tex-job Kill the currently running @TeX{} job started by @code{texinfo-tex-region} or @code{texinfo-tex-buffer}, or any other process running in the Texinfo shell buffer.@refill @item C-c C-t C-x @itemx M-x texinfo-quit-tex-job Quit a @TeX{} formatting job that has stopped because of an error by sending an @key{x} to it. When you do this, @TeX{} preserves a record of what it did in a @file{.log} file.@refill @item C-c C-t C-l @itemx M-x texinfo-recenter-tex-output-buffer Redisplay the shell buffer in which the @TeX{} printing and formatting commands are run to show its most recent output.@refill @end table Thus, the usual sequence of commands for formatting a buffer is as follows (with comments to the right):@refill @example @group C-c C-t C-b @r{Run @TeX{} on the buffer.} C-c C-t C-i @r{Sort the indices.} C-c C-t C-b @r{Rerun @TeX{} to regenerate indices.} C-c C-t C-p @r{Print the @sc{dvi} file.} C-c C-t C-q @r{Display the printer queue.} @end group @end example The Texinfo mode @TeX{} formatting commands start a subshell in Emacs called the @file{*texinfo-tex-shell*}. The @code{texinfo-tex-command}, @code{texinfo-texindex-command}, and @code{tex-dvi-print-command} commands are all run in this shell. You can watch the commands operate in the @samp{*texinfo-tex-shell*} buffer, and you can switch to and from and use the @samp{*texinfo-tex-shell*} buffer as you would any other shell buffer.@refill The formatting and print commands depend on the values of several variables. The default values are:@refill @sp 1 @need 700 @example @r{Variable} @r{Default value} texinfo-tex-command "tex" texinfo-texindex-command "texindex" texinfo-tex-shell-cd-command "cd" texinfo-tex-dvi-print-command "lpr -d" texinfo-show-tex-queue-command "lpq" texinfo-delete-from-print-queue-command "lprm" texinfo-start-of-header "%**start" texinfo-end-of-header "%**end" texinfo-tex-trailer "@@bye" @end example The default values of @code{texinfo-tex-command} and @code{texinfo-texindex-command} are set in the @file{texnfo-tex.el} file.@refill You can change the values of these variables with the @kbd{M-x edit-options} command (@pxref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual}), with the @kbd{M-x set-variable} command (@pxref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual}), or with your @file{.emacs} initialization file (@pxref{Init File, , , emacs, The GNU Emacs Manual}).@refill @node Compile-Command, Requirements Summary, Texinfo Mode Printing, Format/Print Hardcopy @comment node-name, next, previous, up @section Using the Local Variables List @cindex Local variables @cindex Compile command for formatting @cindex Format with the compile command Yet another way to apply the @TeX{} formatting command to a Texinfo file is to put that command in a @dfn{local variables list} at the end of the Texinfo file. You can then specify the @TeX{} formatting command as a @code{compile-command} and have Emacs run the @TeX{} formatting command by typing @kbd{M-x compile}. This creates a special shell called the @samp{*compilation buffer*} in which Emacs runs the compile command. For example, at the end of the @file{gdb.texinfo} file, after the @code{@@bye}, you would put the following:@refill @example @@c Local Variables: @@c compile-command: "tex gdb.texinfo" @@c End: @end example @noindent This technique is most often used by programmers who also compile programs this way; see @ref{Compilation, , , emacs, The GNU Emacs Manual}.@refill @node Requirements Summary, Preparing for TeX, Compile-Command, Format/Print Hardcopy @comment node-name, next, previous, up @section @TeX{} Formatting Requirements Summary @cindex Requirements for formatting @cindex Formatting requirements Every Texinfo file that is to be input to @TeX{} must begin with a @code{\input} command and contain an @code{@@settitle} command:@refill @example \input texinfo @@settitle @var{name-of-manual} @end example @noindent The first command instructs @TeX{} to load the macros it needs to process a Texinfo file and the second command specifies the title of printed manual.@refill Every Texinfo file must end with a line that terminates @TeX{} processing and forces out unfinished pages:@refill @example @@bye @end example Strictly speaking, these three lines are all a Texinfo file needs for @TeX{}, besides the body. (The @code{@@setfilename} line is the only line that a Texinfo file needs for Info formatting.)@refill Usually, the file's first line contains an @samp{@@c -*-texinfo-*-} comment that causes Emacs to switch to Texinfo mode when you edit the file. In addition, the beginning usually includes an @code{@@setfilename} for Info formatting, an @code{@@setchapternewpage} command, a title page, a copyright page, and permissions. Besides an @code{@@bye}, the end of a file usually includes indices and a table of contents.@refill @noindent @ifinfo For more information, see@* @ref{setchapternewpage, , @code{@@setchapternewpage}},@* @ref{Headings, ,Page Headings},@* @ref{Titlepage & Copyright Page},@* @ref{Printing Indices & Menus}, and@* @ref{Contents}. @end ifinfo @iftex For more information, see @ref{setchapternewpage, , @code{@@setchapternewpage}}, @ref{Headings, ,Page Headings}, @ref{Titlepage & Copyright Page}, @ref{Printing Indices & Menus}, and @ref{Contents}. @end iftex @node Preparing for TeX, Overfull hboxes, Requirements Summary, Format/Print Hardcopy @comment node-name, next, previous, up @section Preparing to Use @TeX{} @cindex Preparing to use @TeX{} @cindex @TeX{} input initialization @cindex @code{TEXINPUTS} environment variable @vindex TEXINPUTS @cindex @b{.profile} initialization file @cindex @b{.cshrc} initialization file @cindex Initialization file for @TeX{} input @TeX{} needs to know where to find the @file{texinfo.tex} file that you have told it to input with the @samp{\input texinfo} command at the beginning of the first line. The @file{texinfo.tex} file tells @TeX{} how to handle @@-commands. (@file{texinfo.tex} is included in the standard GNU distributions.)@refill Usually, the @file{texinfo.tex} file is put in the default directory that contains @TeX{} macros (the @file{/usr/lib/tex/macros} directory) when GNU Emacs or other GNU software is installed. In this case, @TeX{} will find the file and you do not need to do anything special. Alternatively, you can put @file{texinfo.tex} in the directory in which the Texinfo source file is located, and @TeX{} will find it there.@refill However, you may want to specify the location of the @code{\input} file yourself. One way to do this is to write the complete path for the file after the @code{\input} command. Another way is to set the @code{TEXINPUTS} environment variable in your @file{.cshrc} or @file{.profile} file. The @code{TEXINPUTS} environment variable will tell @TeX{} where to find the @file{texinfo.tex} file and any other file that you might want @TeX{} to use.@refill Whether you use a @file{.cshrc} or @file{.profile} file depends on whether you use @code{csh}, @code{sh}, or @code{bash} for your shell command interpreter. When you use @code{csh}, it looks to the @file{.cshrc} file for initialization information, and when you use @code{sh} or @code{bash}, it looks to the @file{.profile} file.@refill In a @file{.cshrc} file, you could use the following @code{csh} command sequence:@refill @example setenv TEXINPUTS .:/usr/me/mylib:/usr/lib/tex/macros @end example In a @file{.profile} file, you could use the following @code{sh} command sequence: @example TEXINPUTS=.:/usr/me/mylib:/usr/lib/tex/macros export TEXINPUTS @end example @noindent This would cause @TeX{} to look for @file{\input} file first in the current directory, indicated by the @samp{.}, then in a hypothetical user's @file{me/mylib} directory, and finally in the system library.@refill @node Overfull hboxes, smallbook, Preparing for TeX, Format/Print Hardcopy @comment node-name, next, previous, up @section Overfull ``hboxes'' @cindex Overfull ``hboxes'' @cindex hboxes, overfull @cindex Final output @TeX{} is sometimes unable to typeset a line without extending it into the right margin. This can occur when @TeX{} comes upon what it interprets as a long word that it cannot hyphenate, such as an electronic mail network address or a very long title. When this happens, @TeX{} prints an error message like this:@refill @example Overfull \hbox (20.76302pt too wide) @end example @noindent (In @TeX{}, lines are in ``horizontal boxes'', hence the term, ``hbox''. The backslash, @samp{\}, is the @TeX{} equivalent of @samp{@@}.)@refill @TeX{} also provides the line number in the Texinfo source file and the text of the offending line, which is marked at all the places that @TeX{} knows how to hyphenate words. @xref{Debugging with TeX, , Catching Errors with @TeX{} Formatting}, for more information about typesetting errors.@refill If the Texinfo file has an overfull hbox, you can rewrite the sentence so the overfull hbox does not occur, or you can decide to leave it. A small excursion into the right margin often does not matter and may not even be noticeable.@refill @cindex Black rectangle in hardcopy @cindex Rectangle, ugly, black in hardcopy @findex finalout However, if you do leave an overfull hbox, unless told otherwise, @TeX{} will print a large, ugly, black rectangle beside the line. This is so you will notice the location of the problem if you are correcting a draft. To prevent such a monstrosity from marring your final printout, put the following in the beginning of the Texinfo file on a line of its own, before the @code{@@titlepage} command:@refill @example @@finalout @end example @node smallbook, , Overfull hboxes, Format/Print Hardcopy @comment node-name, next, previous, up @section Printing ``Small'' Books @findex smallbook @cindex Small book size @cindex Book, printing small @cindex Page sizes for books @cindex Size of printed book By default, @TeX{} typesets pages for printing in an 8.5 by 11 inch format. However, you can direct @TeX{} to typeset a document in a 7 by 9.25 inch format that is suitable for bound books by inserting the following command on a line by itself at the beginning of the Texinfo file, before the title page:@refill @example @@smallbook @end example @noindent (Since regular sized books are often about 7 by 9.25 inches, this command might better have been called the @code{@@regularbooksize} command, but it came to be called the @code{@@smallbook} command by comparison to the 8.5 by 11 inch format.)@refill If you write the @code{@@smallbook} command between the start-of-header and end-of-header lines, the Texinfo mode @TeX{} region formatting command, @code{texinfo-tex-region}, will format the region in ``small'' book size (@pxref{Start of Header}). The Free Software Foundation distributes printed copies of @cite{The GNU Emacs Manual} and other manuals in the ``small'' book size. @xref{smallexample & smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}, for information about commands that make it easier to produce examples for a smaller manual.@refill @node Create an Info File, Install an Info File, Format/Print Hardcopy, Top @comment node-name, next, previous, up @chapter Creating an Info File @cindex Creating an Info file @cindex Info, creating an on-line file @cindex Formatting a file for Info @code{makeinfo} is a utility that converts a Texinfo file into an Info file; @code{texinfo-format-region} and @code{texinfo-format-buffer} are GNU Emacs functions that do the same.@refill A Texinfo file must possess an @code{@@setfilename} line near its beginning, otherwise the Info formatting commands will fail.@refill For information on installing the Info file in the Info system, see @ref{Install an Info File}.@refill @menu * makeinfo advantages:: @code{makeinfo} provides better error checking. * Running makeinfo:: How to run @code{makeinfo} from a shell. * makeinfo options:: Specify fill-column and other options. * Pointer Validation:: How to check that pointers point somewhere. * makeinfo in Emacs:: How to run @code{makeinfo} from Emacs. * texinfo-format commands:: Two Info formatting commands written in Emacs Lisp are an alternative to @code{makeinfo}. * Tag and Split Files:: How tagged and split files help Info to run better. @end menu @node makeinfo advantages, Running makeinfo, , Create an Info File @ifinfo @heading @code{makeinfo} Preferred @end ifinfo The @code{makeinfo} utility creates an Info file from a Texinfo source file more quickly than either of the Emacs formatting commands and provides better error messages. We recommend it. @code{makeinfo} is a C program that is independent of Emacs. You do not need to run Emacs to use @code{makeinfo}, which means you can use @code{makeinfo} on machines that are too small to run Emacs. You can run @code{makeinfo} in any one of three ways: from an operating system shell, from a shell inside Emacs, or by typing a key command in Texinfo mode in Emacs. @refill The @code{texinfo-format-region} and the @code{texinfo-format-buffer} commands are useful if you cannot run @code{makeinfo}. Also, in some circumstances, they format short regions or buffers more quickly than @code{makeinfo}.@refill @node Running makeinfo, makeinfo options, makeinfo advantages, Create an Info File @section Running @code{makeinfo} from a Shell To create an Info file from a Texinfo file, type @code{makeinfo} followed by the name of the Texinfo file. Thus, to create the Info file for Bison, type the following at the shell prompt (where @samp{%} is the prompt):@refill @example % makeinfo bison.texinfo @end example (You can run a shell inside Emacs by typing @kbd{M-x shell}.)@refill @ifinfo Sometimes you will want to specify options. For example, if you wish to discover which version of @code{makeinfo} you are using, type:@refill @example % makeinfo --version @end example @xref{makeinfo options}, for more information. @end ifinfo @node makeinfo options, Pointer Validation, Running makeinfo, Create an Info File @comment node-name, next, previous, up @section Options for @code{makeinfo} @cindex @code{makeinfo} options @cindex Options for @code{makeinfo} The @code{makeinfo} command takes a number of options. Most often, options are used to set the value of the fill column and specify the footnote style. Each command line option is a word preceded by @samp{--}@footnote{@samp{--} has replaced @samp{+}, the old introductory character, to maintain POSIX.2 compatibility without losing long-named options.} or a letter preceded by @samp{-}. You can use abbreviations for the option names as long as they are unique.@refill For example, you could use the following command to create an Info file for @file{bison.texinfo} in which each line is filled to only 68 columns (where @samp{%} is the prompt):@refill @example % makeinfo --fill-column=68 bison.texinfo @end example You can write two or more options in sequence, like this:@refill @example % makeinfo --no-split --fill-column=70 @dots{} @end example @noindent This would keep the Info file together as one possibly very long file and would also set the fill column to 70.@refill @iftex If you wish to discover which version of @code{makeinfo} you are using, type:@refill @example % makeinfo --version @end example @end iftex The options are:@refill @need 100 @table @code @item -D @var{var} Cause @var{var} to be defined. This is equivalent to @code{@@set @var{var}} in the Texinfo file. @need 150 @item --error-limit=@var{limit} Set the maximum number of errors that @code{makeinfo} will report before exiting (on the assumption that continuing would be useless). The default number of errors that can be reported before @code{makeinfo} gives up is 100.@refill @need 150 @item --fill-column=@var{width} Specify the maximum number of columns in a line; this is the right-hand edge of a line. Paragraphs that are filled will be filled to this width. (Filling is the process of breaking up and connecting lines so that lines are the same length as or shorter than the number specified as the fill column. Lines are broken between words.)@refill @item --footnote-style=@var{style} Set the footnote style to @var{style}, either @samp{end} for the end node style or @samp{separate} for the separate node style. The value set by this option overrides the value set in a Texinfo file by an @code{@@footnotestyle} command. When the footnote style is @samp{separate}, @code{makeinfo} makes a new node containing the footnotes found in the current node. When the footnote style is @samp{end}, @code{makeinfo} places the footnote references at the end of the current node.@refill @need 150 @item -I @var{dir} Add @code{dir} to the directory search list for finding files that are included using the @code{@@include} command. By default, @code{makeinfo} searches only the current directory. @need 150 @item --no-headers Do not include menus or node lines in the output. This results in an @sc{ascii} file that you cannot read in Info since it does not contain the requisite nodes or menus; but you can print such a file in a single, typewriter-like font and produce acceptable output. @need 150 @item --no-split Suppress the splitting stage of @code{makeinfo}. Normally, large output files (where the size is greater than 70k bytes) are split into smaller subfiles, each one approximately 50k bytes. If you specify @samp{--no-split}, @code{makeinfo} will not split up the output file.@refill @need 100 @item --no-pointer-validate @item --no-validate Suppress the pointer-validation phase of @code{makeinfo}. Normally, after a Texinfo file is processed, some consistency checks are made to ensure that cross references can be resolved, etc. @xref{Pointer Validation}.@refill @need 150 @item --no-warn Suppress the output of warning messages. This does @emph{not} suppress the output of error messages, only warnings. You might want this if the file you are creating has examples of Texinfo cross references within it, and the nodes that are referenced do not actually exist.@refill @need 150 @item --output=@var{file} @itemx -o @var{file} Specify that the output should be directed to @var{file} and not to the file name specified in the @code{@@setfilename} command found in the texinfo source. @var{file} can be the special token @samp{-}, which specifies standard output. @need 150 @item --paragraph-indent=@var{indent} Set the paragraph indentation style to @var{indent}. The value set by this option overrides the value set in a Texinfo file by an @code{@@paragraphindent} command. The value of @var{indent} is interpreted as follows:@refill @itemize @bullet @item If the value of @var{indent} is @samp{asis}, do not change the existing indentation at the starts of paragraphs.@refill @item If the value of @var{indent} is zero, delete any existing indentation.@refill @item If the value of @var{indent} is greater than zero, indent each paragraph by that number of spaces.@refill @end itemize @need 100 @item --reference-limit=@var{limit} Set the value of the number of references to a node that @code{makeinfo} will make without reporting a warning. If a node has more than this number of references in it, @code{makeinfo} will make the references but also report a warning.@refill @need 150 @item -U @var{var} Cause @var{var} to be undefined. This is equivalent to @code{@@clear @var{var}} in the Texinfo file. @need 100 @item --verbose Cause @code{makeinfo} to display messages saying what it is doing. Normally, @code{makeinfo} only outputs messages if there are errors or warnings.@refill @need 100 @item --version Report the version number of this copy of @code{makeinfo}.@refill @end table @node Pointer Validation, makeinfo in Emacs, makeinfo options, Create an Info File @section Pointer Validation @cindex Pointer validation with @code{makeinfo} @cindex Validation of pointers If you do not suppress pointer-validation (by using the @samp{--no-pointer-validation} option), @code{makeinfo} will check the validity of the final Info file. Mostly, this means ensuring that nodes you have referenced really exist. Here is a complete list of what is checked:@refill @enumerate @item If a `Next', `Previous', or `Up' node reference is a reference to a node in the current file and is not an external reference such as to @file{(dir)}, then the referenced node must exist.@refill @item In every node, if the `Previous' node is different from the `Up' node, then the `Previous' node must also be pointed to by a `Next' node.@refill @item Every node except the `Top' node must have an `Up' pointer.@refill @item The node referenced by an `Up' pointer must contain a reference to the current node in some manner other than through a `Next' reference. This includes menu entries and cross references.@refill @item If the `Next' reference of a node is not the same as the `Next' reference of the `Up' reference, then the node referenced by the `Next' pointer must have a `Previous' pointer that points back to the current node. This rule allows the last node in a section to point to the first node of the next chapter.@refill @end enumerate @node makeinfo in Emacs, texinfo-format commands, Pointer Validation, Create an Info File @section Running @code{makeinfo} inside Emacs @cindex Running @code{makeinfo} in Emacs @cindex @code{makeinfo} inside Emacs @cindex Shell, running @code{makeinfo} in You can run @code{makeinfo} in GNU Emacs Texinfo mode by using either the @code{makeinfo-region} or the @code{makeinfo-buffer} commands. In Texinfo mode, the commands are bound to @kbd{C-c C-m C-r} and @kbd{C-c C-m C-b} by default.@refill @table @kbd @item C-c C-m C-r @itemx M-x makeinfo-region Format the current region for Info.@refill @findex makeinfo-region @item C-c C-m C-b @itemx M-x makeinfo-buffer Format the current buffer for Info.@refill @findex makeinfo-buffer @end table When you invoke either @code{makeinfo-region} or @code{makeinfo-buffer}, Emacs prompts for a file name, offering the name of the visited file as the default. You can edit the default file name in the minibuffer if you wish, before typing @key{RET} to start the @code{makeinfo} process.@refill The Emacs @code{makeinfo-region} and @code{makeinfo-buffer} commands run the @code{makeinfo} program in a temporary shell buffer. If @code{makeinfo} finds any errors, Emacs displays the error messages in the temporary buffer.@refill @cindex Errors, parsing @cindex Parsing errors @findex next-error You can parse the error messages by typing @kbd{C-x `} (@code{next-error}). This causes Emacs to go to and position the cursor on the line in the Texinfo source that @code{makeinfo} thinks caused the error. @xref{Compilation, , Running @code{make} or Compilers Generally, emacs, The GNU Emacs Manual}, for more information about using the @code{next-error} command.@refill In addition, you can kill the shell in which the @code{makeinfo} command is running or make the shell buffer display its most recent output.@refill @table @kbd @item C-c C-m C-k @itemx M-x makeinfo-kill-job @findex makeinfo-kill-job Kill the current running @code{makeinfo} job created by @code{makeinfo-region} or @code{makeinfo-buffer}.@refill @item C-c C-m C-l @itemx M-x makeinfo-recenter-output-buffer @findex makeinfo-recenter-output-buffer Redisplay the @code{makeinfo} shell buffer to display its most recent output.@refill @end table @noindent (Note that the parallel commands for killing and recentering a @TeX{} job are @kbd{C-c C-t C-k} and @kbd{C-c C-t C-l}. @xref{Texinfo Mode Printing}.)@refill You can specify options for @code{makeinfo} by setting the @code{makeinfo-options} variable with either the @kbd{M-x edit-options} or the @kbd{M-x set-variable} command, or by setting the variable in your @file{.emacs} initialization file.@refill For example, you could write the following in your @file{.emacs} file:@refill @example @group (setq makeinfo-options "--paragraph-indent=0 --no-split --fill-column=70 --verbose") @end group @end example @noindent @ifinfo For more information, see@* @ref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual},@* @ref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual},@* @ref{Init File, , , emacs, The GNU Emacs Manual}, and@* @ref{makeinfo options, , Options for @code{makeinfo}}. @end ifinfo @iftex For more information, see @ref{Edit Options, , Editing Variable Values, emacs, The GNU Emacs Manual}, @ref{Examining, , Examining and Setting Variables, emacs, The GNU Emacs Manual}, @ref{Init File, , , emacs, The GNU Emacs Manual}, and @ref{makeinfo options, , Options for @code{makeinfo}}. @end iftex @node texinfo-format commands, Tag and Split Files, makeinfo in Emacs, Create an Info File @comment node-name, next, previous, up @section The @code{texinfo-format@dots{}} Commands @findex texinfo-format-region @findex texinfo-format-buffer In GNU Emacs in Texinfo mode, you can format part or all of a Texinfo file with the @code{texinfo-format-region} command. This formats the current region and displays the formatted text in a temporary buffer called @samp{*Info Region*}.@refill Similarly, you can format a buffer with the @code{texinfo-format-buffer} command. This command creates a new buffer and generates the Info file in it. Typing @kbd{C-x C-s} will save the Info file under the name specified by the @code{@@setfilename} line which must be near the beginning of the Texinfo file.@refill @table @kbd @item C-c C-e C-r @itemx @code{texinfo-format-region} Format the current region for Info. @findex texinfo-format-region @item C-c C-e C-b @itemx @code{texinfo-format-buffer} Format the current buffer for Info. @findex texinfo-format-buffer @end table The @code{texinfo-format-region} and @code{texinfo-format-buffer} commands provide you with some error checking, and other functions can provide you with further help in finding formatting errors. These procedures are described in an appendix; see @ref{Catching Mistakes}. However, the @code{makeinfo} program is often faster and provides better error checking (@pxref{makeinfo in Emacs}).@refill @node Tag and Split Files, , texinfo-format commands, Create an Info File @comment node-name, next, previous, up @section Tag Files and Split Files @cindex Making a tag table automatically @cindex Tag table, making automatically If a Texinfo file has more than 30,000 bytes, @code{texinfo-format-buffer} automatically creates a tag table for its Info file; @code{makeinfo} always creates a tag table. With a @dfn{tag table}, Info can jump to new nodes more quickly than it can otherwise.@refill @cindex Indirect subfiles In addition, if the Texinfo file contains more than about 70,000 bytes, @code{texinfo-format-buffer} and @code{makeinfo} split the large Info file into shorter @dfn{indirect} subfiles of about 50,000 bytes each. Big files are split into smaller files so that Emacs does not need to make a large buffer to hold the whole of a large Info file; instead, Emacs allocates just enough memory for the small, split off file that is needed at the time. This way, Emacs avoids wasting memory when you run Info. (Before splitting was implemented, Info files were always kept short and @dfn{include files} were designed as a way to create a single, large printed manual out of the smaller Info files. @xref{Include Files}, for more information. Include files are still used for very large documents, such as @cite{The Emacs Lisp Reference Manual}, in which each chapter is a separate file.)@refill When a file is split, Info itself makes use of a shortened version of the original file that contains just the tag table and references to the files that were split off. The split off files are called @dfn{indirect} files.@refill The split off files have names that are created by appending @w{@samp{-1}}, @w{@samp{-2}}, @w{@samp{-3}} and so on to the file name specified by the @code{@@setfilename} command. The shortened version of the original file continues to have the name specified by @code{@@setfilename}.@refill At one stage in writing this document, for example, the Info file was saved as @file{test-texinfo} and that file looked like this:@refill @example @group Info file: test-texinfo, -*-Text-*- produced by texinfo-format-buffer from file: new-texinfo-manual.texinfo ^_ Indirect: test-texinfo-1: 102 test-texinfo-2: 50422 test-texinfo-3: 101300 ^_^L Tag table: (Indirect) Node: overview^?104 Node: info file^?1271 Node: printed manual^?4853 Node: conventions^?6855 @dots{} @end group @end example @noindent (But @file{test-texinfo} had far more nodes than are shown here.) Each of the split off, indirect files, @file{test-texinfo-1}, @file{test-texinfo-2}, and @file{test-texinfo-3}, is listed in this file after the line that says @samp{Indirect:}. The tag table is listed after the line that says @samp{Tag table:}. @refill In the list of indirect files, the number following the file name records the cumulative number of bytes in the preceding indirect files, not counting the file list itself, the tag table, or the permissions text in each file. In the tag table, the number following the node name records the location of the beginning of the node, in bytes from the beginning.@refill If you are using @code{texinfo-format-buffer} to create Info files, you may want to run the @code{Info-validate} command. (The @code{makeinfo} command does such a good job on its own, you do not need @code{Info-validate}.) However, you cannot run the @kbd{M-x Info-validate} node-checking command on indirect files. For information on how to prevent files from being split and how to validate the structure of the nodes, see @ref{Using Info-validate}.@refill @node Install an Info File, Command List, Create an Info File, Top @comment node-name, next, previous, up @chapter Installing an Info File @cindex Installing an Info file @cindex Info file installation @cindex @file{dir} directory for Info installation Info files are usually kept in the @file{@dots{}/emacs/info} directory. (You can find the location of this directory within Emacs by typing @kbd{C-h i} to enter Info and then typing @kbd{C-x C-f} to see the full pathname to the @file{info} directory.) @menu * Directory file:: The top level menu for all Info files. * New Info File:: Listing a new info file. * Other Info Directories:: How to specify Info files that are located in other directories. @end menu @node Directory file, New Info File, , Install an Info File @ifinfo @heading The @file{dir} File @end ifinfo For Info to work, the @file{info} directory must contain a file that serves as a top level directory for the Info system. By convention, this file is called @file{dir}. The @file{dir} file is itself an Info file. It contains the top level menu for all the Info files in the system. The menu looks like this:@refill @example * Menu: * Info: (info). Documentation browsing system. * Emacs: (emacs). The extensible, self-documenting text editor. * Texinfo: (texinfo). With one source file, make either a printed manual using TeX or an Info file. @dots{} @end example @noindent Each of these menu entries points to the `Top' node of the Info file that is named in parentheses. (The menu entry does not need to specify the `Top' node, since Info goes to the `Top' node if no node name is mentioned. @xref{Other Info Files, , Nodes in Other Info Files}.)@refill Thus, the @samp{Info} entry points to the `Top' node of the @file{info} file and the @samp{Emacs} entry points to the `Top' node of the @file{emacs} file.@refill In each of the Info files, the `Up' pointer of the `Top' node refers back to the @code{dir} file. For example, the line for the `Top' node of the Emacs manual looks like this in Info:@refill @example File: emacs Node: Top, Up: (DIR), Next: Distrib @end example @noindent (Note that in this case, the file name is written in upper case letters---it can be written in either upper or lower case. Info has a feature that it will change the case of the file name to lower case if it cannot find the name as written.)@refill @c !!! Can any file name be written in upper or lower case, @c or is dir a special case? @c Yes, apparently so, at least with Gillespie's Info. --rjc 24mar92 @c @node New Info File, Other Info Directories, Directory file, Install an Info File @section Listing a New Info File @cindex Adding a new info file @cindex Listing a new info file @cindex New info file, listing it @cindex Info file, listing new one @cindex @file{dir} file listing To add a new Info file to your system, write a new menu entry to the menu in the @file{dir} file by editing the @file{dir} file by hand. Also, put the new Info file in the @file{@dots{}/emacs/info} directory. For example, if you were adding documentation for GDB, you would make the following new entry:@refill @example * GDB: (gdb). The source-level C debugger. @end example @noindent The first part of the menu entry is the menu entry name; it is followed by a colon. The second part is the name of the Info file, in parentheses; it is followed by a period. The third part of the entry is the description of the item.@refill Conventionally, the name of an Info file has a @file{.info} extension. Thus, you might list the name of the file like this: @example * GDB: (gdb.info). The source-level C debugger. @end example @noindent However, Info will look for a file with a @file{.info} extension if it does not find the file under the name given in the menu. This means that in a menu you can refer to the file @file{gdb.info} as @file{gdb}, as shown in the first example. This looks better. @node Other Info Directories, , New Info File, Install an Info File @comment node-name, next, previous, up @section Info Files in Other Directories @cindex Installing Info in another directory @cindex Info installed in another directory @cindex Another Info directory If an Info file is not in the @file{info} directory, there are two ways to specify its location:@refill @itemize @bullet @item Write the pathname as the menu's second part, or;@refill @item Specify the @file{info} directory name in an environment variable in your @file{.profile} or @file{.cshrc} initialization file. (Only you and others with the same environment variable will be able to find Info files whose location is specified this way.)@refill @end itemize For example, to reach a test file in the @file{~bob/manuals} directory, you could add an entry like this to the menu in the @file{dir} file:@refill @example * Test: (~bob/manuals/info-test). Bob's own test file. @end example @noindent In this case, the absolute file name of the @file{info-test} file is written as the second part of the menu entry.@refill @vindex INFOPATH Alternatively, you may set the @code{INFOPATH} environment variable in your @file{.cshrc} or @file{.profile} file. The @code{INFOPATH} environment variable will tell Info where to look.@refill If you use @code{sh} or @code{bash} for your shell command interpreter, you must set the @code{INFOPATH} environment variable in the @file{.profile} initialization file; but if you use @code{csh}, you must set the variable in the @file{.cshrc} initialization file. The two files require slightly different command formats.@refill @itemize @bullet @item In a @file{.cshrc} file, you could set the @code{INFOPATH} variable as follows:@refill @smallexample setenv INFOPATH .:~bob/manuals:/usr/local/emacs/info @end smallexample @item In a @file{.profile} file, you would achieve the same effect by writing:@refill @smallexample INFOPATH=.:~bob/manuals:/usr/local/emacs/info export INFOPATH @end smallexample @end itemize @noindent Either form would cause Info to look first in the current directory, indicated by the @samp{.}, then in the @file{~bob/manuals} directory, and finally in the @file{/usr/local/emacs/info} directory (which is the usual location for the standard Info directory).@refill @c ================ Appendix starts here ================ @node Command List, Tips, Install an Info File, Top @appendix @@-Command List @cindex Alphabetical @@-command list @cindex List of @@-Commands @cindex @@-Command list Here is an alphabetical list of the @@-commands in Texinfo. Square brackets (@r{[}@w{ }@r{]}) indicate optional arguments; an ellipsis (@samp{@dots{}}) indicates repeated text. @sp 1 @table @code @item @@* Force a line break. Do not end a paragraph that uses @code{@@*} with an @code{@@refill} command. @xref{Line Breaks}.@refill @item @@. Stands for a period that really does end a sentence (usually after an end-of-sentence capital letter). @xref{Controlling Spacing}.@refill @item @@: Indicate to @TeX{} that an immediately preceding period, question mark, exclamation mark, or colon does not end a sentence. Prevent @TeX{} from inserting extra whitespace as it does at the end of a sentence. The command has no effect on the Info file output. @xref{Controlling Spacing}.@refill @item @@@@ Stands for @samp{@@}. @xref{Braces Atsigns Periods, , Inserting @samp{@@}}.@refill @item @@@{ Stands for a left-hand brace, @samp{@{}. @xref{Braces Atsigns Periods, , Inserting @@ braces and periods}.@refill @item @@@} Stands for a right-hand brace, @samp{@}}. @xref{Braces Atsigns Periods, , Inserting @@ braces and periods}.@refill @item @@appendix @var{title} Begin an appendix. The title appears in the table of contents of a printed manual. In Info, the title is underlined with asterisks. @xref{unnumbered & appendix, , The @code{@@unnumbered} and @code{@@appendix} Commands}.@refill @item @@appendixsec @var{title} @itemx @@appendixsection @var{title} Begin an appendix section within an appendix. The section title appears in the table of contents of a printed manual. In Info, the title is underlined with equal signs. @code{@@appendixsection} is a longer spelling of the @code{@@appendixsec} command. @xref{unnumberedsec appendixsec heading, , Section Commands}.@refill @item @@appendixsubsec @var{title} Begin an appendix subsection within an appendix. The title appears in the table of contents of a printed manual. In Info, the title is underlined with hyphens. @xref{unnumberedsubsec appendixsubsec subheading, , Subsection Commands}.@refill @item @@appendixsubsubsec @var{title} Begin an appendix subsubsection within a subappendix. The title appears in the table of contents of a printed manual. In Info, the title is underlined with periods. @xref{subsubsection,, The `subsub' Commands}.@refill @item @@asis Used following @code{@@table}, @code{@@ftable}, and @code{@@vtable} to print the table's first column without highlighting (``as is''). @xref{Two-column Tables, , Making a Two-column Table}.@refill @item @@author @var{author} Typeset @var{author} flushleft and underline it. @xref{title subtitle author, , The @code{@@title} and @code{@@author} Commands}.@refill @item @@b@{@var{text}@} Print @var{text} in @b{bold} font. No effect in Info. @xref{Fonts}.@refill @ignore @item @@br Force a paragraph break. If used within a line, follow @code{@@br} with braces. @xref{br, , @code{@@br}}.@refill @end ignore @item @@bullet@{@} Generate a large round dot, or the closest possible thing to one. @xref{bullet, , @code{@@bullet}}.@refill @item @@bye Terminate @TeX{} processing on the file. @TeX{} does not see any of the contents of the file following the @code{@@bye} command. @xref{Ending a File}.@refill @item @@c @var{comment} Begin a comment in Texinfo. The rest of the line does not appear in either the Info file or the printed manual. A synonym for @code{@@comment}. @xref{Conventions, , General Syntactic Conventions}.@refill @item @@cartouche Highlight an example or quotation by drawing a box with rounded corners around it. Pair with @code{@@end cartouche}. No effect in Info. @xref{cartouche, , Drawing Cartouches Around Examples}.)@refill @item @@center @var{line-of-text} Center the line of text following the command. @xref{titlefont center sp, , @code{@@center}}.@refill @item @@chapheading @var{title} Print a chapter-like heading in the text, but not in the table of contents of a printed manual. In Info, the title is underlined with asterisks. @xref{majorheading & chapheading, , @code{@@majorheading} and @code{@@chapheading}}.@refill @item @@chapter @var{title} Begin a chapter. The chapter title appears in the table of contents of a printed manual. In Info, the title is underlined with asterisks. @xref{chapter, , @code{@@chapter}}.@refill @item @@cindex @var{entry} Add @var{entry} to the index of concepts. @xref{Index Entries, , Defining the Entries of an Index}.@refill @item @@cite@{@var{reference}@} Highlight the name of a book or other reference that lacks a companion Info file. @xref{cite, , @code{@@cite}}.@refill @item @@clear @var{flag} Unset @var{flag}, preventing the Texinfo formatting commands from formatting text between subsequent pairs of @code{@@ifset @var{flag}} and @code{@@end ifset} commands. @xref{set and clear, , @code{@@set} and @code{@@clear}}.@refill @item @@code@{@var{sample-code}@} Highlight text that is an expression, a syntactically complete token of a program, or a program name. @xref{code, , @code{@@code}}.@refill @item @@comment @var{comment} Begin a comment in Texinfo. The rest of the line does not appear in either the Info file or the printed manual. A synonym for @code{@@c}. @xref{Conventions, , General Syntactic Conventions}.@refill @item @@contents Print a complete table of contents. Has no effect in Info, which uses menus instead. @xref{Contents, , Generating a Table of Contents}.@refill @item @@copyright@{@} Generate a copyright symbol. @xref{copyright symbol, , @code{@@copyright}}.@refill @ignore @item @@ctrl@{@var{ctrl-char}@} Describe an @sc{ascii} control character. Insert actual control character into Info file. @xref{ctrl, , @code{@@ctrl}}.@refill @end ignore @item @@defcodeindex @var{index-name} Define a new index and its indexing command. Print entries in an @code{@@code} font. @xref{New Indices, , Defining New Indices}.@refill @item @@defcv @var{category} @var{class} @var{name} Format a description for a variable associated with a class in object-oriented programming. Takes three arguments: the category of thing being defined, the class to which it belongs, and its name. @xref{Definition Commands}.@refill @item @@deffn @var{category} @var{name} @var{arguments}@dots{} Format a description for a function, interactive command, or similar entity that may take arguments. @code{@@deffn} takes as arguments the category of entity being described, the name of this particular entity, and its arguments, if any. @xref{Definition Commands}.@refill @item @@defindex @var{index-name} Define a new index and its indexing command. Print entries in a roman font. @xref{New Indices, , Defining New Indices}.@refill @item @@defivar @var{class} @var{instance-variable-name} Format a description for an instance variable in object-oriented programming. The command is equivalent to @samp{@@defcv @{Instance Variable@} @dots{}}. @xref{Definition Commands}.@refill @item @@defmac @var{macro-name} @var{arguments}@dots{} Format a description for a macro. The command is equivalent to @samp{@@deffn Macro @dots{}}. @xref{Definition Commands}.@refill @item @@defmethod @var{class} @var{method-name} @var{arguments}@dots{} Format a description for a method in object-oriented programming. The command is equivalent to @samp{@@defop Method @dots{}}. Takes as arguments the name of the class of the method, the name of the method, and its arguments, if any. @xref{Definition Commands}.@refill @item @@defop @var{category} @var{class} @var{name} @var{arguments}@dots{} Format a description for an operation in object-oriented programming. @code{@@defop} takes as arguments the overall name of the category of operation, the name of the class of the operation, the name of the operation, and its arguments, if any. @xref{Definition Commands}.@refill @need 100 @item @@defopt @var{option-name} Format a description for a user option. The command is equivalent to @samp{@@defvr @{User Option@} @dots{}}. @xref{Definition Commands}.@refill @need 100 @item @@defspec @var{special-form-name} @var{arguments}@dots{} Format a description for a special form. The command is equivalent to @samp{@@deffn @{Special Form@} @dots{}}. @xref{Definition Commands}.@refill @need 200 @item @@deftp @var{category} @var{name-of-type} @var{attributes}@dots{} Format a description for a data type. @code{@@deftp} takes as arguments the category, the name of the type (which is a word like @samp{int} or @samp{float}), and then the names of attributes of objects of that type. @xref{Definition Commands}.@refill @item @@deftypefn @var{classification} @var{data-type} @var{name} @var{arguments}@dots{} Format a description for a function or similar entity that may take arguments and that is typed. @code{@@deftypefn} takes as arguments the classification of entity being described, the type, the name of the entity, and its arguments, if any. @xref{Definition Commands}.@refill @item @@deftypefun @var{data-type} @var{function-name} @var{arguments}@dots{} Format a description for a function in a typed language. The command is equivalent to @samp{@@deftypefn Function @dots{}}. @xref{Definition Commands}.@refill @item @@deftypevr @var{classification} @var{data-type} @var{name} Format a description for something like a variable in a typed language---an entity that records a value. Takes as arguments the classification of entity being described, the type, and the name of the entity. @xref{Definition Commands}.@refill @item @@deftypevar @var{data-type} @var{variable-name} Format a description for a variable in a typed language. The command is equivalent to @samp{@@deftypevr Variable @dots{}}. @xref{Definition Commands}.@refill @item @@defun @var{function-name} @var{arguments}@dots{} Format a description for functions. The command is equivalent to @samp{@@deffn Function @dots{}}. @xref{Definition Commands}.@refill @item @@defvar @var{variable-name} Format a description for variables. The command is equivalent to @samp{@@defvr Variable @dots{}}. @xref{Definition Commands}.@refill @item @@defvr @var{category} @var{name} Format a description for any kind of variable. @code{@@defvr} takes as arguments the category of the entity and the name of the entity. @xref{Definition Commands}.@refill @item @@dfn@{@var{term}@} Highlight the introductory or defining use of a term. @xref{dfn, , @code{@@dfn}}.@refill @need 100 @item @@display Begin a kind of example. Indent text, do not fill, do not select a new font. Pair with @code{@@end display}. @xref{display, , @code{@@display}}.@refill @need 100 @item @@dmn@{@var{dimension}@} Format a dimension. Causes @TeX{} to insert a narrow space before @var{dimension}. Has no effect in Info. Used for writing a number followed by an abbreviation of a dimension name, such as @samp{12@dmn{pt}}, written as @samp{12@@dmn@{pt@}}, with no space between the number and the @code{@@dmn} command. @xref{dmn, , @code{@@dmn}}.@refill @need 100 @item @@dots@{@} Insert an ellipsis: @samp{@dots{}}. @xref{dots, , @code{@@dots}}.@refill @need 100 @item @@emph@{@var{text}@} Highlight @var{text}; text is displayed in @emph{italics} in printed output, and surrounded by asterisks in Info. @xref{Emphasis, , Emphasizing Text}.@refill @need 100 @item @@enumerate Begin a numbered list, using @code{@@item} for each entry. Pair with @code{@@end enumerate}. @xref{enumerate, , @code{@@enumerate}}.@refill @need 100 @item @@equiv@{@} Indicate to the reader the exact equivalence of two forms with a glyph: @samp{@equiv{}}. @xref{Equivalence}.@refill @item @@error@{@} Indicate to the reader with a glyph that the following text is an error message: @samp{@error{}}. @xref{Error Glyph}.@refill @item @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page footings for even-numbered (left-hand) pages. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@evenheading [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page headings for even-numbered (left-hand) pages. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@everyfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page footings for every page. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@everyheading [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page headings for every page. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@example Begin an example. Indent text, do not fill, and select fixed-width font. Pair with @code{@@end example}. @xref{example, , @code{@@example}}.@refill @item @@exdent @var{line-of-text} Remove any indentation a line might have. @xref{exdent, , Undoing the Indentation of a Line}.@refill @item @@expansion@{@} Indicate the result of a macro expansion to the reader with a special glyph: @samp{@expansion{}}. @xref{expansion, , @expansion{} Indicating an Expansion}.@refill @item @@file@{@var{filename}@} Highlight the name of a file, buffer, node, or directory. @xref{file, , @code{@@file}}.@refill @item @@finalout Prevent @TeX{} from printing large black warning rectangles beside over-wide lines. @xref{Overfull hboxes}.@refill @need 100 @item @@findex @var{entry} Add @var{entry} to the index of functions. @xref{Index Entries, , Defining the Entries of an Index}.@refill @need 200 @item @@flushleft Left justify every line but leave the right end ragged. Leave font as is. Pair with @code{@@end flushleft}. @xref{flushleft & flushright, , @code{@@flushleft} and @code{@@flushright}}.@refill @need 200 @item @@flushright Right justify every line but leave the left end ragged. Leave font as is. Pair with @code{@@end flushright}. @xref{flushleft & flushright, , @code{@@flushleft} and @code{@@flushright}}.@refill @need 200 @item @@footnote@{@var{text-of-footnote}@} Enter a footnote. Footnote text is printed at the bottom of the page by @TeX{}; Info may format in either `End' node or `Separate' node style. @xref{Footnotes}.@refill @item @@footnotestyle @var{style} Specify an Info file's footnote style, either @samp{end} for the end node style or @samp{separate} for the separate node style. @xref{Footnotes}.@refill @item @@format Begin a kind of example. Like @code{@@example} or @code{@@display}, but do not narrow the margins and do not select the fixed-width font. Pair with @code{@@end format}. @xref{example, , @code{@@example}}.@refill @item @@ftable @var{formatting-command} Begin a two-column table, using @code{@@item} for each entry. Automatically enter each of the items in the first column into the index of functions. Pair with @code{@@end ftable}. The same as @code{@@table}, except for indexing. @xref{ftable vtable, , @code{@@ftable} and @code{@@vtable}}.@refill @item @@group Hold text together that must appear on one printed page. Pair with @code{@@end group}. Not relevant to Info. @xref{group, , @code{@@group}}.@refill @item @@heading @var{title} Print an unnumbered section-like heading in the text, but not in the table of contents of a printed manual. In Info, the title is underlined with equal signs. @xref{unnumberedsec appendixsec heading, , Section Commands}.@refill @item @@headings @var{on-off-single-double} Turn page headings on or off, or specify single-sided or double-sided page headings for printing. @code{@@headings on} is synonymous with @code{@@headings double}. @xref{headings on off, , The @code{@@headings} Command}.@refill @item @@i@{@var{text}@} Print @var{text} in @i{italic} font. No effect in Info. @xref{Fonts}.@refill @item @@ifclear @var{flag} If @var{flag} is cleared, the Texinfo formatting commands format text between @code{@@ifclear @var{flag}} and the following @code{@@end ifclear} command. @xref{set and clear, , @code{@@set} and @code{@@clear}}.@refill @item @@ifinfo Begin a stretch of text that will be ignored by @TeX{} when it typesets the printed manual. The text appears only in the Info file. Pair with @code{@@end ifinfo}. @xref{Conditionals, , Conditionally Visible Text}.@refill @item @@ifset @var{flag} If @var{flag} is set, the Texinfo formatting commands format text between @code{@@ifset @var{flag}} and the following @code{@@end ifset} command. @xref{set and clear, , @code{@@set} and @code{@@clear}}.@refill @item @@iftex Begin a stretch of text that will not appear in the Info file, but will be processed only by @TeX{}. Pair with @code{@@end iftex}. @xref{Conditionals, , Conditionally Visible Text}.@refill @item @@ignore Begin a stretch of text that will not appear in either the Info file or the printed output. Pair with @code{@@end ignore}. @xref{Comments, , Comments and Ignored Text}.@refill @item @@include @var{filename} Incorporate the contents of the file @var{filename} into the Info file or printed document. @xref{Include Files}.@refill @item @@inforef@{@var{node-name}, [@var{entry-name}], @var{info-file-name}@} Make a cross reference to an Info file for which there is no printed manual. @xref{inforef, , Cross references using @code{@@inforef}}.@refill @item \input @var{macro-definitions-file} Use the specified macro definitions file. This command is used only in the first line of a Texinfo file to cause @TeX{} to make use of the @file{texinfo} macro definitions file. The backslash in @code{\input} is used instead of an @code{@@} because @TeX{} does not properly recognize @code{@@} until after it has read the definitions file. @xref{Header, , The Texinfo File Header}.@refill @item @@item Indicate the beginning of a marked paragraph for @code{@@itemize} and @code{@@enumerate}; indicate the beginning of the text of a first column entry for @code{@@table}, @code{@@ftable}, and @code{@@vtable}. @xref{Lists and Tables}.@refill @item @@itemize @var{mark-generating-character-or-command} Produce a sequence of indented paragraphs, with a mark inside the left margin at the beginning of each paragraph. Pair with @code{@@end itemize}. @xref{itemize, , @code{@@itemize}}.@refill @item @@itemx Like @code{@@item} but do not generate extra vertical space above the item text. @xref{itemx, , @code{@@itemx}}.@refill @item @@kbd@{@var{keyboard-characters}@} Indicate text that consists of characters of input to be typed by users. @xref{kbd, , @code{@@kbd}}.@refill @item @@key@{@var{key-name}@} Highlight @var{key-name}, a conventional name for a key on a keyboard. @xref{key, , @code{@@key}}.@refill @item @@kindex @var{entry} Add @var{entry} to the index of keys. @xref{Index Entries, , Defining the Entries of an Index}.@refill @item @@lisp Begin an example of Lisp code. Indent text, do not fill, and select fixed-width font. Pair with @code{@@end lisp}. @xref{Lisp Example, , @code{@@lisp}}.@refill @item @@majorheading @var{title} Print a chapter-like heading in the text, but not in the table of contents of a printed manual. Generate more vertical whitespace before the heading than the @code{@@chapheading} command. In Info, the chapter heading line is underlined with asterisks. @xref{majorheading & chapheading, , @code{@@majorheading} and @code{@@chapheading}}.@refill @item @@menu Mark the beginning of a menu of nodes in Info. No effect in a printed manual. Pair with @code{@@end menu}. @xref{Menus}.@refill @item @@minus@{@} Generate a minus sign. @xref{minus, , @code{@@minus}}.@refill @item @@need @var{n} Start a new page in a printed manual if fewer than @var{n} mils (thousandths of an inch) remain on the current page. @xref{need, , @code{@@need}}.@refill @item @@node @var{name, next, previous, up} Define the beginning of a new node in Info, and serve as a locator for references for @TeX{}. @xref{node, , @code{@@node}}.@refill @need 200 @item @@noindent Prevent text from being indented as if it were a new paragraph. @xref{noindent, , @code{@@noindent}}.@refill @item @@oddfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page footings for odd-numbered (right-hand) pages. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@oddheading [@var{left}] @@| [@var{center}] @@| [@var{right}] Specify page headings for odd-numbered (right-hand) pages. Not relevant to Info. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@page Start a new page in a printed manual. No effect in Info. @xref{page, , @code{@@page}}.@refill @item @@paragraphindent @var{indent} Indent paragraphs by @var{indent} number of spaces; delete indentation if the value of @var{indent} is 0; and do not change indentation if @var{indent} is @code{asis}. @xref{paragraphindent, , Paragraph Indenting}.@refill @item @@pindex @var{entry} Add @var{entry} to the index of programs. @xref{Index Entries, , Defining the Entries of an Index}.@refill @item @@point@{@} Indicate the position of point in a buffer to the reader with a glyph: @samp{@point{}}. @xref{Point Glyph, , Indicating Point in a Buffer}.@refill @item @@print@{@} Indicate printed output to the reader with a glyph: @samp{@print{}}. @xref{Print Glyph}.@refill @item @@printindex @var{index-name} Print an alphabetized two-column index in a printed manual or generate an alphabetized menu of index entries for Info. @xref{Printing Indices & Menus}.@refill @item @@pxref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} Make a reference that starts with a lower case `see' in a printed manual. Use within parentheses only. Do not follow command with a punctuation mark. The Info formatting commands automatically insert terminating punctuation as needed, which is why you do not need to insert punctuation. Only the first argument is mandatory. @xref{pxref, , @code{@@pxref}}.@refill @item @@quotation Narrow the margins to indicate text that is quoted from another real or imaginary work. Write command on a line of its own. Pair with @code{@@end quotation}. @xref{quotation, , @code{@@quotation}}.@refill @need 100 @item @@r@{@var{text}@} Print @var{text} in @r{roman} font. No effect in Info. @xref{Fonts}.@refill @need 300 @item @@ref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} Make a reference. In a printed manual, the reference does not start with a `See'. Follow command with a punctuation mark. Only the first argument is mandatory. @xref{ref, , @code{@@ref}}.@refill @need 300 @item @@refill In Info, refill and indent the paragraph after all the other processing has been done. No effect on @TeX{}, which always refills. This command is no longer needed, since all formatters now automatically refill. @xref{Refilling Paragraphs}.@refill @need 300 @item @@result@{@} Indicate the result of an expression to the reader with a special glyph: @samp{@result{}}. @xref{result, , @code{@@result}}.@refill @item @@samp@{@var{text}@} Highlight @var{text} that is a literal example of a sequence of characters. Used for single characters, for statements, and often for entire shell commands. @xref{samp, , @code{@@code}}.@refill @item @@sc@{@var{text}@} Set @var{text} in a printed output in @sc{the small caps font} and set text in the Info file in uppercase letters. @xref{Smallcaps}.@refill @item @@section @var{title} Begin a section within a chapter. In a printed manual, the section title is numbered and appears in the table of contents. In Info, the title is underlined with equal signs. @xref{section, , @code{@@section}}.@refill @item @@set @var{flag} Set @var{flag}, causing the Texinfo formatting commands to format text between subsequent pairs of @code{@@ifset @var{flag}} and @code{@@end ifset} commands. @xref{set and clear, , @code{@@set} and @code{@@clear}}.@refill @item @@setchapternewpage @var{on-off-odd} Specify whether chapters start on new pages, and if so, whether on odd-numbered (right-hand) new pages. @xref{setchapternewpage, , @code{@@setchapternewpage}}.@refill @item @@setfilename @var{info-file-name} Provide a name for the Info file. @xref{Conventions, , General Syntactic Conventions}.@refill @item @@settitle @var{title} Provide a title for page headers in a printed manual. @xref{Conventions, , General Syntactic Conventions}.@refill @item @@shortcontents Print a short table of contents. Not relevant to Info, which uses menus rather than tables of contents. A synonym for @code{@@summarycontents}. @xref{Contents, , Generating a Table of Contents}.@refill @need 400 @item @@smallbook Cause @TeX{} to produce a printed manual in a 7 by 9.25 inch format rather than the regular 8.5 by 11 inch format. @xref{smallbook, , Printing Small Books}. Also, see @ref{smallexample & smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}.@refill @need 400 @item @@smallexample Indent text to indicate an example. Do not fill, select fixed-width font. In @code{@@smallbook} format, print text in a smaller font than with @code{@@example}. Pair with @code{@@end smallexample}. @xref{smallexample & smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}.@refill @need 400 @item @@smalllisp Begin an example of Lisp code. Indent text, do not fill, select fixed-width font. In @code{@@smallbook} format, print text in a smaller font. Pair with @code{@@end smalllisp}. @xref{smallexample & smalllisp, , @code{@@smallexample} and @code{@@smalllisp}}.@refill @need 500 @item @@sp @var{n} Skip @var{n} blank lines. @xref{sp, , @code{@@sp}}.@refill @need 500 @item @@strong @var{text} Emphasize @var{text} by typesetting it in a @strong{bold} font for the printed manual and by surrounding it with asterisks for Info. @xref{emph & strong, , Emphasizing Text}.@refill @item @@subheading @var{title} Print an unnumbered subsection-like heading in the text, but not in the table of contents of a printed manual. In Info, the title is underlined with hyphens. @xref{unnumberedsubsec appendixsubsec subheading, , @code{@@unnumberedsubsec} @code{@@appendixsubsec} @code{@@subheading}}.@refill @item @@subsection @var{title} Begin a subsection within a section. In a printed manual, the subsection title is numbered and appears in the table of contents. In Info, the title is underlined with hyphens. @xref{subsection, , @code{@@subsection}}.@refill @item @@subsubheading @var{title} Print an unnumbered subsubsection-like heading in the text, but not in the table of contents of a printed manual. In Info, the title is underlined with periods. @xref{subsubsection, , The `subsub' Commands}.@refill @item @@subsubsection @var{title} Begin a subsubsection within a subsection. In a printed manual, the subsubsection title is numbered and appears in the table of contents. In Info, the title is underlined with periods. @xref{subsubsection, , The `subsub' Commands}.@refill @item @@subtitle @var{title} In a printed manual, set a subtitle in a normal sized font flush to the right-hand side of the page. Not relevant to Info, which does not have title pages. @xref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author} Commands}.@refill @item @@summarycontents Print a short table of contents. Not relevant to Info, which uses menus rather than tables of contents. A synonym for @code{@@shortcontents}. @xref{Contents, , Generating a Table of Contents}.@refill @need 300 @item @@syncodeindex @var{from-index} @var{into-index} Merge the index named in the first argument into the index named in the second argument, printing the entries from the first index in @code{@@code} font. @xref{Combining Indices}.@refill @need 300 @item @@synindex @var{from-index} @var{into-index} Merge the index named in the first argument into the index named in the second argument. Do not change the font of @var{from-index} entries. @xref{Combining Indices}.@refill @need 100 @item @@t@{@var{text}@} Print @var{text} in a @t{fixed-width}, typewriter-like font. No effect in Info. @xref{Fonts}.@refill @need 400 @item @@table @var{formatting-command} Begin a two-column table, using @code{@@item} for each entry. Write each first column entry on the same line as @code{@@item}. First column entries are printed in the font resulting from @var{formatting-command}. Pair with @code{@@end table}. @xref{Two-column Tables, , Making a Two-column Table}. Also see @ref{ftable vtable, , @code{@@ftable} and @code{@@vtable}}, and @ref{itemx, , @code{@@itemx}}.@refill @item @@TeX@{@} Insert the logo @TeX{}. @xref{TeX and copyright, , Inserting @TeX{} and @copyright{}}.@refill @item @@tex Enter @TeX{} completely. Pair with @code{@@end tex}. @xref{Using Ordinary TeX Commands, , Using Ordinary @TeX{} Commands}.@refill @item @@thischapter In a heading or footing, stands for the number and name of the current chapter, in the format `Chapter 1: Title'. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@thischaptername In a heading or footing, stands for the name of the current chapter. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@thisfile In a heading or footing, stands for the name of the current @code{@@include} file. Does not insert anything if not within an @code{@@include} file. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@thispage In a heading or footing, stands for the current page number. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @ignore @item @@thissection In a heading or footing, stands for the title of the current section. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @end ignore @item @@thistitle In a heading or footing, stands for the name of the document, as specified by the @code{@@settitle} command. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@tindex @var{entry} Add @var{entry} to the index of data types. @xref{Index Entries, , Defining the Entries of an Index}.@refill @item @@title @var{title} In a printed manual, set a title flush to the left-hand side of the page in a larger than normal font and underline it with a black rule. Not relevant to Info, which does not have title pages. @xref{title subtitle author, , The @code{@@title} @code{@@subtitle} and @code{@@author} Commands}.@refill @need 400 @item @@titlefont@{@var{text}@} In a printed manual, print @var{text} in a larger than normal font. Not relevant to Info, which does not have title pages. @xref{titlefont center sp, , The @code{@@titlefont} @code{@@center} and @code{@@sp} Commands}.@refill @need 300 @item @@titlepage Indicate to Texinfo the beginning of the title page. Write command on a line of its own. Pair with @code{@@end titlepage}. Nothing between @code{@@titlepage} and @code{@@end titlepage} appears in Info. @xref{titlepage, , @code{@@titlepage}}.@refill @need 150 @item @@today@{@} Insert the current date, in `1 Jan 1900' style. @xref{Custom Headings, , How to Make Your Own Headings}.@refill @item @@top @var{title} In a Texinfo file to be formatted with @code{makeinfo}, identify the topmost @code{@@node} line in the file, which must be written on the line immediately preceding the @code{@@top} command. Used for @code{makeinfo}'s node pointer insertion feature. The title is underlined with asterisks. Both the @code{@@node} line and the @code{@@top} line normally should be enclosed by @code{@@ifinfo} and @code{@@end ifinfo}. In @TeX{} and @code{texinfo-format-buffer}, the @code{@@top} command is merely a synonym for @code{@@unnumbered}. @xref{makeinfo Pointer Creation, , Creating Pointers with @code{makeinfo}}. @item @@unnumbered @var{title} In a printed manual, begin a chapter that appears without chapter numbers of any kind. The title appears in the table of contents of a printed manual. In Info, the title is underlined with asterisks. @xref{unnumbered & appendix, , @code{@@unnumbered} and @code{@@appendix}}.@refill @item @@unnumberedsec @var{title} In a printed manual, begin a section that appears without section numbers of any kind. The title appears in the table of contents of a printed manual. In Info, the title is underlined with equal signs. @xref{unnumberedsec appendixsec heading, , Section Commands}.@refill @item @@unnumberedsubsec @var{title} In a printed manual, begin an unnumbered subsection within a chapter. The title appears in the table of contents of a printed manual. In Info, the title is underlined with hyphens. @xref{unnumberedsubsec appendixsubsec subheading, , @code{@@unnumberedsubsec} @code{@@appendixsubsec} @code{@@subheading}}.@refill @item @@unnumberedsubsubsec @var{title} In a printed manual, begin an unnumbered subsubsection within a chapter. The title appears in the table of contents of a printed manual. In Info, the title is underlined with periods. @xref{subsubsection, , The `subsub' Commands}.@refill @item @@var@{@var{metasyntactic-variable}@} Highlight a metasyntactic variable, which is something that stands for another piece of text. @xref{var, , Indicating Metasyntactic Variables}.@refill @need 400 @item @@vindex @var{entry} Add @var{entry} to the index of variables. @xref{Index Entries, , Defining the Entries of an Index}.@refill @need 400 @item @@vskip @var{amount} In a printed manual, insert whitespace so as to push text on the remainder of the page towards the bottom of the page. Used in formatting the copyright page with the argument @samp{0pt plus 1filll}. (Note spelling of @samp{filll}.) @code{@@vskip} may be used only in contexts ignored for Info. @xref{Copyright & Permissions, , The Copyright Page and Printed Permissions}.@refill @need 400 @item @@vtable @var{formatting-command} Begin a two-column table, using @code{@@item} for each entry. Automatically enter each of the items in the first column into the index of variables. Pair with @code{@@end vtable}. The same as @code{@@table}, except for indexing. @xref{ftable vtable, , @code{@@ftable} and @code{@@vtable}}.@refill @need 400 @item @@w@{@var{text}@} Prevent @var{text} from being split across two lines. Do not end a paragraph that uses @code{@@w} with an @code{@@refill} command. In the Texinfo file, keep @var{text} on one line. @xref{w, , @code{@@w}}.@refill @need 400 @item @@xref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} Make a reference that starts with `See' in a printed manual. Follow command with a punctuation mark. Only the first argument is mandatory. @xref{xref, , @code{@@xref}}.@refill @end table @node Tips, Sample Texinfo File, Command List, Top @comment node-name, next, previous, up @appendix Tips and Hints Here are some tips for writing Texinfo documentation:@refill @cindex Tips @cindex Usage tips @cindex Hints @itemize @bullet @item Write in the present tense, not in the past or the future. @item Write actively! For example, write ``We recommend that @dots{}'' rather than ``It is recommended that @dots{}''. @item Use 70 or 72 as your fill column. Longer lines are hard to read. @item Include a copyright notice and copying permissions. @end itemize @subsubheading Index, index, index! Write many index entries, in different ways. Readers like indices; they are helpful and convenient. Although it is easiest to write index entries as you write the body of the text, some people prefer to write entries afterwards. In either case, write an entry before the paragraph to which it applies. This way, an index entry points to the first page of a paragraph that is split across pages. Here are more hints we have found valuable: @itemize @bullet @item Write each index entry differently, so each entry refers to a different place in the document. The index of an Info file lists only one location for each entry. @item Write index entries only where a topic is discussed significantly. For example, it is not useful to index ``debugging information'' in a chapter on reporting bugs. Someone who wants to know about debugging information will certainly not find it in that chapter. @item Consistently capitalize the first word of every index entry, or else use lower case. According to convention, you should capitalize the first word of an index entry. However, this practice may make an index look crowded. Some writers prefer lower case. Regardless of which you prefer, choose one style and stick to it. Mixing the two styles looks bad. @item Always capitalize or use upper case for those words in an index for which this is proper, such as names of countries or acronyms. @item Write the indexing commands that refer to a whole section immediately after the section command, and write the indexing commands that refer to the paragraph before the paragraph. @example @group @exdent @r{For example:} @@section The Dog and the Fox @@cindex Jumping, in general @@cindex Leaping @end group @group @@cindex Dog, lazy, jumped over @@cindex Lazy dog jumped over @@cindex Fox, jumps over dog @@cindex Quick fox jumps over dog The quick brown fox jumps over the lazy dog. @end group @end example @noindent (Note that the example shows entries for the same concept that are written in different ways---@samp{Lazy dog}, and @samp{Dog, lazy}---so readers can look up the concept in different ways.) @end itemize @subsubheading Blank lines @itemize @bullet @item Insert a blank line between a sectioning command and the first following sentence or paragraph, or between the indexing commands associated with the sectioning command and the first following sentence or paragraph, as shown in the tip on indexing. Otherwise, a formatter may fold title and paragraph together. @item Always insert a blank line before an @code{@@table} command and after an @code{@@end table} command; but never insert a blank line after an @code{@@table} command or before an @code{@@end table} command. @need 1000 For example: @example @group Types of fox: @@table @@samp @@item Quick Jump over lazy dogs. @end group @group @@item Brown Also jump over lazy dogs. @@end table @end group @group @@noindent On the other hand, @dots{} @end group @end example Insert blank lines before and after @code{@@itemize} @dots{} @code{@@end itemize} and @code{@@enumerate} @dots{} @code{@@end enumerate} in the same way. @end itemize @subsubheading Complete phrases Complete phrases are easier to read than @dots{}. @itemize @bullet @item Write entries in an itemized list as complete sentences; or at least, as complete phrases. Incomplete expressions @dots{} awkward @dots{} like this. @item Write the prefatory sentence or phrase for a multi-item list or table as a complete expression. Do not write ``You can set:''; instead, write ``You can set these variables:''. The former expression sounds cut off. @end itemize @subsubheading Editions, dates and versions Write the edition and version numbers and date in three places in every manual: @enumerate @item In the first @code{@@ifinfo} section, for people reading the Texinfo file. @item In the @code{@@titlepage} section, for people reading the printed manual. @item In the `Top' node, for people reading the Info file. @end enumerate @noindent Also, it helps to write a note before the first ifinfo section to explain what you are doing. @example @group @exdent @r{For example:} @@c ===> NOTE! <== @@c Specify the edition and version numbers and date @@c in *three* places: @@c 1. First ifinfo section 2. title page 3. top node @@c To find the locations, search for !!set @end group @group @@ifinfo @@c !!set edition, date, version This is Edition 4.03, January 1992, of the @@cite@{GDB Manual@} for GDB Version 4.3. @dots{} @end group @end example @subsubheading Definition Commands Definition commands are @code{@@deffn}, @code{@@defun}, @code{@@defmac}, and the like, and enable you to write descriptions in a uniform format.@refill @itemize @bullet @item Write just one definition command for each entity you define with a definition command. The automatic indexing feature creates an index entry that leads the reader to the definition. @item Use @code{@@table} @dots{} @code{@@end table} in an appendix that contains a summary of functions, not @code{@@deffn} or other definition commands. @end itemize @subsubheading Capitalization @itemize @bullet @item Capitalize @samp{Texinfo}; it is a name. Do not write the @samp{x} or @samp{i} in upper case. @item Capitalize @samp{Info}; it is a name. @item Write @TeX{} using the @code{@@TeX@{@}} command. Note the uppercase @samp{T} and @samp{X}. This command causes the formatters to typeset the name according to the wishes of Donald Knuth, who wrote @TeX{}. @end itemize @subsubheading Spaces Do not use spaces to format a Texinfo file, except inside of @code{@@example} @dots{} @code{@@end example} and similar commands. For example, @TeX{} fills the following: @example @group @@kbd@{C-x v@} @@kbd@{M-x vc-next-action@} Perform the next logical operation on the version-controlled file corresponding to the current buffer. @end group @end example @noindent so it looks like this: @iftex @quotation @kbd{C-x v} @kbd{M-x vc-next-action} Perform the next logical operation on the version-controlled file corresponding to the current buffer. @end quotation @end iftex @ifinfo @quotation `C-x v' `M-x vc-next-action' Perform the next logical operation on the version-controlled file corresponding to the current buffer. @end quotation @end ifinfo @noindent In this case, the text should be formatted with @code{@@table}, @code{@@item}, and @code{@@itemx}, to create a table. @subsubheading @@code, @@samp, @@var, and @samp{---} @itemize @bullet @item Use @code{@@code} around Lisp symbols, including command names. For example: @example The main function is @@code@{vc-next-action@}, @dots{} @end example @item Avoid putting letters such as @samp{s} immediately after an @samp{@@code}. Such letters look bad. @item Use @code{@@var} around meta-variables. Do not write angle brackets around them. @item Use three hyphens in a row, @samp{---}, to indicate a long dash. @TeX{} typesets these as a long dash and the Info formatters reduce three hyphens to two. @end itemize @subsubheading Periods Outside of Quotes Place periods and other punctuation marks @emph{outside} of quotations, unless the punctuation is part of the quotation. This practice goes against convention, but enables the reader to distinguish between the contents of the quotation and the whole passage. For example, you should write the following sentence with the period outside the end quotation marks: @example Evidently, @samp{au} is an abbreviation for ``author''. @end example @noindent since @samp{au} does @emph{not} serve as an abbreviation for @samp{author.} (with a period following the word). @subsubheading Introducing New Terms @itemize @bullet @item Introduce new terms so that a user who does not know them can understand them from context; or write a definition for the term. For example, in the following, the terms ``check in'', ``register'' and ``delta'' are all appearing for the first time; the example sentence should be rewritten so they are understandable. @quotation The major function assists you in checking in a file to your version control system and registering successive sets of changes to it as deltas. @end quotation @item Use the @code{@@dfn} command around a word being introduced, to indicate that the user should not expect to know the meaning already, and should expect to learn the meaning from this passage. @end itemize @subsubheading @@pxref @c !!! maybe include this in the tips on pxref @ignore By the way, it is okay to use pxref with something else in front of it within the parens, as long as the pxref is followed by the close paren, and the material inside the parents is not part of a larger sentence. It is okay to use @xref inside parens as part of a complete sentence with its own ending punctuation. Perhaps the texinfo manual should give more detail about this. @end ignore Absolutely never use @code{@@pxref} except in the special context for which it is designed: inside parentheses, with the closing parenthesis following immediately after the closing brace. One formatter automatically inserts closing punctuation and the other does not. This means that the output looks right both in printed output and in an Info file, but only when the command is used inside parentheses. @subsubheading Invoking from a Shell You can invoke programs such as Emacs, GCC, and GAWK from a shell. The documentation for each program should contain a section that describes this. Unfortunately, if the node names and titles for these sections are all different, readers find it hard to search for the section.@refill Name such sections with a phrase beginning with the word @w{`Invoking @dots{}'}, as in `Invoking Emacs'; this way users can find the section easily. @subsubheading @sc{ansi c} Syntax When you use @code{@@example} to describe a C function's calling conventions, use the @sc{ansi c} syntax, like this:@refill @example void dld_init (char *@@var@{path@}); @end example @noindent And in the subsequent discussion, refer to the argument values by writing the same argument names, again highlighted with @code{@@var}.@refill Avoid the obsolete style that looks like this:@refill @example #include dld_init (path) char *path; @end example Also, it is best to avoid writing @code{#include} above the declaration just to indicate that the function is declared in a header file. The practice may give the misimpression that the @code{#include} belongs near the declaration of the function. Either state explicitly which header file holds the declaration or, better yet, name the header file used for a group of functions at the beginning of the section that describes the functions.@refill @subsubheading Bad Examples Here are several examples of bad writing to avoid: @quotation If you are working with other people, it assists in coordinating everyone's changes so they do not step on each other. @end quotation @noindent It is not clear what `it' refers to. @quotation SCCS, RCS and other version-control systems all perform similar functions in broadly similar ways (it is this resemblance which makes a unified control mode like this possible). @end quotation @noindent Say, ``@dots{} makes a unified interface such as VC mode possible.'' @quotation When you are done editing the file, you must perform a @code{@@dfn}@{check in@}. @end quotation @noindent Say, `` @dots{} you must @code{@@dfn}@{check in@} the new version.'' That flows better. @subsubheading And Finally @dots{} @itemize @bullet @item Pronounce @TeX{} as if the @samp{X} were a Greek `chi', as the last sound in the name `Bach'. But pronounce Texinfo as in `speck': @samp{teckinfo}. @item Write notes for yourself at the very end of a Texinfo file after the @code{@@bye}. None of the formatters process text after the @code{@@bye}; it is as if the text were within @code{@@ignore} @dots{} @code{@@end ignore}. @end itemize @node Sample Texinfo File, Sample Permissions, Tips, Top @comment node-name, next, previous, up @appendix A Sample Texinfo File @cindex Sample Texinfo file, no comments Here is a complete, short sample Texinfo file, without any commentary. You can see this file, with comments, in the first chapter. @xref{Short Sample, , A Short Sample Texinfo File}. @sp 1 @example \input texinfo @@c -*-texinfo-*- @@c %**start of header @@setfilename sample.info @@settitle Sample Document @@c %**end of header @@setchapternewpage odd @@ifinfo This is a short example of a complete Texinfo file. Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. @@end ifinfo @@titlepage @@sp 10 @@comment The title is printed in a large font. @@center @@titlefont@{Sample Title@} @@c The following two commands start the copyright page. @@page @@vskip 0pt plus 1filll Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. @@end titlepage @@node Top, First Chapter, (dir), (dir) @@comment node-name, next, previous, up @@menu * First Chapter:: The first chapter is the only chapter in this sample. * Concept Index:: This index has two entries. @@end menu @@node First Chapter, Concept Index, Top, Top @@comment node-name, next, previous, up @@chapter First Chapter @@cindex Sample index entry This is the contents of the first chapter. @@cindex Another sample index entry Here is a numbered list. @@enumerate @@item This is the first item. @@item This is the second item. @@end enumerate The @@code@{makeinfo@} and @@code@{texinfo-format-buffer@} commands transform a Texinfo file such as this into an Info file; and @@TeX@{@} typesets it for a printed manual. @@node Concept Index, , First Chapter, Top @@comment node-name, next, previous, up @@unnumbered Concept Index @@printindex cp @@contents @@bye @end example @node Sample Permissions, Include Files, Sample Texinfo File, Top @appendix Sample Permissions @cindex Permissions @cindex Copying permissions Texinfo files should contain sections that tell the readers that they have the right to copy and distribute the Texinfo file, the Info file, the printed manual, and any accompanying software. Here are samples containing the standard text of the Free Software Foundation copying permission notice for an Info file and printed manual. @xref{Distrib, , Distribution, emacs, The GNU Emacs Manual}, for an example of the text that could be used in the software ``Distribution'', ``General Public License'', and ``NO WARRANTY'' sections of a document.@refill @menu * Inserting Permissions:: How to put permissions in your document. * ifinfo Permissions:: Sample @samp{ifinfo} copying permissions. * Titlepage Permissions:: Sample Titlepage copying permissions. @end menu @node Inserting Permissions, ifinfo Permissions, , Sample Permissions @ifinfo @appendixsec Inserting Permissions @end ifinfo In a Texinfo file, the first @code{@@ifinfo} section usually begins with a line that says what the file documents. This is what a person reading the unprocessed Texinfo file or using the advanced Info command @kbd{g *} sees first. @inforef{Expert, Advanced Info commands, info}, for more information. (A reader using the regular Info commands will usually start reading at the first node and skip this first section, which is not in a node.)@refill In the @code{@@ifinfo} section, the summary sentence should be followed by a copyright notice and then by the copying permission notice. One of the copying permission paragraphs is enclosed in @code{@@ignore} and @code{@@end ignore} commands. This paragraph states that the Texinfo file can be processed through @TeX{} and printed, provided the printed manual carries the proper copying permission notice. This paragraph is not made part of the Info file since it is not relevant to the Info file; but it is a mandatory part of the Texinfo file since it permits people to process the Texinfo file in @TeX{}.@refill In the printed manual, the Free Software Foundation copying permission notice follows the copyright notice and publishing information and is located within the region delineated by the @code{@@titlepage} and @code{@@end titlepage} commands. The copying permission notice is exactly the same as the notice in the @code{@@ifinfo} section except that the paragraph enclosed in @code{@@ignore} and @code{@@end ignore} commands is not part of the notice.@refill To make it simple to copy the permission notice into each section of the Texinfo file, the complete permission notices for each section are reproduced in full below.@refill Note that you may need to specify the correct name of a section mentioned in the permission notice. For example, in @cite{The GDB Manual}, the name of the section referring to the General Public License is called the ``GDB General Public License'', but in the sample shown below, that section is referred to generically as the ``General Public License''.@refill @node ifinfo Permissions, Titlepage Permissions, Inserting Permissions, Sample Permissions @comment node-name, next, previous, up @appendixsec @samp{ifinfo} Copying Permissions @cindex @samp{ifinfo} permissions In the @code{@@ifinfo} section of the Texinfo file, the standard Free Software Foundation permission notices reads as follows:@refill @example This file documents @dots{} Copyright 1988 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @@ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries a copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @@end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Distribution'' and ``General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled ``Distribution'' and ``General Public License'' may be included in a translation approved by the author instead of in the original English. @end example @node Titlepage Permissions, , ifinfo Permissions, Sample Permissions @comment node-name, next, previous, up @appendixsec Titlepage Copying Permissions @cindex Titlepage permissions In the @code{@@titlepage} section of the Texinfo file, the standard Free Software Foundation copying permission notice follows the copyright notice and publishing information. The standard phrasing is as follows: @example Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections entitled ``Distribution'' and ``General Public License'' are included exactly as in the original, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that the sections entitled ``Distribution'' and ``General Public License'' may be included in a translation approved by the author instead of in the original English. @end example @node Include Files, Headings, Sample Permissions, Top @comment node-name, next, previous, up @appendix Include Files @cindex Include files When @TeX{} or an Info formatting command sees an @code{@@include} command in a Texinfo file, it processes the contents of the file named by the command and incorporates them into the @sc{dvi} or Info file being created. Index entries from the included file are incorporated into the indices of the output file.@refill Include files let you keep a single large document as a collection of conveniently small parts.@refill @menu * Using Include Files:: How to use the @code{@@include} command. * texinfo-multiple-files-update:: How to create and update nodes and menus when using included files. * Include File Requirements:: What @code{texinfo-multiple-files-update} expects. * Sample Include File:: A sample outer file with included files within it; and a sample included file. * Include Files Evolution:: How use of the @code{@@include} command has changed over time. @end menu @node Using Include Files, texinfo-multiple-files-update, , Include Files @appendixsec How to Use Include Files @findex include To include another file within a Texinfo file, write the @code{@@include} command at the beginning of a line and follow it on the same line by the name of a file to be included. For example:@refill @example @@include buffers.texi @end example An included file should simply be a segment of text that you expect to be included as is into the overall or @dfn{outer} Texinfo file; it should not contain the standard beginning and end parts of a Texinfo file. In particular, you should not start an included file with a line saying @samp{\input texinfo}; if you do, that phrase is inserted into the output file as is. Likewise, you should not end an included file with an @code{@@bye} command; that command will stop @TeX{} processing immediately.@refill In the past, you were required to write an @code{@@setfilename} line at the beginning of an included file, but no longer. Now, it does not matter whether you write such a line. If an @code{@@setfilename} line exists in an included file, it is ignored.@refill Conventionally, an included file begins with an @code{@@node} line that is followed by an @code{@@chapter} line. Each included file is one chapter. This makes it easy to use the regular node and menu creating and updating commands to create the node pointers and menus within the included file. However, the simple Emacs node and menu creating and updating commands do not work with multiple Texinfo files. Thus you cannot use these commands to fill in the `Next', `Previous', and `Up' pointers of the @code{@@node} line that begins the included file. Also, you cannot use the regular commands to create a master menu for the whole file. Either you must insert the menus and the `Next', `Previous', and `Up' pointers by hand, or you must use the GNU Emacs Texinfo mode command, @code{texinfo-multiple-files-update}, that is designed for @code{@@include} files.@refill @node texinfo-multiple-files-update, Include File Requirements, Using Include Files, Include Files @appendixsec @code{texinfo-multiple-files-update} @findex texinfo-multiple-files-update GNU Emacs Texinfo mode provides the @code{texinfo-multiple-files-update} command. This command creates or updates `Next', `Previous', and `Up' pointers of included files as well as those in the outer or overall Texinfo file, and it creates or updates a main menu in the outer file. Depending whether you call it with optional arguments, the command updates only the pointers in the first @code{@@node} line of the included files or all of them:@refill @table @kbd @item M-x texinfo-multiple-files-update Called without any arguments:@refill @itemize @minus @item Create or update the `Next', `Previous', and `Up' pointers of the first @code{@@node} line in each file included in an outer or overall Texinfo file.@refill @item Create or update the `Top' level node pointers of the outer or overall file.@refill @item Create or update a main menu in the outer file.@refill @end itemize @item C-u M-x texinfo-multiple-files-update Called with @kbd{C-u} as a prefix argument: @itemize @minus{} @item Create or update pointers in the first @code{@@node} line in each included file. @item Create or update the `Top' level node pointers of the outer file. @item Create and insert a master menu in the outer file. The master menu is made from all the menus in all the included files.@refill @end itemize @item C-u 8 M-x texinfo-multiple-files-update Called with a numeric prefix argument, such as @kbd{C-u 8}: @itemize @minus @item Create or update @strong{all} the `Next', `Previous', and `Up' pointers of all the included files.@refill @item Create or update @strong{all} the menus of all the included files.@refill @item Create or update the `Top' level node pointers of the outer or overall file.@refill @item And then create a master menu in the outer file. This is similar to invoking @code{texinfo-master-menu} with an argument when you are working with just one file.@refill @end itemize @end table @noindent Note the use of the prefix argument in interactive use: with a regular prefix argument, just @w{@kbd{C-u}}, the @code{texinfo-multiple-files-update} command inserts a master menu; with a numeric prefix argument, such as @kbd{C-u 8}, the command updates @strong{every} pointer and menu in @strong{all} the files and then inserts a master menu.@refill @node Include File Requirements, Sample Include File, texinfo-multiple-files-update, Include Files @appendixsec Include File Requirements @cindex Include file requirements @cindex Requirements for include files If you plan to use the @code{texinfo-multiple-files-update} command, the outer Texinfo file that lists included files within it should contain nothing but the beginning and end parts of a Texinfo file, and a number of @code{@@include} commands listing the included files. It should not even include indices, which should be listed in an included file of their own.@refill Moreover, each of the included files must contain exactly one highest level node (conventionally, @code{@@chapter} or equivalent), and this node must be the first node in the included file. Furthermore, each of these highest level nodes in each included file must be at the same hierarchical level in the file structure. Usually, each is an @code{@@chapter}, an @code{@@appendix}, or an @code{@@unnumbered} node. Thus, normally, each included file contains one, and only one, chapter or equivalent-level node.@refill The outer file should contain only @emph{one} node, the `Top' node. It should @emph{not} contain any nodes besides the single `Top' node. The @code{texinfo-multiple-files-update} command will not process them.@refill @node Sample Include File, Include Files Evolution, Include File Requirements, Include Files @appendixsec Sample File with @code{@@include} @cindex Sample @code{@@include} file @cindex @code{@@include} file sample Here is an example of a complete outer Texinfo file with @code{@@include} files within it before running @code{texinfo-multiple-files-update}, which would insert a main or master menu:@refill @example @group \input texinfo @@c -*-texinfo-*- @c %**start of header @@setfilename include-example.info @@settitle Include Example @c %**end of header @end group @group @@setchapternewpage odd @@titlepage @@sp 12 @@center @@titlefont@{Include Example@} @@sp 2 @@center by Whom Ever @end group @group @@page @@vskip 0pt plus 1filll Copyright @@copyright@{@} 1990 Free Software Foundation, Inc. @@end titlepage @end group @group @@ifinfo @@node Top, First, (dir), (dir) @@top Master Menu @@end ifinfo @end group @group @@include foo.texinfo @@include bar.texinfo @@include concept-index.texinfo @end group @group @@summarycontents @@contents @@bye @end group @end example An included file, such as @file{foo.texinfo}, might look like this:@refill @example @group @@node First, Second, , Top @@chapter First Chapter Contents of first chapter @dots{} @end group @end example The full contents of @file{concept-index.texinfo} might be as simple as this: @example @group @@node Concept Index, , Second, Top @@unnumbered Concept Index @@printindex cp @end group @end example The outer Texinfo source file for @cite{The GNU Emacs Lisp Reference Manual} is named @file{elisp.texi}. This outer file contains a master menu with 417 entries and a list of 41 @code{@@include} files.@refill @node Include Files Evolution, , Sample Include File, Include Files @comment node-name, next, previous, up @appendixsec Evolution of Include Files When Info was first created, it was customary to create many small Info files on one subject. Each Info file was formatted from its own Texinfo source file. This custom meant that Emacs did not need to make a large buffer to hold the whole of a large Info file when someone wanted information; instead, Emacs allocated just enough memory for the small Info file that contained the particular information sought. This way, Emacs could avoid wasting memory.@refill References from one file to another were made by referring to the file name as well as the node name. (@xref{Other Info Files, , Referring to Other Info Files}. Also, see @ref{Four and Five Arguments, , @code{@@xref} with Four and Five Arguments}.)@refill Include files were designed primarily as a way to create a single, large printed manual out of several smaller Info files. In a printed manual, all the references were within the same document, so @TeX{} could automatically determine the references' page numbers. The Info formatting commands used include files only for creating joint indices; each of the individual Texinfo files had to be formatted for Info individually. (Each, therefore, required its own @code{@@setfilename} line.)@refill However, because large Info files are now split automatically, it is no longer necessary to keep them small.@refill Nowadays, multiple Texinfo files are used mostly for large documents, such as @cite{The GNU Emacs Lisp Reference Manual}, and for projects in which several different people write different sections of a document simultaneously.@refill In addition, the Info formatting commands have been extended to work with the @code{@@include} command so as to create a single large Info file that is split into smaller files if necessary. This means that you can write menus and cross references without naming the different Texinfo files.@refill @node Headings, Catching Mistakes, Include Files, Top @comment node-name, next, previous, up @appendix Page Headings @cindex Headings @cindex Footings @cindex Page numbering @cindex Page headings @cindex Formatting headings and footings Most printed manuals contain headings along the top of every page except the title and copyright pages. Some manuals also contain footings. (Headings and footings have no meaning to Info, which is not paginated.)@refill @menu * Headings Introduced:: Conventions for using page headings. * Heading Format:: Standard page heading formats. * Heading Choice:: How to specify the type of page heading. * Custom Headings:: How to create your own headings and footings. @end menu @node Headings Introduced, Heading Format, , Headings @ifinfo @heading Headings Introduced @end ifinfo Texinfo provides standard page heading formats for manuals that are printed on one side of each sheet of paper and for manuals that are printed on both sides of the paper. Usually, you will use one or other of these formats, but you can specify your own format, if you wish.@refill In addition, you can specify whether chapters should begin on a new page, or merely continue the same page as the previous chapter; and if chapters begin on new pages, you can specify whether they must be odd-numbered pages.@refill By convention, a book is printed on both sides of each sheet of paper. When you open a book, the right-hand page is odd-numbered, and chapters begin on right-hand pages---a preceding left-hand page is left blank if necessary. Reports, however, are often printed on just one side of paper, and chapters begin on a fresh page immediately following the end of the preceding chapter. In short or informal reports, chapters often do not begin on a new page at all, but are separated from the preceding text by a small amount of whitespace.@refill The @code{@@setchapternewpage} command controls whether chapters begin on new pages, and whether one of the standard heading formats is used. In addition, Texinfo has several heading and footing commands that you can use to generate your own heading and footing formats.@refill In Texinfo, headings and footings are single lines at the tops and bottoms of pages; you cannot create multiline headings or footings. Each header or footer line is divided into three parts: a left part, a middle part, and a right part. Any part, or a whole line, may be left blank. Text for the left part of a header or footer line is set flushleft; text for the middle part is centered; and, text for the right part is set flushright.@refill @node Heading Format, Heading Choice, Headings Introduced, Headings @comment node-name, next, previous, up @appendixsec Standard Heading Formats Texinfo provides two standard heading formats, one for manuals printed on one side of each sheet of paper, and the other for manuals printed on both sides of the paper. By default, nothing is specified for the footing of a Texinfo file, so the footing remains blank.@refill The standard format for single-sided printing consists of a header line in which the left-hand part contains the name of the chapter, the central part is blank, and the right-hand part contains the page number.@refill The single-sided page looks like this: @example @group _______________________ | | | chapter page number | | | | Start of text ... | | ... | | | @end group @end example The standard format for two-sided printing depends on whether the page number is even or odd. By convention, even-numbered pages are on the left- and odd-numbered pages are on the right. (@TeX{} will adjust the widths of the left- and right-hand margins. Usually, widths are correct, but during double-sided printing, it is wise to check that pages will bind properly---sometimes a printer will produce output in which the even-numbered pages have a larger right-hand margin than the odd-numbered pages.)@refill In the standard double-sided format, the left part of the left-hand (even-numbered) page contains the page number, the central part is blank, and the right part contains the title (specified by the @code{@@settitle} command). The left part of the right-hand (odd-numbered) page contains the name of the chapter, the central part is blank, and the right part contains the page number.@refill The two pages, side by side as in an open book, look like this:@refill @example @group _______________________ _______________________ | | | | | page number title | | chapter page number | | | | | | Start of text ... | | More text ... | | ... | | ... | | | | | @end group @end example @noindent The chapter name is preceded by the word @samp{Chapter}, the chapter number and a colon. This makes it easier to keep track of where you are in the manual.@refill @node Heading Choice, Custom Headings, Heading Format, Headings @comment node-name, next, previous, up @appendixsec Specifying the Type of Heading @TeX{} does not begin to generate page headings for a standard Texinfo file until it reaches the @code{@@end titlepage} command. Thus, the title and copyright pages are not numbered. The @code{@@end titlepage} command causes @TeX{} to begin to generate page headings according to a standard format specified by the @code{@@setchapternewpage} command that precedes the @code{@@titlepage} section.@refill There are four possibilities:@refill @table @asis @item No @code{@@setchapternewpage} command Cause @TeX{} to specify the single-sided heading format, with chapters on new pages. This is the same as @code{@@setchapternewpage on}.@refill @item @code{@@setchapternewpage on} Specify the single-sided heading format, with chapters on new pages.@refill @item @code{@@setchapternewpage off} Cause @TeX{} to start a new chapter on the same page as the last page of the preceding chapter, after skipping some vertical whitespace. Also cause @TeX{} to typeset for single-sided printing. (You can override the headers format with the @code{@@headings double} command; see @ref{headings on off, , The @code{@@headings} Command}.)@refill @item @code{@@setchapternewpage odd} Specify the double-sided heading format, with chapters on new pages.@refill @end table @noindent Texinfo lacks an @code{@@setchapternewpage even} command.@refill @node Custom Headings, , Heading Choice, Headings @comment node-name, next, previous, up @appendixsec How to Make Your Own Headings You can use the standard headings provided with Texinfo or specify your own.@refill @c Following paragraph is verbose to prevent overfull hboxes. Texinfo provides six commands for specifying headings and footings. The @code{@@everyheading} command and @code{@@everyfooting} command generate page headers and footers that are the same for both even- and odd-numbered pages. The @code{@@evenheading} command and @code{@@evenfooting} command generate headers and footers for even-numbered (left-hand) pages; and the @code{@@oddheading} command and @code{@@oddfooting} command generate headers and footers for odd-numbered (right-hand) pages.@refill Write custom heading specifications in the Texinfo file immediately after the @code{@@end titlepage} command. Enclose your specifications between @code{@@iftex} and @code{@@end iftex} commands since the @code{texinfo-format-buffer} command may not recognize them. Also, you must cancel the predefined heading commands with the @code{@@headings off} command before defining your own specifications.@refill Here is how to tell @TeX{} to place the chapter name at the left, the page number in the center, and the date at the right of every header for both even- and odd-numbered pages:@refill @example @group @@iftex @@headings off @@everyheading @@thischapter @@| @@thispage @@| @@today@{@} @@end iftex @end group @end example @noindent You need to divide the left part from the central part and the central part from the right had part by inserting @samp{@@|} between parts. Otherwise, the specification command will not be able to tell where the text for one part ends and the next part begins.@refill Each part can contain text or @@-commands. The text is printed as if the part were within an ordinary paragraph in the body of the page. The @@-commands replace themselves with the page number, date, chapter name, or whatever.@refill Here are the six heading and footing commands:@refill @findex everyheading @findex everyfooting @table @code @item @@everyheading @var{left} @@| @var{center} @@| @var{right} @itemx @@everyfooting @var{left} @@| @var{center} @@| @var{right} The `every' commands specify the format for both even- and odd-numbered pages. These commands are for documents that are printed on one side of each sheet of paper, or for documents in which you want symmetrical headers or footers.@refill @findex evenheading @findex evenfooting @findex oddheading @findex oddfooting @item @@evenheading @var{left} @@| @var{center} @@| @var{right} @itemx @@oddheading @var{left} @@| @var{center} @@| @var{right} @itemx @@evenfooting @var{left} @@| @var{center} @@| @var{right} @itemx @@oddfooting @var{left} @@| @var{center} @@| @var{right} The `even' and `odd' commands specify the format for even-numbered pages and odd-numbered pages. These commands are for books and manuals that are printed on both sides of each sheet of paper.@refill @end table Use the @samp{@@this@dots{}} series of @@-commands to provide the names of chapters and sections and the page number. You can use the @samp{@@this@dots{}} commands in the left, center, or right portions of headers and footers, or anywhere else in a Texinfo file so long as they are between @code{@@iftex} and @code{@@end iftex} commands.@refill @need 1000 Here are the @samp{@@this@dots{}} commands:@refill @table @code @findex thispage @item @@thispage Expands to the current page number.@refill @c !!! Karl Berry says that `thissection' fails on page breaks. @ignore @item @@thissection Expands to the name of the current section.@refill @end ignore @findex thischaptername @item @@thischaptername Expands to the name of the current chapter.@refill @findex thischapter @item @@thischapter Expands to the number and name of the current chapter, in the format `Chapter 1: Title'.@refill @findex thistitle @item @@thistitle Expands to the name of the document, as specified by the @code{@@settitle} command.@refill @findex thisfile @item @@thisfile For @code{@@include} files only: expands to the name of the current @code{@@include} file. If the current Texinfo source file is not an @code{@@include} file, this command has no effect. This command does @emph{not} provide the name of the current Texinfo source file unless it is an @code{@@include} file. (@xref{Include Files}, for more information about @code{@@include} files.)@refill @end table @noindent You can also use the @code{@@today@{@}} command, which expands to the current date, in `1 Jan 1900' format.@refill @findex today Other @@-commands and text are printed in a header or footer just as if they were in the body of a page. It is useful to incorporate text, particularly when you are writing drafts:@refill @example @group @@iftex @@headings off @@everyheading @@emph@{Draft!@} @@| @@thispage @@| @@thischapter @@everyfooting @@| @@| Version: 0.27: @@today@{@} @@end iftex @end group @end example Beware of overlong titles: they may overlap another part of the header or footer and blot it out.@refill @node Catching Mistakes, Refilling Paragraphs, Headings, Top @comment node-name, next, previous, up @appendix Formatting Mistakes @cindex Structure, catching mistakes in @cindex Nodes, catching mistakes @cindex Catching mistakes @cindex Correcting mistakes @cindex Mistakes, catching @cindex Problems, catching @cindex Debugging the Texinfo structure Besides mistakes in the content of your documentation, there are two kinds of mistake you can make with Texinfo: you can make mistakes with @@-commands, and you can make mistakes with the structure of the nodes and chapters.@refill Emacs has two tools for catching the @@-command mistakes and two for catching structuring mistakes.@refill For finding problems with @@-commands, you can run @TeX{} or a region formatting command on the region that has a problem; indeed, you can run these commands on each region as you write it.@refill For finding problems with the structure of nodes and chapters, you can use @kbd{C-c C-s} (@code{texinfo-show-structure}) and the related @code{occur} command and you can use the @kbd{M-x Info-validate} command.@refill @menu * makeinfo preferred:: @code{makeinfo} finds errors. * Debugging with Info:: How to catch errors with Info formatting. * Debugging with TeX:: How to catch errors with @TeX{} formatting. * Using texinfo-show-structure:: How to use @code{texinfo-show-structure}. * Using occur:: How to list all lines containing a pattern. * Running Info-Validate:: How to find badly referenced nodes. @end menu @node makeinfo preferred, Debugging with Info, , Catching Mistakes @ifinfo @heading @code{makeinfo} Find Errors @end ifinfo The @code{makeinfo} program does an excellent job of catching errors and reporting them---far better than @code{texinfo-format-region} or @code{texinfo-format-buffer}. In addition, the various functions for automatically creating and updating node pointers and menus remove many opportunities for human error.@refill If you can, use the updating commands to create and insert pointers and menus. These prevent many errors. Then use @code{makeinfo} (or its Texinfo mode manifestations, @code{makeinfo-region} and @code{makeinfo-buffer}) to format your file and check for other errors. This is the best way to work with Texinfo. But if you cannot use @code{makeinfo}, or your problem is very puzzling, then you may want to use the tools described in this appendix.@refill @node Debugging with Info, Debugging with TeX, makeinfo preferred, Catching Mistakes @comment node-name, next, previous, up @appendixsec Catching Errors with Info Formatting @cindex Catching errors with Info formatting @cindex Debugging with Info formatting After you have written part of a Texinfo file, you can use the @code{texinfo-format-region} or the @code{makeinfo-region} command to see whether the region formats properly.@refill Most likely, however, you are reading this section because for some reason you cannot use the @code{makeinfo-region} command; therefore, the rest of this section presumes that you are using @code{texinfo-format-region}.@refill If you have made a mistake with an @@-command, @code{texinfo-format-region} will stop processing at or after the error and display an error message. To see where in the buffer the error occurred, switch to the @samp{*Info Region*} buffer; the cursor will be in a position that is after the location of the error. Also, the text will not be formatted after the place where the error occurred (or more precisely, where it was detected).@refill For example, if you accidentally end a menu with the command @code{@@end menus} with an `s' on the end, instead of with @code{@@end menu}, you will see an error message that says:@refill @example @@end menus is not handled by texinfo @end example @noindent The cursor will stop at the point in the buffer where the error occurs, or not long after it. The buffer will look like this:@refill @example @group ---------- Buffer: *Info Region* ---------- * Menu: * Using texinfo-show-structure:: How to use `texinfo-show-structure' to catch mistakes. * Running Info-Validate:: How to check for unreferenced nodes. @@end menus @point{} ---------- Buffer: *Info Region* ---------- @end group @end example The @code{texinfo-format-region} command sometimes provides slightly odd error messages. For example, the following cross reference fails to format:@refill @example (@@xref@{Catching Mistakes, for more info.) @end example @noindent In this case, @code{texinfo-format-region} detects the missing closing brace but displays a message that says @samp{Unbalanced parentheses} rather than @samp{Unbalanced braces}. This is because the formatting command looks for mismatches between braces as if they were parentheses.@refill Sometimes @code{texinfo-format-region} fails to detect mistakes. For example, in the following, the closing brace is swapped with the closing parenthesis:@refill @example (@@xref@{Catching Mistakes), for more info.@} @end example @noindent Formatting produces: @example (*Note for more info.: Catching Mistakes) @end example The only way for you to detect this error is to realize that the reference should have looked like this:@refill @example (*Note Catching Mistakes::, for more info.) @end example Incidentally, if you are reading this node in Info and type @kbd{f @key{RET}} (@code{Info-follow-reference}), you will generate an error message that says: @example No such node: "Catching Mistakes) The only way @dots{} @end example @noindent This is because Info perceives the example of the error as the first cross reference in this node and if you type a @key{RET} immediately after typing the Info @kbd{f} command, Info will attempt to go to the referenced node. If you type @kbd{f catch @key{TAB} @key{RET}}, Info will complete the node name of the correctly written example and take you to the `Catching Mistakes' node. (If you try this, you can return from the `Catching Mistakes' node by typing @kbd{l} (@code{Info-last}).) @c !!! section on using Elisp debugger ignored. @ignore Sometimes @code{texinfo-format-region} will stop long after the original error; this is because it does not discover the problem until then. In this case, you will need to backtrack.@refill @c menu @c * Using the Emacs Lisp Debugger:: How to use the Emacs Lisp debugger. @c end menu @c node Using the Emacs Lisp Debugger @c appendixsubsec Using the Emacs Lisp Debugger @c index Using the Emacs Lisp debugger @c index Emacs Lisp debugger @c index Debugger, using the Emacs Lisp If an error is especially elusive, you can turn on the Emacs Lisp debugger and look at the backtrace; this tells you where in the @code{texinfo-format-region} function the problem occurred. You can turn on the debugger with the command:@refill @example M-x set-variable @key{RET} debug-on-error @key{RET} t @key{RET} @end example @noindent and turn it off with @example M-x set-variable @key{RET} debug-on-error @key{RET} nil @key{RET} @end example Often, when you are using the debugger, it is easier to follow what is going on if you use the Emacs Lisp files that are not byte-compiled. The byte-compiled sources send octal numbers to the debugger that may look mysterious. To use the uncompiled source files, load @file{texinfmt.el} and @file{texinfo.el} with the @kbd{M-x load-file} command.@refill The debugger will not catch an error if @code{texinfo-format-region} does not detect one. In the example shown above, @code{texinfo-format-region} did not find the error when the whole list was formatted, but only when part of the list was formatted. When @code{texinfo-format-region} did not find an error, the debugger did not find one either. @refill However, when @code{texinfo-format-region} did report an error, it invoked the debugger. This is the backtrace it produced:@refill @example ---------- Buffer: *Backtrace* ---------- Signalling: (search-failed "[@},]") re-search-forward("[@},]") (while ...) (let ...) texinfo-format-parse-args() (let ...) texinfo-format-xref() funcall(texinfo-format-xref) (if ...) (let ...) (if ...) (while ...) texinfo-format-scan() (save-excursion ...) (let ...) texinfo-format-region(103370 103631) * call-interactively(texinfo-format-region) ---------- Buffer: *Backtrace* ---------- @end example The backtrace is read from the bottom up. @code{texinfo-format-region} was called interactively; and it, in turn, called various functions, including @code{texinfo-format-scan}, @code{texinfo-format-xref} and @code{texinfo-format-parse-args}. Inside the function @code{texinfo-format-parse-args}, the function @code{re-search-forward} was called; it was this function that could not find the missing right-hand brace.@refill @xref{Lisp Debug, , Debugging Emacs Lisp, emacs, The GNU Emacs Manual}, for more information.@refill @end ignore @node Debugging with TeX, Using texinfo-show-structure, Debugging with Info, Catching Mistakes @comment node-name, next, previous, up @appendixsec Catching Errors with @TeX{} Formatting @cindex Catching errors with @TeX{} formatting @cindex Debugging with @TeX{} formatting You can also catch mistakes when you format a file with @TeX{}.@refill Usually, you will want to do this after you have run @code{texinfo-format-buffer} (or, better, @code{makeinfo-buffer}) on the same file, because @code{texinfo-format-buffer} sometimes displays error messages that make more sense than @TeX{}. (@xref{Debugging with Info}, for more information.)@refill For example, @TeX{} was run on a Texinfo file, part of which is shown here:@refill @example ---------- Buffer: texinfo.texi ---------- name of the texinfo file as an extension. The @@samp@{??@} are `wildcards' that cause the shell to substitute all the raw index files. (@@xref@{sorting indices, for more information about sorting indices.)@@refill ---------- Buffer: texinfo.texi ---------- @end example @noindent (The cross reference lacks a closing brace.) @TeX{} produced the following output, after which it stopped:@refill @example ---------- Buffer: *texinfo-tex-shell* ---------- Runaway argument? @{sorting indices, for more information about sorting indices.) @@refill @@ETC. ! Paragraph ended before @@xref was complete. @@par l.27 ? ---------- Buffer: *texinfo-tex-shell* ---------- @end example In this case, @TeX{} produced an accurate and understandable error message: @example Paragraph ended before @@xref was complete. @end example @noindent @samp{@@par} is an internal @TeX{} command of no relevance to Texinfo. @samp{l.27} means that @TeX{} detected the problem on line 27 of the Texinfo file. The @samp{?} is the prompt @TeX{} uses in this circumstance.@refill Unfortunately, @TeX{} is not always so helpful, and sometimes you must truly be a Sherlock Holmes to discover what went wrong.@refill In any case, if you run into a problem like this, you can do one of three things.@refill @enumerate @item You can tell @TeX{} to continue running and ignore just this error by typing @key{RET} at the @samp{?} prompt.@refill @item You can tell @TeX{} to continue running and to ignore all errors as best it can by typing @kbd{r @key{RET}} at the @samp{?} prompt.@refill This is often the best thing to do. However, beware: the one error may produce a cascade of additional error messages as its consequences are felt through the rest of the file. (To stop @TeX{} when it is producing such an avalanche of error messages, type @kbd{C-d} (or @kbd{C-c C-d}, if you running a shell inside Emacs.))@refill @item You can tell @TeX{} to stop this run by typing @kbd{x @key{RET}} at the @samp{?} prompt.@refill @end enumerate Please note that if you are running @TeX{} inside Emacs, you need to switch to the shell buffer and line at which @TeX{} offers the @samp{?} prompt.@refill Sometimes @TeX{} will format a file without producing error messages even though there is a problem. This usually occurs if a command is not ended but @TeX{} is able to continue processing anyhow. For example, if you fail to end an itemized list with the @code{@@end itemize} command, @TeX{} will write a @sc{dvi} file that you can print out. The only error message that @TeX{} will give you is the somewhat mysterious comment that@refill @example (@@end occurred inside a group at level 1) @end example @noindent However, if you print the @sc{dvi} file, you will find that the text of the file that follows the itemized list is entirely indented as if it were part of the last item in the itemized list. The error message is the way @TeX{} says that it expected to find an @code{@@end} command somewhere in the file; but that it could not determine where it was needed.@refill Another source of notoriously hard-to-find errors is a missing @code{@@end group} command. If you ever are stumped by incomprehensible errors, look for a missing @code{@@end group} command first.@refill If the Texinfo file lacks header lines, @TeX{} may stop in the beginning of its run and display output that looks like the following. The @samp{*} indicates that @TeX{} is waiting for input.@refill @example This is TeX, Version 2.0 for Berkeley UNIX (preloaded format=plain-cm 87.10.25) (test.texinfo [1]) * @end example @noindent In this case, simply type @kbd{\end @key{RET}} after the asterisk. Then write the header lines in the Texinfo file and run the @TeX{} command again. (Note the use of the backslash, @samp{\}. @TeX{} uses @samp{\} instead of @samp{@@}; and in this circumstance, you are working directly with @TeX{} not with Texinfo.)@refill @node Using texinfo-show-structure, Using occur, Debugging with TeX, Catching Mistakes @comment node-name, next, previous, up @appendixsec Using @code{texinfo-show-structure} @cindex Showing the structure of a file @findex texinfo-show-structure It is not always easy to keep track of the nodes, chapters, sections, and subsections of a Texinfo file. This is especially true if you are revising or adding to a Texinfo file that someone else has written.@refill In GNU Emacs, in Texinfo mode, the @code{texinfo-show-structure} command lists all the lines that begin with the @@-commands that specify the structure: @code{@@chapter}, @code{@@section}, @code{@@appendix}, and so on. With an argument (@w{@kbd{C-u}} as prefix argument, if interactive), the command also shows the @code{@@node} lines. The @code{texinfo-show-structure} command is bound to @kbd{C-c C-s} in Texinfo mode, by default.@refill The lines are displayed in a buffer called the @samp{*Occur*} buffer. For example, when @code{texinfo-show-structure} was run on an earlier version of this appendix, it produced the following:@refill @smallexample Lines matching "^@@\\(chapter \\|sect\\|sub\\|unnum\\|major\\| heading \\|appendix\\)" in buffer texinfo.texi. 4:@@appendix Formatting Mistakes 52:@@appendixsec Catching Errors with Info Formatting 222:@@appendixsec Catching Errors with @@TeX@{@} Formatting 338:@@appendixsec Using @@code@{texinfo-show-structure@} 407:@@appendixsubsec Using @@code@{occur@} 444:@@appendixsec Finding Badly Referenced Nodes 513:@@appendixsubsec Running @@code@{Info-validate@} 573:@@appendixsubsec Splitting a File Manually @end smallexample This says that lines 4, 52, and 222 of @file{texinfo.texi} begin with the @code{@@appendix}, @code{@@appendixsec}, and @code{@@appendixsec} commands respectively. If you move your cursor into the @samp{*Occur*} window, you can position the cursor over one of the lines and use the @kbd{C-c C-c} command (@code{occur-mode-goto-occurrence}), to jump to the corresponding spot in the Texinfo file. @xref{Other Repeating Search, , Using Occur, emacs, The GNU Emacs Manual}, for more information about @code{occur-mode-goto-occurrence}.@refill The first line in the @samp{*Occur*} window describes the @dfn{regular expression} specified by @var{texinfo-heading-pattern}. This regular expression is the pattern that @code{texinfo-show-structure} looks for. @xref{Regexps, , Using Regular Expressions, emacs, The GNU Emacs Manual}, for more information.@refill When you invoke the @code{texinfo-show-structure} command, Emacs will display the structure of the whole buffer. If you want to see the structure of just a part of the buffer, of one chapter, for example, use the @kbd{C-x n} (@code{narrow-to-region}) command to mark the region. (@xref{Narrowing, , , emacs, The GNU Emacs Manual}.) This is how the example used above was generated. (To see the whole buffer again, use @kbd{C-x w} (@code{widen}).)@refill If you call @code{texinfo-show-structure} with a prefix argument by typing @w{@kbd{C-u C-c C-s}}, it will list lines beginning with @code{@@node} as well as the lines beginning with the @@-sign commands for @code{@@chapter}, @code{@@section}, and the like.@refill You can remind yourself of the structure of a Texinfo file by looking at the list in the @samp{*Occur*} window; and if you have mis-named a node or left out a section, you can correct the mistake.@refill @node Using occur, Running Info-Validate, Using texinfo-show-structure, Catching Mistakes @comment node-name, next, previous, up @appendixsec Using @code{occur} @cindex Occurrences, listing with @code{@@occur} @findex occur Sometimes the @code{texinfo-show-structure} command produces too much information. Perhaps you want to remind yourself of the overall structure of a Texinfo file, and are overwhelmed by the detailed list produced by @code{texinfo-show-structure}. In this case, you can use the @code{occur} command directly. To do this, type@refill @example @kbd{M-x occur} @end example @noindent and then, when prompted, type a @dfn{regexp}, a regular expression for the pattern you want to match. (@xref{Regexps, , Regular Expressions, emacs, The GNU Emacs Manual}.) The @code{occur} command works from the current location of the cursor in the buffer to the end of the buffer. If you want to run @code{occur} on the whole buffer, place the cursor at the beginning of the buffer.@refill For example, to see all the lines that contain the word @samp{@@chapter} in them, just type @samp{@@chapter}. This will produce a list of the chapters. It will also list all the sentences with @samp{@@chapter} in the middle of the line.@refill If you want to see only those lines that start with the word @samp{@@chapter}, type @samp{^@@chapter} when prompted by @code{occur}. If you want to see all the lines that end with a word or phrase, end the last word with a @samp{$}; for example, @samp{catching mistakes$}. This can be helpful when you want to see all the nodes that are part of the same chapter or section and therefore have the same `Up' pointer.@refill @xref{Other Repeating Search, , Using Occur, emacs , The GNU Emacs Manual}, for more information.@refill @node Running Info-Validate, , Using occur, Catching Mistakes @comment node-name, next, previous, up @appendixsec Finding Badly Referenced Nodes @findex Info-validate @cindex Nodes, checking for badly referenced @cindex Checking for badly referenced nodes @cindex Looking for badly referenced nodes @cindex Finding badly referenced nodes @cindex Badly referenced nodes You can use the @code{Info-validate} command to check whether any of the `Next', `Previous', `Up' or other node pointers fail to point to a node. This command checks that every node pointer points to an existing node. The @code{Info-validate} command works only on Info files, not on Texinfo files.@refill The @code{makeinfo} program validates pointers automatically, so you do not need to use the @code{Info-validate} command if you are using @code{makeinfo}. You only may need to use @code{Info-validate} if you are unable to run @code{makeinfo} and instead must create an Info file using @code{texinfo-format-region} or @code{texinfo-format-buffer}, or if you write an Info file from scratch.@refill @menu * Using Info-validate:: How to run @code{Info-validate}. * Unsplit:: How to create an unsplit file. * Tagifying:: How to tagify a file. * Splitting:: How to split a file manually. @end menu @node Using Info-validate, Unsplit, , Running Info-Validate @appendixsubsec Running @code{Info-validate} @cindex Running @code{Info-validate} @cindex Info validating a large file @cindex Validating a large file To use @code{Info-validate}, visit the Info file you wish to check and type:@refill @example M-x Info-validate @end example @noindent (Note that the @code{Info-validate} command requires an upper case `I'. You may also need to create a tag table before running @code{Info-validate}. @xref{Tagifying}.)@refill If your file is valid, you will receive a message that says ``File appears valid''. However, if you have a pointer that does not point to a node, error messages will be displayed in a buffer called @samp{*problems in info file*}.@refill For example, @code{Info-validate} was run on a test file that contained only the first node of this manual. One of the messages said:@refill @example In node "Overview", invalid Next: Texinfo Mode @end example @noindent This meant that the node called @samp{Overview} had a `Next' pointer that did not point to anything (which was true in this case, since the test file had only one node in it).@refill Now suppose we add a node named @samp{Texinfo Mode} to our test case but we do not specify a `Previous' for this node. Then we will get the following error message:@refill @example In node "Texinfo Mode", should have Previous: Overview @end example @noindent This is because every `Next' pointer should be matched by a `Previous' (in the node where the `Next' points) which points back.@refill @code{Info-validate} also checks that all menu entries and cross references point to actual nodes.@refill Note that @code{Info-validate} requires a tag table and does not work with files that have been split. (The @code{texinfo-format-buffer} command automatically splits files larger than 100,000 bytes.) In order to use @code{Info-validate} on a large file, you must run @code{texinfo-format-buffer} with an argument so that it does not split the Info file; and you must create a tag table for the unsplit file.@refill @node Unsplit, Tagifying, Using Info-validate, Running Info-Validate @comment node-name, next, previous, up @appendixsubsec Creating an Unsplit File @cindex Creating an unsplit file @cindex Unsplit file creation You can run @code{Info-validate} only on a single Info file that has a tag table. The command will not work on the indirect subfiles that are generated when a master file is split. If you have a large file (longer than 70,000 bytes or so), you need to run the @code{texinfo-format-buffer} or @code{makeinfo-buffer} command in such a way that it does not create indirect subfiles. You will also need to create a tag table for the Info file. After you have done this, you can run @code{Info-validate} and look for badly referenced nodes.@refill The first step is to create an unsplit Info file. To prevent @code{texinfo-format-buffer} from splitting a Texinfo file into smaller Info files, give a prefix to the @kbd{M-x texinfo-format-buffer} command:@refill @example C-u M-x texinfo-format-buffer @end example @noindent or else @example C-u C-c C-e C-b @end example @noindent When you do this, Texinfo will not split the file and will not create a tag table for it. @refill @cindex Making a tag table manually @cindex Tag table, making manually @node Tagifying, Splitting, Unsplit, Running Info-Validate @appendixsubsec Tagifying a File After creating an unsplit Info file, you must create a tag table for it. Visit the Info file you wish to tagify and type:@refill @example M-x Info-tagify @end example @noindent (Note the upper case @key{I} in @code{Info-tagify}.) This creates an Info file with a tag table that you can validate.@refill The third step is to validate the Info file:@refill @example M-x Info-validate @end example @noindent (Note the upper case @key{I} in @code{Info-validate}.) In brief, the steps are:@refill @example @group C-u M-x texinfo-format-buffer M-x Info-tagify M-x Info-validate @end group @end example After you have validated the node structure, you can rerun @code{texinfo-format-buffer} in the normal way so it will construct a tag table and split the file automatically, or you can make the tag table and split the file manually.@refill @node Splitting, , Tagifying, Running Info-Validate @comment node-name, next, previous, up @appendixsubsec Splitting a File Manually @cindex Splitting an Info file manually @cindex Info file, splitting manually You should split a large file or else let the @code{texinfo-format-buffer} or @code{makeinfo-buffer} command do it for you automatically. (Generally you will let one of the formatting commands do this job for you. @xref{Create an Info File}.)@refill The split-off files are called the indirect subfiles.@refill Info files are split to save memory. With smaller files, Emacs does not have make such a large buffer to hold the information.@refill If an Info file has more than 30 nodes, you should also make a tag table for it. @xref{Using Info-validate}, for information about creating a tag table. (Again, tag tables are usually created automatically by the formatting command; you only need to create a tag table yourself if you are doing the job manually. Most likely, you will do this for a large, unsplit file on which you have run @code{Info-validate}.)@refill @c Info-split is autoloaded in `loaddefs.el' in Emacs 18.51 @ignore Before running @code{Info-split}, you need to load the @code{info} library into Emacs by giving the command @kbd{M-x load-library @key{RET} info @key{RET}}. @end ignore Visit the Info file you wish to tagify and split and type the two commands:@refill @example M-x Info-tagify M-x Info-split @end example @noindent (Note that the @samp{I} in @samp{Info} is upper case.)@refill When you use the @code{Info-split} command, the buffer is modified into a (small) Info file which lists the indirect subfiles. This file should be saved in place of the original visited file. The indirect subfiles are written in the same directory the original file is in, with names generated by appending @samp{-} and a number to the original file name.@refill The primary file still functions as an Info file, but it contains just the tag table and a directory of subfiles.@refill @node Refilling Paragraphs, Command Syntax, Catching Mistakes, Top @comment node-name, next, previous, up @appendix Refilling Paragraphs @cindex Refilling paragraphs @cindex Filling paragraphs @findex refill The @code{@@refill} command refills and, optionally, indents the first line of a paragraph.@footnote{Perhaps the command should have been called the @code{@@refillandindent} command, but @code{@@refill} is shorter and the name was chosen before indenting was possible.} The @code{@@refill} command is no longer important, but we describe it here because you once needed it. You will see it in many old Texinfo files.@refill Without refilling, paragraphs containing long @@-constructs may look bad after formatting because the formatter removes @@-commands and shortens some lines more than others. In the past, neither the @code{texinfo-format-region} command nor the @code{texinfo-format-buffer} command refilled paragraphs automatically. The @code{@@refill} command had to be written at the end of every paragraph to cause these formatters to fill them. (Both @TeX{} and @code{makeinfo} have always refilled paragraphs automatically.) Now, all the Info formatters automatically fill and indent those paragraphs that need to be filled and indented.@refill The @code{@@refill} command causes @code{texinfo-format-region} and @code{texinfo-format-buffer} to refill a paragraph in the Info file @emph{after} all the other processing has been done. For this reason, you can not use @code{@@refill} with a paragraph containing either @code{@@*} or @code{@@w@{ @dots{} @}} since the refilling action will override those two commands.@refill The @code{texinfo-format-region} and @code{texinfo-format-buffer} commands now automatically append @code{@@refill} to the end of each paragraph that should be filled. They do not append @code{@@refill} to the ends of paragraphs that contain @code{@@*} or @w{@code{@@w@{ @dots{}@}}} and therefore do not refill or indent them.@refill @node Command Syntax, Obtaining TeX, Refilling Paragraphs, Top @comment node-name, next, previous, up @appendix @@-Command Syntax @cindex @@-Command Syntax The character @samp{@@} is used to start special Texinfo commands. (It has the same meaning that @samp{\} has in Plain@TeX{}.) Texinfo has four types of @@-command:@refill @table @asis @item 1. Non-alphabetic commands. These commands consist of an @@ followed by a punctuation mark or other character that is not part of the alphabet. Non-alphabetic commands are almost always part of the text within a paragraph, and never take any argument. The two characters (@@ and the other one) are complete in themselves; none is followed by braces. The non-alphabetic commands are: @code{@@.}, @code{@@:}, @code{@@*}, @code{@@@@}, @code{@@@{}, and @code{@@@}}.@refill @item 2. Alphabetic commands that do not require arguments. These commands start with @@ followed by a word followed by left- and right-hand braces. These commands insert special symbols in the document; they do not require arguments. For example, @code{@@dots@{@}} @result{} @samp{@dots{}}, @code{@@equiv@{@}} @result{} @samp{@equiv{}}, @code{@@TeX@{@}} @result{} `@TeX{}', and @code{@@bullet@{@}} @result{} @samp{@bullet{}}.@refill @item 3. Alphabetic commands that require arguments within braces. These commands start with @@ followed by a letter or a word, followed by an argument within braces. For example, the command @code{@@dfn} indicates the introductory or defining use of a term; it is used as follows: @samp{In Texinfo, @@@@-commands are @@dfn@{mark-up@} commands.}@refill @item 4. Alphabetic commands that occupy an entire line. These commands occupy an entire line. The line starts with @@, followed by the name of the command (a word); for example, @code{@@center} or @code{@@cindex}. If no argument is needed, the word is followed by the end of the line. If there is an argument, it is separated from the command name by a space. Braces are not used.@refill @end table @cindex Braces and argument syntax Thus, the alphabetic commands fall into classes that have different argument syntaxes. You cannot tell to which class a command belongs by the appearance of its name, but you can tell by the command's meaning: if the command stands for a glyph, it is in class 2 and does not require an argument; if it makes sense to use the command together with other text as part of a paragraph, the command is in class 3 and must be followed by an argument in braces; otherwise, it is in class 4 and uses the rest of the line as its argument.@refill The purpose of having a different syntax for commands of classes 3 and 4 is to make Texinfo files easier to read, and also to help the GNU Emacs paragraph and filling commands work properly. There is only one exception to this rule: the command @code{@@refill}, which is always used at the end of a paragraph immediately following the final period or other punctuation character. @code{@@refill} takes no argument and does @emph{not} require braces. @code{@@refill} never confuses the Emacs paragraph commands because it cannot appear at the beginning of a line.@refill @node Obtaining TeX, New Features, Command Syntax, Top @appendix How to Obtain @TeX{} @cindex Obtaining @TeX{} @cindex @TeX{}, how to obtain @c !!! Here is information about obtaining TeX. Update it whenever. @c Last updated by RJC on 13 January 1992 @c based on message from elisabet@@max.u.washington.edu @TeX{} is freely redistributable. You can obtain @TeX{} for Unix systems from the University of Washington for a distribution fee.@refill To order a full distribution, send $200.00 for a 1/2-inch 9-track 1600 bpi (@code{tar} or @code{cpio}) tape reel, or $210.00 for a 1/4-inch 4-track QIC-24 (@code{tar} or @code{cpio}) cartridge, to:@refill @display Northwest Computing Support Center DR-10, Thomson Hall 35 University of Washington Seattle, Washington 98195 @end display @noindent Please make checks payable to the University of Washington.@refill Prepaid orders are preferred but purchase orders are acceptable; however, purchase orders carry an extra charge of $10.00, to pay for processing.@refill Overseas sites: please add to the base cost $20.00 for shipment via air parcel post, or $30.00 for shipment via courier.@refill Please check with the Northwest Computing Support Center at the University of Washington for current prices and formats:@refill @example @group @r{telephone:} (206) 543-6259 @r{email:} elisabet@@max.u.washington.edu @end group @end example @node New Features, Command and Variable Index, Obtaining TeX, Top @appendix Second Edition Features The second edition of the Texinfo manual describes more than 20 new Texinfo mode commands and more than 50 previously undocumented Texinfo @@-commands. This edition is more than twice the length of the first edition. Here is a brief description of the new commands.@refill @menu * New Texinfo Mode Commands:: The updating commands are especially useful. * New Commands:: Many newly described @@-commands. @end menu @node New Texinfo Mode Commands, New Commands, , New Features @appendixsec New Texinfo Mode Commands Texinfo mode provides commands and features especially designed for working with Texinfo files. More than 20 new commands have been added, including commands for automatically creating and updating both nodes and menus. This is a tedious task when done by hand.@refill The keybindings are intended to be somewhat mnemonic.@refill @subheading Update Pointers @noindent Create or update `Next', `Previous', and `Up' node pointers.@refill @noindent @xref{Updating Nodes and Menus}. @example @group C-c C-u C-n @r{Update a node.} C-c C-u C-e @r{Update every node in the buffer.} @end group @end example @subheading Update Menus @noindent Create or update menus.@refill @noindent @xref{Updating Nodes and Menus}. @example @group C-c C-u m @r{Create or update a master menu.} @r{With @kbd{C-u} as a prefix argument,} @r{first create or update all nodes} @r{and regular menus.} @end group @group C-c C-u C-m @r{Make or update a menu.} @end group @group C-c C-u C-a @r{Make or update all the menus in a buffer.} @r{With @kbd{C-u} as a prefix argument,} @r{first update all the nodes.} @end group @end example @subheading Format for Info @noindent Provide keybindings both for the Info formatting commands that are written in Emacs Lisp and for @code{makeinfo} which is written in C.@refill @noindent @xref{Info Formatting}. @noindent Use the Emacs lisp @code{texinfo-format@dots{}} commands: @example @group C-c C-e C-r @r{Format the region.} C-c C-e C-b @r{Format the buffer.} @end group @end example @noindent Use @code{makeinfo}: @example @group C-c C-m C-r @r{Format the region.} C-c C-m C-b @r{Format the buffer.} @end group @group C-c C-m C-l @r{Recenter the @code{makeinfo} output buffer.} C-c C-m C-k @r{Kill the @code{makeinfo} formatting job.} @end group @end example @subheading Typeset and Print @noindent Typeset and print Texinfo documents from within Emacs.@refill @ifinfo @noindent @xref{Printing}. @end ifinfo @iftex @noindent @xref{Printing, , Formatting and Printing}. @end iftex @example @group C-c C-t C-r @r{Run @TeX{} on the region.} C-c C-t C-b @r{Run @TeX{} on the buffer.} @end group @group C-c C-t C-i @r{Run} @code{texindex}. C-c C-t C-p @r{Print the @sc{dvi} file.} C-c C-t C-q @r{Show the print queue.} C-c C-t C-d @r{Delete a job from the print queue.} @end group @group C-c C-t C-k @r{Kill the current @TeX{} formatting job.} C-c C-t C-x @r{Quit a currently stopped @TeX{} formatting job.} C-c C-t C-l @r{Recenter the output buffer.} @end group @end example @subheading Other Updating Commands @noindent The ``other updating commands'' do not have standard keybindings because they are used less frequently.@refill @noindent @xref{Other Updating Commands}. @example @group M-x texinfo-insert-node-lines @r{Insert missing @code{@@node} lines using} @r{section titles as node names.} @end group @group M-x texinfo-multiple-files-update @r{Update a multi-file document.} @r{With @kbd{C-u 8} as a numeric prefix,} @r{update @strong{every} pointer and} @r{menu in @strong{all} the files and} @r{then insert a master menu.} @end group @group M-x texinfo-indent-menu-description @r{Indent descriptions in menus.} @end group @group M-x texinfo-sequential-node-update @r{Insert node pointers in strict sequence.} @end group @end example @node New Commands, , New Texinfo Mode Commands, New Features @appendixsec New Texinfo @@-Commands The second edition of the Texinfo manual describes more than 50 commands that were not described in the first edition. A third or so of these commands existed in Texinfo but were not documented in the manual; the others are new. Here is a listing, with brief descriptions of them.@refill @subheading Indexing @noindent Create your own index, and merge indices.@refill @noindent @xref{Indices}. @example @group @@defindex @var{index-name} @r{Define a new index and its indexing command.} @r{See also the @code{@@defcodeindex} command.} @end group @group @@synindex @var{from-index} @var{into-index} @r{Merge first index into second index.} @r{See also the @code{@@syncodeindex} command.} @end group @end example @subheading Definitions @noindent Describe functions, variables, macros, commands, user options, special forms, and other such artifacts in a uniform format.@refill @noindent @xref{Definition Commands}. @example @group @@deffn @var{category} @var{name} @var{arguments}@dots{} @r{Format a description for functions, interactive} @r{commands, and similar entities.} @end group @group @@defvr, @@defop, @dots{} @r{15 other related commands.} @end group @end example @subheading Glyphs @noindent Indicate the results of evaluation, expansion, printed output, an error message, equivalence of expressions, and the location of point.@refill @noindent @xref{Glyphs}. @example @group @@equiv@{@} @r{Equivalence:}@samp{@equiv{}} @@error@{@} @r{Error message:} @samp{@error{}} @end group @group @@expansion@{@} @r{Macro expansion:} @samp{@expansion{}} @@point@{@} @r{Position of point:} @samp{@point{}} @end group @group @@print@{@} @r{Printed output:} @samp{@print{}} @@result@{@} @r{Result of an expression:} @samp{@result{}} @end group @end example @subheading Page Headings @noindent Customize page headings. @noindent @xref{Headings}. @example @group @@headings @var{on-off-single-double} @r{Headings on or off, single, or double-sided.} @end group @group @@evenfooting [@var{left}] @@| [@var{center}] @@| [@var{right}] @r{Footings for even-numbered (left-hand) pages.} @end group @group @@evenheading, @@everyheading, @@oddheading, @dots{} @r{Five other related commands.} @end group @group @@thischapter @r{Insert name of chapter and chapter number.} @end group @group @@thischaptername, @@thisfile, @@thistitle, @@thispage @r{Related commands.} @end group @end example @subheading Formatting @noindent Format blocks of text. @noindent @xref{Quotations and Examples}, and@* @ref{Lists and Tables, , Making Lists and Tables}. @example @@cartouche @r{Draw rounded box surrounding text (not in Info).} @group @@enumerate @var{optional-arg} @r{Enumerate a list with letters or numbers.} @end group @group @@exdent @var{line-of-text} @r{Remove indentation.} @end group @@flushleft @r{Left justify.} @@flushright @r{Right justify.} @@format @r{Do not narrow nor change font.} @group @@ftable @var{formatting-command} @@vtable @var{formatting-command} @r{Two-column table with indexing.} @end group @group @@lisp @r{For an example of Lisp code.} @@smallexample @@smalllisp @r{Like} @@example and @@lisp @r{but for} @@smallbook. @end group @end example @subheading Conditionals @noindent Conditionally format text. @noindent @xref{set and clear, , @code{@@set} and @code{@@clear}}. @example @group @@set @var{flag} @r{Set a flag.} @@clear @var{flag} @r{Clear a flag.} @end group @group @@ifset @var{flag} @r{Format, if flag is set.} @@ifclear @var{flag} @r{Ignore, if flag is set.} @end group @end example @subheading @@heading series for Titles @noindent Produce unnumbered headings that do not appear in a table of contents. @noindent @xref{Structuring}. @example @group @@heading @var{title} @r{Unnumbered section-like heading not listed} @r{in the table of contents of a printed manual.} @end group @group @@chapheading, @@majorheading @@subheading, @@subsubheading @r{Related commands.} @end group @end example @subheading Font commands @noindent @xref{Smallcaps}, and @* @ref{Fonts}. @example @group @@r@{@var{text}@} @r{Print in roman font.} @@sc@{@var{text}@} @r{Print in} @sc{small caps} @r{font.} @end group @end example @subheading Miscellaneous @noindent See @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author} Commands},@* see @ref{Overfull hboxes},@* see @ref{Footnotes},@* see @ref{dmn, , Format a Dimension},@* see @ref{minus, , Inserting a Minus Sign},@* see @ref{paragraphindent, , Paragraph Indenting},@* see @ref{Cross Reference Commands},@* see @ref{title subtitle author, , @code{@@title} @code{@@subtitle} and @code{@@author}}, and@* see @ref{Custom Headings, , How to Make Your Own Headings}. @need 500 @example @group @@author @var{author} @r{Typeset author's name.} @end group @@finalout @r{Produce cleaner printed output.} @group @@footnotestyle @r{Specify footnote style.} @end group @group @@dmn@{@var{dimension}@} @r{Format a dimension.} @end group @@minus@{@} @r{Generate a minus sign.} @group @@paragraphindent @r{Specify paragraph indentation.} @end group @group @@ref@{@var{node-name}, @r{[}@var{entry}@r{]}, @r{[}@var{topic-or-title}@r{]}, @r{[}@var{info-file}@r{]}, @r{[}@var{manual}@r{]}@} @r{Make a reference. In the printed manual, the} @r{reference does not start with the word `see'.} @end group @group @@title @var{title} @r{Typeset @var{title} in the alternative} @r{title page format.} @end group @group @@subtitle @var{subtitle} @r{Typeset @var{subtitle} in the alternative} @r{title page format.} @@today@{@} @r{Insert the current date.} @end group @end example @node Command and Variable Index, Concept Index, New Features, Top @comment node-name, next, previous, up @unnumbered Command and Variable Index This is an alphabetical list of all the @@-commands and several variables. To make the list easier to use, the commands are listed without their preceding @samp{@@}.@refill @printindex fn @node Concept Index, , Command and Variable Index, Top @comment node-name, next, previous, up @unnumbered Concept Index @printindex cp @page @summarycontents @contents @bye texinfo-2.15/README0000644000175000017500000001553712415566450011256 0ustar ggTexinfo, Version 2.15 ===================== * This is a very late beta test. We have fixed many (I hope most!) of the bugs you have reported and I hope soon to make a `real' release. Also, we have clarified some of the wording in the Texinfo manual. This release includes texinfo2.texi edition 2.15 texinfmt.el version 2.23 texinfo.el version 2.11 texnfo-upd.el version 2.12 texnfo-tex.el version 2.07 makeinfo.el version 2.04 makeinfo.c version 1.47 info.c version 1.44 texindex.c version 1.45 * Note that the info.el included in this distribution is the same info.el distributed with Emacs version 18. * In Texinfo mode, `C-c C-c e' inserts `@end' and attempts to insert the correct following word, such as `example' or `table'. (This command does not handle nested lists correctly, but inserts the word appropriate to the immediately preceding list.) Also, certain other `texinfo-insert-...' commands, such as `C-c C-c c', put the braces around the following word if given a prefix arg of one. * Note for people running TeX: the new `@cartouche' command requires a a font, `lcircle10' that is occasionally called `circle10' in older TeX distributions. To avoid trouble, use `make install' to install this package. This will install `lcircle10' as an alias for `circle10' if you don't have it already. You can also run the script `fixfonts' to install the alias and do nothing else. Detailed information about this problem can be found at the end of this file. * Please try this out and send me bug reports. 12 June 1992 Robert J. Chassell Bugs to bob@gnu.ai.mit.edu. I maintain the Emacs Lisp files and the manual. I forward bug reports for info, makeinfo, and texindex to bfox@gnu.ai.mit.edu, reports for texinfo.tex to rms@gnu.ai.mit.edu, and reports for texi2dvi to friedman@prep.ai.mit.edu. Use a command such as 'tar xvzf texinfo2.tar.Z' to uncompress and extract the files. This directory contains version 2 of the Texinfo package: texinfo2.texi This is Edition 2 of the Texinfo Manual README This file Makefile Create a compressed tar file of the package, as distributed New-features Summary of new features texinfo.tex Definitions file used by Tex texi2dvi Shell script for producing indexed DVI files >texi2roff< to be added when new version is ready Convert Texinfo file to [nt]roff form. The `elisp' subdirectory contains Emacs lisp code: texinfo.el Texinfo mode texnfo-upd.el Texinfo node and menu updating texinfmt.el Emacs Lisp Info formatting makeinfo.el Emacs interface to the `makeinfo' formatting program texnfo-tex.el TeX and hardcopy printing info.el The standard Emacs version 18 Info files, informat.el included here for convenience. All these files should be installed in the default load-path for Emacs; otherwise Emacs will not be able to load the autoloaded support files, such as `texinfmt.el'. The `texinfo.el' file contains the autoload commands; it is the only file that needs to be loaded initially. The `C' subdirectory contains C code: makeinfo.c `makeinfo' source info.c `info' source getopt.c support files getopt1.c getopt.h texindex.c sort indices for TeX; included here for convenience configure Create a Makefile which in turn creates an `info' or `makeinfo' executable, or a C sources distribution. configure.in Template for creating `configure' using m4 macros (distributed separately under the name `autoconf'). Makefile.in Template for `configure' to use to make a Makefile (Run `configure' first, then `make' to compile info, makeinfo, and texindex.) This separate Texinfo package is temporary; after a period of testing, this documentation and software will be merged into the Emacs distribution. (But we may continue to distribute this in a separate package as well, for the convenience of those who just want these files.) Special note for TeX: Finding the right font for @cartouche =========================================================== The `@cartouche' command requires a a font, `lcircle10' that is occasionally called `circle10' in older TeX distributions. If you see the following error message ! Font \circle=lcircle10 not loadable: Metric (TFM) file not found. your system may be using the older font. If it is, you can use `circle10' in place of `lcircle10'. Since the emerging convention is to use the new name, we recommend you keep `texinfo.tex' as is and make symbolic links to the font files with the old names. You will need to make symbolic links to several font files. Look for files with names similar to the following: `circle10.mf' This is the Metafont source for the font; sometimes used automatically by DVI output programs to generate pixel files. `circle10.tfm' This is the file actually used by TeX; it describes the measurements of the characters in the font. `circle10.300pk' `circle10.96pk' `pk' files contain the pixels for the character images that are used by your DVI output program. On your system, these files may have other numbers where this example shows "300" and "96". You may also have more, or fewer, `pk' files. `circle10.300gf' `circle10.96gf' `gf' files are an older alternative to `pk' files; if you can't find the `pk' files, look for these. As with the `pk' files, the numbers may be different on your system. Establish links to each of these files so they're available with both the `circle10' and the `lcircle10' prefix. If you can't do this, or don't know how to, contact the person responsible for TeX at your site. If possible, use symbolic links (`ln -s') so you can more easily keep track of what you have done. For example, you could make a line in the directory where you found `circle10.tfm' on your system as follows: ln -s circle10.tfm lcircle10.tfm You may have more, or fewer, `pk' (or `gf') files than in our example. Don't worry about this; just link each of the `circle10' `pk' (or `gf') files you have to the corresponding `f'lcircle10 file. Usually all the `pk' files for one font are in a single directory, though it's not always the same as the directory for `mf' or `tfm' files. When fonts are all in one directory, you can make the links for all the pixel files using a shell command such as the following, which is for the GNU shell: for pk in circle10.*pk; do ln -s $pk l$pk; done ================ end README file texinfo-2.15/Makefile0000644000175000017500000000733712415566434012037 0ustar gg #### Makefile for the version 2 Texinfo package -*- text -*- #### # Robert J. Chassell # Bugs to bob@ai.mit.edu. I maintain the Emacs Lisp files and the # manual, and I forward bug reports for info and makeinfo to # bfox@gnu.ai.mit.edu, who maintains those utilities. # A `make dist' command creates a compressed tar file of version 2 of # the Texinfo package, including both the Texinfo and the `makeinfo' # files. The file is called `texinfo-2.15.tar.Z' (or some similar # name, defined with the 'TEXINFO2_DIRECTORY' variable). # # This Makefile presumes that the Texinfo documentation and # miscellaneous files are in the current directory, the Emacs lisp code # is in a `elisp' subdirectory and the `makeinfo' files are in a `C' # subdirectory. # Use `tar xvzf texinfo-2.15.tar.Z' to uncompress and extract the contents # of `texinfo-2.15.tar.Z'. # The contents of `texinfo-2.15.tar.Z' expand to a megabyte or so. # Before mailing texinfo-2.15.tar.Z, if you should mail it, # uuencode the file with the following command: # uuencode texinfo-2.15.tar.Z texinfo-2.15.tar.Z > texinfo-2.15.tar.Z.uu #### ==> Specify the following as appropriate: texinfo-2.15, or whatever TEXINFO2_DIRECTORY = texinfo-2.15 TEXINFO_DOCUMENTATION = texinfo2.texi TEXINFO_SUPPORT = README COPYING ChangeLog Makefile New-features fixfonts TEXINFO_ELISP_SOURCES = elisp/texinfo.el \ elisp/texnfo-upd.el \ elisp/texinfmt.el \ elisp/texnfo-tex.el \ elisp/makeinfo.el #### include `texi2roff' when it becomes available #### OTHER_TEXINFO_SOURCES = texi2dvi texinfo.tex INFO_ELISP_SOURCES = elisp/info.el elisp/informat.el MAKEINFO_SOURCES = C/makeinfo.c C/info.c C/texindex.c \ C/getopt.c C/getopt1.c MAKEINFO_HEADERS = C/getopt.h MAKEINFO_SUPPORT = C/Makefile.in C/configure C/configure.in C/ChangeLog # This Makefile creates subdirectories and links the sources into it. # When the contents of the tar file are extracted, the files extract # into the a subdirectory called `texinfo2' containing the # documentation and miscellaneous files, and subsubdirectories, called # `elisp' and `C', containing the software. INSTALL = install -c # These permit overriding just for certain files. INSTALL_PROGRAM = $(INSTALL) INSTALL_DATA = $(INSTALL) MAKE = make # Common prefix for installation directories. # NOTE: This directory must exist when you start installation. prefix = /usr/TeX # Directory in which to put the executable for the commands. bindir = ${prefix}/bin # Directory in which to put the directories used by auxiliary programs. libdir = ${prefix}/lib/tex all: cd C; $(MAKE) all info: cd C; $(MAKE) info makeinfo: cd C; $(MAKE) makeinfo texindex: cd C; $(MAKE) texindex TAGS: cd C; $(MAKE) TAGS clean: cd C; $(MAKE) clean distclean: cd C; $(MAKE) distclean realclean: cd C; $(MAKE) realclean install: $(INSTALL_PROGRAM) texi2dvi $(bindir)/texi2dvi $(INSTALL_DATA) texinfo.tex $(libdir)/inputs/texinfo.tex # Make sure font lcircle10 can be used for formatting and printing. ./fixfonts cd C; $(MAKE) install dist: $(TEXINFO_DOCUMENTATION) $(TEXINFO_ELISP_SOURCES) \ $(OTHER_TEXINFO_SOURCES) \ $(TEXINFO_SUPPORT) \ $(INFO_ELISP_SOURCES) \ $(MAKEINFO_SOURCES) $(MAKEINFO_HEADERS) $(MAKEINFO_SUPPORT) rm -fr $(TEXINFO2_DIRECTORY) mkdir $(TEXINFO2_DIRECTORY) $(TEXINFO2_DIRECTORY)/elisp \ $(TEXINFO2_DIRECTORY)/C ln $(TEXINFO_DOCUMENTATION) $(TEXINFO_SUPPORT) \ $(OTHER_TEXINFO_SOURCES) \ $(TEXINFO2_DIRECTORY) ln $(TEXINFO_ELISP_SOURCES) $(INFO_ELISP_SOURCES) \ $(TEXINFO2_DIRECTORY)/elisp ln $(MAKEINFO_SOURCES) $(MAKEINFO_HEADERS) \ $(MAKEINFO_SUPPORT) \ $(TEXINFO2_DIRECTORY)/C tar chvzf $(TEXINFO2_DIRECTORY).tar.Z $(TEXINFO2_DIRECTORY) -rm -r $(TEXINFO2_DIRECTORY) ######################################################################