bhl-1.7.3/0040775000076400007640000000000010146223104011712 5ustar guerryguerrybhl-1.7.3/fdl.txt0100644000076400007640000004765710053644727013255 0ustar guerryguerry GNU Free Documentation License Version 1.2, November 2002 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 0. PREAMBLE The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque". Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement. C. State on the Title page the name of the publisher of the Modified Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. H. Include an unaltered copy of this License. I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version. N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section. O. Preserve any Warranty Disclaimers. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements". 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document 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. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation 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. See http://www.gnu.org/copyleft/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with...Texts." line with this: with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software. bhl-1.7.3/contrib/0040775000076400007640000000000010146222047013357 5ustar guerryguerrybhl-1.7.3/contrib/bhl2html0100755000076400007640000000233510053644726015030 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2html functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2html [-l lisp_directory] [-f in_file] [-o out_file]" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2html will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # delegate all the work to bhl2xxx bhl2xxx $@ html bhl-1.7.3/contrib/bhl2texinfo0100755000076400007640000000234610053644726015542 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2texinfo functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2texinfo [-l lisp_directory] [-f in_file] [-o out_file]" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2texinfo will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # delegate all the work to bhl2xxx bhl2xxx $@ texi bhl-1.7.3/contrib/bhl2xxx0100755000076400007640000000467210053644726014721 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2xxx functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2xxx [-l lisp_directory] [-f in_file] [-o out_file] (html|latex|sgml|txt)" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2xxx will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # Run the actual emacs conversion of the BHL input. function convert { /usr/bin/env emacs \ --batch \ --load=$lispdir/bhl.el \ --execute="(bhl2xxx-batch-wrapper \"$infile\" '$lang)" } # clean up, saving the input to the input.bhl.dead file. function cleanup { if [ -e $msgfile ]; then mv $msgfile input.bhl.dead fi exit } # process the command line arguments lispdir=$(pwd) while getopts ":f:l:o:" opt do case $opt in f ) infile=$OPTARG;; l ) lispdir=$OPTARG;; o ) outfile=$OPTARG;; \? ) usage exit 1;; esac done shift $(($OPTIND - 1)) lang=$1 # Trap some common signals (CTRL-C type stuff) and clean up... trap cleanup INT TERM # For dreadfully obscure reasons, emacs cannot easily read stdin into # a buffer. Therefore, if the input is coming from stdin, create a # temporary input file, if needed and read that in. if [ -z $infile ]; then msgfile="/tmp/bhlinput$$" # $$ -> process id: helps make a unique name cat > $msgfile infile=$msgfile fi # do the conversion if [ -z $outfile ]; then # if sending to stdout (convert) 2> /dev/null else touch $outfile (convert) > $outfile 2> "$outfile.log" fi # do normal cleanup if [ -e $msgfile ]; then rm -f $msgfile fi bhl-1.7.3/contrib/bhl2txt0100755000076400007640000000233010053644726014676 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2txt functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2txt [-l lisp_directory] [-f in_file] [-o out_file]" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2txt will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # delegate all the work to bhl2xxx bhl2xxx $@ txt bhl-1.7.3/contrib/bhl2sgml0100755000076400007640000000233410053644726015025 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2sgml functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2sgml [-l lisp_directory] [-f in_file] [-o out_file]" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2sgml will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # delegate all the work to bhl2xxx bhl2xxx $@ sgml bhl-1.7.3/contrib/bhl2latex0100755000076400007640000000234010053644726015175 0ustar guerryguerry#!/usr/bin/env bash # This script allows the user to run the bhl2latex functions without # needing to start emacs. # 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., 59 Temple Place, Suite 330, Boston, # MA 02111-1307 USA function usage { echo "Usage: bhl2latex [-l lisp_directory] [-f in_file] [-o out_file]" echo echo "The lisp_directory is the path to the location of the bhl.el file." echo "It defaults to the present working directory." echo echo "bhl2latex will read from stdin if no in_file is specified, and write" echo "to stdout if no out_file is specified." } # delegate all the work to bhl2xxx bhl2xxx $@ latex bhl-1.7.3/README0100644000076400007640000000416410053644727012611 0ustar guerryguerryThe BHL mode --- Table of contents 1. What is BHL? 2. Install BHL 3. Contact --- End of the table of contents This is the README file of the BHL mode. This File is better viewed with the BHL mode. Last update: 07/03/2003. 1. What is BHL? BHL is an Emacs mode that enables you to convert brut text files into HTML, LaTeX and SGML files. "BHL" is an acronym for: "from *B*rut to *H*tml and *L*aTeX" (SGML was implemented later). In order to convert TXT files into other formats, you need to use some syntactical elements. The purpose of this mode is to use the most _invisible_ and _convenient_ syntax. By *invisible syntax*, I mean that the source file must be as readable as possible (like any TXT file must be). By *convenient syntax*, I mean that the syntax must fit user's habits. Here's a list of syntactical elements that BHL handles: * title, sections, subsections, subsubsections; * bold, emphasis, underlign, bold-italic; * lists (nested, ordered, non-ordered, description lists); * tables; * comments; * images (only in the html output); * URLs; * horizontal rules; * footnotes; * special chars; * quote, verbatim and minipage environments. BHL handles also a _table of contents_: you can insert the table of contents of the working file, browse the toc in a new buffer, and update the numbering of sections with just one keystroke. 2. Install BHL Edit the _Makefile_. Set the load-path of your elisp files, etc. When you're ok with the _Makefile_, type in your shell: * ~$ make * ~$ make install * ~$ make info * ~$ make install-info * ~$ make pdf You may have to edit the `dir' file in the info path. This installation procedure will also install some scripts from the `contrib' directory. These scripts allow you to perform the core conversion functions of BHL from a shell. Thanks to D. Katz for these contribs. 3. Contact The URL of the BHL homepage is: * http://www.nongnu.org/bhl The project pages of bhl are: * http://sv.nongnu.org/projects/bhl * http://sv.nongnu.org/download/bhl Please feel free to mail me any bug report or suggestion: * mailto:bastien1NOSPAM@free.fr ==Bastien Guerry== bhl-1.7.3/bhl.el0100644000076400007640000043731510146222500013010 0ustar guerryguerry;;; bhl.el --- From (P)lain text to (H)tml and (L)aTeX. ;; Time-stamp: <2004-11-15 22:53:04 guerry> ;; Copyright (C) 2002 2003 2004 Bastien Guerry ;; Emacs Lisp Archive Entry ;; Filename: bhl.el ;; Author: Bastien Guerry ;; Maintainer: Bastien Guerry ;; Version: 1.7.3 ;; Revised: 13/11/2004 ;; Created: 16/11/2002 ;; Keywords: convert plain text html latex sgml linuxdoc texinfo ;; Description: convert raw text into HTML/SGML/LaTeX/Texinfo/Text ;; URL: http://www.nongnu.org/bhl/ ;; This file is not part of GNU Emacs. ;; 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., 59 Temple Place, Suite 330, Boston, ;; MA 02111-1307 USA ;;; Commentary: ;; BHL mode is a mode wich enables you to convert plain text files into ;; HTML, LaTeX and SGML (Linuxdoc) files. This is a simple mode, with ;; simple conversion functions, dedicated to simple source files. ;;; Neighbours: ;; emacs-wiki.el with latex-markup.el, html-markup.el and texinfo-markup.el ;; See the WikiDiscussion on http://www.emacswiki.org. ;;; Installation: ;; With `bhl.tar.gz': ;; [your_shell]$ tar zxvf bhl-*.tar.gz ;; [your_shell]$ make && make install ;; [your_shell]$ make info && make install-info ;; [your_shell]$ make pdf ;; [your_shell]$ make html ;; With: `bhl.el': ;; Just compile `bhl.el' and put it in your load-path. ;; Add to your `~/.emacs.el': ;; (autoload 'bhl-mode "bhl" "BHL Mode" t) ;; (add-to-list 'auto-mode-alist '("\\.bhl$" . bhl-mode)) ;;; Usage: ;; `bhl2html'..................[C-c C-w] -> convert BHL to HTML ;; `bhl2latex'.................[C-c C-l] -> convert BHL to LaTeX ;; `bhl2sgml'..................[C-c C-s] -> convert BHL to SGML (Linuxdoc) ;; `bhl2txt'...................[C-c C-d] -> convert BHL to TXT ;; `bhl2texinfo'...............[C-c C-o] -> convert BHL to Texinfo ;; `bhl-insert-toc'............[C-c C-c t] -> insert the table of contents ;; `bhl-insert-url'............[C-c C-c h] -> insert an URL ;; `bhl-insert-image'..........[C-c C-c i] -> insert an image ;; `bhl-insert-verbatim'.......[C-c C-c v] -> insert a verbatim environment ;; `bhl-insert-minipage'.......[C-c C-c m] -> insert a minipage ;; `bhl-insert-tab'............[M-TAB] -> insert a rigid tab ;; `bhl-change-font-bold'......[C-c C-f C-b] -> change font (bold) ;; `bhl-change-font-emphasis'..[C-c C-f C-e] -> change font (emphasis) ;; `bhl-change-font-underline'.[C-c C-f C-u] -> change font (underline) ;; `bhl-change-font-truetype'..[C-c C-f C-t] -> change font (truetype) ;; `bhl-change-font-bolditalic'[C-c C-f C-_] -> change font (bold-italic) ;; `bhl-change-font-normal'....[C-c C-f C-n] -> change font (normal) ;; `bhl-show-toc'..............[C-c C-t] -> generate a browsable table of contents ;; `bhl-update-toc'............[C-c M-t] -> update the prefix labels of sections ;; `bhl-guess-style'...........[C-c M-s] -> guess the sectioning style of buffer ;; `bhl-show-lol'..............[C-c C-/] -> generate a browsable list of links ;; `bhl-goto-next-section'.....[C-c C-n] -> go to the next section ;; `bhl-goto-previous-section'.[C-c C-p] -> go to the previous section ;; `bhl-goto-next-url-or-wiki'.[C-TAB] -> go to the next URL or WikiName ;; `bhl-show-version'..........[C-c C-v] -> display the BHL mode version number ;;; Known problems: ;; * BHL can't update sections if there are only (sub)subsections. ;;; Acknowledgments: ;; Thanks to Thierry Stoehr, Serge Basterot, Christoph Conrad, Peter ;; Kindermann, Mario Lang, Tim Cross. Special thanks to Daniel ;; P. Katz for the bhl2xxx-batch-wrapper function and other contribs. ;;; Summary: ;; Page 1 - Variables and constants ;; Page 2 - Custom ;; Page 3 - Faces ;; Page 4 - Mode ;; Page 5 - Menu ;; Page 6 - Miscellaneous ;; Page 7 - Table of content ;; Page 8 - Submit bug report ;; Page 9 - bhl2xxx ;;; Code: (eval-when-compile (mapcar 'require '(custom cl easymenu derived mouse font-lock)) (unless (featurep 'xemacs) (require 'texnfo-upd) (require 'footnote))) ;;;; 1 - CONSTANTS (defconst bhl-startup-message-lines '("Please use \\[bhl-submit-bug-report] to report bugs." "BHL comes with ABSOLUTELY NO WARRANTY." "Thanks for using the BHL mode!") "Lines to be displayed with `bhl-show-version'.") (defconst bhl-help-address "bastien1NOSPAM@free.fr" "The address of the current maintainer.") ;;;; Regexp constants (defconst bhl-wiki-names-regexp "\\<[A-Z][a-z]+\\([A-Z][a-z]+\\)+\\>" "Match a WikiName.") (defconst bhl-generic-url-regexp "\\(url:\\|https?://\\|file:///\\|telnet:\\|mime:\\|s?news:\\|ftp://\\|mailto:\\)\\([^ [\n\t<]+\\>/?\\)" "Match a generic URL.") (defconst bhl-url-regexp (concat "\\(\\(" bhl-generic-url-regexp "\\)\\|\\[\\[\\(\\(mailto:\\)?\\([^]\n\t]+\\>/?\\)\\)\\]\\[\\(\\<[^]\t]+\\)\\]\\]\\)") "Match a BHL URL. Designed to work with `bhl-convert-url'. * When matching a raw URL: (match-string 0) : return the whole URL. (match-string 3) : return the prefix of the URL (http:// of ftp:// or ...). (match-string 4) : return the rest of the URL. * When matching an URL put into square brackets: (match-string 0) : return the URL and its name into brackets. (match-string 5) : return only the URL. - If the URL is of the form: \"mailto:bastien1NOSPAM@free.fr\": (match-string 6) : return \"mailto:\". (match-string 7) : return the email. - Else: (match-string 7) : return the URL. (match-string 8) : return the name of the URL.") (defconst bhl-img-regexp "\\[\\[\\([^] \n\t]+\.\\(BMP\\|EPS\\|GIF\\|JP\\(?:E?G\\)\\|P\\(?:BM\\|GM\\|NG\\|PM\\|S\\)\\|TIFF\\|X\\(?:[BP]M\\)\\|bmp\\|eps\\|gif\\|jp\\(?:e?g\\)\\|p\\(?:bm\\|gm\\|ng\\|pm\\|s\\)\\|tiff\\|x\\(?:[bp]m\\)\\)\\)\\]\\]" "Match images.") ; `image-file-name-regexp' does not suffice (defconst bhl-title-regexp "\\`[ \t\n\r]*\\([^\n]+\\)$" "Match the title.") (defconst bhl-hr-regexp "^\\([<>-]\\)---+\\(\\[\\(\\([0-9]+\\)[^] ]*\\)\\]\\)?" "Match a horizontal rule.") (defconst bhl-hr1-regexp "^\\([<>=]\\)===+\\(\\[\\(\\([0-9]+\\)[^] ]*\\)\\]\\)?" "Match a horizontal rule.") (defconst bhl-hr2-regexp "^\\([<>/]\\)///+\\(\\[\\(\\([0-9]+\\)[^] ]*\\)\\]\\)?" "Match a horizontal rule.") (defconst bhl-minipage-regexp "^\\([<>%]\\)\\([-%]\\)%+\\(\\[\\([^] ]+\\)\\]\\)?" "Match a starting minipage environment.") (defconst bhl-list-regexp "^\t\t?\t?\t?\t?\\([-*o]\\|[0-9]+\\.\\) " "Match lists items.") (defconst bhl-descrip-regexp "^\\(\t+\\)\\([^\n-]+\\) -- " "Match items of lists of descriptions.") (defconst bhl-list-regexp-list '(("^\\(\t\t\t\t\t\\)\\([-*o]\\|[0-9]+\.\\) " "^\t\t?\t?\t?\\([-*o]\\|[0-9]+\.\\) \\|^[^\n\t ]\\|\\'") ("^\\(\t\t\t\t\\)\\([-*o]\\|[0-9]+\.\\) " "^\t\t?\t?\\([-*o]\\|[0-9]+\.\\) \\|^[^\n\t ]\\|\\'") ("^\\(\t\t\t\\)\\([-*o]\\|[0-9]+\.\\) " "^\t\t?\\([-*o]\\|[0-9]+\.\\) \\|^[^\n\t ]\\|\\'") ("^\\(\t\t\\)\\([-*o]\\|[0-9]+\.\\) " "^\t\\([-*o]\\|[0-9]+\.\\) \\|^[^\n\t ]\\|\\'") ("^\\(\t\\)\\([-*o]\\|[0-9]+\.\\) " "^[^\n\t ]\\|\\'")) "A list of regexp that match list items of third, second and first level.") (defconst bhl-list-syntax-alist '((html ("") ("
    " "
  1. " "
") ("
" "
" "
" "
")) (latex ("\\begin{itemize}" "\\\\item " "\\end{itemize}") ("\\begin{enumerate}" "\\\\item " "\\end{enumerate}") ("\\begin{description}" "\\item [" "] " "\\end{description}")) (sgml ("

" "" "") ("

" "" "") ("

" "" " " "")) (texi ("@itemize @minus" "@item\n" "@end itemize") ("@enumerate" "@item\n" "@end enumerate") ("@table @emph" "@item " "\n" "@end table"))) "Alist of syntactic elements composing unordered, ordered and description lists.") ;;; Miscellaneous variables (defvar bhl-local-lol-list nil) (defvar bhl-local-latex-class "") (defvar bhl-local-latex-class-options nil) (defvar bhl-local-html-style "") (defvar bhl-local-lang "") (defvar bhl-local-texi-titlepage-style "") (defvar bhl-mode-map (make-keymap) "Keymap for the BHL major mode.") (defvar bhl-toc-mode-map (make-keymap) "Keymap for the BHL toc mode.") (defvar bhl-lol-mode-map (make-keymap) "Keymap for the BHL lol mode.") (defvar bhl-version "1.7.1" "The current version of the BHL mode.") (defvar bhl-popup-menu-map (if (current-local-map) (copy-keymap (current-local-map)) (make-keymap)) "A popup menu for BHL.") (defvar bhl-toc-temporary-depth nil "The depth of toc set into the *toc* buffer.") (defvar bhl-toc-point-list nil "The list of points used to browse the toc.") (defvar bhl-tpl nil "The list of point positions corresponding to the list of (sub)sections. See `bhl-tsl'.") (defvar bhl-tsl nil "The list of sections required to build and browse the toc. See `bhl-tpl'.") (defvar bhl-font-lock-keywords nil "Keywords to be fontified in the BHL mode.") (defvar bhl-conversion-log nil "This variable stores the log for each conversion.") (defvar bhl-xxx-conversions-list nil "Alist of conversion functions.") (defvar bhl-tag-regexp-list nil "Tags elements understood by BHL.") (defconst bhl-tag-regexp-list0 '("[^\\]\\(__\\([^ \t\r\n\"_][^_]*\\)__\\)" "[^\\]\\(==\\([^ \t\r\n=\"][^=]*\\)==\\)" "[^_\\]\\(_\\([^ \t\r\n_\"][^_]*\\)_\\)[^_]" "[^\\]\\(\\*\\([^ \t\r\n*\"][^*]*\\)\\*\\)") "Tags elements understood by BHL.") (defconst bhl-tag-regexp-list1 '("[^\\]\\(__\\([^ \t\r\n\"_][^\n\r_]*\\)__\\)" "[^\\]\\(==\\([^ \t\r\n=\"][^\n\r=]*\\)==\\)" "[^_\\]\\(_\\([^ \t\r\n_\"][^\n\r_]*\\)_\\)[^_]" "[^\\]\\(\\*\\([^ \t\r\n*\"][^\n\r*]*\\)\\*\\)") "Tags elements understood by BHL.") (defconst bhl-tag-syntax-alist '((html ("" "") ("" "") ("" "") ("" "")) (latex ("\\underline{" "}") ("\\texttt{" "}") ("\\emph{" "}") ("\\textbf{" "}")) (sgml ("" "") ("" "") ("" "") ("" "")) (texi ("@i{" "}") ("@t{" "}") ("@emph{" "}") ("@strong{" "}")) (txt ("" "") ("" "") ("" "") ("" ""))) "Alist of font beautifiers tags corresponding to each conversion format.") (defconst bhl-section-syntax-alist '((html ("

" "

") ("

" "

") ("

" "

")) (latex ("\\section{" "}") ("\\subsection{" "}") ("\\subsubsection{" "}")) (latex-nonum ("\\section\*{" "}") ("\\subsection\*{" "}") ("\\subsubsection\*{" "}")) (sgml ("" "") ("" "") ("" "")) (texi ("@chapter " "") ("@section " "") ("@subsection " "")) (txt ("= " " =") ("== " " ==") ("=== " " ==="))) "Alist of sections tags corresponding to each conversion format.") (defvar bhl-sectioning-regexp-list nil "Alist of regexp that match sections and subsections. the first element matches the prefix of a sections title. the second element matches the prefix of a subsections title. the third element matches the prefix of a subsections title.") ;; punctuation marks (defconst bhl-fr-punctuation '(("\\(:\\)[ \t\n]" " :" "~:" "@ :") ("\\(\\?\\)[ \t\n]" " ?" "~?" "@ ?") ("\\(!\\)[ \t\n]" " !" "~!" "@ !") ("\\(;\\)[ \t\n]" " ;" "~;" "@ ;")) "A list of punctuation marks respecting the french typographic conventions.") (defconst bhl-de-punctuation nil "A list of punctuation marks respecting the german typographic conventions.") (defconst bhl-en-punctuation nil "A list of punctuation marks respecting the english typographic conventions.") ;; Quotation marks (defconst bhl-en-quotation-marks '(("[ \'\n\t\(]\\(\\)" "“" "``" "``") ("[ \'\n\t\(]\\(\"\\)" "“" "``" "``") ("\\(\\)[ \n\t,\.:;\?!\)]" "”" "''" "''") ("\\(\"\\)[ \n\t,\.:;\?!\)]" "”" "''" "''")) "A list of quote chars to convert.") (defconst bhl-de-quotation-marks '(("[ \'\n\t\(]\\(\\)" "“" "``" "``") ("[ \'\n\t\(]\\(\"\\)" "“" "``" "``") ("\\(\\)[ \n\t,\.:;\?!\)]" "”" "''" "''") ("\\(\"\\)[ \n\t,\.:;\?!\)]" "”" "''" "''")) "A list of quote chars to convert.") (defconst bhl-fr-quotation-marks '(("[ \'\n\t\(]\\(\\)" "« " "~" "``") ("[ \'\n\t\(]\\(\"\\)" "« " "~" "``") ("\\(\\)[ \n\t,\.:;\?!\)]" " »" "~" "''") ("\\(\"\\)[ \n\t,\.:;\?!\)]" " »" "~" "''")) "A list of quote characters to convert.") ;; Special characters (defconst bhl-fr-special-chars '(("<" "‹" "<" "<") (">" "›" ">" ">") ("oe" "œ" "\\oe{}" "@oe{}") ("OE" "Œ" "\\OE{}" "@OE{}") ("ae" "æ" "\\ae{}" "@ae{}") ("AE" "Æ" "\\AE{}" "@EA{}")) "A list of strings to convert into french ligatured characters.") (defconst bhl-de-special-chars '(("<" "‹" "<" "<") (">" "›" ">" ">") ("oe" "ö" "" "@\"o") ("Oe" "Ö" "" "@\"O") ("ae" "ä" "" "ae") ("Ae" "Ä" "" "Ae") ("Ue" "Ü" "" "Ue") ("" "ß" "" "@ss{}")) "A list of strings to convert into german ligatured characters.") (defconst bhl-en-special-chars '(("<" "‹" "<" "<") (">" "›" ">" ">")) "A list of strings to convert into english ligatured characters.") (defconst bhl-latex-escaped-chars '("$" "&" "%" "{" "}")) (defconst bhl-texi-escaped-chars '("@" "{" "}")) (defconst bhl-escapable-chars '("*" "_" "#" "\\")) ;;;; 2 - CUSTOM (defgroup bhl nil "BHL mode: convert plain TXT to HTML, LaTeX and SGML." :group 'wp :link '(custom-manual "(bhl)Top") :link '(url-link "http://www.nongnu.org/bhl") :prefix "bhl-") (defgroup bhl-wiki nil "BHL as a local wiki." :group 'bhl) (defgroup bhl2html nil "Customize the `bhl2html' output." :group 'bhl) (defgroup bhl2latex nil "Customize the `bhl2latex' output." :group 'bhl) (defgroup bhl2texinfo nil "Customize the `bhl2texinfo' output." :group 'bhl) (defgroup bhl2sgml nil "Customize the `bhl2sgml' output." :group 'bhl) (defgroup bhl2txt nil "Customize the `bhl2txt' output." :group 'bhl) (defgroup bhl-toc nil "How to handle the table of contents." :group 'bhl) (defgroup bhl-tables nil "How BHL must build tables." :group 'bhl) (defgroup bhl-faces nil "*BHL faces used in BHL mode." :group 'faces :group 'bhl) ;;;; Main custom (defcustom bhl-mode-hook '(turn-on-auto-fill) "Normal hook run when entering BHL mode." :type '(hook) :group 'bhl) (defcustom bhl-after-conversion-hook '(bhl-initialize-properties) "Hook run after any conversion. The default hook is `bhl-initialize-properties'. If you remove this function, the conversion properties of the last converted buffer will be the default conversion properties for the next converted buffer." :type '(hook) :group 'bhl) (defcustom bhl-autoguess-style-flag t "Non-nil means autoguess the sectioning style. When you find a file, BHL tries to guess its sectioning style and sets the value of `bhl-sectioning-default-style' to the value of the file's style. See `bhl-guess-style' and `bhl-sectioning-default-style'." :type '(boolean) :link '(custom-manual "(bhl)Sections") :group 'bhl) (defcustom bhl-sectioning-default-style 'num "The style of sections and (sub)subsections in the BHL file. NUM indicates numerical style (e.g. \"1.2.\"). ALPHA indicates alphabetical style (e.g. \"A.B.\"). ASTER indicates that you use asteriks (e.g. \"*\"). EQUAL-SIGN indicates that you use equal-sign (e.g. \"=\"). MY indicates your own style, as defined by `bhl-my-sectioning-regexp-list'." :type '(radio (const :tag "Numerical" num) (const :tag "Alphabetical" alpha) (const :tag "Asterisks" aster) (const :tag "Equal signs" equal-sign) (const :tag "My own style" my)) :link '(custom-manual "(bhl)Sections") :group 'bhl) (defcustom bhl-my-sectioning-regexp-list '("[0-9]+\\. " "[0-9]+\\.[0-9]+\\. " "[0-9]+\\.[0-9]+\\.[0-9]+\\. ") "Your own list of regexp that match (sub)sections' prefix. The default value for this list is equal to the value of `bhl-sectioning-regexp-list'. Please pay a special attention to whitespaces. Don't use any subexpression. Don't use the \{.\} construct. If you want to choose your own list for the current sectioning style, set `bhl-sectioning-default-style' to 'my. Remind that you cannot use `bhl-update-toc' anymore if you select your own sectioning style." :type '(list (regexp :tag "Section ") (regexp :tag "Subsection ") (regexp :tag "Subsubsection")) :link '(custom-manual "(bhl)Sections") :group 'bhl) (defcustom bhl-verbatim-ignore '(tag comment list description table url wikiname images special-char tex-label footnote quote) "A list of non-converted elements inside verbatim regions. Here are the relevant symbols that you can insert in this list: tag : *word* and the like. comment : #comment stings list : * lists description : Description -- table : | tables | url : any kind of URL wikiname : WikiNames images : [[image.jpg]] special-char : e.g. ligatured \"oe\" tex-label : LaTeX, TeX and LaTeX2e footnote : footnote like this one[1] quote : [tab]A quoted sentence" :type '(repeat (symbol :tag "Ignore ")) :link '(custom-manual "(bhl)Environments") :group 'bhl) (defcustom bhl-ignored-regexps nil "A list of regexps. The lines matching these regexps are automatically skipped." :type '(repeat (regexp)) :group 'bhl) (defcustom bhl-tags-overlap-flag t "Non-nil means that you can use tags on multiple lines." :type '(boolean) :group 'bhl) (defcustom bhl-i18n-conventions '("en" t t t) "English, french and german conventions. These conventions are relative to the punctuation, the quotation marks and some special characters." :type '(list (radio :tag "Language" (const :tag "English" "en") (const :tag "French" "fr") (const :tag "German" "de")) (boolean :tag "Punctuation " :indent 2 :help-echo "Non-nil means follow punctuation conventions.") (boolean :tag "Quotation marks " :indent 2 :help-echo "Non-nil means convert quotation marks.") (boolean :tag "Special chars " :indent 2 :help-echo "Non-nil means convert special characters.")) :link '(custom-manual "(bhl)Global options") :group 'bhl) (defcustom bhl-browse-url-function 'browse-url "Function to call to browse a URL." :type '(function) :group 'bhl) (defcustom bhl-tab-width 3 "*The default width of the tab character." :type '(integer) :group 'bhl) ;; BHL as local Wiki (defcustom bhl-is-a-local-wiki-flag nil "Non-nil means that MixedCase words are wikinames." :type '(boolean) :group 'bhl-wiki) (defcustom bhl-default-wikifiles-extension ".bhl" "The default extension for new files created when following a wiki name." :type '(string :tag "Extension ") :group 'bhl-wiki) (defcustom bhl-downcase-wikifiles-names-flag nil "Non-nil means that BHL downcases the name of a wiki file." :type '(boolean) :group 'bhl-wiki) (defcustom bhl-non-wiki-names-list nil "A list of strings that are NOT WikiNames." :type '(repeat (string :tag "Non-wiki name ")) :group 'bhl-wiki) ;;;; Customize the table of contents (defcustom bhl-default-toc-depth 3 "*The default depth of the table of contents." :type '(integer) :link '(custom-manual "(bhl)The table of contents") :group 'bhl-toc) (defcustom bhl-intro-toc "--- Table of contents" "*A string inserted just before the table of contents." :type '(string) :group 'bhl-toc) (defcustom bhl-end-toc "--- End of the table of contents" "*A string inserted just after the table of contents." :type '(string) :group 'bhl-toc) (defcustom bhl-toc-location "top" "*The place into which the table of contents is inserted." :type '(radio (const :tag "Juste after title" "top") (const :tag "Juste before end" "bottom") (other :tag "On the point" "point")) :link '(custom-manual "(bhl)The table of contents") :group 'bhl-toc) ;;;; Customize the conversion of tables (defcustom bhl-table-location "htbp" "*The location of the table. \"here top bottom page\" means put the table here or at the top of the page or at the bottom of the page or on a separate page." :type '(radio (const :tag "here" "h") (const :tag "top" "t") (const :tag "bottom" "b") (const :tag "page" "p") (other :tag "here top bottom page" "htbp")) :group 'bhl-tables) (defcustom bhl-table-align "center" "*How to align each table." :type '(radio (const "left") (const "center") (const "right")) :group 'bhl-tables) (defcustom bhl-table-cell-align "c" "*How to align each cell in a table." :type '(radio (const :tag "left" "l") (const :tag "center" "c") (other :tag "right" "r")) :group 'bhl-tables) ;;;; Customize the HTML output. (defcustom bhl-after-html-conversion-hook nil "Hook run after the conversion into HTML. This hook is run just before `bhl-after-conversion-hook'." :type '(hook) :group 'bhl2html) (defcustom bhl2html-properties-list '(t t nil t t) "List of properties of the `bhl2html' conversion." :type '(list (boolean :tag "Check dubious tags ") (boolean :tag "Insert sections' prefix ") (boolean :tag "Ask caption for tables ") (boolean :tag "Use i18n conventions ") (boolean :tag "Convert toc ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2html) (defcustom bhl-html-conversions-list '(t t t t t t t t nil t t t t t) "*A list of conversion functions to perform with `bhl2html'. Each element of this list corresponds to a conversion function." :type '(list (boolean :tag "Convert verbatim regions ") (boolean :tag "Convert horizontal rules ") (boolean :tag "Convert images ") (boolean :tag "Convert URLs ") (boolean :tag "Convert definition lists ") (boolean :tag "Convert normal list ") (boolean :tag "Convert tables ") (boolean :tag "Convert LaTeX labels " :help-echo "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" properly.") (boolean :tag "Convert footnotes ") (boolean :tag "Convert minipage " :help-echo "Minipages are tables in HTML and minipages in LaTeX.") (boolean :tag "Convert comments ") (boolean :tag "Convert escape sequences ") (boolean :tag "Convert WikiNames ") (boolean :tag "Convert quote ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2html) (defcustom bhl-html-title-tags '("

" "

") "A list of the opening and closing HTML tags for the title." :type '(list (string :tag "Opening tag") (string :tag "Closing tag")) :group 'bhl2html) (defcustom bhl-html-subtitle-tags '("

" "

") "A list of the opening and closing HTML tags for the subtitle." :type '(list (string :tag "Opening tag") (string :tag "Closing tag")) :group 'bhl2html) (defcustom bhl-html-meta-alist '(("generator" . "bhl2html")) "*A list of META tags. The first field is the value of \"NAME\". The second field is the value of \"CONTENT\". Example: author (in the first field [key]) Monique (in the second field [value]) outputs " :type '(alist :key-type (string :tag "Name" :help-echo "Insert the \"NAME\" value of the META tag.") :value-type (string :tag "Content" :help-echo "Insert the \"CONTENT\" value of the META tag.")) :group 'bhl2html) (defcustom bhl-html-link-alist '(("generator-home" . "http://www.nongnu.org/bhl")) "*A list of LINK tags. The first field is the value of \"REL\". The second field is the value of \"HREF\". Example: alternate (in the first field [key]) indexbis.html (in the second field [value]) outputs " :type '(alist :key-type (string :tag "REL" :help-echo "Insert the \"REL\" value of the LINK tag.") :value-type (string :tag "HREF" :help-echo "Insert the \"HREF\" value of the LINK tag.")) :group 'bhl2html) (defcustom bhl-html-doctype "" "*The DOCTYPE description of the HTML document." :type '(string) :group 'bhl2html) (defcustom bhl-html-content-type "" "*The META tag which describes the content type of the HTML document." :type '(string) :group 'bhl2html) (defcustom bhl-html-default-style "" "*The style to be inserted in the header of the HTML output." :type '(string) :group 'bhl2html) (defcustom bhl-html-table-param-alist '(("cellpadding" . "3") ("cellspacing" . "0") ("border" . "1")) "*Alist of parameters for the conversion of tables. The first field is the name of the parameter, the second field specifies its value. Example: \"cellpadding\" (in the first field [key]) \"3\" (in the second field [value]) outputs " :type '(alist :key-type (string :tag "Property" :help-echo "Insert the property name.") :value-type (string :tag "Value" :help-echo "Insert the value of the property.")) :group 'bhl2html) (defcustom bhl-html-para-align "none" "*How to align paragraphs." :type '(radio (const "left") (const "center") (const "justify") (const "right") (const "none")) :group 'bhl2html) (defcustom bhl-html-img-align "center" "*How to align each image." :type '(radio (const "left") (const "center") (const "right")) :group 'bhl2html) (defcustom bhl-html-list-item-is-para-flag t "*Non-nil means that a list item is a paragraph." :type '(boolean) :group 'bhl2html) ;;;; Customize the LaTeX output. (defcustom bhl-after-latex-conversion-hook nil "Hook run after the conversion into LaTeX. This hook is run just before `bhl-after-conversion-hook'." :type '(hook) :group 'bhl2latex) (defcustom bhl2latex-properties-list '(t t nil t t) "List of properties of the `bhl2latex' conversion." :type '(list (boolean :tag "Check dubious tags ") (boolean :tag "Insert sections' prefix ") (boolean :tag "Ask caption for tables ") (boolean :tag "Use i18n conventions ") (boolean :tag "Convert toc ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2latex) (defcustom bhl-latex-conversions-list '(t t t t t t t t nil t t t t t) "*A list of conversion functions to perform with `bhl2latex'. Each element of this list corresponds to a conversion function." :type '(list (boolean :tag "Convert verbatim regions ") (boolean :tag "Convert horizontal rules ") (boolean :tag "Convert images ") (boolean :tag "Convert URLs ") (boolean :tag "Convert definition lists ") (boolean :tag "Convert normal list ") (boolean :tag "Convert tables ") (boolean :tag "Convert LaTeX labels " :help-echo "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" properly.") (boolean :tag "Convert footnotes ") (boolean :tag "Convert minipage " :help-echo "Minipages are tables in HTML and minipages in LaTeX.") (boolean :tag "Convert comments ") (boolean :tag "Convert escape sequences ") (boolean :tag "Convert WikiNames ") (boolean :tag "Convert quote ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2latex) (defcustom bhl-latex-packages-alist '(("inputenc" . "latin1")) "*Alist of packages to be included in the LaTeX header. The first field is the name of the package, the second field specifies optional elements. Example: inputenc (in the first field [key]) latin1 (in the second field [value]) outputs \\usepackage[latin1]{inputenc}" :type '(alist :key-type (string :tag "Package" :help-echo "Insert the name of the LaTeX package.") :value-type (string :tag "Options" :help-echo "Insert the values of the package options.")) :group 'bhl2latex) (defcustom bhl-latex-default-class "article" "*The document's class for the LaTeX output." :type '(string) :group 'bhl2latex) (defcustom bhl-latex-default-class-options '("12pt" "a4paper") "*The default options for the \documentclass command in the LaTeX output." :type '(repeat (string :tag "Option ")) :group 'bhl2latex) (defcustom bhl-latex-extra-preambles nil "*A list of lines to be included in the LaTeX header." :type '(repeat (string :tag "Preamble line")) :group 'bhl2latex) (defcustom bhl-latex-extra-body nil "*A list of lines to be included before the first section." :type '(repeat (string :tag "Pre-body line")) :group 'bhl2latex) ;; Customize the SGML output (defcustom bhl-after-sgml-conversion-hook nil "Hook run after the conversion into SGML. This hook is run just before `bhl-after-conversion-hook'." :type '(hook) :group 'bhl2sgml) (defcustom bhl2sgml-properties-list '(t nil t) "List of properties of the `bhl2sgml' conversion." :type '(list (boolean :tag "Check dubious tags ") (boolean :tag "Ask caption for tables ") (boolean :tag "Use i18n conventions ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2sgml) (defcustom bhl-sgml-conversions-list '(t t t t t t t t nil t t t t t) "*A list of conversion functions to perform with `bhl2sgml'. Each element of this list corresponds to a conversion function." :type '(list (boolean :tag "Convert verbatim regions ") (boolean :tag "Convert horizontal rules ") (boolean :tag "Convert images ") (boolean :tag "Convert URLs ") (boolean :tag "Convert definition lists ") (boolean :tag "Convert normal list ") (boolean :tag "Convert tables ") (boolean :tag "Convert LaTeX labels " :help-echo "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" properly.") (boolean :tag "Convert footnotes ") (boolean :tag "Convert minipage " :help-echo "Minipages are tables in HTML and minipages in LaTeX.") (boolean :tag "Convert comments ") (boolean :tag "Convert escape sequences ") (boolean :tag "Convert WikiNames ") (boolean :tag "Convert quote ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2sgml) (defcustom bhl-sgml-minipage-tag "" "The style of any minipage in the SGML output. The default value is \"\". This means that a minipage is formatted as an example of code." :type '(string) :group 'bhl2sgml) (defcustom bhl-sgml-list-item-is-para-flag t "*Non-nil means that a list item is a paragraph." :type '(boolean) :group 'bhl2sgml) ;; Customize the TEXI output (defcustom bhl-after-texi-conversion-hook '(texinfo-every-node-update bhl-texi-make-menu) "Hook run after the conversion into TEXI. This hook is run just before `bhl-after-conversion-hook'." :type '(hook) :group 'bhl2texinfo) (defcustom bhl2texi-properties-list '(t t t) "List of properties of the `bhl2texinfo' conversion." :type '(list (boolean :tag "Check dubious tags ") (boolean :tag "Use i18n conventions ") (boolean :tag "Convert toc ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2texinfo) (defcustom bhl-texi-conversions-list '(t t t t t t nil t t t t t t t) "*A list of conversion functions to perform with `bhl2html'. Each element of this list corresponds to a conversion function." :type '(list (boolean :tag "Convert verbatim regions ") (boolean :tag "Convert horizontal rules ") (boolean :tag "Convert images ") (boolean :tag "Convert URLs ") (boolean :tag "Convert definition lists ") (boolean :tag "Convert normal list ") (boolean :tag "Convert tables ") (boolean :tag "Convert LaTeX labels " :help-echo "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" properly.") (boolean :tag "Convert footnotes ") (boolean :tag "Convert minipage " :help-echo "Minipages are tables in HTML and minipages in LaTeX.") (boolean :tag "Convert comments " :help-echo "In TEXI output, converting comments means deleting them.") (boolean :tag "Convert escape sequences ") (boolean :tag "Convert WikiNames ") (boolean :tag "Convert quote ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2texinfo) (defcustom bhl-texi-setchapternewpage-flag "on" "Non-nil means that chapter are inserted into a new page." :type '(radio (const "on") (const "off")) :group 'bhl2texinfo) (defcustom bhl-texi-titlepage-style 'classical "The style of the titlepage in the TEXI output." :type '(radio (const :tag "Classical" classical) (const :tag "Centered" centered)) :group 'bhl2texinfo) (defcustom bhl-texi-centered-minipage-tag "display" "The style of the centered minipage in the TEXI output. The default value is \"display\". This means that a so-called centered minipage is formatted as an example without special font." :type '(string) :group 'bhl2texinfo) (defcustom bhl-texi-table-tag "verbatim" "The tag for the conversion of tables in the TEXI output. The default value is \"verbatim\". If you want to skip tables when converting into TEXI, you should set this to \"ignore\"." :type '(radio (const "verbatim") (const "ignore")) :group 'bhl2texinfo) ;; Customize the TXT output (defcustom bhl-after-txt-conversion-hook '(bhl-tab-to-spc) "Hook run after the conversion into TXT. This hook is run just before `bhl-after-conversion-hook'." :type '(hook) :group 'bhl2txt) (defcustom bhl2txt-properties-list '(t t t) "List of properties of the `bhl2txt' conversion." :type '(list (boolean :tag "Center title and sections ") (boolean :tag "Convert toc ") (boolean :tag "Convert tabs to spaces ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2txt) (defcustom bhl-txt-conversions-list '(t t t t nil nil t nil nil t t t t nil) "*A list of conversion functions to perform with `bhl2html'. Each element of this list corresponds to a conversion function." :type '(list (boolean :tag "Convert verbatim regions ") (boolean :tag "Convert horizontal rules ") (boolean :tag "Convert images ") (boolean :tag "Convert URLs ") (boolean :tag "Convert definition lists ") (boolean :tag "Convert normal list ") (boolean :tag "Convert tables ") (boolean :tag "Convert LaTeX labels " :help-echo "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" properly.") (boolean :tag "Convert footnotes ") (boolean :tag "Convert minipage " :help-echo "Minipages are tables in HTML and minipages in LaTeX.") (boolean :tag "Convert comments " :help-echo "In TXT output, converting comments means deleting them.") (boolean :tag "Convert escape sequences ") (boolean :tag "Convert WikiNames ") (boolean :tag "Convert quote ")) :link '(custom-manual "(bhl)Properties of conversion") :group 'bhl2txt) ;; Set up after custom (defvar bhl-sectioning-style-alist `((num ("[0-9]+\\. " "[0-9]+\\.[0-9]+\\. " "[0-9]+\\.[0-9]+\\.[0-9]+\\. ")) (alpha ("[A-Z]\\. " "[A-Z]\\.[A-Z]\\. " "[A-Z]\\.[A-Z]\\.[A-Z]\\. ")) (aster ("\\* " "\\*\\* " "\\*\\*\\* ")) (equal-sign ("= " "== " "=== ")) (my ,bhl-my-sectioning-regexp-list))) ;;;; 3 - FACES (defface bhl-img-face '((t (:foreground "aquamarine4"))) "*The BHL face for images." :group 'bhl-faces) (defface bhl-wiki-face '((t (:foreground "aquamarine4"))) "*The BHL face for WikiNames." :group 'bhl-faces) (defface bhl-url-face '((t (:foreground "aquamarine4"))) "*The BHL face for URL." :group 'bhl-faces) (defface bhl-comment-face '((t (:foreground "darkcyan"))) "*The BHL face for comments." :group 'bhl-faces) (defface bhl-list-face '((t (:foreground "royalblue"))) "*The BHL face for list separators." :group 'bhl-faces) (defface bhl-descrip-face '((t (:foreground "royalblue"))) "*The BHL face for descriptive list separators." :group 'bhl-faces) (defface bhl-hr-face '((t (:foreground "darkred"))) "*The BHL face for horizontal rule." :group 'bhl-faces) (defface bhl-toc-face '((t (:foreground "darkcyan"))) "*The BHL face for the table of contents separators." :group 'bhl-faces) (defface bhl-title-face '((t (:weight bold :height 1.9))) "*The BHL face for the title." :group 'bhl-faces) (defface bhl-section-face '((t (:weight bold :height 1.6))) "*The BHL face for the sections." :group 'bhl-faces) (defface bhl-subsection-face '((t (:weight bold :height 1.3))) "*The BHL face for the subsections." :group 'bhl-faces) (defface bhl-subsubsection-face '((t (:weight bold))) "*The BHL face for the subsubsections." :group 'bhl-faces) (defface bhl-tt-face '((t (:foreground "darkred"))) "*The BHL face for truetype font text." :group 'bhl-faces) (defface bhl-underline-face '((t (:underline t))) "*The BHL face for underlined text." :group 'bhl-faces) (defface bhl-bold-face '((t (:weight bold))) "*The BHL face for bold text." :group 'bhl-faces) (defface bhl-italic-face '((t (:slant italic))) "*The BHL face for italic text." :group 'bhl-faces) (defface bhl-special-face '((t (:foreground "NavajoWhite1"))) "*The BHL face for minipage and verbatim environment." :group 'bhl-faces) (defvar bhl-img-face 'bhl-img-face "*The BHL face for images.") (defvar bhl-list-face 'bhl-list-face "*The BHL face for list separators.") (defvar bhl-descrip-face 'bhl-descrip-face "*The BHL face for descriptive list separators.") (defvar bhl-hr-face 'bhl-hr-face "*The BHL face for horizontal rule.") (defvar bhl-toc-face 'bhl-toc-face "*The BHL face for the table of contents separators.") (defvar bhl-title-face 'bhl-title-face "*The BHL face for the title.") (defvar bhl-section-face 'bhl-section-face "*The BHL face for the sections.") (defvar bhl-subsection-face 'bhl-subsection-face "*The BHL face for the subsections.") (defvar bhl-subsubsection-face 'bhl-subsubsection-face "*The BHL face pour les subsubsections.") (defvar bhl-tt-face 'bhl-tt-face "*The BHL face for truetype font text.") (defvar bhl-special-face 'bhl-special-face "*The BHL face for minipage and verbatim environment.") (defvar bhl-underline-face 'bhl-underline-face "*The BHL face for underlined text.") (defvar bhl-italic-face 'bhl-italic-face "*The BHL face for italic text.") (defvar bhl-bold-face 'bhl-bold-face "*The BHL face for bold text.") ;;;; 4 - MODE ;; XEmacs compatibility issues (defalias 'bhl-match-string (if (fboundp 'match-string-no-properties) 'match-string-no-properties 'match-string)) (defun bhl-replace-regexp-in-string (regexp rep string &optional fixedcase literal subexp start) "Replace every occurrence for REGEXP with REP in STRING. Return a new string containing the replacements. Optional arguments FIXEDCASE, LITERAL and SUBEXP are like the arguments with the same names of function `replace-match'. If START is non-nil, start replacements at that index in STRING. REP is either a string used as the NEWTEXT arg of `replace-match' or a function. If it is a function it is applied to each match to generate the replacement passed to `replace-match'; the `match-data' at this point are such that match 0 is the function's argument. To replace only the first match (if any), make REGEXP match up to \\' and replace a sub-expression, e.g. (replace-regexp-in-string \"\\(foo\\).*\\'\" \"bar\" \" foo foo\" nil nil 1) => \" bar foo\"" (let ((l (length string)) (start (or start 0)) matches str mb me) (save-match-data (while (and (< start l) (string-match regexp string start)) (setq mb (match-beginning 0) me (match-end 0)) (when (= me mb) (setq me (min l (1+ mb)))) (string-match regexp (setq str (substring string mb me))) (setq matches (cons (replace-match (if (stringp rep) rep (funcall rep (match-string 0 str))) fixedcase literal str subexp) (cons (substring string start mb) matches))) (setq start me)) (setq matches (cons (substring string start l) matches)) (apply #'concat (nreverse matches))))) (defsubst bhl-mark-active () "Return non-nil if the mark is active." (if (featurep 'xemacs) (region-active-p) mark-active)) (defsubst bhl-add-to-conversion-log (text) "Add TEXT to the conversions list." (setq bhl-conversion-log (add-to-list 'bhl-conversion-log text))) (defsubst bhl-string-to-anchor (str) "Convert the string STR into an anchor (shorter)." (substring str 0 (if (< (length str) 10) (length str) 10))) (defsubst bhl-cleanup-cell (cell) "Clean up a CELL by stripping leading and closing tabs/whitespaces." (funcall 'bhl-replace-regexp-in-string "^[ \t]*" "" (funcall 'bhl-replace-regexp-in-string "[ \t]*$" "" cell))) (defsubst bhl-subst-char-in-string (fromchar tochar string) "Convert FROMCHAR to TOCHAR in STRING." (let ((cpt 0)) (while (< cpt (length string)) (when (equal (aref string cpt) fromchar) (aset string cpt tochar)) (setq cpt (1+ cpt)))) string) (defsubst bhl-shrink-window-to-fit () "Shrink the current window to fit." (or (< (- (- (window-height) (count-lines (point-min) (point-max))) 2) 0) (shrink-window (- (- (window-height) (count-lines (point-min) (point-max))) 2)))) (defsubst bhl-indent-line () "Indent line function." (interactive) (let (column) (save-excursion (forward-line -1) (cond ((looking-at "\t[0-9]") (skip-chars-forward " o\t1234567890.*") (setq column (current-column))) ((looking-at "\t") (skip-chars-forward " o\t*") (setq column (current-column))) (nil (setq column (current-column))))) (if column (indent-to column)))) ;; Convert TABS into SPACES in the TXT output. (defsubst bhl-tab-to-spc () "Replace tabs with whitespaces." (when (get 'txt 'bhl-tas) (save-excursion (goto-char (point-min)) (while (re-search-forward "^[ ]*\\(\t\\)" nil t) (replace-match " " t t nil 1) (goto-char (point-min)))))) (defun bhl-texi-make-menu () "Make menus in the TEXI output." (interactive) (goto-char (point-min)) (while (re-search-forward "^@\\(chapter\\|section\\|subsection\\)" nil t) (goto-char (match-beginning 0)) (save-match-data (save-excursion (texinfo-make-menu))) (goto-char (match-end 0))) (goto-char (point-min))) (defsubst bhl-texi-toggle-accents () "Toggle accents in the TEXI output." (interactive) (goto-char (point-min)) (let ((turn (re-search-forward "\\(@\'\\|@`\\|@^\\)" nil t)) (accents '(("" "@'e") ("" "@`e") ("" "@`a") ("" "@^u") ("" "@^e") ("" "@^o") ("" "@^{@dotless{i}}") ("" "@^a") ("" "@`u") ("" "@,{c}")))) (while (car accents) (goto-char (point-min)) (while (search-forward (if turn (cadr (car accents)) (car (car accents))) nil t) (unless (or (get-text-property (match-beginning 0) 'category) (save-excursion (beginning-of-line) (looking-at "@node"))) (replace-match (if turn (car (car accents)) (cadr (car accents)))))) (setq accents (cdr accents))))) (defsubst bhl2html-set-default-plist () "Set the plist of the `bhl2html' conversion." (put 'html 'list-item-is-para bhl-html-list-item-is-para-flag) (put 'html 'conversions-list bhl-html-conversions-list) (put 'html 'lang (car bhl-i18n-conventions)) (put 'html 'after-conversion-hook 'bhl-after-html-conversion-hook) (put 'html 'bhl-check (nth 0 bhl2html-properties-list)) (put 'html 'bhl-prefix (nth 1 bhl2html-properties-list)) (put 'html 'bhl-caption (nth 2 bhl2html-properties-list)) (put 'html 'bhl-i18n (nth 3 bhl2html-properties-list)) (put 'html 'bhl-toc (nth 4 bhl2html-properties-list))) (defsubst bhl2latex-set-default-plist () "Set the plist of the `bhl2latex' conversion." (put 'latex 'conversions-list bhl-latex-conversions-list) (put 'latex 'lang (car bhl-i18n-conventions)) (put 'latex 'after-conversion-hook 'bhl-after-latex-conversion-hook) (put 'latex 'bhl-check (nth 0 bhl2latex-properties-list)) (put 'latex 'bhl-prefix (nth 1 bhl2latex-properties-list)) (put 'latex 'bhl-caption (nth 2 bhl2latex-properties-list)) (put 'latex 'bhl-i18n (nth 3 bhl2latex-properties-list)) (put 'latex 'bhl-toc (nth 4 bhl2latex-properties-list))) (defsubst bhl2sgml-set-default-plist () "Set the plist of the `bhl2sgml' conversion." (put 'sgml 'list-item-is-para bhl-sgml-list-item-is-para-flag) (put 'sgml 'conversions-list bhl-sgml-conversions-list) (put 'sgml 'lang (car bhl-i18n-conventions)) (put 'sgml 'after-conversion-hook 'bhl-after-sgml-conversion-hook) (put 'sgml 'bhl-check (nth 0 bhl2sgml-properties-list)) (put 'sgml 'bhl-caption (nth 1 bhl2sgml-properties-list)) (put 'sgml 'bhl-i18n (nth 2 bhl2sgml-properties-list))) (defsubst bhl2texi-set-default-plist () "Set the plist of the `bhl2texinfo' conversion." (put 'texi 'conversions-list bhl-texi-conversions-list) (put 'texi 'lang (car bhl-i18n-conventions)) (put 'texi 'after-conversion-hook 'bhl-after-texi-conversion-hook) (put 'texi 'bhl-check (nth 0 bhl2texi-properties-list)) (put 'texi 'bhl-i18n (nth 1 bhl2texi-properties-list)) (put 'texi 'bhl-toc (nth 2 bhl2texi-properties-list))) (defsubst bhl2txt-set-default-plist () "Set the plist of the `bhl2txt' conversion." (put 'txt 'conversions-list bhl-txt-conversions-list) (put 'txt 'after-conversion-hook 'bhl-after-txt-conversion-hook) (put 'txt 'bhl-center (car bhl2txt-properties-list)) (put 'txt 'bhl-toc (nth 1 bhl2txt-properties-list)) (put 'txt 'bhl-tas (nth 2 bhl2txt-properties-list))) ;; Sectioning style (defun bhl-set-sectioning-regexp-list () "Set `bhl-sectioning-regexp-list'." (setq bhl-sectioning-regexp-list (if (eq bhl-sectioning-default-style 'my) bhl-my-sectioning-regexp-list (cadr (assq bhl-sectioning-default-style bhl-sectioning-style-alist)))) (bhl-set-font-lock-keywords)) (defun bhl-guess-style () "Guess the sectioning style of the current buffer. Set `bhl-sectioning-default-style' to it." (interactive) (setq bhl-sectioning-default-style (bhl-sectioning-guess-style)) (bhl-set-sectioning-regexp-list)) (defun bhl-sectioning-guess-style () "Return the sectioning style of the current buffer." (let (endstyle) (mapcar (lambda (style) (unless endstyle (when (save-excursion (re-search-forward (concat "^" (caadr (assq style bhl-sectioning-style-alist))) nil t)) (setq endstyle style)))) '(num alpha aster equal-sign my)) (or endstyle bhl-sectioning-default-style))) ;; Fontlock keywords (defsubst bhl-set-font-lock-keywords () "Set font-lock keywords. It is necessary to set keywords each time the style of sectioning is changed." (setq bhl-font-lock-keywords (list (cons bhl-title-regexp bhl-title-face) (cons bhl-list-regexp bhl-list-face) (cons bhl-img-regexp bhl-img-face) (list bhl-descrip-regexp 0 bhl-descrip-face 'append) (cons bhl-hr-regexp bhl-hr-face) (cons bhl-hr1-regexp bhl-hr-face) (cons bhl-hr2-regexp bhl-hr-face) (cons (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$") bhl-section-face) (cons (concat "^" (nth 1 bhl-sectioning-regexp-list) ".*$") bhl-subsection-face) (cons (concat "^" (nth 2 bhl-sectioning-regexp-list) ".*$") bhl-subsubsection-face) (list (nth 0 bhl-tag-regexp-list) 1 bhl-underline-face 'append) (list (nth 1 bhl-tag-regexp-list) 1 bhl-tt-face 'append) (list (nth 2 bhl-tag-regexp-list) 1 bhl-italic-face 'append) (list (nth 3 bhl-tag-regexp-list) 1 bhl-bold-face 'append) (cons bhl-minipage-regexp bhl-special-face) (cons "^--$" bhl-special-face) (cons bhl-intro-toc bhl-toc-face) (cons bhl-end-toc bhl-toc-face) 'bhl-comment-highlight 'bhl-quote-highlight 'bhl-url-highlight 'bhl-generic-url-highlight)) (font-lock-mode) ;; ok, this is rather stupid, but I can't find another way... (font-lock-mode)) (defsubst bhl-wiki-set-font-lock-keywords () "Set font-lock keywords for BHL as a local wiki. See also `bhl-is-a-local-wiki-flag'." (add-to-list 'bhl-font-lock-keywords 'bhl-wiki-names-highlight 'bhl-non-wiki-names-unhighlight) (font-lock-mode) (font-lock-mode)) (defsubst bhl-toggle-wiki () "Toggle `bhl-is-a-local-wiki-flag'." (interactive) (setq bhl-is-a-local-wiki-flag (not bhl-is-a-local-wiki-flag)) (if bhl-is-a-local-wiki-flag (bhl-wiki-set-font-lock-keywords) (progn (setq bhl-font-lock-keywords (delq 'bhl-non-wiki-names-unhighlight (delq 'bhl-wiki-names-highlight bhl-font-lock-keywords))) (font-lock-mode) (font-lock-mode)))) (defsubst bhl-toggle-tags-overlap () "Toggle `bhl-tags-overlap-flag'." (interactive) (setq bhl-tags-overlap-flag (not bhl-tags-overlap-flag)) (if bhl-tags-overlap-flag (setq bhl-tag-regexp-list bhl-tag-regexp-list0) (setq bhl-tag-regexp-list bhl-tag-regexp-list1)) (if bhl-is-a-local-wiki-flag (bhl-wiki-set-font-lock-keywords) (bhl-set-font-lock-keywords)) (bhl-mode)) (defun bhl-sectioning-switch-style (&optional style) "Switch the current sectioning style to STYLE." (interactive) (let ((sty (or style (intern (completing-read "Switch to style: " '(("num" 1) ("alpha" 2) ("aster" 3) ("equal-sign" 4)) nil t))))) (bhl-update-toc sty) (setq bhl-sectioning-default-style sty) (bhl-set-sectioning-regexp-list) (bhl-set-font-lock-keywords) (when (eq bhl-is-a-local-wiki-flag t) (bhl-wiki-set-font-lock-keywords)) (message "The style of sectioning has been set to \"%s\"." (symbol-name sty)))) (defsubst bhl-initialize-properties () "Initialize the properties of conversions." (bhl2html-set-default-plist) (bhl2latex-set-default-plist) (bhl2sgml-set-default-plist) (bhl2txt-set-default-plist) (bhl2texi-set-default-plist)) (easy-menu-define bhl-menu bhl-mode-map "Menu of the BHL mode" '("BHL" ;; the main conversion commands ("bhl2html" ["Convert into HTML" bhl2html] "---" ["Check dubious tags" (bhl-toggle-property 'bhl-check 'html) :style toggle :selected (get 'html 'bhl-check)] ["Prefix sections" (bhl-toggle-property 'bhl-prefix 'html) :style toggle :selected (get 'html 'bhl-prefix)] ["Use i18n conventions" (bhl-toggle-property 'bhl-i18n 'html) :style toggle :selected (get 'html 'bhl-i18n)] ["Ask tables caption" (bhl-toggle-property 'bhl-caption 'html) :style toggle :selected (get 'html 'bhl-caption)] ["Convert toc" (bhl-toggle-property 'bhl-toc 'html) :style toggle :selected (get 'html 'bhl-toc)]) ("bhl2latex" ["Convert into LaTeX" bhl2latex] "---" ["Check dubious tags" (bhl-toggle-property 'bhl-check 'latex) :style toggle :selected (get 'latex 'bhl-check)] ["Prefix sections" (bhl-toggle-property 'bhl-prefix 'latex) :style toggle :selected (get 'latex 'bhl-prefix)] ["Use i18n conventions" (bhl-toggle-property 'bhl-i18n 'latex) :style toggle :selected (get 'latex 'bhl-i18n)] ["Ask tables caption" (bhl-toggle-property 'bhl-caption 'latex) :style toggle :selected (get 'latex 'bhl-caption)] ["Convert toc" (bhl-toggle-property 'bhl-toc 'latex) :style toggle :selected (get 'latex 'bhl-toc)]) ("bhl2texinfo" ["Convert into Texinfo" bhl2texinfo] "---" ["Check dubious tags" (bhl-toggle-property 'bhl-check 'texi) :style toggle :selected (get 'texi 'bhl-check)] ["Use i18n conventions" (bhl-toggle-property 'bhl-i18n 'texi) :style toggle :selected (get 'texi 'bhl-i18n)] ["Convert toc" (bhl-toggle-property 'bhl-toc 'texi) :style toggle :selected (get 'texi 'bhl-toc)]) ("bhl2sgml" ["Convert into SGML" bhl2sgml] "---" ["Check dubious tags" (bhl-toggle-property 'bhl-check 'sgml) :style toggle :selected (get 'sgml 'bhl-check)] ["Use i18n conventions" (bhl-toggle-property 'bhl-i18n 'sgml) :style toggle :selected (get 'sgml 'bhl-i18n)] ["Ask tables caption" (bhl-toggle-property 'bhl-caption 'sgml) :style toggle :selected (get 'sgml 'bhl-caption)]) ("bhl2txt" ["Convert into TXT" bhl2txt] "---" ["Center sections" (bhl-toggle-property 'bhl-center 'txt) :style toggle :selected (get 'txt 'bhl-center)] ["Tabs are spaces" (bhl-toggle-property 'bhl-tas 'txt) :style toggle :selected (get 'txt 'bhl-tas)] ["Convert toc" (bhl-toggle-property 'bhl-toc 'txt) :style toggle :selected (get 'txt 'bhl-toc)]) "---" ;; insert commands ("Insert" ["Insert toc" bhl-insert-toc t] ["Insert lol" bhl-insert-lol t] ["Insert URL" bhl-insert-url t] ["Insert image" bhl-insert-image t] ["Insert minipage" bhl-insert-minipage t] ["Insert verbatim" bhl-insert-verbatim t] ["Insert hr" bhl-insert-hr t]) ;; changing font commands ("Change font" ["Bold" bhl-change-font-bold t] ["Emphasis" bhl-change-font-emphasis t] ["Underline" bhl-change-font-underline t] ["TrueType" bhl-change-font-truetype t] ["Bold italic" bhl-change-font-bolditalic t] "---" ["Normal" bhl-change-font-normal t]) ;; browse the source ("Go to" ["Next section" bhl-goto-next-section t] ["Previous section" bhl-goto-previous-section t] ["Next URL or WikiName" bhl-goto-next-url-or-wiki t]) "---" ;; handling the table of contents ["Browse the lol" bhl-show-lol t] ["Browse the toc" bhl-show-toc t] ["Update toc" bhl-update-toc t] ("Toc location" ["Toc at the top" (setq bhl-toc-location "top") :style radio :selected (equal bhl-toc-location "top")] ["Toc on the point" (setq bhl-toc-location "point") :style radio :selected (equal bhl-toc-location "point")] ["Toc at the bottom" (setq bhl-toc-location "bottom") :style radio :selected (equal bhl-toc-location "bottom")]) ("Toc depth" ["Sections only" (setq bhl-default-toc-depth 1) :style radio :selected (equal bhl-default-toc-depth 1)] ["Sections and subsections" (setq bhl-default-toc-depth 2) :style radio :selected (equal bhl-default-toc-depth 2)] ["Maximum depth [3]" (setq bhl-default-toc-depth 3) :style radio :selected (equal bhl-default-toc-depth 3)]) ;; miscellaneous "---" ["BHL Wiki" bhl-toggle-wiki :style radio :selected (eq bhl-is-a-local-wiki-flag t)] ["Tags overlap" bhl-toggle-tags-overlap :style radio :selected (eq bhl-tags-overlap-flag t)] ("Sectioning style" ["Guess" bhl-guess-style t] "---" ["Numerical" (bhl-sectioning-switch-style 'num) :style radio :selected (eq bhl-sectioning-default-style 'num)] ["Alphabetical" (bhl-sectioning-switch-style 'alpha) :style radio :selected (eq bhl-sectioning-default-style 'alpha)] ["Asterisks" (bhl-sectioning-switch-style 'aster) :style radio :selected (eq bhl-sectioning-default-style 'aster)] ["Equal signs" (bhl-sectioning-switch-style 'equal-sign) :style radio :selected (eq bhl-sectioning-default-style 'equal-sign)] ["My style" (progn (setq bhl-sectioning-default-style 'my) (bhl-set-sectioning-regexp-list) (bhl-set-font-lock-keywords) (when (eq bhl-is-a-local-wiki-flag t) (bhl-wiki-set-font-lock-keywords)) (message "The style of sectioning has been set to \"my\".")) :style radio :selected (eq bhl-sectioning-default-style 'my)]) ("I18n conventions" ["English" (setcar bhl-i18n-conventions "en") :style radio :selected (equal (car bhl-i18n-conventions) "en")] ["French" (setcar bhl-i18n-conventions "fr") :style radio :selected (equal (car bhl-i18n-conventions) "fr")] ["German" (setcar bhl-i18n-conventions "de") :style radio :selected (equal (car bhl-i18n-conventions) "de")]) "---" ["Mail buffer" bhl-compose-mail] "---" ;; miscellaneous (again) ["View last conversion log" bhl-view-log t] ["Submit bug report" bhl-submit-bug-report t] ["Customize BHL" (customize-group "bhl") t] ["BHL info manual" (info "bhl.info")] ["BHL version" bhl-show-version t])) ;;;###autoload (define-derived-mode bhl-mode text-mode "BHL" "B - Brute, H - HTML, L - LaTeX. The BHL mode enables you to convert plain text files into HTML, LaTeX and SGML files. This is a simple mode, with simple conversion functions and converts only simple source files. \\ + Sections: =========== 1. : insert a section. 1.1. : insert a subsection. 1.1.1. : insert a subsubsection. A. : insert a section. A.A. : insert a subsection. A.A.A. : insert a subsubsection. + Font change: ============== *a word* : bold _a word_ : emphasis _*a word*_ : bold-italic __a word__ : underline ==a word== : truetype -- This part of text will be inserted as verbatim text. -- %%[2cm] This part of text will be put inside a minipage which width is 2cm (size is optional). %% + Key bindings: =============== \\[bhl2html] : convert the buffer into HTML. \\[bhl2sgml] : convert the buffer into SGML (Linuxdoc). \\[bhl2latex] : convert the buffer into LaTeX. \\[bhl2texinfo] : convert the buffer into TEXI. \\[bhl2txt] : convert the buffer into TXT. \\[bhl-insert-url] : ask for an URL and its name, then insert it. \\[bhl-insert-image] : ask for an image file name, then insert it. \\[bhl-insert-hr] : insert a horizontal rule. \\[bhl-insert-minipage] : insert a minipage. \\[bhl-insert-verbatim] : insert a verbatim environment. \\[bhl-insert-toc] : insert the table of contents. Take the toc depth as an optional argument. \\[bhl-insert-tab] : insert a tab rigidly. \\[bhl-comment-region] : comment the region \\[universal-argument] \\[bhl-comment-region] : uncomment the region. \\[bhl-view-log] : view the log of the last conversion. \\[bhl-compose-mail] : compose mail with the result of bhl2txt on the current buffer. \\[bhl-show-toc] : browse the table of contents. \\[bhl-update-toc] : update the sections' prefix. \\[bhl-show-lol] : browse the list of links. \\[bhl-goto-next-section] : go to the next section. \\[universal-argument] \\[bhl-goto-next-section] : go to the next section or (sub)subsection. \\[bhl-goto-previous-section] : go to the previous section. \\[universal-argument] \\[bhl-goto-previous-section] : go to the previous section or (sub)subsection. \\[bhl-goto-next-url-or-wiki] : go to the next URL or WikiName. \\[bhl-submit-bug-report] : submit a bug report. \\[bhl-show-version] : display the current version of BHL. + List separators: ================== TAB(S) and \"*\" or \"-\" or \"o\" and a whitespace: a non-ordered list item. TAB(S) and 0-9 and dot and a whitespace: an ordered list item. TAB and a definition term and \"--\" and a whitespace: a definition list item. + List examples: ================ * Here is - a simple - nested list o with three levels o of nested items. 1. Here is... 2. ...an ordered list * inside another list. A term -- and its definition. Another term -- and its definition. + bhl-mode-map: =============== \\{bhl-mode-map}" (kill-all-local-variables) (use-local-map bhl-mode-map) (easy-menu-add bhl-menu) (make-local-variable 'font-lock-defaults) (make-local-variable 'indent-line-function) (setq bhl-tag-regexp-list (if bhl-tags-overlap-flag bhl-tag-regexp-list0 bhl-tag-regexp-list1)) (when bhl-autoguess-style-flag (bhl-guess-style)) (bhl-set-sectioning-regexp-list) (when (eq bhl-is-a-local-wiki-flag t) (bhl-wiki-set-font-lock-keywords)) (bhl-initialize-properties) (setq indent-line-function 'bhl-indent-line tab-width bhl-tab-width font-lock-defaults '(bhl-font-lock-keywords t) font-lock-multiline t mode-name "BHL" major-mode 'bhl-mode) (mapcar 'run-hooks bhl-mode-hook)) ;; Conversion commandse (define-key bhl-mode-map [(control c) (control w)] 'bhl2html) (define-key bhl-mode-map [(control c) (control l)] 'bhl2latex) (define-key bhl-mode-map [(control c) (control s)] 'bhl2sgml) (define-key bhl-mode-map [(control c) (control d)] 'bhl2txt) (define-key bhl-mode-map [(control c) (control o)] 'bhl2texinfo) ;; Toc/lol commands (define-key bhl-mode-map [(control c) (control t)] 'bhl-show-toc) (define-key bhl-mode-map [(control c) (meta t)] 'bhl-update-toc) (define-key bhl-mode-map [(control c) (meta s)] 'bhl-guess-style) (define-key bhl-mode-map [(control c) (control /)] 'bhl-show-lol) ;; Insert (define-key bhl-mode-map [(control c) (control c) ?t] 'bhl-insert-toc) (define-key bhl-mode-map [(control c) (control c) ?l] 'bhl-insert-lol) (define-key bhl-mode-map [(control c) (control c) ?h] 'bhl-insert-url) (define-key bhl-mode-map [(control c) (control c) ?i] 'bhl-insert-image) (define-key bhl-mode-map [(control c) (control c) ?m] 'bhl-insert-minipage) (define-key bhl-mode-map [(control c) (control c) ?v] 'bhl-insert-verbatim) (define-key bhl-mode-map [(control c) (control c) ?r] 'bhl-insert-hr) (define-key bhl-mode-map [(meta tab)] 'bhl-insert-tab) ;; Font commands (define-key bhl-mode-map [(control c) ?\;] 'bhl-comment-region) (define-key bhl-mode-map [(control c) (control f) (control b)] 'bhl-change-font-bold) (define-key bhl-mode-map [(control c) (control f) (control e)] 'bhl-change-font-emphasis) (define-key bhl-mode-map [(control c) (control f) (control n)] 'bhl-change-font-normal) (define-key bhl-mode-map [(control c) (control f) (control u)] 'bhl-change-font-underline) (define-key bhl-mode-map [(control c) (control f) (control t)] 'bhl-change-font-truetype) (define-key bhl-mode-map [(control c) (control f) (control _)] 'bhl-change-font-bolditalic) ;; Move inside your document (define-key bhl-mode-map [?\r] 'newline-and-indent) (define-key bhl-mode-map [(control c) (control n)] 'bhl-goto-next-section) (define-key bhl-mode-map [(control c) (control p)] 'bhl-goto-previous-section) (define-key bhl-mode-map [(control tab)] 'bhl-goto-next-url-or-wiki) ;; Other (define-key bhl-mode-map [(control down-mouse-3)] 'bhl-popup-menu) (define-key bhl-mode-map [(control c) (control v)] 'bhl-show-version) (define-key bhl-mode-map [(control c) (control x) ?m] 'bhl-compose-mail) ;; M-x bhl = M-x bhl-mode (defalias 'bhl 'bhl-mode) ;;;; 5 - MENU ;;Pop up menu (defsubst bhl-popup-menu () "Pop up a menu." (interactive) (eval (x-popup-menu t bhl-popup-menu-map))) (define-key bhl-popup-menu-map [bhl-compose-mail] '("Mail buffer" . bhl-compose-mail)) (define-key bhl-popup-menu-map [bhl-show-lol] '("Show lol" . bhl-show-lol)) (define-key bhl-popup-menu-map [bhl-show-toc] '("Show toc" . bhl-show-toc)) (define-key bhl-popup-menu-map [bhl2txt] '("bhl2txt" . bhl2txt)) (define-key bhl-popup-menu-map [bhl2sgml] '("bhl2sgml" . bhl2html)) (define-key bhl-popup-menu-map [bhl2texinfo] '("bhl2texinfo" . bhl2texinfo)) (define-key bhl-popup-menu-map [bhl2latex] '("bhl2latex" . bhl2latex)) (define-key bhl-popup-menu-map [bhl2html] '("bhl2html" . bhl2html)) ;;;; 6 - OTHER FUNCTIONS ;; Ignore some lines (defun bhl-ignore-regexp-line () "Ignore some lines matching regexp." (goto-char (point-min)) (mapcar (lambda (regexp) (save-excursion (let ((kill-whole-line t)) (while (re-search-forward regexp nil t) (beginning-of-line) (kill-line))))) bhl-ignored-regexps)) ;;Font handling: (defun bhl-change-font (tagbeg tagend) "Insert TAGBEG and TAGEND at the beginning/end of a region." (let* ((beg (if (bhl-mark-active) (mark) (point))) (end (point)) (temp beg)) (when (< end beg) (setq beg end end temp)) (goto-char beg) (while (memq t (mapcar (lambda (char) (equal (char-before (point)) char)) '(?* ?= ?_))) (delete-char -1) (setq end (1- end))) (insert tagbeg) (goto-char (+ (length tagbeg) end)) (while (memq t (mapcar (lambda (char) (equal (char-after (point)) char)) '(?* ?= ?_))) (delete-char 1)) (save-excursion (insert tagend)) (setq mark-active nil))) (defun bhl-change-font-bold () "Change font to bold." (interactive) (bhl-change-font "*" "*")) (defun bhl-change-font-emphasis () "Change font to emphasis." (interactive) (bhl-change-font "_" "_")) (defun bhl-change-font-truetype () "Change font to truetype." (interactive) (bhl-change-font "==" "==")) (defun bhl-change-font-underline () "Change font to underline." (interactive) (bhl-change-font "__" "__")) (defun bhl-change-font-bolditalic () "Change font to bold-italic." (interactive) (bhl-change-font "_*" "*_")) (defun bhl-change-font-normal () "Strip any font beautifier." (interactive) (bhl-change-font "" "")) ;; Sectioning ;; Move inside the BHL source (defun bhl-goto-next-section (&optional arg) "Go to the title of the next section. If ARG is non-nil, go to the title of the next section or (sub)subsection." (interactive "P") (let ((reg (if arg (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$" "\\|^" (nth 1 bhl-sectioning-regexp-list) ".*$" "\\|^" (nth 2 bhl-sectioning-regexp-list) ".*$") (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$")))) (re-search-forward reg nil t))) (defun bhl-goto-previous-section (&optional arg) "Go to the title of the previous section. If ARG is non-nil, go to the title of the previous section or (sub)subsection." (interactive "P") (let ((reg (if arg (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$" "\\|^" (nth 1 bhl-sectioning-regexp-list) ".*$" "\\|^" (nth 2 bhl-sectioning-regexp-list) ".*$") (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$")))) (re-search-backward reg nil t))) ;; Follow URLs and Wiki links (defun bhl-goto-next-url-or-wiki () "Go to the next URL or WikiName." (interactive) (let ((case-fold-search) (reg (concat bhl-url-regexp "\\|" bhl-wiki-names-regexp))) (if (looking-at reg) (forward-char)) (or (re-search-forward reg nil t) (progn (goto-char (point-min)) (re-search-forward reg nil t)))) (goto-char (match-beginning 0))) (defun bhl-url-at-point () "Return non-nil if a URL is at point." (save-excursion (skip-chars-backward "^'\"<>[{}( \t\n") (looking-at bhl-generic-url-regexp))) (defun bhl-visit-url (link) "Visit the URL named LINK." (funcall bhl-browse-url-function link)) (defun bhl-follow-url-at-point () "Visit the link at point." (interactive) (when (bhl-url-at-point) (cond ((equal (substring (match-string 0) 0 7) "mailto:") (compose-mail (substring (match-string 0) 7))) (t (bhl-visit-url (or (match-string 5) (match-string 0))))))) (defun bhl-follow-url-at-mouse (event) "According to EVENT, visit the link at point." (interactive "e") (save-excursion (when (fboundp 'posn-window) (set-buffer (window-buffer (posn-window (event-start event)))) (goto-char (posn-point (event-start event)))) (when (bhl-url-at-point) (cond ((equal (substring (match-string 0) 0 7) "mailto:") (compose-mail (substring (match-string 0) 7))) (t (bhl-visit-url (or (match-string 5) (match-string 0)))))))) ;; Follow WikiNames (defun bhl-wiki-name-at-point () "Return non-nil if a URL is at point." (save-excursion (let (case-fold-search) (skip-chars-backward "^'\"<>[{}( \t\n") (looking-at bhl-wiki-names-regexp)))) (defun bhl-follow-wiki-name-at-point () "Visit the WikiName at point." (interactive) (when (bhl-wiki-name-at-point) (find-file (concat (if bhl-downcase-wikifiles-names-flag (downcase (match-string 0)) (match-string 0)) bhl-default-wikifiles-extension)) (delete-other-windows))) (defun bhl-follow-wiki-name-at-mouse (event) "Visit the WikiName at EVENT." (interactive "e") (save-excursion (when (fboundp 'posn-window) (set-buffer (window-buffer (posn-window (event-start event)))) (goto-char (posn-point (event-start event)))) (when (bhl-wiki-name-at-point) (find-file (concat (if bhl-downcase-wikifiles-names-flag (downcase (match-string 0)) (match-string 0)) bhl-default-wikifiles-extension))))) (defsubst bhl-wiki-names-highlight (limit) "Highlight WikiNames in the BHL buffer limited to LIMIT." (let ((map (copy-keymap (current-local-map))) case-fold-search) (define-key map [(mouse-2)] 'bhl-follow-wiki-name-at-mouse) (define-key map [(return)] 'bhl-follow-wiki-name-at-point) (while (re-search-forward bhl-wiki-names-regexp limit t) (or (member (match-string 0) bhl-non-wiki-names-list) (add-text-properties (match-beginning 0) (match-end 0) `(face bhl-wiki-face rear-nonsticky t local-map ,map mouse-face highlight help-echo "mouse-2: follow WikiName")))))) (defsubst bhl-non-wiki-names-unhighlight (limit) "Unhighlight non-wiki-names found in `bhl-non-wiki-names-list'. Search is bounded to LIMIT." (let (case-fold-search) (while (re-search-forward bhl-wiki-names-regexp limit t) (when (member (match-string 0) bhl-non-wiki-names-list) (remove-text-properties (match-beginning 0) (match-end 0) `(face rear-nonsticky local-map mouse-face help-echo)))))) ;; Toggle properties (defun bhl-toggle-property (prop symb) "Toggle the property PROP in SYMB." (put symb prop (not (get symb prop)))) ;; Show BHL version (defun bhl-show-version () "Display version infos about BHL." (interactive) (message "BHL mode %s, Copyright (C) 2003 Bastien Guerry; type C-h m for help." bhl-version) (if (sit-for 3) (let ((lines bhl-startup-message-lines)) (while (and (sit-for 3) lines) (message (substitute-command-keys (car lines))) (setq lines (cdr lines))))) (message "")) ;; Don't INDENT paragraphs. Restrict indentation to lists. (defsubst bhl-insert-tab () "Tabulation for the BHL mode. Use this function to indent list items. Don't indent paragraphs." (interactive) (indent-to (+ (current-column) tab-width))) (defun bhl-compose-mail () "Mail the content of the BHL buffer in plain text." (interactive) (bhl2txt) (save-buffer) (let ((file (buffer-file-name))) (compose-mail) (save-excursion (goto-char (point-max)) (setq tab-width 3) (insert-file-contents file)))) ;; Check for dubious comments (defun bhl-check-comment (arg) "Check for dubious comment strings in the ARG output." (let ((regexp (cond ((eq arg 'latex) "%+") ((eq arg 'texi) "@c[ \t\n]") (t "")))) (goto-char (point-min)) (while (re-search-forward regexp nil t) (bhl-add-to-conversion-log (format "Dubious comment \"%s\" at point %s." (match-string 0) (match-beginning 0)))))) ;; Check for dubious tags (in verbatim environments) (defun bhl-check-existing-tags (arg) "Check if there is no tag of the ARG format in the source file. Especially need for verbatim environments." (save-excursion (goto-char (point-min)) (let ((reg (cond ((eq arg 'latex) "\\\\\\(\\w+\\){\\(\\w+\\)}") ((eq arg 'texi) "@\\(\\w+\\){\\(\\w+\\)}") (t "<\\(/?[^>\t\n]+\\)>"))) (rep (cond ((eq arg 'latex) "\$\\\\backslash\$\\1\\\\{\\2\\\\}") ((eq arg 'texi) "@@\\1@{\\2@}") (t "‹\\1›")))) (query-replace-regexp reg rep)))) ;; Highlighting functions (defsubst bhl-comment-highlight (limit) "Highlight comment strings limited to LIMIT." (while (re-search-forward "^#\\(.*\\)$" limit t) (add-text-properties (match-beginning 0) (match-end 0) '(face bhl-comment-face category comment))) (while (re-search-forward "[^\\]\\(#.*\\)$" limit t) (add-text-properties (match-beginning 1) (match-end 1) '(face bhl-comment-face category comment)))) (defsubst bhl-quote-highlight (limit) "Highlight quote strings limited to LIMIT." (while (re-search-forward "^\t.*$" limit t) (unless (string-match " --\\|\t+\*\\|\t+[0-9]+\. \\|\t+- \\|\t+o " (match-string 0)) (add-text-properties (match-beginning 0) (match-end 0) '(category quote))))) (defsubst bhl-url-highlight (limit) "Highlight URLs in the BHL buffer limited to LIMIT." (while (re-search-forward bhl-url-regexp limit t) (add-text-properties (match-beginning 0) (match-end 0) '(face bhl-url-face category link rear-nonsticky t)))) (defsubst bhl-generic-url-highlight (limit) "Highlight URLs in the BHL buffer limited to LIMIT." (let ((map (copy-keymap (current-local-map)))) (define-key map [(mouse-2)] 'bhl-follow-url-at-mouse) (define-key map [(return)] 'bhl-follow-url-at-point) (while (re-search-forward bhl-generic-url-regexp limit t) (add-text-properties (match-beginning 0) (match-end 0) `(category link rear-nonsticky t local-map ,map mouse-face highlight help-echo "mouse-2: follow URL"))))) (defsubst bhl-highlight-toc-buffer () "Highlight the *toc* buffer." (save-excursion (goto-char (point-min)) (re-search-forward bhl-intro-toc nil t) (add-text-properties (match-beginning 0) (match-end 0) '(face bold)) (while (re-search-forward (concat "^[ ]*\\(" (nth 0 bhl-sectioning-regexp-list) "\\|" (nth 1 bhl-sectioning-regexp-list) "\\|" (nth 2 bhl-sectioning-regexp-list) "\\)\\(.*\\)$") nil t) (add-text-properties (match-beginning 2) (match-end 2) '(mouse-face highlight help-echo "mouse-2: go to this section"))))) ;; Convert quote chars in HTML and SGML (defun bhl-convert-quote-char () "Convert the quote character in HTML and SGML." (interactive) (save-excursion (goto-char (point-min)) (while (re-search-forward "<\\|>" nil t) (if (equal (match-string 0) "<") (replace-match "‹") (replace-match "›"))))) ;; Handle footnotes (defun bhl-convert-footnotes (arg) "Convert footnotes into ARG format." (let ((ftn-regexp (concat (regexp-quote footnote-start-tag) (eval (intern (concat "footnote-" (symbol-name footnote-style) "-regexp"))) (regexp-quote footnote-end-tag)))) (goto-char (point-min)) (when (and (re-search-forward "^Footnotes.*$" nil t) (eq arg 'html)) (replace-match (concat "

" (match-string 0) "") t t)) (while (re-search-forward (concat "\\(" ftn-regexp "\\)[ ]*") nil t) (let* ((num (match-string 1))) (when (eq arg 'html) (replace-match (concat "

" num "  "))) (funcall 'bhl-replace-footnote num arg (bhl-subst-char-in-string ?\n ? (buffer-substring-no-properties (point) (progn (re-search-forward "\\[\\|^$" nil t) (goto-char (1- (match-beginning 0))))))))) (when (or (eq arg 'latex) (eq arg 'texi)) (bhl-skip-footnotes)) (bhl-add-to-conversion-log "Footnotes conversion."))) (defun bhl-skip-footnotes (&optional arg) "Skip footnotes according to ARG format." (save-excursion (goto-char (point-min)) (when arg (while (re-search-forward (concat (regexp-quote footnote-start-tag) (eval (intern (concat "footnote-" (symbol-name footnote-style) "-regexp"))) (regexp-quote footnote-end-tag)) nil t) (replace-match ""))) (goto-char (point-min)) (when (re-search-forward "^Footnotes.*$" nil t) (kill-region (match-beginning 0) (point-max))))) (defun bhl-replace-footnote (num arg content) "Replace the footnote number NUM into ARG format with CONTENT." (save-excursion (goto-char (point-min)) (re-search-forward (regexp-quote num) nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (or (and (eq cat 'verbatim) (memq 'footnote bhl-verbatim-ignore)) (eq cat 'link) (eq cat 'comment))) (cond ((eq arg 'latex) (let ((section (save-match-data (save-excursion (beginning-of-line) (looking-at (mapconcat (lambda (str) str) bhl-sectioning-regexp-list "\\|")))))) (replace-match (concat (if section "\\protect" "") "\\footnote{" content "}") t t))) ((eq arg 'texi) (replace-match (concat "@footnote{" content "}") t t)) ((eq arg 'html) (replace-match (concat "" (match-string 0) ""))))))) (defun bhl-convert-quote (arg) "Convert quote environment into ARG format." (save-excursion (goto-char (point-min)) (while (re-search-forward "^\t.*$" nil t) (let ((result (bhl-match-string 0)) (loc (match-beginning 0)) (intro-tag (cond ((eq arg 'latex) "\n\\begin{quote}") ((eq arg 'html) "\n

") ((eq arg 'texi) "\n@quotation") ((eq arg 'sgml) "\n"))) (end-tag (cond ((eq arg 'latex) "\\end{quote}\n") ((eq arg 'html) "
\n") ((eq arg 'texi) "@end quotation\n") ((eq arg 'sgml) "\n")))) (if (not (or (string-match " --\\|\t+\\* \\|\t+[0-9]+\. \\|\t+- \\|\t+o " result) (and (memq 'quote bhl-verbatim-ignore) (get-text-property loc 'category) 'verbatim))) (progn (forward-line -1) (end-of-line) (insert intro-tag) (re-search-forward "^$\\|^--$\\|^[<>%][-%]%+.*$" nil t) (beginning-of-line) (insert end-tag)) (re-search-forward "^$" nil t)))))) ;; convert verbatim, minipages and horizontal rules (defun bhl-convert-verbatim (arg) "Convert verbatim environment into ARG format." (goto-char (point-min)) (while (re-search-forward "^--$" nil t) (bhl-convert-special arg '("" "
" "

" "\\begin{verbatim}" "@verbatim") '("" "

" "" "\\end{verbatim}" "@end verbatim") "--" "--"))) (defun bhl-convert-minipage (arg) "Convert minipage into ARG format." (goto-char (point-min)) (while (re-search-forward bhl-minipage-regexp nil t) (let ((border (if (equal (match-string 2) "-") (cond ((eq arg 'texi) "@cartouche\n") ((eq arg 'html) " border: 1pt solid\;") ((eq arg 'latex) "\\fbox{") (t "")) "")) (end-border (cond ((and (eq arg 'latex) (equal (match-string 2) "-")) "}") ((and (eq arg 'texi) (equal (match-string 2) "-")) "\n@end cartouche"))) (bhl-intro-minipage (regexp-quote (match-string 0))) justify width intro-minipage end-minipage) (cond ((eq arg 'latex) (cond ((equal (match-string 1) "<") (setq justify "flushleft")) ((equal (match-string 1) ">") (setq justify "flushright")) (t (setq justify "center"))) (if (match-string 4) (setq width (match-string 4)) (setq width "\\textwidth"))) ((eq arg 'html) (cond ((equal (match-string 1) "<") (setq justify "left")) ((equal (match-string 1) ">") (setq justify "right")) (t (setq justify "center"))) (if (match-string 4) (setq width (match-string 4)) (setq width "100%"))) ((eq arg 'texi) (cond ((equal (match-string 1) "<") (setq justify "flushleft")) ((equal (match-string 1) ">") (setq justify "flushright")) (t (setq justify bhl-texi-centered-minipage-tag))) (if (match-string 4) (setq width (match-string 4)) (setq width "100%")))) (setq intro-minipage `("" ,(concat "
\n" "
") ,(concat "

" bhl-sgml-minipage-tag) ,(concat "\\vspace{.3cm}\n\\begin{" justify "}\n" border "\\begin{minipage}[c]{" width "}") ,(concat border "@" justify))) (setq end-minipage `("" "

\n
" "
" ,(concat "\\end{minipage}" end-border "\n\\end{" justify "}\n\\vspace{.3cm}") ,(concat "@end " justify end-border))) (bhl-convert-special arg intro-minipage end-minipage bhl-intro-minipage "^%%+")))) (defun bhl-convert-hr (arg) "Convert a raw of dashes into an horizontal rule. ARG is the output format." (goto-char (point-min)) (while (re-search-forward bhl-hr-regexp nil t) (let (justify width) (cond ((equal (match-string 1) "<") (setq justify "left")) ((equal (match-string 1) ">") (setq justify "right")) (t (setq justify "center"))) (cond ((eq arg 'txt) (if (match-string 4) (setq width (string-to-number (match-string 4))) (setq width (or fill-column 70))) (let (replacmt) (if (equal justify "right") (setq replacmt (concat (make-string (- (or fill-column 70) width) 32) (make-string width ?-))) (setq replacmt (make-string (or width fill-column 70) ?-))) (replace-match replacmt) (when (equal justify "center") (center-line)))) ((eq arg 'latex) (setq width (or (match-string 3) "\\\\textwidth")) (let (flush) (setq flush (if (equal justify "center") "" "flush")) (replace-match (concat "\\\\begin{" flush justify "}\n\\\\rule{" width "}{1pt}\n\\\\end{" flush justify"}")))) ((eq arg 'html) (setq width (or (match-string 3) "100%")) (replace-match (concat "
"))) (t (replace-match "")))))) (defun bhl-convert-hr1 (arg) "Convert a raw of dashes into an horizontal rule. ARG is the output format." (goto-char (point-min)) (while (re-search-forward bhl-hr1-regexp nil t) (let (justify width) (cond ((equal (match-string 1) "<") (setq justify "left")) ((equal (match-string 1) ">") (setq justify "right")) (t (setq justify "center"))) (cond ((eq arg 'txt) (if (match-string 4) (setq width (string-to-number (match-string 4))) (setq width (or fill-column 70))) (let (replacmt) (if (equal justify "right") (setq replacmt (concat (make-string (- (or fill-column 70) width) 32) (make-string width ?-))) (setq replacmt (make-string (or width fill-column 70) ?-))) (replace-match replacmt) (when (equal justify "center") (center-line)))) ((eq arg 'latex) (setq width (or (match-string 3) "\\\\textwidth")) (let (flush) (setq flush (if (equal justify "center") "" "flush")) (replace-match (concat "\\\\begin{" flush justify "}\n\\\\rule{" width "}{5pt}\n\\\\end{" flush justify"}")))) ((eq arg 'html) (setq width (or (match-string 3) "100%")) (replace-match (concat "
"))) (t (replace-match "")))))) (defun bhl-convert-hr2 (arg) "Convert a raw of dashes into an horizontal rule. ARG is the output format." (goto-char (point-min)) (while (re-search-forward bhl-hr2-regexp nil t) (let (justify width) (cond ((equal (match-string 1) "<") (setq justify "left")) ((equal (match-string 1) ">") (setq justify "right")) (t (setq justify "center"))) (cond ((eq arg 'txt) (if (match-string 4) (setq width (string-to-number (match-string 4))) (setq width (or fill-column 70))) (let (replacmt) (if (equal justify "right") (setq replacmt (concat (make-string (- (or fill-column 70) width) 32) (make-string width ?-))) (setq replacmt (make-string (or width fill-column 70) ?-))) (replace-match replacmt) (when (equal justify "center") (center-line)))) ((eq arg 'latex) (setq width (or (match-string 3) "\\\\textwidth")) (let (flush) (setq flush (if (equal justify "center") "" "flush")) (replace-match (concat "\\\\begin{" flush justify "}\n\\\\rule{" width "}{10pt}\n\\\\end{" flush justify"}")))) ((eq arg 'html) (setq width (or (match-string 3) "100%")) (replace-match (concat "
"))) (t (replace-match "")))))) (defun bhl-convert-special (arg intro-tag end-tag mark-beg mark-end) "Convert a specific region into ARG format. INTRO-TAG is a list of TXT, HTML, SGML and LaTeX tags to insert at the beginning of the region. END-TAG is a list of TXT, HTML, SGML and LaTeX tags to insert at the end of the region. MARK-BEG is the delimiter of the beginning of the region. MARK-END is the delimiter of the end of the region." (save-excursion (goto-char (point-min)) (let ((prefix (cond ((eq arg 'txt) (nth 0 intro-tag)) ((eq arg 'html) (nth 1 intro-tag)) ((eq arg 'sgml) (nth 2 intro-tag)) ((eq arg 'latex) (nth 3 intro-tag)) ((eq arg 'texi) (nth 4 intro-tag)))) (suffix (cond ((eq arg 'txt) (nth 0 end-tag)) ((eq arg 'html) (nth 1 end-tag)) ((eq arg 'sgml) (nth 2 end-tag)) ((eq arg 'latex) (nth 3 end-tag)) ((eq arg 'texi) (nth 4 end-tag))))) (when (re-search-forward (concat "^\\(" mark-beg "\\)$") nil t) (replace-match prefix t t nil 1)) (when (re-search-forward (concat "^\\(" mark-end "\\)$") nil t) (replace-match suffix t t nil 1))))) ;; Insertion functions (defun bhl-insert-special (arg) "Insert a special environment, according to ARG. When ARG is a dash, insert a horizontal rule. When ARG is \"%\", insert a minipage." (let ((mk "") (align (completing-read "Align: " '(("left" 1) ("center" 2) ("right" 3)) nil t "center")) (width (read-from-minibuffer "Width: "))) (cond ((equal align "left") (setq mk "<")) ((equal align "center") (setq mk arg)) ((equal align "right") (setq mk ">"))) (insert (concat mk (make-string 3 (string-to-char arg)) (if (equal width "") "\n" (concat "[" width "]\n")))))) (defun bhl-insert-url () "Read an URL and its name from the minibuffer." (interactive) (let ((url (read-from-minibuffer "URL: " "")) (name (read-from-minibuffer "Name: "))) (if (equal name "") (insert url) (insert "[[" url "][" name "]]")) (message "URL \"%s\" named \"%s\" inserted." url name))) (defun bhl-insert-image (filename) "Read a FILENAME to insert as an image." (interactive "FInsert image: ") (if (file-directory-p filename) (signal 'file-error (list "Opening input file" "file is a directory" filename)) (insert "[[" (file-name-nondirectory filename) "]]") (message "Image \"%s\" inserted." (file-name-nondirectory filename)))) (defun bhl-insert-hr () "Insert a horizontal rule." (interactive) (bhl-insert-special "-") (message "Horizontal rule inserted.")) (defun bhl-insert-minipage () "Insert a minipage." (interactive) (bhl-insert-special "%") (save-excursion (insert "\n%%%%")) (message "Minipage inserted.")) (defun bhl-insert-verbatim () "Insert a verbatim environment." (interactive) (insert "--\n") (save-excursion (insert "--")) (message "Verbatim environment inserted.")) ;; Core of the conversion (defsubst bhl-replace-section (arg sec beg end &optional num ctr) "Replace section's labels with the right tags (HTML or LaTeX). Here are the arguments: ARG: the output format; SEC: a regexp which matches the section; BEG: a string to be inserted just before the title of the section; END: a string to be inserted just after the title of the section; NUM (optional): if nil, no prefix is used for sections' title. CTR (optional): if t, center line." (goto-char (point-min)) (while (re-search-forward (concat "\\(^" sec "\\)\\(.*$\\)") nil t) (let ((str (match-string 0)) (strnonum (match-string 2))) (replace-match (concat beg (if num (match-string 1) "") strnonum end) t t) (when ctr (center-line)) (cond ((eq arg 'html) (beginning-of-line) (insert "\n")) ((eq arg 'texi) (beginning-of-line) (insert "@node " strnonum "\n")))))) (defsubst bhl-replace-tag (word beg end) "Replace tags (HTML or LaTeX). WORD is the string to be replaced. BEG and END are the beginning end ending tags." (goto-char (point-min)) (while (re-search-forward word nil t) (unless (or (and (text-property-any (match-beginning 2) (match-end 2) 'category 'verbatim) (memq 'tag bhl-verbatim-ignore)) (text-property-any (match-beginning 2) (match-end 2) 'category 'link) (text-property-any (match-beginning 2) (match-end 2) 'category 'comment)) (replace-match (concat beg (match-string 2) end) t t nil 1)))) ;; A generic conversion function for punctuation and special characters. ;; By default, special chars are not converted in verbatim environments. (defun bhl-convert-char (arg lst) "Convert into the ARG format some strings from LST." (let ((cpt 0) case-fold-search) (while (nth cpt lst) (goto-char (point-min)) (while (re-search-forward (car (nth cpt lst)) nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (or (and (eq cat 'verbatim) (memq 'special-char bhl-verbatim-ignore)) (eq cat 'link) (eq cat 'comment))) (replace-match (cond ((eq arg 'texi) (cadddr (nth cpt lst))) ((eq arg 'latex) (caddr (nth cpt lst))) ((or (eq arg 'html) (eq arg 'sgml)) (if (and (eq arg 'sgml) (or (equal (match-string 0) "oe") (equal (match-string 0) "OE"))) (match-string 0) (cadr (nth cpt lst)))) (t (match-string 0))) t t nil (if (match-string 1) 1 0)))) (setq cpt (1+ cpt))))) (defun bhl-convert-tex (arg) "Convert \"LaTeX\", \"LaTeX2e\" and \"TeX\" strings into ARG format." (goto-char (point-min)) (while (re-search-forward "\\" nil t) (unless (get-text-property (1+ (match-beginning 0)) 'category) (cond ((eq arg 'texi) (replace-match "@TeX{}" t t)) ((eq arg 'latex) (replace-match "\\TeX{}" t t)) ((eq arg 'html) (replace-match "TEX" t t)) (t (match-string 0) t t)))) (goto-char (point-min)) (let ((case-fold-search t)) (while (re-search-forward "\\<\\(LaTeX\\)\\(2\\)?\\(e\\)?\\>" nil t) (unless (let ((cat (get-text-property (match-beginning 1) 'category))) (or (and (eq cat 'verbatim) (memq 'tex-label bhl-verbatim-ignore)) (eq cat 'link) (eq cat 'comment))) (replace-match (cond ((eq arg 'latex) (concat "\\LaTeX" (match-string 3) "{}")) ((eq arg 'texi) (concat "La@TeX{}" (if (match-string 3) (concat (match-string 2) (match-string 3))))) ((eq arg 'html) (concat "LATEX" (if (match-string 3) (concat (match-string 2) "&epsilon")))) (t (match-string 0))) t t))))) (defun bhl-convert-img (arg) "Convert inserted images into ARG format." (goto-char (point-min)) (while (re-search-forward bhl-img-regexp nil t) (unless (let ((cat (get-text-property (1- (match-beginning 0)) 'category))) (or (and (eq cat 'verbatim) (memq 'images bhl-verbatim-ignore)) (eq cat 'comment))) (replace-match (cond ((eq arg 'html) (concat "

\""")) ((eq arg 'texi) (concat "@c " (match-string 1))) ((eq arg 'latex) (concat "% " (match-string 1))) ((eq arg 'sgml) (concat "")) (t "")) t t)))) (defun bhl-convert-list (arg) "Convert lists into ARG format." (let ((regexp-list (if (eq arg 'texi) (reverse bhl-list-regexp-list) bhl-list-regexp-list))) (while (car regexp-list) (let ((regexp1 (caar regexp-list)) (regexp2 (cadar regexp-list))) (bhl-convert-list-intern arg regexp1 regexp2) (setq regexp-list (cdr regexp-list)))))) (defun bhl-convert-list-intern (arg regexp1 regexp2) "Convert list in ARG format using REGEXP1 and REGEXP2." (goto-char (point-min)) (while (re-search-forward regexp1 nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (or (and (eq cat 'verbatim) (memq 'list bhl-verbatim-ignore)) (eq cat 'comment))) (beginning-of-line) (let* ((tab (if (eq arg 'texi) "" (bhl-subst-char-in-string ?\t ? (substring (match-string 1) 1)))) (conversion (assq arg bhl-list-syntax-alist)) (syntax (if (string-match "[0-9]" (match-string 2)) (caddr conversion) (cadr conversion)))) (insert (concat tab (car syntax) "\n")) (while (re-search-forward regexp1 (save-excursion (forward-char 1) (re-search-forward regexp2 nil t) (match-beginning 0)) t) (let ((para (when (and (or (eq arg 'html) (eq arg 'sgml)) (get arg 'list-item-is-para)) "

"))) (replace-match (concat (unless (eq arg 'texi) " ") tab (cadr syntax) para)))) (forward-char 1) (re-search-forward regexp2 nil t) (beginning-of-line) (skip-chars-backward "\n\t ") (insert (concat "\n" tab (caddr syntax))))))) (defun bhl-convert-description (arg) "Convert description lists into ARG format." (goto-char (point-min)) (let ((syntax (cadddr (assq arg bhl-list-syntax-alist)))) (while (re-search-forward "^\\(\t+\\)\\([^\n-]+\\) -- " nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (or (and (eq cat 'verbatim) (memq 'description bhl-verbatim-ignore)) (eq cat 'comment))) (let ((tab (if (eq arg 'texi) "" (bhl-subst-char-in-string ?\t ? (substring (match-string 1) 1))))) (beginning-of-line) (insert (concat tab (car syntax) "\n")) (while (re-search-forward bhl-descrip-regexp (save-match-data (save-excursion (forward-char 1) (re-search-forward "^[\\'\"&*_=a-zA-Z0-9<]" nil t))) t) (replace-match (concat (if (eq arg 'texi) "" " ") tab (cadr syntax) (match-string 2) (caddr syntax) (when (and (or (eq arg 'html) (eq arg 'sgml)) (get arg 'list-item-is-para)) "

")) t t)) (forward-char 1) (re-search-forward "^[\t ]*$\\|\\'" nil t) (beginning-of-line) (skip-chars-backward "\n\t ") (insert (concat "\n" tab (cadddr syntax)))))))) (defun bhl-convert-url (&optional arg) "Convert an URL. An optional argument ARG specifies the output format." (goto-char (point-min)) (while (re-search-forward bhl-url-regexp nil t) (unless (or (and (memq 'url bhl-verbatim-ignore) (get-text-property (1- (match-beginning 0)) 'category) 'verbatim) (eq (get-text-property (1- (match-beginning 0)) 'category) 'comment)) (cond ((eq arg 'txt) (cond ((equal (match-string 3) "mailto:") (replace-match (match-string 4) nil t)) ((equal (match-string 3) "url:") (replace-match (match-string 4) nil t)) ((equal (match-string 6) "mailto:") (replace-match (concat (match-string 7) " (" (match-string 8) ")") nil t)) ((match-string 8) (replace-match (concat (match-string 5) " (" (match-string 8) ")") nil t)) (t (replace-match (match-string 1) nil t)))) ((eq arg 'html) (cond ((equal (match-string 3) "mailto:") (replace-match (concat "" (match-string 4) "") nil t)) ((equal (match-string 3) "url:") (replace-match (concat "" (match-string 4) "") nil t)) ((replace-match (concat "" (or (match-string 8) (match-string 1))"") nil t)))) ((eq arg 'texi) (cond ((equal "url:" (match-string 3)) (replace-match (concat "@uref{" (match-string 4) "}"))) ((replace-match (concat "@uref{" (or (match-string 5) (match-string 1)) (if (match-string 8) (concat "," (match-string 8) "}") "}")))))) ((eq arg 'sgml) (cond ((equal "url:" (match-string 3)) (replace-match (concat ""))) ((replace-match (concat ""))))) ((eq arg 'latex) (cond ((equal (match-string 3) "url:") (replace-match (concat "\\url{" (match-string 4) "}") nil t)) ((equal (match-string 3) "mailto:") (replace-match (concat "\\url{" (match-string 4) "}") nil t)) ((equal (match-string 6) "mailto:") (replace-match (concat (match-string 8) " (\\url{" (match-string 7) "})") nil t)) ((match-string 8) (replace-match (concat (match-string 8) " (\\url{" (match-string 5) "})") nil t)) (t (replace-match (concat "\\url{" (match-string 1) "}") nil t)))))))) ;; Map tables (defsubst bhl-map-table () "Map and delete tables." (let ((beg (point)) (limit (save-excursion (re-search-forward "^[^|]" nil t))) table) (while (re-search-forward "^|.*$" limit t) (setq table (append table (list (split-string (bhl-match-string 0) "|"))))) (kill-region beg (point)) table)) (defun bhl-table-beg (arg &optional table caption) "Create in ARG format the TABLE beginning tag with CAPTION." (cond ((eq arg 'html) (concat "

\n")) ((eq arg 'latex) (concat "\\begin{table}[" bhl-table-location "]\n" (cond ((equal bhl-table-align "left") "\\flushleft\n") ((equal bhl-table-align "center") "\\centering\n") ((equal bhl-table-align "right") "\\flushright\n")) "\\begin{tabular}{" (make-string (length (car table)) (string-to-char bhl-table-cell-align)) "}\n")) ((eq arg 'sgml) (concat "

\n" "\n")))) (defsubst bhl-convert-table (arg) "Convert tables into ARG format." (cond ((eq arg 'html) (bhl-html-convert-table)) ((eq arg 'texi) (bhl-texi-convert-table)) ((eq arg 'txt) (bhl-txt-convert-table)) (t (bhl-xxx-convert-table arg)))) (defun bhl-texi-convert-table () "Convert tables into TEXI format." (bhl-txt-convert-table) (goto-char (point-min)) (while (re-search-forward "^|" nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'table bhl-verbatim-ignore))) (goto-char (match-beginning 0)) (insert "@" bhl-texi-table-tag "\n") (re-search-forward "^[ \t]*$" nil t) (insert "@end " bhl-texi-table-tag "\n")))) (defun bhl-txt-convert-table () "Convert tables into TXT format." (goto-char (point-min)) (save-excursion (while (re-search-forward "|[ \t]*@" nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'table bhl-verbatim-ignore))) (replace-match (bhl-subst-char-in-string ?@ ? (bhl-match-string 0)) t t)))) (save-excursion (while (re-search-forward "@[ \t]*|" nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'table bhl-verbatim-ignore))) (replace-match (bhl-subst-char-in-string ?@ ? (bhl-match-string 0)) t t))))) (defun bhl-html-convert-table () "Convert tables into HTML format." (goto-char (point-min)) (let* ((cell-align (cond ((equal bhl-table-cell-align "l") "left") ((equal bhl-table-cell-align "c") "center") ((equal bhl-table-cell-align "r") "right"))) (tdbeg (concat "\n")) (while (car tbl) (insert " \n") (mapcar (lambda (str) (insert (concat " " (if (string-match "[ \t]*\\(@.*\\)@.*" str) (progn (aset str (match-beginning 1) ? ) (aset str (match-end 1) ? ) (concat thbeg (bhl-cleanup-cell str) "\n")) (concat tdbeg (bhl-cleanup-cell str) "\n"))))) (car tbl)) (insert " \n") (setq tbl (cdr tbl)))) (insert "
")) (thbeg (concat ""))) (while (re-search-forward "^|" nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'table bhl-verbatim-ignore))) (beginning-of-line) (let* ((caption (when (get 'html 'bhl-caption) (read-from-minibuffer "Caption: "))) (tbl (bhl-map-table)) (tablebeg (bhl-table-beg 'html tbl caption))) (insert tablebeg) (when caption (insert "
" caption "
\n"))))) (defun bhl-xxx-convert-table (arg) "Convert tables into ARG format." (goto-char (point-min)) (let ((sep (if (eq arg 'latex) "&" "|")) (endline (if (eq arg 'latex) "\\\\" "@"))) (while (re-search-forward "^|" nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'table bhl-verbatim-ignore))) (beginning-of-line) (let* ((caption (if (get arg 'bhl-caption) (read-from-minibuffer "Caption: ") "No summary" )) (tbl (bhl-map-table))) (insert (bhl-table-beg arg tbl)) (mapcar (lambda (str) (let (header) (insert (mapconcat (lambda (strg) (if (string-match "[ \t]*\\(@.*\\)@.*" strg) (progn (aset strg (match-beginning 1) ? ) (aset strg (match-end 1) ? ) (setq header (cond ((eq arg 'latex) " \\hline\n") ((eq arg 'sgml) "\n")))) (setq header "\n")) (bhl-cleanup-cell strg)) str sep) endline header))) tbl) (setq tbl (cdr tbl)) (insert (cond ((eq arg 'latex) (concat "\\end{tabular}\n" (when caption (concat "\\caption{" caption "}\n")) "\\end{table}\n")) (t (concat "\n" (when caption (concat "" caption "\n")) "\n"))))))))) (defun bhl-html-insert-preamble (maintitle title subtitle author style lang encoding) "Insert the preambule of the HTML output. MAINTITLE TITLE SUBTITLE AUTHOR STYLE LANG and ENCODING are passed to this function." (insert bhl-html-doctype "\n\n\n") (if encoding (insert "\n") (insert bhl-html-content-type "\n")) (insert "\n") (let ((cpt 0)) (while (< cpt (safe-length bhl-html-meta-alist)) (insert "\n") (setq cpt (1+ cpt)))) (let ((cpt 0)) (while (< cpt (safe-length bhl-html-link-alist)) (insert "\n") (setq cpt (1+ cpt)))) (if style (insert "\n") (when (not (equal bhl-html-default-style "")) (insert bhl-html-default-style "\n"))) (insert "" title "\n\n\n\n") (search-forward maintitle nil t) (replace-match (concat (car bhl-html-title-tags) title (cadr bhl-html-title-tags) "\n") t t) (when subtitle (insert (car bhl-html-subtitle-tags) subtitle (cadr bhl-html-subtitle-tags)))) (defun bhl-protect-chars (chars) "Escape some CHARS in the LaTeX output." (goto-char (point-min)) (let ((repl (if (eq chars bhl-latex-escaped-chars) "\\" "@"))) (while (car chars) (save-excursion (while (re-search-forward (concat "\\(.\\|^\\)\\(" (regexp-quote (car chars)) "\\)") nil t) (unless (let ((cat (get-text-property (match-beginning 1) 'category))) (or (eq cat 'verbatim) (eq cat 'comment) (save-excursion (beginning-of-line) (string-match bhl-minipage-regexp (match-string 0))))) (replace-match (if (equal (match-string 1) "\\") (match-string 2) (concat (match-string 1) repl (match-string 2))) t t)))) (setq chars (cdr chars))))) (defun bhl-latex-insert-preamble (maintitle title author date class options package) "Insert the preambule of the HTML output. MAINTITLE TITLE AUTHOR DATE CLASS OPTIONS and PACKAGE are passed to this options." (let ((local-class (or class bhl-latex-default-class)) (local-options (or options bhl-latex-default-class-options))) (search-forward maintitle nil t) (replace-match "") (insert "\\documentclass[" (mapconcat (lambda (option) option) local-options ",") "]{" local-class "}\n") (let ((cpt 0)) (while (< cpt (safe-length bhl-latex-packages-alist)) (insert "\\usepackage") (unless (equal "" (cdr (nth cpt bhl-latex-packages-alist))) (insert "[" (cdr (nth cpt bhl-latex-packages-alist)) "]")) (insert "{" (car (nth cpt bhl-latex-packages-alist)) "}\n") (setq cpt (1+ cpt)))) (or (not package) (insert package)) (dolist (line bhl-latex-extra-preambles) (insert line "\n")) (insert "\n\\begin{document}\n") (insert "\n\\title{" title "}") (insert "\n\\author{" author "}") (when date (insert "\n\\date{" date "}")) (insert "\n\\maketitle\n"))) (defun bhl-sgml-insert-preamble (maintitle title author) "Insert the preambule of the SGML output. MAINTITLE TITLE and AUTHOR are passed to this function." (search-forward maintitle nil t) (replace-match "") (insert "\n
\n") (insert "" title "\n") (insert "" author "\n\n") (insert "") (save-excursion (re-search-forward (concat "^" (nth 0 bhl-sectioning-regexp-list)) nil t) (forward-line -1) (insert "\n\n"))) (defun bhl-texi-insert-preamble (maintitle title subtitle author date lang encoding) "Insert the preambule of the TEXI output. MAINTITLE TITLE SUBTITLE AUTHOR DATE LANG and ENCODING are passed to this function." (search-forward maintitle nil t) (replace-match "") (insert "\\input texinfo @c -*-texinfo-*-\n") (insert "\n@c %**start of header\n") (insert "@setfilename " (concat (file-name-sans-extension (file-name-nondirectory buffer-file-name)) ".info" "\n")) (insert "@setchapternewpage " bhl-texi-setchapternewpage-flag "\n") (insert "@settitle " title "\n") (insert "@set AUTHOR " author "\n") (when date (insert "@set UPDATED " date "\n")) (insert "@documentlanguage " (or lang (car bhl-i18n-conventions)) "\n") (when encoding (insert "@documentencoding " encoding "\n")) (insert "@c %**end of header\n\n") (insert "@titlepage\n") (let ((titlepage-style (if (not (equal bhl-local-texi-titlepage-style "")) bhl-local-texi-titlepage-style bhl-texi-titlepage-style))) (if (eq titlepage-style 'classical) (progn (insert "@title " title "\n") (when subtitle (insert "@subtitle " subtitle "\n")) (insert "@author Copyright @copyright{} " (format-time-string "%Y") " @value{AUTHOR}") (insert (if date " - @value{UPDATED}\n" "\n"))) (progn (insert "@center @titlefont{" title "}\n@sp 10\n") (when subtitle (insert "@center " subtitle "\n@sp 1\n")) (insert "@center @value{AUTHOR}\n@sp 1") (insert (if date "\n@center @value{UPDATED}\n" "\n")) (insert "@page\n@vskip 0pt plus 1filll\n") (insert "Copyright @copyright{} " (format-time-string "%Y") " @value{AUTHOR}\n")))) (insert "@end titlepage\n\n") (insert "@ifnottex\n@node top\n") (insert "@top " title "\n@end ifnottex\n\n")) (defun bhl-parse-title (arg) "Find the title of the document for the ARG format." (if (save-excursion (re-search-forward (concat "^#!" (symbol-name arg) "-title!\\(.*\\)") nil t)) (bhl-match-string 1) (if (save-excursion (re-search-forward "^#!title!\\(.*\\)" nil t)) (bhl-match-string 1) (save-excursion (re-search-forward bhl-title-regexp nil t)) (bhl-match-string 1)))) (defun bhl-insert-preamble (arg) "Insert the header of `bhl2html', `bhl2latex' and `bhl2sgml'. ARG defines the output format." (goto-char (point-min)) (let (bhl-local-author bhl-local-date bhl-local-subtitle bhl-local-lang bhl-local-encoding bhl-local-html-style bhl-local-latex-class bhl-local-latex-class-options (bhl-local-latex-package (bhl-parse-latex-package)) (bhl-main-title (save-excursion (re-search-forward bhl-title-regexp nil t) (bhl-match-string 1))) (bhl-local-title (bhl-parse-title arg))) (bhl-parse-header) (unless bhl-local-author (setq bhl-local-author user-full-name)) (bhl-parse-specifications arg) (cond ((eq arg 'html) (bhl-html-insert-preamble bhl-main-title bhl-local-title bhl-local-subtitle bhl-local-author bhl-local-html-style bhl-local-lang bhl-local-encoding)) ((eq arg 'latex) (bhl-latex-insert-preamble bhl-main-title bhl-local-title bhl-local-author bhl-local-date bhl-local-latex-class bhl-local-latex-class-options bhl-local-latex-package)) ((eq arg 'sgml) (bhl-sgml-insert-preamble bhl-main-title bhl-local-title bhl-local-author)) ((eq arg 'texi) (bhl-texi-insert-preamble bhl-main-title bhl-local-title bhl-local-subtitle bhl-local-author bhl-local-date bhl-local-lang bhl-local-encoding)) (t (insert "%% ") (end-of-line) (insert " %%") (when (get arg 'bhl-center) (center-line)) (when bhl-local-subtitle (insert "\n\n" (concat "% " bhl-local-subtitle " %")) (when (get arg 'bhl-center) (center-line))))))) ;;;; 7 - TABLE OF CONTENTS ;; Make the table of content (defun bhl-make-toc () "Create the table of contents. Create the list of section in `bhl-tsl' and the list of corresponding points in `bhl-tpl'." (setq bhl-tsl nil) (setq bhl-tpl nil) (save-excursion (let ((position (point))) (goto-char (point-min)) (while (re-search-forward (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$") nil t) (setq bhl-tsl (append bhl-tsl (list (bhl-match-string 0)))) (setq bhl-tpl (append bhl-tpl (list (match-end 0)))) (let ((limit (save-excursion (re-search-forward (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$\\|\\'") nil t))) ssection ppection) (while (re-search-forward (concat "^" (nth 1 bhl-sectioning-regexp-list) ".*$") limit t) (setq ssection (append ssection (list (bhl-match-string 0)))) (setq ppection (append ppection (list (match-end 0)))) (let ((limit2 (save-excursion (re-search-forward (concat "^" (nth 1 bhl-sectioning-regexp-list) ".*$\\|^" (nth 0 bhl-sectioning-regexp-list) ".*$\\|\\'") nil t))) sssection pppection) (while (re-search-forward (concat "^" (nth 2 bhl-sectioning-regexp-list) ".*$") limit2 t) (setq sssection (append sssection (list (bhl-match-string 0)))) (setq pppection (append pppection (list (match-end 0))))) (unless (not sssection) (setq ssection (append ssection (list sssection))) (setq ppection (append ppection (list pppection)))))) (unless (not ssection) (setq bhl-tsl (append bhl-tsl (list ssection))) (setq bhl-tpl (append bhl-tpl (list ppection)))))))) (null bhl-tsl)) ;; Convert the sections' prefix according to the target style (defsubst bhl-cvt-sec (arg convert) "Convert ARG according to the CONVERT style." (let ((style (or convert bhl-sectioning-default-style))) (cond ((eq style 'num) (concat (number-to-string arg) ".")) ((eq style 'alpha) (concat (char-to-string (+ 64 arg)) ".")) ((eq style 'aster) "*") ((eq style 'equal-sign) "=")))) ;; Update the table of content (defun bhl-update-toc (&optional convert) "Update and maybe CONVERT the table of contents." (interactive) (unless (eq bhl-sectioning-default-style 'my) (save-excursion (let ((scpt 0) (repl "")) (goto-char (point-min)) (while (re-search-forward (concat "^" (nth 0 bhl-sectioning-regexp-list) "\\(.*\\)$") nil t) (setq scpt (1+ scpt)) (setq repl (bhl-cvt-sec scpt convert)) (replace-match (concat repl " " (match-string 1)) t t) (let ((sscpt 0) (rrepl "") (limit (save-excursion (save-match-data (re-search-forward (concat "^" (nth 0 bhl-sectioning-regexp-list) ".*$\\|\\'") nil t))))) (while (re-search-forward (concat "^" (nth 1 bhl-sectioning-regexp-list) "\\(.*\\)$") limit t) (setq sscpt (1+ sscpt)) (setq rrepl (bhl-cvt-sec sscpt convert)) (replace-match (concat repl rrepl " " (match-string 1)) t t) (let ((ssscpt 0) (rrrepl "") (limit2 (save-excursion (save-match-data (re-search-forward (concat "^" (nth 1 bhl-sectioning-regexp-list) ".*$\\|^" (nth 0 bhl-sectioning-regexp-list) ".*$\\|\\'") nil t))))) (while (re-search-forward (concat "^" (nth 2 bhl-sectioning-regexp-list) "\\(.*\\)$") limit2 t) (setq ssscpt (1+ ssscpt)) (setq rrrepl (bhl-cvt-sec ssscpt convert)) (replace-match (concat repl rrepl rrrepl " " (match-string 1)) t t)))))))) (message "Table of contents updated."))) ;; View log in a new buffer (defun bhl-view-log () "Display the log messages of the last ARG conversion." (interactive) (with-output-to-temp-buffer "*Log*" (princ "BHL conversion log:\n") (princ "===================\n\n") (let ((cpt 0)) (when (equal bhl-conversion-log nil) (princ "* Last conversion correctly achieved.")) (while (nth cpt bhl-conversion-log) (princ (concat "* " (nth cpt bhl-conversion-log) "\n")) (setq cpt (1+ cpt)))))) (defun bhl-parse-point-toc (toc depth) "Parse TOC with DEPTH into a list of points." (mapcar (lambda (elem) (if (listp elem) (unless (< (1- depth) 1) (bhl-parse-point-toc elem (1- depth))) (setq bhl-toc-point-list (append bhl-toc-point-list (list elem))))) toc)) (defun bhl-generate-toc (depth &optional html) "Insert a toc of DEPTH, possibly in HTML format." (when html (insert "
    \n")) (setq bhl-toc-point-list nil) (bhl-parse-point-toc bhl-tpl depth) (bhl-parse-toc bhl-tsl depth 0 html) (when html (insert "
\n"))) (defun bhl-parse-toc (toc depth indent html) "Parse TOC with DEPTH and INDENT, possibly in HTML format." (mapcar (lambda (elem) (if (listp elem) (unless (< (1- depth) 1) (when html (insert (concat (make-string (* 2 indent) 32) "
    \n"))) (bhl-parse-toc elem (1- depth) (1+ indent) html) (when html (insert (concat (make-string (* 2 indent) 32) "
\n")))) (insert (if html (concat (make-string (* 2 indent) 32) "
  • " elem "
  • \n") (concat (make-string (1+ (* 2 indent)) 32) elem "\n"))))) toc)) (define-key bhl-toc-mode-map [(mouse-2)] 'bhl-toc-mouse-visit) (define-key bhl-toc-mode-map [?\r] 'bhl-quit-temp-buffer) (define-key bhl-toc-mode-map [(left)] 'bhl-visit-location-previous) (define-key bhl-toc-mode-map [(right)] 'bhl-visit-location-next) (define-key bhl-toc-mode-map [(up)] 'bhl-visit-location-previous) (define-key bhl-toc-mode-map [(down)] 'bhl-visit-location-next) (define-key bhl-toc-mode-map "q" 'bhl-quit-temp-buffer) (define-key bhl-toc-mode-map "f" 'bhl-quit-temp-buffer) (define-key bhl-toc-mode-map "v" 'bhl-quit-temp-buffer) (define-key bhl-toc-mode-map "n" 'bhl-visit-location-next) (define-key bhl-toc-mode-map "p" 'bhl-visit-location-previous) (define-key bhl-toc-mode-map "<" 'bhl-visit-location-top) (define-key bhl-toc-mode-map ">" 'bhl-visit-location-bottom) (define-key bhl-toc-mode-map "?" 'bhl-toc-show-help) (define-key bhl-toc-mode-map "1" 'bhl-show-toc-1) (define-key bhl-toc-mode-map "2" 'bhl-show-toc-2) (define-key bhl-toc-mode-map "3" 'bhl-show-toc-3) (define-key bhl-toc-mode-map "i" 'bhl-toc-insert-toc) ;; BHL TOC menu (easy-menu-define bhl-toc-menu bhl-toc-mode-map "Menu of the BHL minor mode" '("Toc" ["Next item" bhl-visit-location-next t] ["Previous item" bhl-visit-location-previous t] ["Top" bhl-visit-location-top t] ["Bottom" bhl-visit-location-bottom t] ["Follow" bhl-quit-temp-buffer t] "---" ("Toc depth" ["Sections" bhl-show-toc-1 t] ["Subsections" bhl-show-toc-2 t] ["Subsubsections" bhl-show-toc-3 t]) "---" ["Quick help" bhl-toc-show-help t])) ;; BHL TOC mode (defun bhl-toc-mode () "A major mode for browsing the table of content of a BHL document. \\{bhl-toc-mode-map}" (kill-all-local-variables) (use-local-map bhl-toc-mode-map) (easy-menu-add bhl-toc-menu) (setq mode-name "BHL toc") (setq major-mode 'bhl-toc-mode)) (defun bhl-show-toc (&optional depth) "Create a new buffer *toc* with a browsable table of contents. The optional argument DEPTH specifies the toc depth." (interactive "P") (bhl-update-toc) (if (not (bhl-make-toc)) (progn (switch-to-buffer-other-window (get-buffer-create "*toc*")) (bhl-toc-mode) (setq buffer-read-only nil) (kill-region (point-min) (point-max)) (insert bhl-intro-toc " (? for quick help)\n\n") (bhl-generate-toc (or depth bhl-default-toc-depth)) (bhl-highlight-toc-buffer) (setq buffer-read-only t) (setq bhl-toc-temporary-depth (or depth bhl-default-toc-depth)) (bhl-shrink-window-to-fit) (goto-line 3)) (message "There is no (sub)section in this buffer."))) (defun bhl-toc-mouse-visit (event) "Visit the item that is clicked on with EVENT." (interactive "e") (mouse-set-point event) (bhl-visit-location (event-end event))) (defun bhl-visit-location (arg) "Visit the toc/lol item of the current line. ARG is the toc location." (cond ((eq arg 'top) (goto-line 3)) ((eq arg 'bottom) (goto-char (point-max)) (forward-line -1)) ((numberp arg) (forward-line arg))) (beginning-of-line) (let* ((frombuffer (buffer-name)) (nombre (if (equal frombuffer "*toc*") (nth (- (string-to-number (substring (what-line) 5)) 3) bhl-toc-point-list) (progn (beginning-of-line) (re-search-forward "\\([0-9]+\\) : " nil t) (string-to-int (bhl-match-string 1)))))) (when (numberp nombre) (other-window 1) (goto-char nombre) (recenter 0) (switch-to-buffer-other-window frombuffer)))) (defun bhl-skip-toc (&optional arg) "Convert the toc according to the ARG output format. With no ARG, erase the toc in the source file." (interactive) (save-match-data (save-excursion (goto-char (point-min)) (let ((beg (if (search-forward bhl-intro-toc nil t) (match-beginning 0))) (end (if (search-forward bhl-end-toc nil t) (progn (forward-line 1) (point))))) (if (not (eq beg end)) (progn (kill-region beg end) (cond ((and (eq arg 'texi) (get arg 'bhl-toc)) (insert "@contents\n")) ((and (eq arg 'txt) (get arg 'bhl-toc)) (bhl-generate-toc bhl-default-toc-depth)) ((and (eq arg 'html) (get arg 'bhl-toc)) (bhl-generate-toc bhl-default-toc-depth t)) ((and (eq arg 'latex) (get arg 'bhl-prefix) (get arg 'bhl-toc)) (insert "\\setcounter{tocdepth}{" (number-to-string bhl-default-toc-depth) "}\n" "\\tableofcontents\n"))))))))) (defsubst bhl-insert-lol () "Insert the list of links at point." (interactive) (if (setq bhl-local-lol-list (bhl-map-lol)) (let ((lol bhl-local-lol-list)) (while (car lol) (insert (cdar lol) "\n") (setq lol (cdr lol)))) (message "There is no link in this buffer."))) (defun bhl-insert-toc (&optional depth) "Insert the table of contents in the source file. Optional argument DEPTH is the toc depth. Toc place is defined in `bhl-toc-location'." (interactive "P") (if (not (bhl-make-toc)) (progn (bhl-update-toc) (cond ((equal bhl-toc-location "top") (save-excursion (goto-char (point-min)) (re-search-forward bhl-title-regexp nil t) (forward-line 1) (bhl-skip-toc) (forward-line 1) (insert bhl-intro-toc "\n\n") (bhl-generate-toc (or depth bhl-default-toc-depth)) (insert "\n" bhl-end-toc "\n"))) ((equal bhl-toc-location "bottom") (save-excursion (bhl-skip-toc) (goto-char (point-max)) (insert bhl-intro-toc "\n\n") (bhl-generate-toc (or depth bhl-default-toc-depth)) (insert "\n" bhl-end-toc))) ((equal bhl-toc-location "point") (save-excursion (bhl-skip-toc) (insert bhl-intro-toc "\n\n") (bhl-generate-toc (or depth bhl-default-toc-depth)) (insert "\n" bhl-end-toc)))) (message (concat "Table of content inserted at the " bhl-toc-location "."))) (message "There is no (sub)section in this buffer."))) (defun bhl-toc-insert-toc () "Insert the toc from the *toc* buffer." (interactive) (bhl-quit-temp-buffer) (bhl-insert-toc bhl-toc-temporary-depth)) (defun bhl-show-toc-1 () "Display the toc in the *toc* buffer, DEPTH set to one." (interactive) (bhl-quit-temp-buffer) (bhl-show-toc 1)) (defun bhl-show-toc-2 () "Display the toc in the *toc* buffer, DEPTH set to two." (interactive) (bhl-quit-temp-buffer) (bhl-show-toc 2)) (defun bhl-show-toc-3 () "Display the toc in the *toc* buffer, DEPTH set to three." (interactive) (bhl-quit-temp-buffer) (bhl-show-toc 3)) (defun bhl-toc-show-help () "Display a quick help for the browsable toc." (interactive) (message "[n] - next | [p] - previous | [<] - begin | [>] - end | [123] - depth | [i] insert toc")) (defun bhl-visit-location-next () "Visit the next item of the toc/lol buffer." (interactive) (bhl-visit-location 1)) (defun bhl-visit-location-previous () "Visit the previous item of the toc/lol buffer." (interactive) (bhl-visit-location -1)) (defun bhl-visit-location-top () "Visit the first item of the toc/lol buffer." (interactive) (bhl-visit-location 'top)) (defun bhl-visit-location-bottom () "Visit the last item of the toc/lol buffer." (interactive) (bhl-visit-location 'bottom)) (defun bhl-quit-temp-buffer () "Quit the current (top/lol) buffer." (interactive) (kill-this-buffer) (other-window 1) (delete-other-windows)) (define-key bhl-lol-mode-map [(left)] 'bhl-visit-location-previous) (define-key bhl-lol-mode-map [(right)] 'bhl-visit-location-next) (define-key bhl-lol-mode-map [(up)] 'bhl-visit-location-previous) (define-key bhl-lol-mode-map [(down)] 'bhl-visit-location-next) (define-key bhl-lol-mode-map "q" 'bhl-quit-temp-buffer) (define-key bhl-lol-mode-map "f" 'bhl-quit-temp-buffer) (define-key bhl-lol-mode-map "v" 'bhl-quit-temp-buffer) (define-key bhl-lol-mode-map "n" 'bhl-visit-location-next) (define-key bhl-lol-mode-map "p" 'bhl-visit-location-previous) (define-key bhl-lol-mode-map "<" 'bhl-visit-location-top) (define-key bhl-lol-mode-map ">" 'bhl-visit-location-bottom) (define-key bhl-lol-mode-map "?" 'bhl-lol-show-help) (define-key bhl-lol-mode-map "i" 'bhl-lol-insert-lol) (defsubst bhl-lol-insert-lol () "Insert the list of links from the *lol* buffer." (interactive) (bhl-quit-temp-buffer) (bhl-insert-lol)) (defsubst bhl-lol-show-help () "Show help in the bhl *lol* buffer." (interactive) (message "[n] - next | [p] - previous | [<] - begin | [>] - end | [i] insert lol | [q] quit")) ;; Lol menu (easy-menu-define bhl-lol-menu bhl-lol-mode-map "Menu of the BHL minor mode" '("Lol" ["Next item" bhl-visit-location-next t] ["Previous item" bhl-visit-location-previous t] ["Top" bhl-visit-location-top t] ["Bottom" bhl-visit-location-bottom t] ["Follow" bhl-quit-temp-buffer t] "---" ["Quick help" bhl-lol-show-help t])) ;; Lol mode - browse the links of your document (defun bhl-lol-mode () "A major mode for browsing the list of links (lol) of a BHL document. \\{bhl-lol-mode-map}" (kill-all-local-variables) (use-local-map bhl-lol-mode-map) (easy-menu-add bhl-lol-menu) (setq mode-name "BHL lol") (setq major-mode 'bhl-lol-mode)) (defun bhl-show-lol () "Show the lol of the current BHL file." (interactive) (if (setq bhl-local-lol-list (bhl-map-lol)) (progn (switch-to-buffer-other-window (get-buffer-create "*lol*")) (bhl-lol-mode) (setq buffer-read-only nil) (kill-region (point-min) (point-max)) (insert "--- List of links (? for quick help)\n\n") (save-excursion (add-text-properties (goto-char (point-min)) (re-search-forward "ks " nil t) '(face bold))) (let* ((lol bhl-local-lol-list) (size-max (length (int-to-string (caar (reverse lol)))))) (while (car lol) (insert (make-string (- size-max (length (int-to-string (caar lol)))) ? ) (int-to-string (caar lol)) " : " (cdar lol) "\n") (setq lol (cdr lol)))) (bhl-highlight-url-lol-buffer) (bhl-highlight-wiki-lol-buffer) (setq buffer-read-only t) (bhl-shrink-window-to-fit) (goto-line 3)) (message "There is no link in this buffer."))) (defun bhl-highlight-url-lol-buffer () "Highlight URLs in the *Lol* buffer." (goto-char (point-min)) (let ((map (copy-keymap (current-local-map)))) (define-key map [(mouse-2)] 'bhl-follow-url-at-mouse) (define-key map [(return)] 'bhl-follow-url-at-point) (while (re-search-forward (concat "^[ ]*\\([0-9]+\\) : \\(" bhl-generic-url-regexp "\\)$") nil t) (add-text-properties (match-beginning 1) (match-end 1) '(face bhl-url-face)) (add-text-properties (match-beginning 2) (match-end 2) `(category link local-map ,map mouse-face highlight help-echo "mouse-2: follow URL"))))) (defun bhl-highlight-wiki-lol-buffer () "Highlight WikiNames in the *Lol* buffer." (goto-char (point-min)) (let ((map (copy-keymap (current-local-map)))) (define-key map [(mouse-2)] 'bhl-follow-wiki-name-at-mouse) (define-key map [(return)] 'bhl-follow-wiki-name-at-point) (while (re-search-forward (concat "^[ ]*\\([0-9]+\\) : \\(" bhl-wiki-names-regexp "\\)$") nil t) (add-text-properties (match-beginning 1) (match-end 1) '(face bhl-wiki-face)) (add-text-properties (match-beginning 2) (match-end 2) `(category link local-map ,map mouse-face highlight help-echo "mouse-2: follow WikiName"))))) (defun bhl-map-lol () "Map lol and return a list of links." (let (lol-list case-fold-search) (save-excursion (goto-char (point-min)) (while (re-search-forward (concat bhl-generic-url-regexp "\\|" bhl-wiki-names-regexp) nil t) (add-to-list 'lol-list (cons (match-beginning 0) (bhl-match-string 0))))) (reverse lol-list))) ;;;; 8 - Submit bug report (defun bhl-submit-bug-report () "Submit a bug report on BHL Mode." (interactive) (and (y-or-n-p "Do you want to submit a report on BHL Mode? ") (require 'reporter "reporter" t) (reporter-submit-bug-report bhl-help-address (concat "BHL Mode " bhl-version) (list ;; report all important variables 'bhl-mode-hook 'bhl-sectioning-default-style 'bhl-verbatim-ignore 'bhl-my-sectioning-regexp-list 'bhl2html-properties-list 'bhl2latex-properties-list 'bhl2sgml-properties-list 'bhl2txt-properties-list 'bhl-html-conversions-list 'bhl-latex-conversions-list 'bhl-sgml-conversions-list 'bhl-txt-conversions-list 'bhl-i18n-conventions 'bhl-tab-width 'bhl-default-toc-depth 'bhl-toc-location 'bhl-table-location 'bhl-table-align 'bhl-table-cell-align 'bhl-html-table-param-alist 'bhl-html-para-align 'bhl-html-img-align 'bhl-html-meta-alist 'bhl-latex-packages-alist 'bhl-latex-default-class 'bhl-latex-default-class-options) nil nil "Hi Bastien,\n\n"))) ;;;; 9 - BHL2XXX (defun bhl2html () "Convert the BHL source file into a HTML file." (interactive) (bhl2xxx 'html)) (defun bhl2latex () "Convert the BHL source file into a LaTeX file." (interactive) (bhl2xxx 'latex)) (defun bhl2sgml () "Convert the BHL source file into a SGML (Linuxdoc) file." (interactive) (bhl2xxx 'sgml)) (defun bhl2txt () "Convert the BHL source file into a TXT file. Strip font tags and URL/IMG square brackets." (interactive) (bhl2xxx 'txt)) (defun bhl2texinfo () "Convert the BHL source file into a TEXINFO file." (interactive) (bhl2xxx 'texi)) ;; Perform initializations (defun bhl-convert-init (arg) "Initial conversion into ARG format." (save-buffer) (setq bhl-conversion-log nil) (setq bhl-xxx-conversions-list (get arg 'conversions-list)) (let ((bhl-source-file buffer-file-name) (bhl-workfile-name (concat (file-name-sans-extension buffer-file-name) (cond ((eq arg 'latex) ".tex") (t (concat "." (symbol-name arg))))))) (find-file-other-window bhl-workfile-name) (kill-region (point-min) (point-max)) (setq tab-width 3) (insert-file-contents bhl-source-file))) ;; Add properties into the working buffer. (defun bhl-add-text-properties (arg) "Add some text properties to the conversion buffer. ARG is the output format." (goto-char (point-min)) (save-excursion (while (re-search-forward "^--$" nil t) (add-text-properties (match-end 0) (progn (re-search-forward "^--$" nil t) (match-beginning 0)) '(category verbatim)))) (save-excursion (let (case-fold-search) (while (re-search-forward (concat bhl-img-regexp "\\|" bhl-generic-url-regexp "\\|" bhl-wiki-names-regexp) nil t) (add-text-properties (match-beginning 0) (match-end 0) '(category link))))) (save-excursion (while (re-search-forward "[^\\]\\(#.*\\)$" nil t) (add-text-properties (match-beginning 1) (match-end 1) '(category comment)))) (when (eq arg 'latex) (save-excursion (while (re-search-forward bhl-minipage-regexp nil t) (add-text-properties (match-beginning 0) (match-end 0) '(category comment))))) (when (eq arg 'texi) (save-excursion (while (re-search-forward "^|" nil t) (unless (eq (get-text-property (match-beginning 0) 'category) 'verbatim) (add-text-properties (match-beginning 0) (re-search-forward "^[ \t]*$" nil t) '(category table))))))) (defun bhl-convert-misc-1 (arg) "Miscellaneous conversions into ARG format. This conversions are: special char, verbatim, horizontal rules and LaTeX/TeX labels." (when (get arg 'bhl-i18n) (when (nth 1 bhl-i18n-conventions) (bhl-convert-char arg (eval (intern (concat "bhl-" (car bhl-i18n-conventions) "-punctuation"))))) (when (nth 2 bhl-i18n-conventions) (bhl-convert-char arg (eval (intern (concat "bhl-" (car bhl-i18n-conventions) "-quotation-marks"))))) (when (nth 3 bhl-i18n-conventions) (bhl-convert-char arg (eval (intern (concat "bhl-" (car bhl-i18n-conventions) "-special-chars"))))) (bhl-add-to-conversion-log (concat "I18n conventions: " (car bhl-i18n-conventions) "."))) (if (get arg 'bhl-check) (progn (bhl-check-existing-tags arg) (bhl-check-comment arg)) (bhl-add-to-conversion-log "No check of dubious tags.")) (when (nth 13 bhl-xxx-conversions-list) (bhl-convert-quote arg)) (when (nth 0 bhl-xxx-conversions-list) (bhl-convert-verbatim arg)) (when (nth 1 bhl-xxx-conversions-list) (bhl-convert-hr arg)) (when (nth 1 bhl-xxx-conversions-list) (bhl-convert-hr1 arg)) (when (nth 1 bhl-xxx-conversions-list) (bhl-convert-hr2 arg)) (when (nth 7 bhl-xxx-conversions-list) (bhl-convert-tex arg) (bhl-add-to-conversion-log "LaTeX and TeX labels conversion.")) (when (nth 8 bhl-xxx-conversions-list) (condition-case nil (progn (require 'footnote) (if (eq arg 'sgml) (bhl-skip-footnotes arg) (bhl-convert-footnotes arg))) (error (bhl-add-to-conversion-log "BHL was unable to convert footnotes.")))) (when (nth 9 bhl-xxx-conversions-list) (bhl-convert-minipage arg))) (defun bhl-convert-misc-2 (arg) "Miscellaneous conversions into ARG format. This conversion are: images, URLs, description lists, lists, tables." (when (nth 2 bhl-xxx-conversions-list) (bhl-convert-img arg)) (when (and (nth 12 bhl-xxx-conversions-list) bhl-is-a-local-wiki-flag) (bhl-convert-wiki-names arg)) (when (nth 3 bhl-xxx-conversions-list) (bhl-convert-url arg) (when (eq arg 'latex) (bhl-add-to-conversion-log "Please check that you have included the URL package."))) (when (nth 4 bhl-xxx-conversions-list) (bhl-convert-description arg)) (when (nth 5 bhl-xxx-conversions-list) (bhl-convert-list arg)) (when (nth 6 bhl-xxx-conversions-list) (when (not (get arg 'bhl-caption)) (bhl-add-to-conversion-log "No caption was asked for tables.")) (bhl-convert-table arg))) ;; Convert paragraphs (defun bhl-convert-para (arg) "Convert paragraphs into ARG format." (save-excursion (goto-char (point-min)) (when (eq arg 'sgml) (re-search-forward "" nil t) (end-of-line)) (while (re-search-forward "^[\\'\"&*_=a-zA-Z0-9@]" nil t) (goto-char (match-beginning 0)) (if (not (or (eq (get-text-property (match-beginning 0) 'category) 'verbatim) (save-excursion (forward-line -1) (looking-at "<\\|[a-zA-Z0-9]")) (memq t (mapcar (lambda (str) (looking-at str)) bhl-sectioning-regexp-list)))) (save-match-data (cond ((or (eq arg 'sgml) (equal bhl-html-para-align "none")) (insert "

    \n")) (t (insert "\n

    "))) (re-search-forward "^[ \t]*$" nil t) (insert "

    \n")) (forward-line 1))))) ;; Generic function for sections and tags conversion (defun bhl-convert-sec-tag (arg) "Convert sections and tags into ARG format." (when (eq arg 'latex) (dolist (line bhl-latex-extra-body) (insert line "\n"))) (let ((bhl-tag-list (cdr (assq arg bhl-tag-syntax-alist))) (bhl-sec-list (cdr (assq (if (and (eq arg 'latex) (not (get arg 'bhl-prefix))) 'latex-nonum arg) bhl-section-syntax-alist)))) (let ((cpt 0)) (while (< cpt (length bhl-tag-list)) (let ((mt (nth cpt bhl-tag-regexp-list)) (db (car (nth cpt bhl-tag-list))) (fn (cadr (nth cpt bhl-tag-list)))) (bhl-replace-tag mt db fn)) (setq cpt (1+ cpt)))) (let ((cpt 0)) (while (< cpt (length bhl-sec-list)) (let ((mt (nth cpt bhl-sectioning-regexp-list)) (db (car (nth cpt bhl-sec-list))) (fn (cadr (nth cpt bhl-sec-list)))) (bhl-replace-section arg mt db fn (when (eq arg 'html) (get arg 'bhl-prefix)) (when (eq arg 'txt) (get arg 'bhl-center)))) (setq cpt (1+ cpt)))))) ;; Handling comments (defun bhl-convert-comment (arg) "Convert comment into ARG format." (save-excursion (goto-char (point-min)) (while (re-search-forward (concat "\\([^\\\"]\\)\\(#\\)\\(.*\\)$") nil t) (unless (let ((cat (get-text-property (match-beginning 0) 'category))) (and (eq cat 'verbatim) (memq 'comment bhl-verbatim-ignore))) (bhl-add-to-conversion-log (format "Comment \"%s...\" converted." (substring (match-string 3) 0 (if (< (length (match-string 3)) 20) (length (match-string 3)) 20)))) (cond ((eq arg 'latex) (replace-match "%" t t nil 2)) ((eq arg 'texi) (replace-match "@c " t t nil 2)) ((eq arg 'txt) (replace-match "")) (t (replace-match (concat (match-string 1) "") t t))))))) ;; (Un)comment regions (defun bhl-comment-region (&optional prefix) "Comment the region or uncomment it when PREFIX." (interactive "P") (let* ((beg (region-beginning)) (end (region-end))) (save-excursion (goto-char beg) (if prefix (while (re-search-forward "^#\\( \\)?" end t) (setq end (- end (if (match-string 1) 2 1))) (replace-match "")) (while (re-search-forward "^[^\n\r]" end t) (setq end (+ 2 end)) (replace-match (concat "# " (match-string 0)) t t)))))) (defsubst bhl-hide-comment (&optional arg) "Hide comments according to ARG format. With a prefix argument, unhide comments." (interactive "P") (save-excursion (goto-char (point-min)) (let ((func (if arg 'remove-text-properties 'add-text-properties))) (while (re-search-forward "#.*$" nil t) (funcall func (match-beginning 0) (match-end 0) '(invisible t)))))) ;; Convert escape characters (attention escaping \ for bhl2latex) (defun bhl-convert-escape-char (arg) "Convert escape characters for ARG format." (save-excursion (mapcar '(lambda (str) (goto-char (point-min)) (while (search-forward (concat "\\" str) nil t) (let ((cat (get-text-property (match-beginning 0) 'category))) (unless (or (eq cat 'comment) (eq cat 'verbatim) (and (eq arg 'latex) (or (equal str "_") (equal str "#")))) (bhl-add-to-conversion-log (format "Escape character at point %d deleted." (match-beginning 0))) (cond ((eq arg 'latex) (if (equal (match-string 0) "\\\\") (replace-match "$\\backslash$" t t) (replace-match (substring str (1- (safe-length str))) t t))) (t (unless (equal (match-string 0) "\\\\") (replace-match (substring str (1- (safe-length str))) t t)))))))) bhl-escapable-chars))) ;; Convert WikiNames (defun bhl-convert-wiki-names (arg) "Convert WikiNames according to the ARG format." (save-excursion (goto-char (point-min)) (let (case-fold-search) (while (re-search-forward bhl-wiki-names-regexp nil t) (unless (let ((cat (get-text-property (1- (match-beginning 0)) 'category))) (or (member (match-string 0) bhl-non-wiki-names-list) (and (eq cat 'verbatim) (memq 'wikiname bhl-verbatim-ignore)) (eq cat 'comment))) (let* ((wikiname (match-string 0)) (dwikiname (if bhl-downcase-wikifiles-names-flag (downcase wikiname) wikiname))) (cond ((eq arg 'html) (replace-match (concat "" wikiname "") t t)) ((eq arg 'texi) (replace-match (concat "@emph{" wikiname "}") t t)) ((eq arg 'txt) (replace-match wikiname t t)) ((eq arg 'latex) (replace-match (concat "\\emph{" wikiname "}") t t)) ((eq arg 'sgml) (replace-match (concat "") t t))))))))) ;; Convert some special chars in the title strings (defun bhl-clean-title (arg title-regexp) "Clean the title according to the ARG format and the TITLE-REGEXP." (save-excursion (goto-char (point-min)) (let ((string (prog2 (re-search-forward title-regexp nil t) (bhl-match-string 1) (replace-match "" t t nil 1))) (repl-alist (cond ((eq arg 'latex) '(("\\*" . "*") ("&" . "\\&") ("$" . "\\$") ("%" . "\\%") ("{" . "\\{") ("}" . "\\}"))) ((eq arg 'texi) '(("\\*" . "*") ("\\_" . "_") ("\\#" . "#") ("" "@'e") ("" "@`e") ("" "@`a") ("" "@^u") ("" "@^e") ("" "@^o") ("" "@^{@dotless{i}}") ("" "@^a") ("" "@`u") ("" "@,{c}") ("@" . "@@") ("{" . "@{") ("}" . "@}"))) (t '(("\\*" . "*") ("\\_" . "_") ("\\#" . "#")))))) (while (car repl-alist) (setq string (bhl-replace-regexp-in-string (regexp-quote (caar repl-alist)) (cdar repl-alist) string t t)) (setq repl-alist (cdr repl-alist))) (insert string)))) (defun bhl-clean-title-main (arg) "Clean up each title string according to the ARG format." (mapcar '(lambda (regexp) (bhl-clean-title arg regexp)) `(,bhl-title-regexp "^#!texi-title!\\(.*\\)$" "^#!latex-title!\\(.*\\)$" "^#!html-title!\\(.*\\)$" "^#!sgml-title!\\(.*\\)$" "^#!title!\\(.*\\)$" "^#!subtitle!\\(.*\\)$"))) ;; Parse some informations concerning current buffer (defun bhl-parse-header (&optional nodelete) "Parse global informations concerning the current file. Don't delete lines concerning headers if NODELETE is non-nil." (save-excursion (mapcar (lambda (elem) (goto-char (point-min)) (when (re-search-forward (concat "^#!\\(" elem "\\)![ \t]*\\(.*\\)$") nil t) (let ((match (bhl-match-string 2))) (set (intern (concat "bhl-local-" elem)) (if (and (equal elem "date") (string-match "%" match)) (format-time-string match) match))))) '("date" "author" "title" "subtitle" "lang" "encoding"))) (when bhl-local-lang (setcar bhl-i18n-conventions bhl-local-lang))) ;; Convert specification strings (defun bhl-parse-specifications (arg) "Parse specifications strings for ARG output. A specification string looks like: #!html!check:noprefix:nocaption:toc In this example, the `bhl2html' conversion checks for dubious tags, delete sections' prefix, does not ask for tables' caption and insert a table of content." (save-excursion (goto-char (point-min)) (save-excursion (re-search-forward (concat "^#!" (symbol-name arg) "!\\(.*\\)$") nil t) (let ((string (bhl-match-string 1))) (mapcar (lambda (str) (mapcar (lambda (spec) (cond ((equal str spec) (put arg (intern (concat "bhl-" spec)) t)) ((equal str (concat "no" spec)) (put arg (intern (concat "bhl-" spec)) nil)) (t nil))) '("check" "prefix" "caption" "center" "toc" "i18n" "tas"))) (split-string string ":")))) (when (and (eq arg 'latex) (save-excursion (re-search-forward "^#!latex-class!\\(.*\\)$" nil t))) (setq bhl-local-latex-class (bhl-match-string 1))) (when (and (eq arg 'latex) (save-excursion (re-search-forward "^#!latex-options!\\(.*\\)$" nil t))) (setq bhl-local-latex-class-options (split-string (bhl-match-string 1) ":"))) (when (and (eq arg 'texi) (save-excursion (re-search-forward "^#!texi-style!\\(.*\\)$" nil t))) (setq bhl-local-texi-titlepage-style (intern (bhl-match-string 1)))) (when (and (eq arg 'html) (save-excursion (re-search-forward "^#!html-style!\\(.*\\)$" nil t))) (setq bhl-local-html-style (bhl-match-string 1))))) (defun bhl-parse-latex-package () "Parse package specifications for the bhl2latex conversion." (interactive) (when (save-excursion (re-search-forward "^#!latex-packages!\\(.*\\)$" nil t)) (let ((result "") (str (split-string (bhl-match-string 1) ":"))) (mapcar (lambda (strg) (if (string-match "\\[.*\\]" strg) (setq result (concat result "\\usepackage" (substring strg (match-beginning 0) (match-end 0)) "{" (if (equal (match-end 0) (length strg)) (substring strg 0 (match-beginning 0)) (substring strg (match-end 0))) "}\n")) (setq result (concat result "\\usepackage{" strg "}\n")))) str) result))) ;; A wrapper function designed to allow the use of BHL in scripts. ;; Note that Emacs has no very useful and obvious way to read ;; characters from stdin into a buffer, so it will be the caller's job ;; to create a temp file if it wants to be able to take stdin input. (defun bhl2xxx-batch-wrapper (file format &optional outstream) "Convert FILE into FORMAT and send the format to the OUTSTREAM." (find-file file) (bhl-mode) (bhl2xxx format) (princ (buffer-string) outstream) (terpri)) ;; A generic function that converts BHL source files. (defun bhl2xxx (arg) "Convert the BHL source file into a HTML, SGML or LaTeX file. ARG is the output format. OFFLINE is non-nil when BHL is called in batch mode." (bhl-convert-init arg) (bhl-add-text-properties arg) (bhl-clean-title-main arg) (bhl-insert-preamble arg) (narrow-to-region (if (eq arg 'sgml) (search-forward "") (point)) (point-max)) (bhl-ignore-regexp-line) (when (eq arg 'latex) (bhl-protect-chars bhl-latex-escaped-chars)) (when (eq arg 'texi) (bhl-protect-chars bhl-texi-escaped-chars)) (bhl-convert-misc-1 arg) (when (or (eq arg 'html) (eq arg 'sgml)) (condition-case nil (bhl-convert-para arg) (error (bhl-add-to-conversion-log "BHL was unable to convert paragraphs properly.")))) (bhl-convert-misc-2 arg) (bhl-make-toc) (bhl-update-toc) (bhl-skip-toc arg) (bhl-convert-sec-tag arg) (when (nth 10 bhl-xxx-conversions-list) (bhl-convert-comment arg)) (when (nth 11 bhl-xxx-conversions-list) (bhl-convert-escape-char arg)) (bhl-add-to-conversion-log (concat "Sections' prefix: " (symbol-name (get arg 'bhl-prefix)) ".")) (widen) (goto-char (point-max)) (insert (cond ((eq arg 'latex) "\n\n\\end{document}") ((eq arg 'html) "\n\n") ((eq arg 'sgml) "
    ") ((eq arg 'texi) "\n@bye") (t ""))) (run-hooks (get arg 'after-conversion-hook)) (run-hooks 'bhl-after-conversion-hook) (goto-char (point-min)) (message "Converting into %s format...done. " (symbol-name arg))) (provide 'bhl) ;;; bhl.el ends here ;; Preambule ;; Backslash cmds latex ;; insert-tab ;; bib \bibliography{mabibli} reftex bhl-1.7.3/texinfo.tex0100644000076400007640000065551510053644727014143 0ustar guerryguerry% texinfo.tex -- TeX macros to handle Texinfo files. % % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % \def\texinfoversion{2003-03-07.10} % % Copyright (C) 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 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, Inc., 59 Temple Place - Suite 330, % Boston, MA 02111-1307, 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! % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: % ftp://ftp.gnu.org/gnu/texinfo/texinfo.tex % (and all GNU mirrors, see http://www.gnu.org/order/ftp.html) % ftp://tug.org/tex/texinfo.tex % (and all CTAN mirrors, see http://www.ctan.org), % and /home/gd/gnu/doc/texinfo.tex on the GNU machines. % % The GNU Texinfo home page is http://www.gnu.org/software/texinfo. % % The texinfo.tex in any given Texinfo distribution could well be out % of date, so if that's what you're using, please check. % % Send bug reports to bug-texinfo@gnu.org. Please include including a % complete document in each bug report with which we can reproduce the % problem. Patches are, of course, greatly appreciated. % % To process a Texinfo manual with TeX, it's most reliable to use the % texi2dvi shell script that comes with the distribution. For a simple % manual foo.texi, however, you can get away with this: % tex foo.texi % texindex foo.?? % tex foo.texi % tex foo.texi % dvips foo.dvi -o # or whatever; this makes foo.ps. % The extra TeX runs get the cross-reference information correct. % Sometimes one run after texindex suffices, and sometimes you need more % than two; texi2dvi does it as many times as necessary. % % It is possible to adapt texinfo.tex for other languages, to some % extent. You can get the existing language-specific files from the % full Texinfo distribution. \message{Loading texinfo [version \texinfoversion]:} % If in a .fmt file, print the version number % and turn on active characters that we couldn't do earlier because % they might have appeared in the input file name. \everyjob{\message{[Texinfo version \texinfoversion]}% \catcode`+=\active \catcode`\_=\active} \message{Basics,} \chardef\other=12 % We never want plain's \outer definition of \+ in Texinfo. % For @tex, we can use \tabalign. \let\+ = \relax % Save some plain tex macros whose names we will redefine. \let\ptexb=\b \let\ptexbullet=\bullet \let\ptexc=\c \let\ptexcomma=\, \let\ptexdot=\. \let\ptexdots=\dots \let\ptexend=\end \let\ptexequiv=\equiv \let\ptexexclam=\! \let\ptexgtr=> \let\ptexhat=^ \let\ptexi=\i \let\ptexlbrace=\{ \let\ptexless=< \let\ptexplus=+ \let\ptexrbrace=\} \let\ptexslash=\/ \let\ptexstar=\* \let\ptext=\t % If this character appears in an error message or help string, it % starts a new line in the output. \newlinechar = `^^J % Set up fixed words for English if not already set. \ifx\putwordAppendix\undefined \gdef\putwordAppendix{Appendix}\fi \ifx\putwordChapter\undefined \gdef\putwordChapter{Chapter}\fi \ifx\putwordfile\undefined \gdef\putwordfile{file}\fi \ifx\putwordin\undefined \gdef\putwordin{in}\fi \ifx\putwordIndexIsEmpty\undefined \gdef\putwordIndexIsEmpty{(Index is empty)}\fi \ifx\putwordIndexNonexistent\undefined \gdef\putwordIndexNonexistent{(Index is nonexistent)}\fi \ifx\putwordInfo\undefined \gdef\putwordInfo{Info}\fi \ifx\putwordInstanceVariableof\undefined \gdef\putwordInstanceVariableof{Instance Variable of}\fi \ifx\putwordMethodon\undefined \gdef\putwordMethodon{Method on}\fi \ifx\putwordNoTitle\undefined \gdef\putwordNoTitle{No Title}\fi \ifx\putwordof\undefined \gdef\putwordof{of}\fi \ifx\putwordon\undefined \gdef\putwordon{on}\fi \ifx\putwordpage\undefined \gdef\putwordpage{page}\fi \ifx\putwordsection\undefined \gdef\putwordsection{section}\fi \ifx\putwordSection\undefined \gdef\putwordSection{Section}\fi \ifx\putwordsee\undefined \gdef\putwordsee{see}\fi \ifx\putwordSee\undefined \gdef\putwordSee{See}\fi \ifx\putwordShortTOC\undefined \gdef\putwordShortTOC{Short Contents}\fi \ifx\putwordTOC\undefined \gdef\putwordTOC{Table of Contents}\fi % \ifx\putwordMJan\undefined \gdef\putwordMJan{January}\fi \ifx\putwordMFeb\undefined \gdef\putwordMFeb{February}\fi \ifx\putwordMMar\undefined \gdef\putwordMMar{March}\fi \ifx\putwordMApr\undefined \gdef\putwordMApr{April}\fi \ifx\putwordMMay\undefined \gdef\putwordMMay{May}\fi \ifx\putwordMJun\undefined \gdef\putwordMJun{June}\fi \ifx\putwordMJul\undefined \gdef\putwordMJul{July}\fi \ifx\putwordMAug\undefined \gdef\putwordMAug{August}\fi \ifx\putwordMSep\undefined \gdef\putwordMSep{September}\fi \ifx\putwordMOct\undefined \gdef\putwordMOct{October}\fi \ifx\putwordMNov\undefined \gdef\putwordMNov{November}\fi \ifx\putwordMDec\undefined \gdef\putwordMDec{December}\fi % \ifx\putwordDefmac\undefined \gdef\putwordDefmac{Macro}\fi \ifx\putwordDefspec\undefined \gdef\putwordDefspec{Special Form}\fi \ifx\putwordDefvar\undefined \gdef\putwordDefvar{Variable}\fi \ifx\putwordDefopt\undefined \gdef\putwordDefopt{User Option}\fi \ifx\putwordDeftypevar\undefined\gdef\putwordDeftypevar{Variable}\fi \ifx\putwordDeffunc\undefined \gdef\putwordDeffunc{Function}\fi \ifx\putwordDeftypefun\undefined\gdef\putwordDeftypefun{Function}\fi % In some macros, we cannot use the `\? notation---the left quote is % in some cases the escape char. \chardef\colonChar = `\: \chardef\commaChar = `\, \chardef\dotChar = `\. \chardef\equalChar = `\= \chardef\exclamChar= `\! \chardef\questChar = `\? \chardef\semiChar = `\; \chardef\spaceChar = `\ % \chardef\underChar = `\_ % Ignore a token. % \def\gobble#1{} % True if #1 is the empty string, i.e., called like `\ifempty{}'. % \def\ifempty#1{\ifemptyx #1\emptymarkA\emptymarkB}% \def\ifemptyx#1#2\emptymarkB{\ifx #1\emptymarkA}% % Hyphenation fixes. \hyphenation{ap-pen-dix} \hyphenation{eshell} \hyphenation{mini-buf-fer mini-buf-fers} \hyphenation{time-stamp} \hyphenation{white-space} % Margin to add to right of even pages, to left of odd pages. \newdimen\bindingoffset \newdimen\normaloffset \newdimen\pagewidth \newdimen\pageheight % 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. We also make % some effort to order the tracing commands to reduce output in the log % file; cf. trace.sty in LaTeX. % \def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% \def\loggingall{% \tracingstats2 \tracingpages1 \tracinglostchars2 % 2 gives us more in etex \tracingparagraphs1 \tracingoutput1 \tracingmacros2 \tracingrestores1 \showboxbreadth\maxdimen \showboxdepth\maxdimen \ifx\eTeXversion\undefined\else % etex gives us more logging \tracingscantokens1 \tracingifs1 \tracinggroups1 \tracingnesting2 \tracingassigns1 \fi \tracingcommands3 % 3 gives us more in etex \errorcontextlines\maxdimen }% % add check for \lastpenalty to plain's definitions. If the last thing % we did was a \nobreak, we don't want to insert more space. % \def\smallbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\smallskipamount \removelastskip\penalty-50\smallskip\fi\fi} \def\medbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\medskipamount \removelastskip\penalty-100\medskip\fi\fi} \def\bigbreak{\ifnum\lastpenalty<10000\par\ifdim\lastskip<\bigskipamount \removelastskip\penalty-200\bigskip\fi\fi} % For @cropmarks command. % Do @cropmarks to get crop marks. % \newif\ifcropmarks \let\cropmarks = \cropmarkstrue % % Dimensions to add cropmarks at corners. % Added by P. A. MacKay, 12 Nov. 1986 % \newdimen\outerhsize \newdimen\outervsize % set by the paper size routines \newdimen\cornerlong \cornerlong=1pc \newdimen\cornerthick \cornerthick=.3pt \newdimen\topandbottommargin \topandbottommargin=.75in % Main output routine. \chardef\PAGE = 255 \output = {\onepageout{\pagecontents\PAGE}} \newbox\headlinebox \newbox\footlinebox % \onepageout takes a vbox as an argument. Note that \pagecontents % does insertions, but you have to call it yourself. \def\onepageout#1{% \ifcropmarks \hoffset=0pt \else \hoffset=\normaloffset \fi % \ifodd\pageno \advance\hoffset by \bindingoffset \else \advance\hoffset by -\bindingoffset\fi % % Do this outside of the \shipout so @code etc. will be expanded in % the headline as they should be, not taken literally (outputting ''code). \setbox\headlinebox = \vbox{\let\hsize=\pagewidth \makeheadline}% \setbox\footlinebox = \vbox{\let\hsize=\pagewidth \makefootline}% % {% % Have to do this stuff outside the \shipout because we want it to % take effect in \write's, yet the group defined by the \vbox ends % before the \shipout runs. % \escapechar = `\\ % use backslash in output files. \indexdummies % don't expand commands in the output. \normalturnoffactive % \ in index entries must not stay \, e.g., if % the page break happens to be in the middle of an example. \shipout\vbox{% % Do this early so pdf references go to the beginning of the page. \ifpdfmakepagedest \pdfmkdest{\the\pageno} \fi % \ifcropmarks \vbox to \outervsize\bgroup \hsize = \outerhsize \vskip-\topandbottommargin \vtop to0pt{% \line{\ewtop\hfil\ewtop}% \nointerlineskip \line{% \vbox{\moveleft\cornerthick\nstop}% \hfill \vbox{\moveright\cornerthick\nstop}% }% \vss}% \vskip\topandbottommargin \line\bgroup \hfil % center the page within the outer (page) hsize. \ifodd\pageno\hskip\bindingoffset\fi \vbox\bgroup \fi % \unvbox\headlinebox \pagebody{#1}% \ifdim\ht\footlinebox > 0pt % Only leave this space if the footline is nonempty. % (We lessened \vsize for it in \oddfootingxxx.) % The \baselineskip=24pt in plain's \makefootline has no effect. \vskip 2\baselineskip \unvbox\footlinebox \fi % \ifcropmarks \egroup % end of \vbox\bgroup \hfil\egroup % end of (centering) \line\bgroup \vskip\topandbottommargin plus1fill minus1fill \boxmaxdepth = \cornerthick \vbox to0pt{\vss \line{% \vbox{\moveleft\cornerthick\nsbot}% \hfill \vbox{\moveright\cornerthick\nsbot}% }% \nointerlineskip \line{\ewbot\hfil\ewbot}% }% \egroup % \vbox from first cropmarks clause \fi }% end of \shipout\vbox }% end of group with \normalturnoffactive \advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi } \newinsert\margin \dimen\margin=\maxdimen \def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} {\catcode`\@ =11 \gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi % marginal hacks, juha@viisa.uucp (Juha Takala) \ifvoid\margin\else % marginal info is present \rlap{\kern\hsize\vbox to\z@{\kern1pt\box\margin \vss}}\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 is the rest of % the input line (except we remove a trailing comment). #1 should be a % macro which expects an ordinary undelimited TeX argument. % \def\parsearg#1{% \let\next = #1% \begingroup \obeylines \futurelet\temp\parseargx } % If the next token is an obeyed space (from an @example environment or % the like), remove it and recurse. Otherwise, we're done. \def\parseargx{% % \obeyedspace is defined far below, after the definition of \sepspaces. \ifx\obeyedspace\temp \expandafter\parseargdiscardspace \else \expandafter\parseargline \fi } % Remove a single space (as the delimiter token to the macro call). {\obeyspaces % \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} {\obeylines % \gdef\parseargline#1^^M{% \endgroup % End of the group started in \parsearg. % % First remove any @c comment, then any @comment. % Result of each macro is put in \toks0. \argremovec #1\c\relax % \expandafter\argremovecomment \the\toks0 \comment\relax % % % Call the caller's macro, saved as \next in \parsearg. \expandafter\next\expandafter{\the\toks0}% }% } % Since all \c{,omment} does is throw away the argument, we can let TeX % do that for us. The \relax here is matched by the \relax in the call % in \parseargline; it could be more or less anything, its purpose is % just to delimit the argument to the \c. \def\argremovec#1\c#2\relax{\toks0 = {#1}} \def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} % \argremovec{,omment} might leave us with trailing spaces, though; e.g., % @end itemize @c foo % will have two active spaces as part of the argument with the % `itemize'. Here we remove all active spaces from #1, and assign the % result to \toks0. % % This loses if there are any *other* active characters besides spaces % in the argument -- _ ^ +, for example -- since they get expanded. % Fortunately, Texinfo does not define any such commands. (If it ever % does, the catcode of the characters in questionwill have to be changed % here.) But this means we cannot call \removeactivespaces as part of % \argremovec{,omment}, since @c uses \parsearg, and thus the argument % that \parsearg gets might well have any character at all in it. % \def\removeactivespaces#1{% \begingroup \ignoreactivespaces \edef\temp{#1}% \global\toks0 = \expandafter{\temp}% \endgroup } % Change the active space to expand to nothing. % \begingroup \obeyspaces \gdef\ignoreactivespaces{\obeyspaces\let =\empty} \endgroup \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; press 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{Press RETURN 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. % \def\end{\parsearg\endxxx} \def\endxxx #1{% \removeactivespaces{#1}% \edef\endthing{\the\toks0}% % \expandafter\ifx\csname E\endthing\endcsname\relax \expandafter\ifx\csname \endthing\endcsname\relax % There's no \foo, i.e., no ``environment'' foo. \errhelp = \EMsimple \errmessage{Undefined command `@end \endthing'}% \else \unmatchedenderror\endthing \fi \else % Everything's ok; the right environment has been started. \csname E\endthing\endcsname \fi } % There is an environment #1, but it hasn't been started. Give an error. % \def\unmatchedenderror#1{% \errhelp = \EMsimple \errmessage{This `@end #1' doesn't have a matching `@#1'}% } % Define the control sequence \E#1 to give an unmatched @end error. % \def\defineunmatchedend#1{% \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% } %% Simple single-character @ commands % @@ prints an @ % Kludge this until the fonts are right (grr). \def\@{{\tt\char64}} % This is turned off because it was never documented % and you can use @w{...} around a quote to suppress ligatures. %% Define @` and @' to be the same as ` and ' %% but suppressing ligatures. %\def\`{{`}} %\def\'{{'}} % Used to generate quoted braces. \def\mylbrace {{\tt\char123}} \def\myrbrace {{\tt\char125}} \let\{=\mylbrace \let\}=\myrbrace \begingroup % Definitions to produce \{ and \} commands for indices, % and @{ and @} for the aux file. \catcode`\{ = \other \catcode`\} = \other \catcode`\[ = 1 \catcode`\] = 2 \catcode`\! = 0 \catcode`\\ = \other !gdef!lbracecmd[\{]% !gdef!rbracecmd[\}]% !gdef!lbraceatcmd[@{]% !gdef!rbraceatcmd[@}]% !endgroup % Accents: @, @dotaccent @ringaccent @ubaraccent @udotaccent % Others are defined by plain TeX: @` @' @" @^ @~ @= @u @v @H. \let\, = \c \let\dotaccent = \. \def\ringaccent#1{{\accent23 #1}} \let\tieaccent = \t \let\ubaraccent = \b \let\udotaccent = \d % Other special characters: @questiondown @exclamdown % Plain TeX defines: @AA @AE @O @OE @L (plus lowercase versions) @ss. \def\questiondown{?`} \def\exclamdown{!`} % Dotless i and dotless j, used for accents. \def\imacro{i} \def\jmacro{j} \def\dotless#1{% \def\temp{#1}% \ifx\temp\imacro \ptexi \else\ifx\temp\jmacro \j \else \errmessage{@dotless can be used only with i or j}% \fi\fi } % Be sure we're in horizontal mode when doing a tie, since we make space % equivalent to this in @example-like environments. Otherwise, a space % at the beginning of a line will start with \penalty -- and % since \penalty is valid in vertical mode, we'd end up putting the % penalty on the vertical list instead of in the new paragraph. {\catcode`@ = 11 % Avoid using \@M directly, because that causes trouble % if the definition is written into an index file. \global\let\tiepenalty = \@M \gdef\tie{\leavevmode\penalty\tiepenalty\ } } % @: forces normal size whitespace following. \def\:{\spacefactor=1000 } % @* forces a line break. \def\*{\hfil\break\hbox{}\ignorespaces} % @/ allows a line break. \let\/=\allowbreak % @. is an end-of-sentence period. \def\.{.\spacefactor=3000 } % @! is an end-of-sentence bang. \def\!{!\spacefactor=3000 } % @? is an end-of-sentence query. \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. % % Another complication is that the group might be very large. This can % cause the glue on the previous page to be unduly stretched, because it % does not have much material. In this case, it's better to add an % explicit \vfill so that the extra space is at the bottom. The % threshold for doing this is if the group is more than \vfilllimit % percent of a page (\vfilllimit can be changed inside of @tex). % \newbox\groupbox \def\vfilllimit{0.7} % \def\group{\begingroup \ifnum\catcode13=\active \else \errhelp = \groupinvalidhelp \errmessage{@group invalid in context where filling is enabled}% \fi % % The \vtop we start below produces a box with normal height and large % depth; thus, TeX puts \baselineskip glue before it, and (when the % next line of text is done) \lineskip glue after it. (See p.82 of % the TeXbook.) Thus, space below is not quite equal to space % above. But it's pretty close. \def\Egroup{% \egroup % End the \vtop. % \dimen0 is the vertical size of the group's box. \dimen0 = \ht\groupbox \advance\dimen0 by \dp\groupbox % \dimen2 is how much space is left on the page (more or less). \dimen2 = \pageheight \advance\dimen2 by -\pagetotal % if the group doesn't fit on the current page, and it's a big big % group, force a page break. \ifdim \dimen0 > \dimen2 \ifdim \pagetotal < \vfilllimit\pageheight \page \fi \fi \copy\groupbox \endgroup % End the \group. }% % \setbox\groupbox = \vtop\bgroup % We have to put a strut on the last line in case the @group is in % the midst of an example, rather than completely enclosing it. % Otherwise, the interline space between the last line of the group % and the first line afterwards is too small. But we can't put the % strut in \Egroup, since there it would be on a line by itself. % Hence this just inserts a strut at the beginning of each line. \everypar = {\strut}% % % Since we have a strut on every line, we don't need any of TeX's % normal interline spacing. \offinterlineskip % % OK, but now we have to do something about blank % lines in the input in @example-like environments, which normally % just turn into \lisppar, which will insert no space now that we've % turned off the interline space. Simplest is to make them be an % empty paragraph. \ifx\par\lisppar \edef\par{\leavevmode \par}% % % Reset ^^M's definition to new definition of \par. \obeylines \fi % % Do @comment since we are called inside an environment such as % @example, where each end-of-line in the input causes an % end-of-line in the output. We don't want the end-of-line after % the `@group' to put extra space in the output. Since @group % should appear on a line by itself (according to the Texinfo % manual), we don't worry about eating any user text. \comment } % % 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\nobreak %\prevdepth=-1000pt %}} \def\needx#1{% % Ensure vertical mode, so we don't make a big box in the middle of a % paragraph. \par % % If the @need value is less than one line space, it's useless. \dimen0 = #1\mil \dimen2 = \ht\strutbox \advance\dimen2 by \dp\strutbox \ifdim\dimen0 > \dimen2 % % Do a \strut just to make the height of this box be normal, so the % normal leading is inserted relative to the preceding line. % And a page break here is fine. \vtop to #1\mil{\strut\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 \fi } % @br forces paragraph break \let\br = \par % @dots{} output an ellipsis using the current font. % We do .5em per period so that it has the same spacing in a typewriter % font as three actual period characters. % \def\dots{% \leavevmode \hbox to 1.5em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% } % @enddots{} is an end-of-sentence ellipsis. % \def\enddots{% \leavevmode \hbox to 2em{% \hskip 0pt plus 0.25fil minus 0.25fil .\hss.\hss.\hss.% \hskip 0pt plus 0.5fil minus 0.5fil }% \spacefactor=3000 } % @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}}}} % @inmargin{WHICH}{TEXT} puts TEXT in the WHICH margin next to the current % paragraph. For more general purposes, use the \margin insertion % class. WHICH is `l' or `r'. % \newskip\inmarginspacing \inmarginspacing=1cm \def\strutdepth{\dp\strutbox} % \def\doinmargin#1#2{\strut\vadjust{% \nobreak \kern-\strutdepth \vtop to \strutdepth{% \baselineskip=\strutdepth \vss % if you have multiple lines of stuff to put here, you'll need to % make the vbox yourself of the appropriate size. \ifx#1l% \llap{\ignorespaces #2\hskip\inmarginspacing}% \else \rlap{\hskip\hsize \hskip\inmarginspacing \ignorespaces #2}% \fi \null }% }} \def\inleftmargin{\doinmargin l} \def\inrightmargin{\doinmargin r} % % @inmargin{TEXT [, RIGHT-TEXT]} % (if RIGHT-TEXT is given, use TEXT for left page, RIGHT-TEXT for right; % else use TEXT for both). % \def\inmargin#1{\parseinmargin #1,,\finish} \def\parseinmargin#1,#2,#3\finish{% not perfect, but better than nothing. \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \def\lefttext{#1}% have both texts \def\righttext{#2}% \else \def\lefttext{#1}% have only one text \def\righttext{#1}% \fi % \ifodd\pageno \def\temp{\inrightmargin\righttext}% odd page -> outside is right margin \else \def\temp{\inleftmargin\lefttext}% \fi \temp } % @include file insert text of that file as input. % Allow normal characters that we make active in the argument (a file name). \def\include{\begingroup \catcode`\\=\other \catcode`~=\other \catcode`^=\other \catcode`_=\other \catcode`|=\other \catcode`<=\other \catcode`>=\other \catcode`+=\other \parsearg\includezzz} % Restore active chars for included file. \def\includezzz#1{\endgroup\begingroup % Read the included file in a group so nested @include's work. \def\thisfile{#1}% \let\value=\expandablevalue \input\thisfile \endgroup} \def\thisfile{} % @center line % outputs that line, centered. % \def\center{\parsearg\docenter} \def\docenter#1{{% \ifhmode \hfil\break \fi \advance\hsize by -\leftskip \advance\hsize by -\rightskip \line{\hfil \ignorespaces#1\unskip \hfil}% \ifhmode \break \fi }} % @sp n outputs n lines of vertical space \def\sp{\parsearg\spxxx} \def\spxxx #1{\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{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} \let\c=\comment % @paragraphindent NCHARS % We'll use ems for NCHARS, close enough. % We cannot implement @paragraphindent asis, though. % \def\asisword{asis} % no translation, these are keywords \def\noneword{none} % \def\paragraphindent{\parsearg\doparagraphindent} \def\doparagraphindent#1{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \defaultparindent = 0pt \else \defaultparindent = #1em \fi \fi \parindent = \defaultparindent } % @exampleindent NCHARS % We'll use ems for NCHARS like @paragraphindent. % It seems @exampleindent asis isn't necessary, but % I preserve it to make it similar to @paragraphindent. \def\exampleindent{\parsearg\doexampleindent} \def\doexampleindent#1{% \def\temp{#1}% \ifx\temp\asisword \else \ifx\temp\noneword \lispnarrowing = 0pt \else \lispnarrowing = #1em \fi \fi } % @asis just yields its argument. Used with @table, for example. % \def\asis#1{#1} % @math outputs its argument in math mode. % We don't use $'s directly in the definition of \math because we need % to set catcodes according to plain TeX first, to allow for subscripts, % superscripts, special math chars, etc. % \let\implicitmath = $%$ font-lock fix % % One complication: _ usually means subscripts, but it could also mean % an actual _ character, as in @math{@var{some_variable} + 1}. So make % _ within @math be active (mathcode "8000), and distinguish by seeing % if the current family is \slfam, which is what @var uses. % {\catcode\underChar = \active \gdef\mathunderscore{% \catcode\underChar=\active \def_{\ifnum\fam=\slfam \_\else\sb\fi}% }} % % Another complication: we want \\ (and @\) to output a \ character. % FYI, plain.tex uses \\ as a temporary control sequence (why?), but % this is not advertised and we don't care. Texinfo does not % otherwise define @\. % % The \mathchar is class=0=ordinary, family=7=ttfam, position=5C=\. \def\mathbackslash{\ifnum\fam=\ttfam \mathchar"075C \else\backslash \fi} % \def\math{% \tex \mathcode`\_="8000 \mathunderscore \let\\ = \mathbackslash \mathactive \implicitmath\finishmath} \def\finishmath#1{#1\implicitmath\Etex} % Some active characters (such as <) are spaced differently in math. % We have to reset their definitions in case the @math was an % argument to a command which set the catcodes (such as @item or @section). % { \catcode`^ = \active \catcode`< = \active \catcode`> = \active \catcode`+ = \active \gdef\mathactive{% \let^ = \ptexhat \let< = \ptexless \let> = \ptexgtr \let+ = \ptexplus } } % @bullet and @minus need the same treatment as @math, just above. \def\bullet{\implicitmath\ptexbullet\implicitmath} \def\minus{\implicitmath-\implicitmath} % @refill is a no-op. \let\refill=\relax % If working on a large document in chapters, it is convenient to % be able to disable indexing, cross-referencing, and contents, for test runs. % This is done with @novalidate (before @setfilename). % \newif\iflinks \linkstrue % by default we want the aux files. \let\novalidate = \linksfalse % @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{% \iflinks \readauxfile \fi % \openindices needs to do some work in any case. \openindices \fixbackslash % Turn off hack to swallow `\input texinfo'. \global\let\setfilename=\comment % Ignore extra @setfilename cmds. % % If texinfo.cnf is present on the system, read it. % Useful for site-wide @afourpaper, etc. % Just to be on the safe side, close the input stream before the \input. \openin 1 texinfo.cnf \ifeof1 \let\temp=\relax \else \def\temp{\input texinfo.cnf }\fi \closein1 \temp % \comment % Ignore the actual filename. } % Called from \setfilename. % \def\openindices{% \newindex{cp}% \newcodeindex{fn}% \newcodeindex{vr}% \newcodeindex{tp}% \newcodeindex{ky}% \newcodeindex{pg}% } % @bye. \outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} \message{pdf,} % adobe `portable' document format \newcount\tempnum \newcount\lnkcount \newtoks\filename \newcount\filenamelength \newcount\pgn \newtoks\toksA \newtoks\toksB \newtoks\toksC \newtoks\toksD \newbox\boxA \newcount\countA \newif\ifpdf \newif\ifpdfmakepagedest \ifx\pdfoutput\undefined \pdffalse \let\pdfmkdest = \gobble \let\pdfurl = \gobble \let\endlink = \relax \let\linkcolor = \relax \let\pdfmakeoutlines = \relax \else \pdftrue \pdfoutput = 1 \input pdfcolor \def\dopdfimage#1#2#3{% \def\imagewidth{#2}% \def\imageheight{#3}% % without \immediate, pdftex seg faults when the same image is % included twice. (Version 3.14159-pre-1.0-unofficial-20010704.) \ifnum\pdftexversion < 14 \immediate\pdfimage \else \immediate\pdfximage \fi \ifx\empty\imagewidth\else width \imagewidth \fi \ifx\empty\imageheight\else height \imageheight \fi \ifnum\pdftexversion<13 #1.pdf% \else {#1.pdf}% \fi \ifnum\pdftexversion < 14 \else \pdfrefximage \pdflastximage \fi} \def\pdfmkdest#1{{\normalturnoffactive \pdfdest name{#1} xyz}} \def\pdfmkpgn#1{#1} \let\linkcolor = \Blue % was Cyan, but that seems light? \def\endlink{\Black\pdfendlink} % Adding outlines to PDF; macros for calculating structure of outlines % come from Petr Olsak \def\expnumber#1{\expandafter\ifx\csname#1\endcsname\relax 0% \else \csname#1\endcsname \fi} \def\advancenumber#1{\tempnum=\expnumber{#1}\relax \advance\tempnum by1 \expandafter\xdef\csname#1\endcsname{\the\tempnum}} \def\pdfmakeoutlines{{% \openin 1 \jobname.toc \ifeof 1\else\begingroup \closein 1 % Thanh's hack / proper braces in bookmarks \edef\mylbrace{\iftrue \string{\else}\fi}\let\{=\mylbrace \edef\myrbrace{\iffalse{\else\string}\fi}\let\}=\myrbrace % \def\chapentry ##1##2##3{} \def\secentry ##1##2##3##4{\advancenumber{chap##2}} \def\subsecentry ##1##2##3##4##5{\advancenumber{sec##2.##3}} \def\subsubsecentry ##1##2##3##4##5##6{\advancenumber{subsec##2.##3.##4}} \let\appendixentry = \chapentry \let\unnumbchapentry = \chapentry \let\unnumbsecentry = \secentry \let\unnumbsubsecentry = \subsecentry \let\unnumbsubsubsecentry = \subsubsecentry \input \jobname.toc \def\chapentry ##1##2##3{% \pdfoutline goto name{\pdfmkpgn{##3}}count-\expnumber{chap##2}{##1}} \def\secentry ##1##2##3##4{% \pdfoutline goto name{\pdfmkpgn{##4}}count-\expnumber{sec##2.##3}{##1}} \def\subsecentry ##1##2##3##4##5{% \pdfoutline goto name{\pdfmkpgn{##5}}count-\expnumber{subsec##2.##3.##4}{##1}} \def\subsubsecentry ##1##2##3##4##5##6{% \pdfoutline goto name{\pdfmkpgn{##6}}{##1}} \let\appendixentry = \chapentry \let\unnumbchapentry = \chapentry \let\unnumbsecentry = \secentry \let\unnumbsubsecentry = \subsecentry \let\unnumbsubsubsecentry = \subsubsecentry % % Make special characters normal for writing to the pdf file. % \indexnofonts \let\tt=\relax \turnoffactive \input \jobname.toc \endgroup\fi }} \def\makelinks #1,{% \def\params{#1}\def\E{END}% \ifx\params\E \let\nextmakelinks=\relax \else \let\nextmakelinks=\makelinks \ifnum\lnkcount>0,\fi \picknum{#1}% \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{\the\pgn}}% \linkcolor #1% \advance\lnkcount by 1% \endlink \fi \nextmakelinks } \def\picknum#1{\expandafter\pn#1} \def\pn#1{% \def\p{#1}% \ifx\p\lbrace \let\nextpn=\ppn \else \let\nextpn=\ppnn \def\first{#1} \fi \nextpn } \def\ppn#1{\pgn=#1\gobble} \def\ppnn{\pgn=\first} \def\pdfmklnk#1{\lnkcount=0\makelinks #1,END,} \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces \ifx\p\space\else\addtokens{\filename}{\PP}% \advance\filenamelength by 1 \fi \fi \nextsp} \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else \let \startlink \pdfstartlink \fi \def\pdfurl#1{% \begingroup \normalturnoffactive\def\@{@}% \let\value=\expandablevalue \leavevmode\Red \startlink attr{/Border [0 0 0]}% user{/Subtype /Link /A << /S /URI /URI (#1) >>}% % #1 \endgroup} \def\pdfgettoks#1.{\setbox\boxA=\hbox{\toksA={#1.}\toksB={}\maketoks}} \def\addtokens#1#2{\edef\addtoks{\noexpand#1={\the#1#2}}\addtoks} \def\adn#1{\addtokens{\toksC}{#1}\global\countA=1\let\next=\maketoks} \def\poptoks#1#2|ENDTOKS|{\let\first=#1\toksD={#1}\toksA={#2}} \def\maketoks{% \expandafter\poptoks\the\toksA|ENDTOKS| \ifx\first0\adn0 \else\ifx\first1\adn1 \else\ifx\first2\adn2 \else\ifx\first3\adn3 \else\ifx\first4\adn4 \else\ifx\first5\adn5 \else\ifx\first6\adn6 \else\ifx\first7\adn7 \else\ifx\first8\adn8 \else\ifx\first9\adn9 \else \ifnum0=\countA\else\makelink\fi \ifx\first.\let\next=\done\else \let\next=\maketoks \addtokens{\toksB}{\the\toksD} \ifx\first,\addtokens{\toksB}{\space}\fi \fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \next} \def\makelink{\addtokens{\toksB}% {\noexpand\pdflink{\the\toksC}}\toksC={}\global\countA=0} \def\pdflink#1{% \startlink attr{/Border [0 0 0]} goto name{\pdfmkpgn{#1}} \linkcolor #1\endlink} \def\done{\edef\st{\global\noexpand\toksA={\the\toksB}}\st} \fi % \ifx\pdfoutput \message{fonts,} % Font-change commands. % Texinfo sort of 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. % We don't need math for this one. \def\ttsl{\tenttsl} % Default leading. \newdimen\textleading \textleading = 13.2pt % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. % \def\lineskipfactor{.08333} \def\strutheightpercent{.70833} \def\strutdepthpercent {.29167} % \def\setleading#1{% \normalbaselineskip = #1\relax \normallineskip = \lineskipfactor\normalbaselineskip \normalbaselines \setbox\strutbox =\hbox{% \vrule width0pt height\strutheightpercent\baselineskip depth \strutdepthpercent \baselineskip }% } % Set the font macro #1 to the font named #2, adding on the % specified font prefix (normally `cm'). % #3 is the font's design size, #4 is a scale factor \def\setfont#1#2#3#4{\font#1=\fontprefix#2#3 scaled #4} % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix % before you read in texinfo.tex. \ifx\fontprefix\undefined \def\fontprefix{cm} \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} \def\rmbshape{bx} %where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} \def\ttbshape{tt} \def\ttslshape{sltt} \def\itshape{ti} \def\itbshape{bxti} \def\slshape{sl} \def\slbshape{bxsl} \def\sfshape{ss} \def\sfbshape{ss} \def\scshape{csc} \def\scbshape{csc} \newcount\mainmagstep \ifx\bigger\relax % not really supported. \mainmagstep=\magstep1 \setfont\textrm\rmshape{12}{1000} \setfont\texttt\ttshape{12}{1000} \else \mainmagstep=\magstephalf \setfont\textrm\rmshape{10}{\mainmagstep} \setfont\texttt\ttshape{10}{\mainmagstep} \fi % Instead of cmb10, you may want to use cmbx10. % cmbx10 is a prettier font on its own, but cmb10 % looks better when embedded in a line with cmr10 % (in Bob's opinion). \setfont\textbf\bfshape{10}{\mainmagstep} \setfont\textit\itshape{10}{\mainmagstep} \setfont\textsl\slshape{10}{\mainmagstep} \setfont\textsf\sfshape{10}{\mainmagstep} \setfont\textsc\scshape{10}{\mainmagstep} \setfont\textttsl\ttslshape{10}{\mainmagstep} \font\texti=cmmi10 scaled \mainmagstep \font\textsy=cmsy10 scaled \mainmagstep % A few fonts for @defun, etc. \setfont\defbf\bxshape{10}{\magstep1} %was 1314 \setfont\deftt\ttshape{10}{\magstep1} \def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} % Fonts for indices, footnotes, small examples (9pt). \setfont\smallrm\rmshape{9}{1000} \setfont\smalltt\ttshape{9}{1000} \setfont\smallbf\bfshape{10}{900} \setfont\smallit\itshape{9}{1000} \setfont\smallsl\slshape{9}{1000} \setfont\smallsf\sfshape{9}{1000} \setfont\smallsc\scshape{10}{900} \setfont\smallttsl\ttslshape{10}{900} \font\smalli=cmmi9 \font\smallsy=cmsy9 % Fonts for small examples (8pt). \setfont\smallerrm\rmshape{8}{1000} \setfont\smallertt\ttshape{8}{1000} \setfont\smallerbf\bfshape{10}{800} \setfont\smallerit\itshape{8}{1000} \setfont\smallersl\slshape{8}{1000} \setfont\smallersf\sfshape{8}{1000} \setfont\smallersc\scshape{10}{800} \setfont\smallerttsl\ttslshape{10}{800} \font\smalleri=cmmi8 \font\smallersy=cmsy8 % Fonts for title page: \setfont\titlerm\rmbshape{12}{\magstep3} \setfont\titleit\itbshape{10}{\magstep4} \setfont\titlesl\slbshape{10}{\magstep4} \setfont\titlett\ttbshape{12}{\magstep3} \setfont\titlettsl\ttslshape{10}{\magstep4} \setfont\titlesf\sfbshape{17}{\magstep1} \let\titlebf=\titlerm \setfont\titlesc\scbshape{10}{\magstep4} \font\titlei=cmmi12 scaled \magstep3 \font\titlesy=cmsy10 scaled \magstep4 \def\authorrm{\secrm} \def\authortt{\sectt} % Chapter (and unnumbered) fonts (17.28pt). \setfont\chaprm\rmbshape{12}{\magstep2} \setfont\chapit\itbshape{10}{\magstep3} \setfont\chapsl\slbshape{10}{\magstep3} \setfont\chaptt\ttbshape{12}{\magstep2} \setfont\chapttsl\ttslshape{10}{\magstep3} \setfont\chapsf\sfbshape{17}{1000} \let\chapbf=\chaprm \setfont\chapsc\scbshape{10}{\magstep3} \font\chapi=cmmi12 scaled \magstep2 \font\chapsy=cmsy10 scaled \magstep3 % Section fonts (14.4pt). \setfont\secrm\rmbshape{12}{\magstep1} \setfont\secit\itbshape{10}{\magstep2} \setfont\secsl\slbshape{10}{\magstep2} \setfont\sectt\ttbshape{12}{\magstep1} \setfont\secttsl\ttslshape{10}{\magstep2} \setfont\secsf\sfbshape{12}{\magstep1} \let\secbf\secrm \setfont\secsc\scbshape{10}{\magstep2} \font\seci=cmmi12 scaled \magstep1 \font\secsy=cmsy10 scaled \magstep2 % Subsection fonts (13.15pt). \setfont\ssecrm\rmbshape{12}{\magstephalf} \setfont\ssecit\itbshape{10}{1315} \setfont\ssecsl\slbshape{10}{1315} \setfont\ssectt\ttbshape{12}{\magstephalf} \setfont\ssecttsl\ttslshape{10}{1315} \setfont\ssecsf\sfbshape{12}{\magstephalf} \let\ssecbf\ssecrm \setfont\ssecsc\scbshape{10}{\magstep1} \font\sseci=cmmi12 scaled \magstephalf \font\ssecsy=cmsy10 scaled 1315 % The smallcaps and symbol fonts should actually be scaled \magstep1.5, % but that is not a standard magnification. % 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 except % in the main text, 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 font. Plain TeX does \def\bf{\fam=\bffam % \tenbf}, for example. 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 \let\tenttsl=\textttsl \resetmathfonts \setleading{\textleading}} \def\titlefonts{% \let\tenrm=\titlerm \let\tenit=\titleit \let\tensl=\titlesl \let\tenbf=\titlebf \let\tentt=\titlett \let\smallcaps=\titlesc \let\tensf=\titlesf \let\teni=\titlei \let\tensy=\titlesy \let\tenttsl=\titlettsl \resetmathfonts \setleading{25pt}} \def\titlefont#1{{\titlefonts\rm #1}} \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 \let\tenttsl=\chapttsl \resetmathfonts \setleading{19pt}} \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 \let\tenttsl=\secttsl \resetmathfonts \setleading{16pt}} \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 \let\tenttsl=\ssecttsl \resetmathfonts \setleading{15pt}} \let\subsubsecfonts = \subsecfonts % Maybe make sssec fonts scaled magstephalf? \def\smallfonts{% \let\tenrm=\smallrm \let\tenit=\smallit \let\tensl=\smallsl \let\tenbf=\smallbf \let\tentt=\smalltt \let\smallcaps=\smallsc \let\tensf=\smallsf \let\teni=\smalli \let\tensy=\smallsy \let\tenttsl=\smallttsl \resetmathfonts \setleading{10.5pt}} \def\smallerfonts{% \let\tenrm=\smallerrm \let\tenit=\smallerit \let\tensl=\smallersl \let\tenbf=\smallerbf \let\tentt=\smallertt \let\smallcaps=\smallersc \let\tensf=\smallersf \let\teni=\smalleri \let\tensy=\smallersy \let\tenttsl=\smallerttsl \resetmathfonts \setleading{9.5pt}} % Set the fonts to use with the @small... environments. \let\smallexamplefonts = \smallfonts % About \smallexamplefonts. If we use \smallfonts (9pt), @smallexample % can fit this many characters: % 8.5x11=86 smallbook=72 a4=90 a5=69 % If we use \smallerfonts (8pt), then we can fit this many characters: % 8.5x11=90+ smallbook=80 a4=90+ a5=77 % For me, subjectively, the few extra characters that fit aren't worth % the additional smallness of 8pt. So I'm making the default 9pt. % % By the way, for comparison, here's what fits with @example (10pt): % 8.5x11=71 smallbook=60 a4=75 a5=58 % % I wish we used A4 paper on this side of the Atlantic. % % --karl, 24jan03. % Set up the default fonts, so we can use them for creating boxes. % \textfonts % Define these so they can be easily changed for other fonts. \def\angleleft{$\langle$} \def\angleright{$\rangle$} % Count depth in font-changes, for error checks \newcount\fontdepth \fontdepth=0 % Fonts for short table of contents. \setfont\shortcontrm\rmshape{12}{1000} \setfont\shortcontbf\bxshape{12}{1000} \setfont\shortcontsl\slshape{12}{1000} \setfont\shortconttt\ttshape{12}{1000} %% 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\smartslanted#1{{\ifusingtt\ttsl\sl #1}\futurelet\next\smartitalicx} \def\smartitalic#1{{\ifusingtt\ttsl\it #1}\futurelet\next\smartitalicx} \let\i=\smartitalic \let\var=\smartslanted \let\dfn=\smartslanted \let\emph=\smartitalic \let\cite=\smartslanted \def\b#1{{\bf #1}} \let\strong=\b % We can't just use \exhyphenpenalty, because that only has effect at % the end of a paragraph. Restore normal hyphenation at the end of the % group within which \nohyphenation is presumably called. % \def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} \def\restorehyphenation{\hyphenchar\font = `- } % Set sfcode to normal for the chars that usually have another value. % Can't use plain's \frenchspacing because it uses the `\x notation, and % sometimes \x has an active definition that messes things up. % \catcode`@=11 \def\frenchspacing{% \sfcode\dotChar =\@m \sfcode\questChar=\@m \sfcode\exclamChar=\@m \sfcode\colonChar=\@m \sfcode\semiChar =\@m \sfcode\commaChar =\@m } \catcode`@=\other \def\t#1{% {\tt \rawbackslash \frenchspacing #1}% \null } \let\ttfont=\t \def\samp#1{`\tclose{#1}'\null} \setfont\keyrm\rmshape{8}{1000} \font\keysy=cmsy9 \def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% \vbox{\hrule\kern-0.4pt \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% \kern-0.4pt\hrule}% \kern-.06em\raise0.4pt\hbox{\angleright}}}} % The old definition, with no lozenge: %\def\key #1{{\ttsl \nohyphenation \uppercase{#1}}\null} \def\ctrl #1{{\tt \rawbackslash \hat}#1} % @file, @option are the same as @samp. \let\file=\samp \let\option=\samp % @code is a modification of @t, % which makes spaces the same size as normal in the surrounding text. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. \spaceskip = \fontdimen2\font % % Switch to typewriter. \tt % % But `\ ' produces the large typewriter interword space. \def\ {{\spaceskip = 0pt{} }}% % % Turn off hyphenation. \nohyphenation % \rawbackslash \frenchspacing #1% }% \null } % We *must* turn on hyphenation at `-' and `_' in \code. % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) % and arrange explicitly to hyphenate at a dash. % -- rms. { \catcode`\-=\active \catcode`\_=\active % \global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex } % % If we end up with any active - characters when handling the index, % just treat them as a normal -. \global\def\indexbreaks{\catcode`\-=\active \let-\realdash} } \def\realdash{-} \def\codedash{-\discretionary{}{}{}} \def\codeunder{% % this is all so @math{@code{var_name}+1} can work. In math mode, _ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) % will therefore expand the active definition of _, which is us % (inside @code that is), therefore an endless loop. \ifusingtt{\ifmmode \mathchar"075F % class 0=ordinary, family 7=ttfam, pos 0x5F=_. \else\normalunderscore \fi \discretionary{}{}{}}% {\_}% } \def\codex #1{\tclose{#1}\endgroup} % @kbd is like @code, except that if the argument is just one @key command, % then @kbd has no effect. % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). \def\kbdinputstyle{\parsearg\kbdinputstylexxx} \def\kbdinputstylexxx#1{% \def\arg{#1}% \ifx\arg\worddistinct \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\ttsl}% \else\ifx\arg\wordexample \gdef\kbdexamplefont{\ttsl}\gdef\kbdfont{\tt}% \else\ifx\arg\wordcode \gdef\kbdexamplefont{\tt}\gdef\kbdfont{\tt}% \else \errhelp = \EMsimple \errmessage{Unknown @kbdinputstyle `\arg'}% \fi\fi\fi } \def\worddistinct{distinct} \def\wordexample{example} \def\wordcode{code} % Default is `distinct.' \kbdinputstyle distinct \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{\kbdfont\look}}\fi \else{\tclose{\kbdfont\look}}\fi} % For @url, @env, @command quotes seem unnecessary, so use \code. \let\url=\code \let\env=\code \let\command=\code % @uref (abbreviation for `urlref') takes an optional (comma-separated) % second argument specifying the text to display and an optional third % arg as text to display instead of (rather than in addition to) the url % itself. First (mandatory) arg is the url. Perhaps eventually put in % a hypertex \special here. % \def\uref#1{\douref #1,,,\finish} \def\douref#1,#2,#3,#4\finish{\begingroup \unsepspaces \pdfurl{#1}% \setbox0 = \hbox{\ignorespaces #3}% \ifdim\wd0 > 0pt \unhbox0 % third arg given, show only that \else \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0 > 0pt \ifpdf \unhbox0 % PDF: 2nd arg given, show only it \else \unhbox0\ (\code{#1})% DVI: 2nd arg given, show both it and url \fi \else \code{#1}% only url given, so show it \fi \fi \endlink \endgroup} % rms does not like angle brackets --karl, 17may97. % So now @email is just like @uref, unless we are pdf. % %\def\email#1{\angleleft{\tt #1}\angleright} \ifpdf \def\email#1{\doemail#1,,\finish} \def\doemail#1,#2,#3\finish{\begingroup \unsepspaces \pdfurl{mailto:#1}% \setbox0 = \hbox{\ignorespaces #2}% \ifdim\wd0>0pt\unhbox0\else\code{#1}\fi \endlink \endgroup} \else \let\email=\uref \fi % Check if we are currently using a typewriter font. 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 property, we can check that font parameter. % \def\ifmonospace{\ifdim\fontdimen3\font=0pt } % 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} % @l was never documented to mean ``switch to the Lisp font'', % and it is not used as such in any manual I can find. We need it for % Polish suppressed-l. --karl, 22sep96. %\def\l#1{{\li #1}\null} % Explicit font changes: @r, @sc, undocumented @ii. \def\r#1{{\rm #1}} % roman font \def\sc#1{{\smallcaps#1}} % smallcaps font \def\ii#1{{\it #1}} % italic font % @acronym downcases the argument and prints in smallcaps. \def\acronym#1{{\smallcaps \lowercase{#1}}} % @pounds{} is a sterling sign. \def\pounds{{\it\$}} % @registeredsymbol - R in a circle. For now, only works in text size; % we'd have to redo the font mechanism to change the \scriptstyle and % \scriptscriptstyle font sizes to make it look right in headings. % Adapted from the plain.tex definition of \copyright. % \def\registeredsymbol{% $^{{\ooalign{\hfil\raise.07ex\hbox{$\scriptstyle\rm R$}\hfil\crcr\Orb}}% }$% } \message{page headings,} \newskip\titlepagetopglue \titlepagetopglue = 1.5in \newskip\titlepagebottomglue \titlepagebottomglue = 2pc % First the title page. Must do @settitle before @titlepage. \newif\ifseenauthor \newif\iffinishedtitlepage % Do an implicit @contents or @shortcontents after @end titlepage if the % user says @setcontentsaftertitlepage or @setshortcontentsaftertitlepage. % \newif\ifsetcontentsaftertitlepage \let\setcontentsaftertitlepage = \setcontentsaftertitlepagetrue \newif\ifsetshortcontentsaftertitlepage \let\setshortcontentsaftertitlepage = \setshortcontentsaftertitlepagetrue \def\shorttitlepage{\parsearg\shorttitlepagezzz} \def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% \endgroup\page\hbox{}\page} \def\titlepage{\begingroup \parindent=0pt \textfonts \let\subtitlerm=\tenrm \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% % \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines \let\tt=\authortt}% % % 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{\titlefonts\rm ##1} % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \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 % % Need this before the \...aftertitlepage checks so that if they are % in effect the toc pages will come out with page numbers. \HEADINGSon % % If they want short, they certainly want long too. \ifsetshortcontentsaftertitlepage \shortcontents \contents \global\let\shortcontents = \relax \global\let\contents = \relax \fi % \ifsetcontentsaftertitlepage \contents \global\let\contents = \relax \global\let\shortcontents = \relax \fi } \def\finishtitlepage{% \vskip4pt \hrule height 2pt width \hsize \vskip\titlepagebottomglue \finishedtitlepagetrue } %%% Set up page headings and footings. \let\thispage=\folio \newtoks\evenheadline % headline on even pages \newtoks\oddheadline % headline on odd pages \newtoks\evenfootline % footline on even pages \newtoks\oddfootline % footline on 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{\oddheadingxxx{#1}\evenheadingxxx{#1}}% \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}}% % % Leave some space for the footline. Hopefully ok to assume % @evenfooting will not be used by itself. \global\advance\pageheight by -\baselineskip \global\advance\vsize by -\baselineskip } \gdef\everyfootingxxx#1{\oddfootingxxx{#1}\evenfootingxxx{#1}} % }% 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 at the start of a document, % and turned `on' after @end titlepage. \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{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\folio\hfil\thistitle}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chapoddpage } \let\contentsalignmacro = \chappager % For single-sided printing, chapter title goes across top left of page, % page number on top right. \def\HEADINGSsingle{ \global\pageno=1 \global\evenfootline={\hfil} \global\oddfootline={\hfil} \global\evenheadline={\line{\thischapter\hfil\folio}} \global\oddheadline={\line{\thischapter\hfil\folio}} \global\let\contentsalignmacro = \chappager } \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}} \global\let\contentsalignmacro = \chapoddpage } \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}} \global\let\contentsalignmacro = \chappager } % Subroutines used in generating headings % This produces Day Month Year style of output. % Only define if not already defined, in case a txi-??.tex file has set % up a different format (e.g., txi-cs.tex does this). \ifx\today\undefined \def\today{% \number\day\space \ifcase\month \or\putwordMJan\or\putwordMFeb\or\putwordMMar\or\putwordMApr \or\putwordMMay\or\putwordMJun\or\putwordMJul\or\putwordMAug \or\putwordMSep\or\putwordMOct\or\putwordMNov\or\putwordMDec \fi \space\number\year} \fi % @settitle line... specifies the title of the document, for headings. % It generates no output of its own. \def\thistitle{\putwordNoTitle} \def\settitle{\parsearg\settitlezzz} \def\settitlezzz #1{\gdef\thistitle{#1}} \message{tables,} % 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). \newif\ifitemxneedsnegativevskip \def\itemxpar{\par\ifitemxneedsnegativevskip\nobreak\vskip-\parskip\nobreak\fi} \def\internalBitem{\smallbreak \parsearg\itemzzz} \def\internalBitemx{\itemxpar \parsearg\itemzzz} \def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} \def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} \def\internalBkitem{\smallbreak \parsearg\kitemzzz} \def\internalBkitemx{\itemxpar \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. % % 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 % % Make this a paragraph so we get the \parskip glue and wrapping, % but leave it ragged-right. \begingroup \advance\leftskip by-\tableindent \advance\hsize by\tableindent \advance\rightskip by0pt plus1fil \leavevmode\unhbox0\par \endgroup % % We're going to be starting a paragraph, but we don't want the % \parskip glue -- logically it's part of the @item we just started. \nobreak \vskip-\parskip % % Stop a page break at the \parskip glue coming up. (Unfortunately % we can't prevent a possible page break at the following % \baselineskip glue.) However, if what follows is an environment % such as @example, there will be no \parskip glue; then % the negative vskip we just would cause the example and the item to % crash together. So we use this bizarre value of 10001 as a signal % to \aboveenvbreak to insert \parskip glue after all. % (Possibly there are other commands that could be followed by % @example which need the same treatment, but not section titles; or % maybe section titles are the only special case and they should be % penalty 10001...) \penalty 10001 \endgroup \itemxneedsnegativevskipfalse \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. \noindent % Do this with kerns and \unhbox so that if there is a footnote in % the item text, it can migrate to the main vertical list and % eventually be printed. \nobreak\kern-\tableindent \dimen0 = \itemmax \advance\dimen0 by \itemmargin \advance\dimen0 by -\wd0 \unhbox0 \nobreak\kern\dimen0 \endgroup \itemxneedsnegativevskiptrue \fi } \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}{}{}{}{}} % @table, @ftable, @vtable. \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\afterenvbreak\endgroup}% \let\Etable=\relax}} \def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} {\obeylines\obeyspaces% \gdef\vtablex #1^^M{% \tabley\vritemindex#1 \endtabley \def\Evtable{\endgraf\afterenvbreak\endgroup}% \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}% Necessary 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\afterenvbreak\endgroup}% \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 itemize \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\afterenvbreak\endgroup}% \def\itemcontents{#1}% \let\item=\itemizeitem} % \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} % @multitable macros % Amy Hendrickson, 8/18/94, 3/6/96 % % @multitable ... @end multitable will make as many columns as desired. % Contents of each column will wrap at width given in preamble. Width % can be specified either with sample text given in a template line, % or in percent of \hsize, the current width of text on page. % Table can continue over pages but will only break between lines. % To make preamble: % % Either define widths of columns in terms of percent of \hsize: % @multitable @columnfractions .25 .3 .45 % @item ... % % Numbers following @columnfractions are the percent of the total % current hsize to be used for each column. You may use as many % columns as desired. % Or use a template: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item ... % using the widest term desired in each column. % % For those who want to use more than one line's worth of words in % the preamble, break the line within one argument and it % will parse correctly, i.e., % % @multitable {Column 1 template} {Column 2 template} {Column 3 % template} % Not: % @multitable {Column 1 template} {Column 2 template} % {Column 3 template} % Each new table line starts with @item, each subsequent new column % starts with @tab. Empty columns may be produced by supplying @tab's % with nothing between them for as many times as empty columns are needed, % ie, @tab@tab@tab will produce two empty columns. % @item, @tab, @multitable or @end multitable do not need to be on their % own lines, but it will not hurt if they are. % Sample multitable: % @multitable {Column 1 template} {Column 2 template} {Column 3 template} % @item first col stuff @tab second col stuff @tab third col % @item % first col stuff % @tab % second col stuff % @tab % third col % @item first col stuff @tab second col stuff % @tab Many paragraphs of text may be used in any column. % % They will wrap at the width determined by the template. % @item@tab@tab This will be in third column. % @end multitable % Default dimensions may be reset by user. % @multitableparskip is vertical space between paragraphs in table. % @multitableparindent is paragraph indent in table. % @multitablecolmargin is horizontal space to be left between columns. % @multitablelinespace is space to leave between table items, baseline % to baseline. % 0pt means it depends on current normal line spacing. % \newskip\multitableparskip \newskip\multitableparindent \newdimen\multitablecolspace \newskip\multitablelinespace \multitableparskip=0pt \multitableparindent=6pt \multitablecolspace=12pt \multitablelinespace=0pt % Macros used to set up halign preamble: % \let\endsetuptable\relax \def\xendsetuptable{\endsetuptable} \let\columnfractions\relax \def\xcolumnfractions{\columnfractions} \newif\ifsetpercent % #1 is the part of the @columnfraction before the decimal point, which % is presumably either 0 or the empty string (but we don't check, we % just throw it away). #2 is the decimal part, which we use as the % percent of \hsize for this column. \def\pickupwholefraction#1.#2 {% \global\advance\colcount by 1 \expandafter\xdef\csname col\the\colcount\endcsname{.#2\hsize}% \setuptable } \newcount\colcount \def\setuptable#1{% \def\firstarg{#1}% \ifx\firstarg\xendsetuptable \let\go = \relax \else \ifx\firstarg\xcolumnfractions \global\setpercenttrue \else \ifsetpercent \let\go\pickupwholefraction \else \global\advance\colcount by 1 \setbox0=\hbox{#1\unskip\space}% Add a normal word space as a % separator; typically that is always in the input, anyway. \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% \fi \fi \ifx\go\pickupwholefraction % Put the argument back for the \pickupwholefraction call, so % we'll always have a period there to be parsed. \def\go{\pickupwholefraction#1}% \else \let\go = \setuptable \fi% \fi \go } % @multitable ... @end multitable definitions: % \def\multitable{\parsearg\dotable} \def\dotable#1{\bgroup \vskip\parskip \let\item=\crcrwithfootnotes % A \tab used to include \hskip1sp. But then the space in a template % line is not enough. That is bad. So let's go back to just & until % we encounter the problem it was intended to solve again. --karl, % nathan@acm.org, 20apr99. \let\tab=&% \let\startfootins=\startsavedfootnote \tolerance=9500 \hbadness=9500 \setmultitablespacing \parskip=\multitableparskip \parindent=\multitableparindent \overfullrule=0pt \global\colcount=0 \def\Emultitable{% \global\setpercentfalse \crcrwithfootnotes\crcr \egroup\egroup }% % % To parse everything between @multitable and @item: \setuptable#1 \endsetuptable % % \everycr will reset column counter, \colcount, at the end of % each line. Every column entry will cause \colcount to advance by one. % The table preamble % looks at the current \colcount to find the correct column width. \everycr{\noalign{% % % \filbreak%% keeps underfull box messages off when table breaks over pages. % Maybe so, but it also creates really weird page breaks when the table % breaks over pages. Wouldn't \vfil be better? Wait until the problem % manifests itself, so it can be fixed for real --karl. \global\colcount=0\relax}}% % % This preamble sets up a generic column definition, which will % be used as many times as user calls for columns. % \vtop will set a single line and will also let text wrap and % continue for many paragraphs if desired. \halign\bgroup&\global\advance\colcount by 1\relax \multistrut\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname % % In order to keep entries from bumping into each other % we will add a \leftskip of \multitablecolspace to all columns after % the first one. % % If a template has been used, we will add \multitablecolspace % to the width of each template entry. % % If the user has set preamble in terms of percent of \hsize we will % use that dimension as the width of the column, and the \leftskip % will keep entries from bumping into each other. Table will start at % left margin and final column will justify at right margin. % % Make sure we don't inherit \rightskip from the outer environment. \rightskip=0pt \ifnum\colcount=1 % The first column will be indented with the surrounding text. \advance\hsize by\leftskip \else \ifsetpercent \else % If user has not set preamble in terms of percent of \hsize % we will advance \hsize by \multitablecolspace. \advance\hsize by \multitablecolspace \fi % In either case we will make \leftskip=\multitablecolspace: \leftskip=\multitablecolspace \fi % Ignoring space at the beginning and end avoids an occasional spurious % blank line, when TeX decides to break the line at the space before the % box from the multistrut, so the strut ends up on a line by itself. % For example: % @multitable @columnfractions .11 .89 % @item @code{#} % @tab Legal holiday which is valid in major parts of the whole country. % Is automatically provided with highlighting sequences respectively marking % characters. \noindent\ignorespaces##\unskip\multistrut}\cr } \def\setmultitablespacing{% test to see if user has set \multitablelinespace. % If so, do nothing. If not, give it an appropriate dimension based on % current baselineskip. \ifdim\multitablelinespace=0pt \setbox0=\vbox{X}\global\multitablelinespace=\the\baselineskip \global\advance\multitablelinespace by-\ht0 %% strut to put in table in case some entry doesn't have descenders, %% to keep lines equally spaced \let\multistrut = \strut \else %% FIXME: what is \box0 supposed to be? \gdef\multistrut{\vrule height\multitablelinespace depth\dp0 width0pt\relax} \fi %% Test to see if parskip is larger than space between lines of %% table. If not, do nothing. %% If so, set to same dimension as multitablelinespace. \ifdim\multitableparskip>\multitablelinespace \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi% \ifdim\multitableparskip=0pt \global\multitableparskip=\multitablelinespace \global\advance\multitableparskip-7pt %% to keep parskip somewhat smaller %% than skip between lines in the table. \fi} % In case a @footnote appears inside an alignment, save the footnote % text to a box and make the \insert when a row of the table is % finished. Otherwise, the insertion is lost, it never migrates to the % main vertical list. --kasal, 22jan03. % \newbox\savedfootnotes % % \dotable \let's \startfootins to this, so that \dofootnote will call % it instead of starting the insertion right away. \def\startsavedfootnote{% \global\setbox\savedfootnotes = \vbox\bgroup \unvbox\savedfootnotes } \def\crcrwithfootnotes{% \crcr \ifvoid\savedfootnotes \else \noalign{\insert\footins{\box\savedfootnotes}}% \fi } \message{conditionals,} % 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 } % Used in nested conditionals, where we have to parse the Texinfo source % and so want to turn off most commands, in case they are used % incorrectly. % % We use \empty instead of \relax for the @def... commands, so that \end % doesn't throw an error. For instance: % @ignore % @deffn ... % @end deffn % @end ignore % % The @end deffn is going to get expanded, because we're trying to allow % nested conditionals. But we don't want to expand the actual @deffn, % since it might be syntactically correct and intended to be ignored. % Since \end checks for \relax, using \empty does not cause an error. % \def\ignoremorecommands{% \let\defcodeindex = \relax \let\defcv = \empty \let\defcvx = \empty \let\Edefcv = \empty \let\deffn = \empty \let\deffnx = \empty \let\Edeffn = \empty \let\defindex = \relax \let\defivar = \empty \let\defivarx = \empty \let\Edefivar = \empty \let\defmac = \empty \let\defmacx = \empty \let\Edefmac = \empty \let\defmethod = \empty \let\defmethodx = \empty \let\Edefmethod = \empty \let\defop = \empty \let\defopx = \empty \let\Edefop = \empty \let\defopt = \empty \let\defoptx = \empty \let\Edefopt = \empty \let\defspec = \empty \let\defspecx = \empty \let\Edefspec = \empty \let\deftp = \empty \let\deftpx = \empty \let\Edeftp = \empty \let\deftypefn = \empty \let\deftypefnx = \empty \let\Edeftypefn = \empty \let\deftypefun = \empty \let\deftypefunx = \empty \let\Edeftypefun = \empty \let\deftypeivar = \empty \let\deftypeivarx = \empty \let\Edeftypeivar = \empty \let\deftypemethod = \empty \let\deftypemethodx = \empty \let\Edeftypemethod = \empty \let\deftypeop = \empty \let\deftypeopx = \empty \let\Edeftypeop = \empty \let\deftypevar = \empty \let\deftypevarx = \empty \let\Edeftypevar = \empty \let\deftypevr = \empty \let\deftypevrx = \empty \let\Edeftypevr = \empty \let\defun = \empty \let\defunx = \empty \let\Edefun = \empty \let\defvar = \empty \let\defvarx = \empty \let\Edefvar = \empty \let\defvr = \empty \let\defvrx = \empty \let\Edefvr = \empty \let\clear = \relax \let\down = \relax \let\evenfooting = \relax \let\evenheading = \relax \let\everyfooting = \relax \let\everyheading = \relax \let\headings = \relax \let\include = \relax \let\item = \relax \let\lowersections = \relax \let\oddfooting = \relax \let\oddheading = \relax \let\printindex = \relax \let\pxref = \relax \let\raisesections = \relax \let\ref = \relax \let\set = \relax \let\setchapternewpage = \relax \let\setchapterstyle = \relax \let\settitle = \relax \let\up = \relax \let\verbatiminclude = \relax \let\xref = \relax } % Ignore @ignore, @ifhtml, @ifinfo, and the like. % \def\direntry{\doignore{direntry}} \def\documentdescriptionword{documentdescription} \def\documentdescription{\doignore{documentdescription}} \def\html{\doignore{html}} \def\ifhtml{\doignore{ifhtml}} \def\ifinfo{\doignore{ifinfo}} \def\ifnottex{\doignore{ifnottex}} \def\ifplaintext{\doignore{ifplaintext}} \def\ifxml{\doignore{ifxml}} \def\ignore{\doignore{ignore}} \def\menu{\doignore{menu}} \def\xml{\doignore{xml}} % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory = \comment % Ignore text until a line `@end #1'. % \def\doignore#1{\begingroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define a command to swallow text until we reach `@end #1'. % This @ is a catcode 12 token (that is the normal catcode of @ in % this texinfo.tex file). We change the catcode of @ below to match. \long\def\doignoretext##1@end #1{\enddoignore}% % % Make sure that spaces turn into tokens that match what \doignoretext wants. \catcode\spaceChar = 10 % % Ignore braces, too, so mismatched braces don't cause trouble. \catcode`\{ = 9 \catcode`\} = 9 % % We must not have @c interpreted as a control sequence. \catcode`\@ = 12 % \def\ignoreword{#1}% \ifx\ignoreword\documentdescriptionword % The c kludge breaks documentdescription, since % `documentdescription' contains a `c'. Means not everything will % be ignored inside @documentdescription, but oh well... \else % Make the letter c a comment character so that the rest of the line % will be ignored. This way, the document can have (for example) % @c @end ifinfo % and the @end ifinfo will be properly ignored. % (We've just changed @ to catcode 12.) \catcode`\c = 14 \fi % % And now expand the command defined above. \doignoretext } % What we do to finish off ignored text. % \def\enddoignore{\endgroup\ignorespaces}% \newif\ifwarnedobs\warnedobsfalse \def\obstexwarn{% \ifwarnedobs\relax\else % We need to warn folks that they may have trouble with TeX 3.0. % This uses \immediate\write16 rather than \message to get newlines. \immediate\write16{} \immediate\write16{WARNING: for users of Unix TeX 3.0!} \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} \immediate\write16{If you are running another version of TeX, relax.} \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} \immediate\write16{ Then upgrade your TeX installation if you can.} \immediate\write16{ (See ftp://ftp.gnu.org/non-gnu/TeX.README.)} \immediate\write16{If you are stuck with version 3.0, run the} \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} \immediate\write16{ to use a workaround.} \immediate\write16{} \global\warnedobstrue \fi } % **In TeX 3.0, setting text in \nullfont hangs tex. For a % workaround (which requires the file ``dummy.tfm'' to be installed), % uncomment the following line: %%%%%\font\nullfont=dummy\let\obstexwarn=\relax % Ignore text, except that we keep track of conditional commands for % purposes of nesting, up to an `@end #1' command. % \def\nestedignore#1{% \obstexwarn % We must actually expand the ignored text to look for the @end % command, so that nested ignore constructs work. Thus, we put the % text into a \vbox and then do nothing with the result. To minimize % the chance of memory overflow, we follow the approach outlined on % page 401 of the TeXbook. % \setbox0 = \vbox\bgroup % Don't complain about control sequences we have declared \outer. \ignoresections % % Define `@end #1' to end the box, which will in turn undefine the % @end command again. \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% % % We are going to be parsing Texinfo commands. Most cause no % trouble when they are used incorrectly, but some commands do % complicated argument parsing or otherwise get confused, so we % undefine them. % % We can't do anything about stray @-signs, unfortunately; % they'll produce `undefined control sequence' errors. \ignoremorecommands % % Set the current font to be \nullfont, a TeX primitive, and define % all the font commands to also use \nullfont. We don't use % dummy.tfm, as suggested in the TeXbook, because some sites % might not have that installed. Therefore, math mode will still % produce output, but that should be an extremely small amount of % stuff compared to the main input. % \nullfont \let\tenrm=\nullfont \let\tenit=\nullfont \let\tensl=\nullfont \let\tenbf=\nullfont \let\tentt=\nullfont \let\smallcaps=\nullfont \let\tensf=\nullfont % Similarly for index fonts. \let\smallrm=\nullfont \let\smallit=\nullfont \let\smallsl=\nullfont \let\smallbf=\nullfont \let\smalltt=\nullfont \let\smallsc=\nullfont \let\smallsf=\nullfont % Similarly for smallexample fonts. \let\smallerrm=\nullfont \let\smallerit=\nullfont \let\smallersl=\nullfont \let\smallerbf=\nullfont \let\smallertt=\nullfont \let\smallersc=\nullfont \let\smallersf=\nullfont % % Don't complain when characters are missing from the fonts. \tracinglostchars = 0 % % Don't bother to do space factor calculations. \frenchspacing % % Don't report underfull hboxes. \hbadness = 10000 % % Do minimal line-breaking. \pretolerance = 10000 % % Do not execute instructions in @tex. \def\tex{\doignore{tex}}% % Do not execute macro definitions. % `c' is a comment character, so the word `macro' will get cut off. \def\macro{\doignore{ma}}% } % @set VAR sets the variable VAR to an empty value. % @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. % % Since we want to separate VAR from REST-OF-LINE (which might be % empty), we can't just use \parsearg; we have to insert a space of our % own to delimit the rest of the line, and then take it out again if we % didn't need it. Make sure the catcode of space is correct to avoid % losing inside @example, for instance. % \def\set{\begingroup\catcode` =10 \catcode`\-=12 \catcode`\_=12 % Allow - and _ in VAR. \parsearg\setxxx} \def\setxxx#1{\setyyy#1 \endsetyyy} \def\setyyy#1 #2\endsetyyy{% \def\temp{#2}% \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. \fi \endgroup } % Can't use \xdef to pre-expand #2 and save some time, since \temp or % \next or other control sequences that we've defined might get us into % an infinite loop. Consider `@set foo @cite{bar}'. \def\setzzz#1#2 \endsetzzz{\expandafter\gdef\csname SET#1\endcsname{#2}} % @clear VAR clears (i.e., unsets) the variable VAR. % \def\clear{\parsearg\clearxxx} \def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} % @value{foo} gets the text saved in variable foo. { \catcode`\_ = \active % % We might end up with active _ or - characters in the argument if % we're called from @code, as @code{@value{foo-bar_}}. So \let any % such active characters to their normal equivalents. \gdef\value{\begingroup \catcode`\-=\other \catcode`\_=\other \indexbreaks \let_\normalunderscore \valuexxx} } \def\valuexxx#1{\expandablevalue{#1}\endgroup} % We have this subroutine so that we can handle at least some @value's % properly in indexes (we \let\value to this in \indexdummies). Ones % whose names contain - or _ still won't work, but we can't do anything % about that. The command has to be fully expandable (if the variable % is set), since the result winds up in the index file. This means that % if the variable's value contains other Texinfo commands, it's almost % certain it will fail (although perhaps we could fix that with % sufficient work to do a one-level expansion on the result, instead of % complete). % \def\expandablevalue#1{% \expandafter\ifx\csname SET#1\endcsname\relax {[No value for ``#1'']}% \message{Variable `#1', used in @value, is not set.}% \else \csname SET#1\endcsname \fi } % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % \def\ifset{\parsearg\doifset} \def\doifset#1{% \expandafter\ifx\csname SET#1\endcsname\relax \let\next=\ifsetfail \else \let\next=\ifsetsucceed \fi \next } \def\ifsetsucceed{\conditionalsucceed{ifset}} \def\ifsetfail{\nestedignore{ifset}} \defineunmatchedend{ifset} % @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % \def\ifclear{\parsearg\doifclear} \def\doifclear#1{% \expandafter\ifx\csname SET#1\endcsname\relax \let\next=\ifclearsucceed \else \let\next=\ifclearfail \fi \next } \def\ifclearsucceed{\conditionalsucceed{ifclear}} \def\ifclearfail{\nestedignore{ifclear}} \defineunmatchedend{ifclear} % @iftex, @ifnothtml, @ifnotinfo, @ifnotplaintext always succeed; we % read the text following, through the first @end iftex (etc.). Make % `@end iftex' (etc.) valid only after an @iftex. % \def\iftex{\conditionalsucceed{iftex}} \def\ifnothtml{\conditionalsucceed{ifnothtml}} \def\ifnotinfo{\conditionalsucceed{ifnotinfo}} \def\ifnotplaintext{\conditionalsucceed{ifnotplaintext}} \defineunmatchedend{iftex} \defineunmatchedend{ifnothtml} \defineunmatchedend{ifnotinfo} \defineunmatchedend{ifnotplaintext} % True conditional. Since \set globally defines its variables, we can % just start and end a group (to keep the @end definition undefined at % the outer level). % \def\conditionalsucceed#1{\begingroup \expandafter\def\csname E#1\endcsname{\endgroup}% } % @defininfoenclose. \let\definfoenclose=\comment \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{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 % Open the file \fi \expandafter\xdef\csname#1index\endcsname{% % Define @#1index \noexpand\doindex{#1}} } % @defindex foo == \newindex{foo} % \def\defindex{\parsearg\newindex} % Define @defcodeindex, like @defindex except put all entries in @code. % \def\defcodeindex{\parsearg\newcodeindex} % \def\newcodeindex#1{% \iflinks \expandafter\newwrite \csname#1indfile\endcsname \openout \csname#1indfile\endcsname \jobname.#1 \fi \expandafter\xdef\csname#1index\endcsname{% \noexpand\docodeindex{#1}}% } % @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. % % @syncodeindex foo bar similar, but put all entries made for index foo % inside @code. % \def\synindex#1 #2 {\dosynindex\doindex{#1}{#2}} \def\syncodeindex#1 #2 {\dosynindex\docodeindex{#1}{#2}} % #1 is \doindex or \docodeindex, #2 the index getting redefined (foo), % #3 the target index (bar). \def\dosynindex#1#2#3{% % Only do \closeout if we haven't already done it, else we'll end up % closing the target index. \expandafter \ifx\csname donesynindex#2\endcsname \undefined % The \closeout helps reduce unnecessary open files; the limit on the % Acorn RISC OS is a mere 16 files. \expandafter\closeout\csname#2indfile\endcsname \expandafter\let\csname\donesynindex#2\endcsname = 1 \fi % redefine \fooindfile: \expandafter\let\expandafter\temp\expandafter=\csname#3indfile\endcsname \expandafter\let\csname#2indfile\endcsname=\temp % redefine \fooindex: \expandafter\xdef\csname#2index\endcsname{\noexpand#1{#3}}% } % 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}}} % Take care of Texinfo commands that can appear in an index entry. % Since there are some commands we want to expand, and others we don't, % we have to laboriously prevent expansion for those that we don't. % \def\indexdummies{% \def\@{@}% change to @@ when we switch to @ as escape char in index files. \def\ {\realbackslash\space }% % Need these in case \tex is in effect and \{ is a \delimiter again. % But can't use \lbracecmd and \rbracecmd because texindex assumes % braces and backslashes are used only as delimiters. \let\{ = \mylbrace \let\} = \myrbrace % % \definedummyword defines \#1 as \realbackslash #1\space, thus % effectively preventing its expansion. This is used only for control % words, not control letters, because the \space would be incorrect % for control characters, but is needed to separate the control word % from whatever follows. % % For control letters, we have \definedummyletter, which omits the % space. % % These can be used both for control words that take an argument and % those that do not. If it is followed by {arg} in the input, then % that will dutifully get written to the index (or wherever). % \def\definedummyword##1{% \expandafter\def\csname ##1\endcsname{\realbackslash ##1\space}% }% \def\definedummyletter##1{% \expandafter\def\csname ##1\endcsname{\realbackslash ##1}% }% % % Do the redefinitions. \commondummies } % For the aux file, @ is the escape character. So we want to redefine % everything using @ instead of \realbackslash. When everything uses % @, this will be simpler. % \def\atdummies{% \def\@{@@}% \def\ {@ }% \let\{ = \lbraceatcmd \let\} = \rbraceatcmd % % (See comments in \indexdummies.) \def\definedummyword##1{% \expandafter\def\csname ##1\endcsname{@##1\space}% }% \def\definedummyletter##1{% \expandafter\def\csname ##1\endcsname{@##1}% }% % % Do the redefinitions. \commondummies } % Called from \indexdummies and \atdummies. \definedummyword and % \definedummyletter must be defined first. % \def\commondummies{% % \normalturnoffactive % % Control letters and accents. \definedummyletter{_}% \definedummyletter{,}% \definedummyletter{"}% \definedummyletter{`}% \definedummyletter{'}% \definedummyletter{^}% \definedummyletter{~}% \definedummyletter{=}% \definedummyword{u}% \definedummyword{v}% \definedummyword{H}% \definedummyword{dotaccent}% \definedummyword{ringaccent}% \definedummyword{tieaccent}% \definedummyword{ubaraccent}% \definedummyword{udotaccent}% \definedummyword{dotless}% % % Other non-English letters. \definedummyword{AA}% \definedummyword{AE}% \definedummyword{L}% \definedummyword{OE}% \definedummyword{O}% \definedummyword{aa}% \definedummyword{ae}% \definedummyword{l}% \definedummyword{oe}% \definedummyword{o}% \definedummyword{ss}% % % Although these internal commands shouldn't show up, sometimes they do. \definedummyword{bf}% \definedummyword{gtr}% \definedummyword{hat}% \definedummyword{less}% \definedummyword{sf}% \definedummyword{sl}% \definedummyword{tclose}% \definedummyword{tt}% % % Texinfo font commands. \definedummyword{b}% \definedummyword{i}% \definedummyword{r}% \definedummyword{sc}% \definedummyword{t}% % \definedummyword{TeX}% \definedummyword{acronym}% \definedummyword{cite}% \definedummyword{code}% \definedummyword{command}% \definedummyword{dfn}% \definedummyword{dots}% \definedummyword{emph}% \definedummyword{env}% \definedummyword{file}% \definedummyword{kbd}% \definedummyword{key}% \definedummyword{math}% \definedummyword{option}% \definedummyword{samp}% \definedummyword{strong}% \definedummyword{uref}% \definedummyword{url}% \definedummyword{var}% \definedummyword{w}% % % Assorted special characters. \definedummyword{bullet}% \definedummyword{copyright}% \definedummyword{dots}% \definedummyword{enddots}% \definedummyword{equiv}% \definedummyword{error}% \definedummyword{expansion}% \definedummyword{minus}% \definedummyword{pounds}% \definedummyword{point}% \definedummyword{print}% \definedummyword{result}% % % Handle some cases of @value -- where the variable name does not % contain - or _, and the value does not contain any % (non-fully-expandable) commands. \let\value = \expandablevalue % % Normal spaces, not active ones. \unsepspaces % % No macro expansion. \turnoffmacros } % If an index command is used in an @example environment, any spaces % therein should become regular spaces in the raw index file, not the % expansion of \tie (\leavevmode \penalty \@M \ ). {\obeyspaces \gdef\unsepspaces{\obeyspaces\let =\space}} % \indexnofonts is used when outputting the strings to sort the index % by, and when constructing control sequence names. It eliminates all % control sequences and just writes whatever the best ASCII sort string % would be for a given command (usually its argument). % \def\indexdummytex{TeX} \def\indexdummydots{...} % \def\indexnofonts{% \def\ { }% \def\@{@}% % how to handle braces? \def\_{\normalunderscore}% % \let\,=\asis \let\"=\asis \let\`=\asis \let\'=\asis \let\^=\asis \let\~=\asis \let\==\asis \let\u=\asis \let\v=\asis \let\H=\asis \let\dotaccent=\asis \let\ringaccent=\asis \let\tieaccent=\asis \let\ubaraccent=\asis \let\udotaccent=\asis \let\dotless=\asis % % Other non-English letters. \def\AA{AA}% \def\AE{AE}% \def\L{L}% \def\OE{OE}% \def\O{O}% \def\aa{aa}% \def\ae{ae}% \def\l{l}% \def\oe{oe}% \def\o{o}% \def\ss{ss}% \def\exclamdown{!}% \def\questiondown{?}% % % Don't no-op \tt, since it isn't a user-level command % and is used in the definitions of the active chars like <, >, |, etc. % Likewise with the other plain tex font commands. %\let\tt=\asis % % Texinfo font commands. \let\b=\asis \let\i=\asis \let\r=\asis \let\sc=\asis \let\t=\asis % \let\TeX=\indexdummytex \let\acronym=\asis \let\cite=\asis \let\code=\asis \let\command=\asis \let\dfn=\asis \let\dots=\indexdummydots \let\emph=\asis \let\env=\asis \let\file=\asis \let\kbd=\asis \let\key=\asis \let\math=\asis \let\option=\asis \let\samp=\asis \let\strong=\asis \let\uref=\asis \let\url=\asis \let\var=\asis \let\w=\asis } \let\indexbackslash=0 %overridden during \printindex. \let\SETmarginindex=\relax % put index entries in margin (undocumented)? % For \ifx comparisons. \def\emptymacro{\empty} % Most index entries go through here, but \dosubind is the general case. % \def\doind#1#2{\dosubind{#1}{#2}\empty} % Workhorse for all \fooindexes. % #1 is name of index, #2 is stuff to put there, #3 is subentry -- % \empty if called from \doind, as we usually are. The main exception % is with defuns, which call us directly. % \def\dosubind#1#2#3{% % Put the index entry in the margin if desired. \ifx\SETmarginindex\relax\else \insert\margin{\hbox{\vrule height8pt depth3pt width0pt #2}}% \fi {% \count255=\lastpenalty {% \indexdummies % Must do this here, since \bf, etc expand at this stage \escapechar=`\\ {% \let\folio = 0% We will 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. % % The main index entry text. \toks0 = {#2}% % % If third arg is present, precede it with space in sort key. \def\thirdarg{#3}% \ifx\thirdarg\emptymacro \else % If the third (subentry) arg is present, add it to the index % line to write. \toks0 = \expandafter{\the\toks0 \space #3}% \fi % % Process the index entry with all font commands turned off, to % get the string to sort by. {\indexnofonts \edef\temp{\the\toks0}% need full expansion \xdef\indexsorttmp{\temp}% }% % % Set up the complete index entry, with both the sort key and % the original text, including any font commands. We write % three arguments to \entry to the .?? file (four in the % subentry case), texindex reduces to two when writing the .??s % sorted result. \edef\temp{% \write\csname#1indfile\endcsname{% \realbackslash entry{\indexsorttmp}{\folio}{\the\toks0}}% }% % % If a skip is the last thing on the list now, preserve it % by backing up by \lastskip, doing the \write, then inserting % the skip again. Otherwise, the whatsit generated by the % \write will make \lastskip zero. The result is that sequences % like this: % @end defun % @tindex whatever % @defun ... % will have extra space inserted, because the \medbreak in the % start of the @defun won't see the skip inserted by the @end of % the previous defun. % % But don't do any of this if we're not in vertical mode. We % don't want to do a \vskip and prematurely end a paragraph. % % Avoid page breaks due to these extra skips, too. % \iflinks \ifvmode \skip0 = \lastskip \ifdim\lastskip = 0pt \else \nobreak\vskip-\skip0 \fi \fi % \temp % do the write % \ifvmode \ifdim\skip0 = 0pt \else \nobreak\vskip\skip0 \fi \fi \fi }% }% \penalty\count255 }% } % 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. % @printindex causes a particular index (the ??s file) to get printed. % It does not print any chapter heading (usually an @unnumbered). % \def\printindex{\parsearg\doprintindex} \def\doprintindex#1{\begingroup \dobreak \chapheadingskip{10000}% % \smallfonts \rm \tolerance = 9500 \indexbreaks % % See if the index file exists and is nonempty. % Change catcode of @ here so that if the index file contains % \initial {@} % as its first line, TeX doesn't complain about mismatched braces % (because it thinks @} is a control sequence). \catcode`\@ = 11 \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. \putwordIndexNonexistent \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 \putwordIndexIsEmpty \else % Index files are almost Texinfo source, but we use \ as the escape % character. It would be better to use @, but that's too big a change % to make right now. \def\indexbackslash{\rawbackslashxx}% \catcode`\\ = 0 \escapechar = `\\ \begindoublecolumns \input \jobname.#1s \enddoublecolumns \fi \fi \closein 1 \endgroup} % These macros are used by the sorted index file itself. % Change them to control the appearance of the index. \def\initial#1{{% % Some minor font changes for the special characters. \let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt % % Remove any glue we may have, we'll be inserting our own. \removelastskip % % We like breaks before the index initials, so insert a bonus. \penalty -300 % % Typeset the initial. Making this add up to a whole number of % baselineskips increases the chance of the dots lining up from column % to column. It still won't often be perfect, because of the stretch % we need before each entry, but it's better. % % No shrink because it confuses \balancecolumns. \vskip 1.67\baselineskip plus .5\baselineskip \leftline{\secbf #1}% \vskip .33\baselineskip plus .1\baselineskip % % Do our best not to break after the initial. \nobreak }} % This typesets a paragraph consisting of #1, dot leaders, and then #2 % flush to the right margin. It is used for index and table of contents % entries. The paragraph is indented by \leftskip. % \def\entry#1#2{\begingroup % % Start a new paragraph if necessary, so our assignments below can't % affect previous text. \par % % Do not fill out the last line with white space. \parfillskip = 0in % % No extra space above this paragraph. \parskip = 0in % % Do not prefer a separate line ending with a hyphen to fewer lines. \finalhyphendemerits = 0 % % \hangindent is only relevant when the entry text and page number % don't both fit on one line. In that case, bob suggests starting the % dots pretty far over on the line. Unfortunately, a large % indentation looks wrong when the entry text itself is broken across % lines. So we use a small indentation and put up with long leaders. % % \hangafter is reset to 1 (which is the value we want) at the start % of each paragraph, so we need not do anything with that. \hangindent = 2em % % When the entry text needs to be broken, just fill out the first line % with blank space. \rightskip = 0pt plus1fil % % A bit of stretch before each entry for the benefit of balancing columns. \vskip 0pt plus1pt % % Start a ``paragraph'' for the index entry so the line breaking % parameters we've set above will have an effect. \noindent % % Insert the text of the index entry. TeX will do line-breaking on it. #1% % The following is kludged to not output a line of dots in the index if % there are no page numbers. The next person who breaks this will be % cursed by a Unix daemon. \def\tempa{{\rm }}% \def\tempb{#2}% \edef\tempc{\tempa}% \edef\tempd{\tempb}% \ifx\tempc\tempd\ \else% % % 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 it, a spurious underfull % \hbox ensues. \ifpdf \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. \else \ #2% The page number ends the paragraph. \fi \fi% \par \endgroup} % Like \dotfill except takes at least 1 em. \def\indexdotfill{\cleaders \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \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 \ifpdf \pdfgettoks#2.\ \the\toksA % The page number ends the paragraph. \else #2 \fi \par }} % Define two-column mode, which we use to typeset indexes. % Adapted from the TeXbook, page 416, which is to say, % the manmac.tex format used to print the TeXbook itself. \catcode`\@=11 \newbox\partialpage \newdimen\doublecolumnhsize \def\begindoublecolumns{\begingroup % ended by \enddoublecolumns % Grab any single-column material above us. \output = {% % % Here is a possibility not foreseen in manmac: if we accumulate a % whole lot of material, we might end up calling this \output % routine twice in a row (see the doublecol-lose test, which is % essentially a couple of indexes with @setchapternewpage off). In % that case we just ship out what is in \partialpage with the normal % output routine. Generally, \partialpage will be empty when this % runs and this will be a no-op. See the indexspread.tex test case. \ifvoid\partialpage \else \onepageout{\pagecontents\partialpage}% \fi % \global\setbox\partialpage = \vbox{% % Unvbox the main output page. \unvbox\PAGE \kern-\topskip \kern\baselineskip }% }% \eject % run that output routine to set \partialpage % % Use the double-column output routine for subsequent pages. \output = {\doublecolumnout}% % % Change the page size parameters. We could do this once outside this % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 % format, but then we repeat the same computation. Repeating a couple % of assignments once per index is clearly meaningless for the % execution time, so we may as well do it in one place. % % First we halve the line length, less a little for the gutter between % the columns. We compute the gutter based on the line length, so it % changes automatically with the paper format. The magic constant % below is chosen so that the gutter has the same value (well, +-<1pt) % as it did when we hard-coded it. % % We put the result in a separate register, \doublecolumhsize, so we % can restore it in \pagesofar, after \hsize itself has (potentially) % been clobbered. % \doublecolumnhsize = \hsize \advance\doublecolumnhsize by -.04154\hsize \divide\doublecolumnhsize by 2 \hsize = \doublecolumnhsize % % Double the \vsize as well. (We don't need a separate register here, % since nobody clobbers \vsize.) \vsize = 2\vsize } % The double-column output routine for all double-column pages except % the last. % \def\doublecolumnout{% \splittopskip=\topskip \splitmaxdepth=\maxdepth % Get the available space for the double columns -- the normal % (undoubled) page height minus any material left over from the % previous page. \dimen@ = \vsize \divide\dimen@ by 2 \advance\dimen@ by -\ht\partialpage % % box0 will be the left-hand column, box2 the right. \setbox0=\vsplit255 to\dimen@ \setbox2=\vsplit255 to\dimen@ \onepageout\pagesofar \unvbox255 \penalty\outputpenalty } % % Re-output the contents of the output page -- any previous material, % followed by the two boxes we just split, in box0 and box2. \def\pagesofar{% \unvbox\partialpage % \hsize = \doublecolumnhsize \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}% } % % All done with double columns. \def\enddoublecolumns{% \output = {% % Split the last of the double-column material. Leave it on the % current page, no automatic page break. \balancecolumns % % If we end up splitting too much material for the current page, % though, there will be another page break right after this \output % invocation ends. Having called \balancecolumns once, we do not % want to call it again. Therefore, reset \output to its normal % definition right away. (We hope \balancecolumns will never be % called on to balance too much material, but if it is, this makes % the output somewhat more palatable.) \global\output = {\onepageout{\pagecontents\PAGE}}% }% \eject \endgroup % started in \begindoublecolumns % % \pagegoal was set to the doubled \vsize above, since we restarted % the current page. We're now back to normal single-column % typesetting, so reset \pagegoal to the normal \vsize (after the % \endgroup where \vsize got restored). \pagegoal = \vsize } % % Called at the end of the double column material. \def\balancecolumns{% \setbox0 = \vbox{\unvbox255}% like \box255 but more efficient, see p.120. \dimen@ = \ht0 \advance\dimen@ by \topskip \advance\dimen@ by-\baselineskip \divide\dimen@ by 2 % target to split to %debug\message{final 2-column material height=\the\ht0, target=\the\dimen@.}% \splittopskip = \topskip % Loop until we get a decent breakpoint. {% \vbadness = 10000 \loop \global\setbox3 = \copy0 \global\setbox1 = \vsplit3 to \dimen@ \ifdim\ht3>\dimen@ \global\advance\dimen@ by 1pt \repeat }% %debug\message{split to \the\dimen@, column heights: \the\ht1, \the\ht3.}% \setbox0=\vbox to\dimen@{\unvbox1}% \setbox2=\vbox to\dimen@{\unvbox3}% % \pagesofar } \catcode`\@ = \other \message{sectioning,} % 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} % We do the following for the sake of pdftex, which needs the actual % letter in the expansion, not just typeset. \def\appendixletter{% \ifnum\appendixno=`A A% \else\ifnum\appendixno=`B B% \else\ifnum\appendixno=`C C% \else\ifnum\appendixno=`D D% \else\ifnum\appendixno=`E E% \else\ifnum\appendixno=`F F% \else\ifnum\appendixno=`G G% \else\ifnum\appendixno=`H H% \else\ifnum\appendixno=`I I% \else\ifnum\appendixno=`J J% \else\ifnum\appendixno=`K K% \else\ifnum\appendixno=`L L% \else\ifnum\appendixno=`M M% \else\ifnum\appendixno=`N N% \else\ifnum\appendixno=`O O% \else\ifnum\appendixno=`P P% \else\ifnum\appendixno=`Q Q% \else\ifnum\appendixno=`R R% \else\ifnum\appendixno=`S S% \else\ifnum\appendixno=`T T% \else\ifnum\appendixno=`U U% \else\ifnum\appendixno=`V V% \else\ifnum\appendixno=`W W% \else\ifnum\appendixno=`X X% \else\ifnum\appendixno=`Y Y% \else\ifnum\appendixno=`Z Z% % The \the is necessary, despite appearances, because \appendixletter is % expanded while writing the .toc file. \char\appendixno is not % expandable, thus it is written literally, thus all appendixes come out % with the same letter (or @) in the toc without it. \else\char\the\appendixno \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi \fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi} % Each @chapter defines this as the name of the chapter. % page headings and footings can use it. @section does likewise. \def\thischapter{} \def\thissection{} \newcount\absseclevel % used to calculate proper heading level \newcount\secbase\secbase=0 % @raise/lowersections modify this count % @raisesections: treat @section as chapter, @subsection as section, etc. \def\raisesections{\global\advance\secbase by -1} \let\up=\raisesections % original BFox name % @lowersections: treat @chapter as section, @section as subsection, etc. \def\lowersections{\global\advance\secbase by 1} \let\down=\lowersections % original BFox name % Choose a numbered-heading macro % #1 is heading level if unmodified by @raisesections or @lowersections % #2 is text for heading \def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \chapterzzz{#2} \or \seczzz{#2} \or \numberedsubseczzz{#2} \or \numberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \chapterzzz{#2} \else \numberedsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses appendix heading levels \def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \appendixzzz{#2} \or \appendixsectionzzz{#2} \or \appendixsubseczzz{#2} \or \appendixsubsubseczzz{#2} \else \ifnum \absseclevel<0 \appendixzzz{#2} \else \appendixsubsubseczzz{#2} \fi \fi } % like \numhead, but chooses numberless heading levels \def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 \ifcase\absseclevel \unnumberedzzz{#2} \or \unnumberedseczzz{#2} \or \unnumberedsubseczzz{#2} \or \unnumberedsubsubseczzz{#2} \else \ifnum \absseclevel<0 \unnumberedzzz{#2} \else \unnumberedsubsubseczzz{#2} \fi \fi } % @chapter, @appendix, @unnumbered. \def\thischaptername{No Chapter Title} \outer\def\chapter{\parsearg\chapteryyy} \def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz \def\chapterzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \chapno by 1 \message{\putwordChapter\space \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{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% \writetocentry{chap}{#1}{{\the\chapno}} \donoderef \global\let\section = \numberedsec \global\let\subsection = \numberedsubsec \global\let\subsubsection = \numberedsubsubsec } % we use \chapno to avoid indenting back \def\appendixbox#1{% \setbox0 = \hbox{\putwordAppendix{} \the\chapno}% \hbox to \wd0{#1\hss}} \outer\def\appendix{\parsearg\appendixyyy} \def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz \def\appendixzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 \global\advance \appendixno by 1 \message{\putwordAppendix\space \appendixletter}% \chapmacro {#1}{\appendixbox{\putwordAppendix{} \appendixletter}}% \gdef\thissection{#1}% \gdef\thischaptername{#1}% \xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% \writetocentry{appendix}{#1}{{\appendixletter}} \appendixnoderef \global\let\section = \appendixsec \global\let\subsection = \appendixsubsec \global\let\subsubsection = \appendixsubsubsec } % @centerchap is like @unnumbered, but the heading is centered. \outer\def\centerchap{\parsearg\centerchapyyy} \def\centerchapyyy #1{{\let\unnumbchapmacro=\centerchapmacro \unnumberedyyy{#1}}} % @top is like @unnumbered. \outer\def\top{\parsearg\unnumberedyyy} \outer\def\unnumbered{\parsearg\unnumberedyyy} \def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz \def\unnumberedzzz #1{% \secno=0 \subsecno=0 \subsubsecno=0 % % This used to be simply \message{#1}, but TeX fully expands the % argument to \message. Therefore, if #1 contained @-commands, TeX % expanded them. For example, in `@unnumbered The @cite{Book}', TeX % expanded @cite (which turns out to cause errors because \cite is meant % to be executed, not expanded). % % Anyway, we don't want the fully-expanded definition of @cite to appear % as a result of the \message, we just want `@cite' itself. We use % \the to achieve this: TeX expands \the only once, % simply yielding the contents of . (We also do this for % the toc entries.) \toks0 = {#1}\message{(\the\toks0)}% % \unnumbchapmacro {#1}% \gdef\thischapter{#1}\gdef\thissection{#1}% \writetocentry{unnumbchap}{#1}{{\the\chapno}} \unnumbnoderef \global\let\section = \unnumberedsec \global\let\subsection = \unnumberedsubsec \global\let\subsubsection = \unnumberedsubsubsec } % Sections. \outer\def\numberedsec{\parsearg\secyyy} \def\secyyy #1{\numhead1{#1}} % normally calls seczzz \def\seczzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% \writetocentry{sec}{#1}{{\the\chapno}{\the\secno}} \donoderef \nobreak } \outer\def\appendixsection{\parsearg\appendixsecyyy} \outer\def\appendixsec{\parsearg\appendixsecyyy} \def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz \def\appendixsectionzzz #1{% \subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % \gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% \writetocentry{sec}{#1}{{\appendixletter}{\the\secno}} \appendixnoderef \nobreak } \outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} \def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz \def\unnumberedseczzz #1{% \plainsecheading {#1}\gdef\thissection{#1}% \writetocentry{unnumbsec}{#1}{{\the\chapno}{\the\secno}} \unnumbnoderef \nobreak } % Subsections. \outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} \def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz \def\numberedsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% \writetocentry{subsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}} \donoderef \nobreak } \outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} \def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz \def\appendixsubseczzz #1{% \gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % \subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% \writetocentry{subsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}} \appendixnoderef \nobreak } \outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} \def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz \def\unnumberedsubseczzz #1{% \plainsubsecheading {#1}\gdef\thissection{#1}% \writetocentry{unnumbsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}} \unnumbnoderef \nobreak } % Subsubsections. \outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} \def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz \def\numberedsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \writetocentry{subsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}} \donoderef \nobreak } \outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} \def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz \def\appendixsubsubseczzz #1{% \gdef\thissection{#1}\global\advance \subsubsecno by 1 % \subsubsecheading {#1} {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% \writetocentry{subsubsec}{#1}{{\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}} \appendixnoderef \nobreak } \outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} \def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz \def\unnumberedsubsubseczzz #1{% \plainsubsubsecheading {#1}\gdef\thissection{#1}% \writetocentry{unnumbsubsubsec}{#1}{{\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}} \unnumbnoderef \nobreak } % 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} % @heading, @subheading, @subsubheading. \def\heading{\parsearg\plainsecheading} \def\subheading{\parsearg\plainsubsecheading} \def\subsubheading{\parsearg\plainsubsubsecheading} % 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 \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\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chapbreak \global\let\pagealignmacro=\chappager} \def\CHAPPAGon{% \global\let\contentsalignmacro = \chappager \global\let\pchapsepmacro=\chappager \global\let\pagealignmacro=\chappager \global\def\HEADINGSon{\HEADINGSsingle}} \def\CHAPPAGodd{ \global\let\contentsalignmacro = \chapoddpage \global\let\pchapsepmacro=\chapoddpage \global\let\pagealignmacro=\chapoddpage \global\def\HEADINGSon{\HEADINGSdouble}} \CHAPPAGon \def\CHAPFplain{ \global\let\chapmacro=\chfplain \global\let\unnumbchapmacro=\unnchfplain \global\let\centerchapmacro=\centerchfplain} % Plain chapter opening. % #1 is the text, #2 the chapter number or empty if unnumbered. \def\chfplain#1#2{% \pchapsepmacro {% \chapfonts \rm \def\chapnum{#2}% \setbox0 = \hbox{#2\ifx\chapnum\empty\else\enspace\fi}% \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title \nobreak } % Plain opening for unnumbered. \def\unnchfplain#1{\chfplain{#1}{}} % @centerchap -- centered and unnumbered. \let\centerparametersmaybe = \relax \def\centerchfplain#1{{% \def\centerparametersmaybe{% \advance\rightskip by 3\rightskip \leftskip = \rightskip \parfillskip = 0pt }% \chfplain{#1}{}% }} \CHAPFplain % The default \def\unnchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt\raggedright \rm #1\hfill}}\bigskip \par\nobreak } \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\centerchfopen #1{% \chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 \parindent=0pt \hfill {\rm #1}\hfill}}\bigskip \par\nobreak } \def\CHAPFopen{ \global\let\chapmacro=\chfopen \global\let\unnumbchapmacro=\unnchfopen \global\let\centerchapmacro=\centerchfopen} % Section titles. \newskip\secheadingskip \def\secheadingbreak{\dobreak \secheadingskip {-1000}} \def\secheading#1#2#3{\sectionheading{sec}{#2.#3}{#1}} \def\plainsecheading#1{\sectionheading{sec}{}{#1}} % Subsection titles. \newskip \subsecheadingskip \def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} \def\subsecheading#1#2#3#4{\sectionheading{subsec}{#2.#3.#4}{#1}} \def\plainsubsecheading#1{\sectionheading{subsec}{}{#1}} % Subsubsection titles. \let\subsubsecheadingskip = \subsecheadingskip \let\subsubsecheadingbreak = \subsecheadingbreak \def\subsubsecheading#1#2#3#4#5{\sectionheading{subsubsec}{#2.#3.#4.#5}{#1}} \def\plainsubsubsecheading#1{\sectionheading{subsubsec}{}{#1}} % Print any size section title. % % #1 is the section type (sec/subsec/subsubsec), #2 is the section % number (maybe empty), #3 the text. \def\sectionheading#1#2#3{% {% \expandafter\advance\csname #1headingskip\endcsname by \parskip \csname #1headingbreak\endcsname }% {% % Switch to the right set of fonts. \csname #1fonts\endcsname \rm % % Only insert the separating space if we have a section number. \def\secnum{#2}% \setbox0 = \hbox{#2\ifx\secnum\empty\else\enspace\fi}% % \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \raggedright \hangindent = \wd0 % zero if no section number \unhbox0 #3}% }% % Add extra space after the heading -- either a line space or a % paragraph space, whichever is more. (Some people like to set % \parskip to large values for some reason.) Don't allow stretch, though. \nobreak \ifdim\parskip>\normalbaselineskip \kern\parskip \else \kern\normalbaselineskip \fi \nobreak } \message{toc,} % Table of contents. \newwrite\tocfile % Write an entry to the toc file, opening it if necessary. % Called from @chapter, etc. We supply {\folio} at the end of the % argument, which will end up as the last argument to the \...entry macro. % % Usage: \writetocentry{chap}{The Name of The Game}{{\the\chapno}} % We open the .toc file for writing here instead of at @setfilename (or % any other fixed time) so that @contents can be anywhere in the document. % \newif\iftocfileopened \def\writetocentry#1#2#3{% \iftocfileopened\else \immediate\openout\tocfile = \jobname.toc \global\tocfileopenedtrue \fi % \iflinks \toks0 = {#2}% \edef\temp{\write\tocfile{\realbackslash #1entry{\the\toks0}#3{\folio}}}% \temp \fi % % Tell \shipout to create a page destination if we're doing pdf, which % will be the target of the links in the table of contents. We can't % just do it on every page because the title pages are numbered 1 and % 2 (the page numbers aren't printed), and so are the first two pages % of the document. Thus, we'd have two destinations named `1', and % two named `2'. \ifpdf \pdfmakepagedesttrue \fi } \newskip\contentsrightmargin \contentsrightmargin=1in \newcount\savepageno \newcount\lastnegativepageno \lastnegativepageno = -1 % Finish up the main text and prepare to read what we've written % to \tocfile. % \def\startcontents#1{% % If @setchapternewpage on, and @headings double, the contents should % start on an odd page, unlike chapters. Thus, we maintain % \contentsalignmacro in parallel with \pagealignmacro. % From: Torbjorn Granlund \contentsalignmacro \immediate\closeout\tocfile % % Don't need to put `Contents' or `Short Contents' in the headline. % It is abundantly clear what they are. \unnumbchapmacro{#1}\def\thischapter{}% \savepageno = \pageno \begingroup % Set up to handle contents files properly. \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 % We can't do this, because then an actual ^ in a section % title fails, e.g., @chapter ^ -- exponentiation. --karl, 9jul97. %\catcode`\^=7 % to see ^^e4 as \"a etc. juha@piuha.ydi.vtt.fi \raggedbottom % Worry more about breakpoints than the bottom. \advance\hsize by -\contentsrightmargin % Don't use the full line length. % % Roman numerals for page numbers. \ifnum \pageno>0 \global\pageno = \lastnegativepageno \fi } % Normal (long) toc. \def\contents{% \startcontents{\putwordTOC}% \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \pdfmakeoutlines \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } % And just the chapters. \def\summarycontents{% \startcontents{\putwordShortTOC}% % \let\chapentry = \shortchapentry \let\appendixentry = \shortappendixentry \let\unnumbchapentry = \shortunnumberedentry % We want a true roman here for the page numbers. \secfonts \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl \let\tt=\shortconttt \rm \hyphenpenalty = 10000 \advance\baselineskip by 1pt % Open it up a little. \def\secentry ##1##2##3##4{} \def\subsecentry ##1##2##3##4##5{} \def\subsubsecentry ##1##2##3##4##5##6{} \let\unnumbsecentry = \secentry \let\unnumbsubsecentry = \subsecentry \let\unnumbsubsubsecentry = \subsubsecentry \openin 1 \jobname.toc \ifeof 1 \else \closein 1 \input \jobname.toc \fi \vfill \eject \contentsalignmacro % in case @setchapternewpage odd is in effect \endgroup \lastnegativepageno = \pageno \global\pageno = \savepageno } \let\shortcontents = \summarycontents \ifpdf \pdfcatalog{/PageMode /UseOutlines}% \fi % 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, ... % Chapters, in the main contents. \def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} % % Chapters, in the short toc. % See comments in \dochapentry re vbox and related settings. \def\shortchapentry#1#2#3{% \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno\bgroup#3\egroup}% } % Appendices, in the main contents. \def\appendixentry#1#2#3{% \dochapentry{\appendixbox{\putwordAppendix{} #2}\labelspace#1}{#3}} % % Appendices, in the short toc. \let\shortappendixentry = \shortchapentry % Typeset the label for a chapter or appendix for the short contents. % The arg is, e.g., `Appendix A' for an appendix, or `3' for a chapter. % We could simplify the code here by writing out an \appendixentry % command in the toc file for appendices, instead of using \chapentry % for both, but it doesn't seem worth it. % \newdimen\shortappendixwidth % \def\shortchaplabel#1{% % This space should be enough, since a single number is .5em, and the % widest letter (M) is 1em, at least in the Computer Modern fonts. % But use \hss just in case. % (This space doesn't include the extra space that gets added after % the label; that gets put in by \shortchapentry above.) \dimen0 = 1em \hbox to \dimen0{#1\hss}% } % Unnumbered chapters. \def\unnumbchapentry#1#2#3{\dochapentry{#1}{#3}} \def\shortunnumberedentry#1#2#3{\tocentry{#1}{\doshortpageno\bgroup#3\egroup}} % Sections. \def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} \def\unnumbsecentry#1#2#3#4{\dosecentry{#1}{#4}} % Subsections. \def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} \def\unnumbsubsecentry#1#2#3#4#5{\dosubsecentry{#1}{#5}} % And subsubsections. \def\subsubsecentry#1#2#3#4#5#6{% \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} \def\unnumbsubsubsecentry#1#2#3#4#5#6{\dosubsubsecentry{#1}{#6}} % 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 want it to be at chapters % if at all possible; hence the \penalty. \def\dochapentry#1#2{% \penalty-300 \vskip1\baselineskip plus.33\baselineskip minus.25\baselineskip \begingroup \chapentryfonts \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup \nobreak\vskip .25\baselineskip plus.1\baselineskip } \def\dosecentry#1#2{\begingroup \secentryfonts \leftskip=\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsecentry#1#2{\begingroup \subsecentryfonts \leftskip=2\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} \def\dosubsubsecentry#1#2{\begingroup \subsubsecentryfonts \leftskip=3\tocindent \tocentry{#1}{\dopageno\bgroup#2\egroup}% \endgroup} % Final typesetting of a toc entry; we use the same \entry macro as for % the index entries, but we want to suppress hyphenation here. (We % can't do that in the \entry macro, since index entries might consist % of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) \def\tocentry#1#2{\begingroup \vskip 0pt plus1pt % allow a little stretch for the sake of nice page breaks % Do not use \turnoffactive in these arguments. Since the toc is % typeset in cmr, characters such as _ would come out wrong; we % have to do the usual translation tricks. \entry{#1}{#2}% \endgroup} % 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,} % @foo ... @end foo. % @point{}, @result{}, @expansion{}, @print{}, @equiv{}. % % 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. % \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}} % The @error{} command. % Adapted from the TeXbook's \boxit. % \newbox\errorbox % {\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} % \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 `\~=\active \let~=\tie \catcode `\%=14 \catcode `\+=\other \catcode `\"=\other \catcode `\==\other \catcode `\|=\other \catcode `\<=\other \catcode `\>=\other \escapechar=`\\ % \let\b=\ptexb \let\bullet=\ptexbullet \let\c=\ptexc \let\,=\ptexcomma \let\.=\ptexdot \let\dots=\ptexdots \let\equiv=\ptexequiv \let\!=\ptexexclam \let\i=\ptexi \let\{=\ptexlbrace \let\+=\tabalign \let\}=\ptexrbrace \let\/=\ptexslash \let\*=\ptexstar \let\t=\ptext % \def\endldots{\mathinner{\ldots\ldots\ldots\ldots}}% \def\enddots{\relax\ifmmode\endldots\else$\mathsurround=0pt \endldots\,$\fi}% \def\@{@}% \let\Etex=\endgroup} % Define @lisp ... @end lisp. % @lisp does a \begingroup so it can rebind things, % including the definition of @end lisp (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, @example, and other % such environments. \null is better than a space, since it doesn't % have any width. \def\lisppar{\null\endgraf} % Make each space character in the input produce a normal interword % space in the output. Don't allow a line break at this space, as this % is used only in environments like @example, where each line of input % should produce a line of output anyway. % {\obeyspaces % \gdef\sepspaces{\obeyspaces\let =\tie}} % Define \obeyedspace to be our active space, whatever it is. This is % for use in \parsearg. {\sepspaces% \global\let\obeyedspace= } % This space is always present above and below environments. \newskip\envskipamount \envskipamount = 0pt % Make spacing and below environment symmetrical. We use \parskip here % to help in doing that, since in @example-like environments \parskip % is reset to zero; thus the \afterenvbreak inserts no space -- but the % start of the next paragraph will insert \parskip. % \def\aboveenvbreak{{% % =10000 instead of <10000 because of a special case in \itemzzz, q.v. \ifnum \lastpenalty=10000 \else \advance\envskipamount by \parskip \endgraf \ifdim\lastskip<\envskipamount \removelastskip % it's not a good place to break if the last penalty was \nobreak % or better ... \ifnum\lastpenalty>10000 \else \penalty-50 \fi \vskip\envskipamount \fi \fi }} \let\afterenvbreak = \aboveenvbreak % \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. \let\nonarrowing=\relax % @cartouche ... @end cartouche: draw rectangle w/rounded corners around % environment contents. \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 \def\cartouche{% \par % can't be in the midst of a paragraph. \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 18.4pt % allow for 3pt kerns on either % side, and for 6pt waste from % each corner char, and rule thickness \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 }} % This macro is called at the beginning of all the @example variants, % inside a group. \def\nonfillstart{% \aboveenvbreak \inENV % This group ends at the end of the body \hfuzz = 12pt % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output \parskip = 0pt \parindent = 0pt \emergencystretch = 0pt % don't try to avoid overfull boxes % @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 } % Define the \E... control sequence only if we are inside the particular % environment, so the error checking in \end will work. % % To end an @example-like environment, we first end the paragraph (via % \afterenvbreak's vertical glue), and then the group. That way we keep % the zero \parskip that the environments set -- \parskip glue will be % inserted at the beginning of the next paragraph in the document, after % the environment. % \def\nonfillfinish{\afterenvbreak\endgroup} % @lisp: indented, narrowed, typewriter font. \def\lisp{\begingroup \nonfillstart \let\Elisp = \nonfillfinish \tt \let\kbdfont = \kbdexamplefont % Allow @kbd to do something special. \gobble % eat return } % @example: Same as @lisp. \def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} % @smallexample and @smalllisp: use smaller fonts. % Originally contributed by Pavel@xerox. \def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}% \def\Esmallexample{\nonfillfinish\endgroup}% \smallexamplefonts \lisp } \let\smallexample = \smalllisp % @display: same as @lisp except keep current font. % \def\display{\begingroup \nonfillstart \let\Edisplay = \nonfillfinish \gobble } % % @smalldisplay: @display plus smaller fonts. % \def\smalldisplay{\begingroup \def\Esmalldisplay{\nonfillfinish\endgroup}% \smallexamplefonts \rm \display } % @format: same as @display except don't narrow margins. % \def\format{\begingroup \let\nonarrowing = t \nonfillstart \let\Eformat = \nonfillfinish \gobble } % % @smallformat: @format plus smaller fonts. % \def\smallformat{\begingroup \def\Esmallformat{\nonfillfinish\endgroup}% \smallexamplefonts \rm \format } % @flushleft (same as @format). % \def\flushleft{\begingroup \def\Eflushleft{\nonfillfinish\endgroup}\format} % @flushright. % \def\flushright{\begingroup \let\nonarrowing = t \nonfillstart \let\Eflushright = \nonfillfinish \advance\leftskip by 0pt plus 1fill \gobble } % @quotation does normal linebreaking (hence we can't use \nonfillstart) % and narrows the margins. % \def\quotation{% \begingroup\inENV %This group ends at the end of the @quotation body {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip \parindent=0pt % We have retained a nonzero parskip for the environment, since we're % doing normal filling. So to avoid extra space below the environment... \def\Equotation{\parskip = 0pt \nonfillfinish}% % % @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 } % LaTeX-like @verbatim...@end verbatim and @verb{...} % If we want to allow any as delimiter, % we need the curly braces so that makeinfo sees the @verb command, eg: % `@verbx...x' would look like the '@verbx' command. --janneke@gnu.org % % [Knuth]: Donald Ervin Knuth, 1996. The TeXbook. % % [Knuth] p.344; only we need to do the other characters Texinfo sets % active too. Otherwise, they get lost as the first character on a % verbatim line. \def\dospecials{% \do\ \do\\\do\{\do\}\do\$\do\&% \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~% \do\<\do\>\do\|\do\@\do+\do\"% } % % [Knuth] p. 380 \def\uncatcodespecials{% \def\do##1{\catcode`##1=12}\dospecials} % % [Knuth] pp. 380,381,391 % Disable Spanish ligatures ?` and !` of \tt font \begingroup \catcode`\`=\active\gdef`{\relax\lq} \endgroup % % Setup for the @verb command. % % Eight spaces for a tab \begingroup \catcode`\^^I=\active \gdef\tabeightspaces{\catcode`\^^I=\active\def^^I{\ \ \ \ \ \ \ \ }} \endgroup % \def\setupverb{% \tt % easiest (and conventionally used) font for verbatim \def\par{\leavevmode\endgraf}% \catcode`\`=\active \tabeightspaces % Respect line breaks, % print special symbols as themselves, and % make each space count % must do in this order: \obeylines \uncatcodespecials \sepspaces } % Setup for the @verbatim environment % % Real tab expansion \newdimen\tabw \setbox0=\hbox{\tt\space} \tabw=8\wd0 % tab amount % \def\starttabbox{\setbox0=\hbox\bgroup} \begingroup \catcode`\^^I=\active \gdef\tabexpand{% \catcode`\^^I=\active \def^^I{\leavevmode\egroup \dimen0=\wd0 % the width so far, or since the previous tab \divide\dimen0 by\tabw \multiply\dimen0 by\tabw % compute previous multiple of \tabw \advance\dimen0 by\tabw % advance to next multiple of \tabw \wd0=\dimen0 \box0 \starttabbox }% } \endgroup \def\setupverbatim{% % Easiest (and conventionally used) font for verbatim \tt \def\par{\leavevmode\egroup\box0\endgraf}% \catcode`\`=\active \tabexpand % Respect line breaks, % print special symbols as themselves, and % make each space count % must do in this order: \obeylines \uncatcodespecials \sepspaces \everypar{\starttabbox}% } % Do the @verb magic: verbatim text is quoted by unique % delimiter characters. Before first delimiter expect a % right brace, after last delimiter expect closing brace: % % \def\doverb'{'#1'}'{#1} % % [Knuth] p. 382; only eat outer {} \begingroup \catcode`[=1\catcode`]=2\catcode`\{=12\catcode`\}=12 \gdef\doverb{#1[\def\next##1#1}[##1\endgroup]\next] \endgroup % \def\verb{\begingroup\setupverb\doverb} % % % Do the @verbatim magic: define the macro \doverbatim so that % the (first) argument ends when '@end verbatim' is reached, ie: % % \def\doverbatim#1@end verbatim{#1} % % For Texinfo it's a lot easier than for LaTeX, % because texinfo's \verbatim doesn't stop at '\end{verbatim}': % we need not redefine '\', '{' and '}'. % % Inspired by LaTeX's verbatim command set [latex.ltx] %% Include LaTeX hack for completeness -- never know %% \begingroup %% \catcode`|=0 \catcode`[=1 %% \catcode`]=2\catcode`\{=12\catcode`\}=12\catcode`\ =\active %% \catcode`\\=12|gdef|doverbatim#1@end verbatim[ %% #1|endgroup|def|Everbatim[]|end[verbatim]] %% |endgroup % \begingroup \catcode`\ =\active \obeylines % % ignore everything up to the first ^^M, that's the newline at the end % of the @verbatim input line itself. Otherwise we get an extra blank % line in the output. \gdef\doverbatim#1^^M#2@end verbatim{#2\end{verbatim}}% \endgroup % \def\verbatim{% \def\Everbatim{\nonfillfinish\endgroup}% \begingroup \nonfillstart \advance\leftskip by -\defbodyindent \begingroup\setupverbatim\doverbatim } % @verbatiminclude FILE - insert text of file in verbatim environment. % % Allow normal characters that we make active in the argument (a file name). \def\verbatiminclude{% \begingroup \catcode`\\=\other \catcode`~=\other \catcode`^=\other \catcode`_=\other \catcode`|=\other \catcode`<=\other \catcode`>=\other \catcode`+=\other \parsearg\doverbatiminclude } \def\setupverbatiminclude{% \begingroup \nonfillstart \advance\leftskip by -\defbodyindent \begingroup\setupverbatim } % \def\doverbatiminclude#1{% % Restore active chars for included file. \endgroup \begingroup \let\value=\expandablevalue \def\thisfile{#1}% \expandafter\expandafter\setupverbatiminclude\input\thisfile \endgroup \nonfillfinish \endgroup } % @copying ... @end copying. % Save the text away for @insertcopying later. Many commands won't be % allowed in this context, but that's ok. % % We save the uninterpreted tokens, rather than creating a box. % Saving the text in a box would be much easier, but then all the % typesetting commands (@smallbook, font changes, etc.) have to be done % beforehand -- and a) we want @copying to be done first in the source % file; b) letting users define the frontmatter in as flexible order as % possible is very desirable. % \def\copying{\begingroup % Define a command to swallow text until we reach `@end copying'. % \ is the escape char in this texinfo.tex file, so it is the % delimiter for the command; @ will be the escape char when we read % it, but that doesn't matter. \long\def\docopying##1\end copying{\gdef\copyingtext{##1}\enddocopying}% % % We must preserve ^^M's in the input file; see \insertcopying below. \catcode`\^^M = \active \docopying } % What we do to finish off the copying text. % \def\enddocopying{\endgroup\ignorespaces} % @insertcopying. Here we must play games with ^^M's. On the one hand, % we need them to delimit commands such as `@end quotation', so they % must be active. On the other hand, we certainly don't want every % end-of-line to be a \par, as would happen with the normal active % definition of ^^M. On the third hand, two ^^M's in a row should still % generate a \par. % % Our approach is to make ^^M insert a space and a penalty1 normally; % then it can also check if \lastpenalty=1. If it does, then manually % do \par. % % This messes up the normal definitions of @c[omment], so we redefine % it. Similarly for @ignore. (These commands are used in the gcc % manual for man page generation.) % % Seems pretty fragile, most line-oriented commands will presumably % fail, but for the limited use of getting the copying text (which % should be quite simple) inserted, we can hope it's ok. % {\catcode`\^^M=\active % \gdef\insertcopying{\begingroup % \parindent = 0pt % looks wrong on title page \def^^M{% \ifnum \lastpenalty=1 % \par % \else % \space \penalty 1 % \fi % }% % % Fix @c[omment] for catcode 13 ^^M's. \def\c##1^^M{\ignorespaces}% \let\comment = \c % % % Don't bother jumping through all the hoops that \doignore does, it % would be very hard since the catcodes are already set. \long\def\ignore##1\end ignore{\ignorespaces}% % \copyingtext % \endgroup}% } \message{defuns,} % @defun etc. % 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\deflastargmargin \deflastargmargin=18pt \newcount\parencount % We want ()&[] to print specially on the defun line. % \def\activeparens{% \catcode`\(=\active \catcode`\)=\active \catcode`\&=\active \catcode`\[=\active \catcode`\]=\active } % Make control sequences which act like normal parenthesis chars. \let\lparen = ( \let\rparen = ) {\activeparens % Now, smart parens don't turn on until &foo (see \amprm) % Be sure that we always have a definition for `(', etc. For example, % if the fn name has parens in it, \boldbrax will not be in effect yet, % so TeX would otherwise complain about undefined control sequence. \global\let(=\lparen \global\let)=\rparen \global\let[=\lbrack \global\let]=\rbrack \gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } \gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} % This is used to turn on special parens % but make & act ordinary (given that it's active). \gdef\boldbraxnoamp{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb\let&=\ampnr} % 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`\(}\global\advance\parencount by 1 } \def\clnr{{\sf\char`\)}\global\advance\parencount by -1 } \let\ampnr = \& \def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} % Active &'s sneak into the index arguments, so make sure it's defined. { \catcode`& = \active \global\let& = \ampnr } % \defname, which formats the name of the @def (not the args). % #1 is the function name. % #2 is the type of definition, such as "Function". % \def\defname#1#2{% % How we'll output the type name. Putting it in brackets helps % distinguish it from the body text that may end up on the next line % just below it. \ifempty{#2}% \def\defnametype{}% \else \def\defnametype{[\rm #2]}% \fi % % Get the values of \leftskip and \rightskip as they were outside the @def... \dimen2=\leftskip \advance\dimen2 by -\defbodyindent % % Figure out values for the paragraph shape. \setbox0=\hbox{\hskip \deflastargmargin{\defnametype}}% \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 % % Output arg 2 ("Function" or some such) but stuck inside a box of % width 0 so it does not interfere with linebreaking. \noindent % {% Adjust \hsize to exclude the ambient margins, % so that \rightline will obey them. \advance \hsize by -\dimen2 \dimen3 = 0pt % was -1.25pc \rlap{\rightline{\defnametype\kern\dimen3}}% }% % % Allow all lines to be underfull without complaint: \tolerance=10000 \hbadness=10000 \advance\leftskip by -\defbodyindent \exdentamount=\defbodyindent {\df #1}\enskip % output function name % \defunargs will be called next to output the arguments, if any. } % Common pieces to start any @def... % #1 is the \E... control sequence to end the definition (which we define). % #2 is the \...x control sequence (which our caller defines). % #3 is the control sequence to process the header, such as \defunheader. % \def\parsebodycommon#1#2#3{% \begingroup\inENV % If there are two @def commands in a row, we'll have a \nobreak, % which is there to keep the function description together with its % header. But if there's nothing but headers, we want to allow a % break after all. Check for penalty 10002 (inserted by % \defargscommonending) instead of 10000, since the sectioning % commands insert a \penalty10000, and we don't want to allow a break % between a section heading and a defun. \ifnum\lastpenalty=10002 \penalty0 \fi \medbreak % % Define the \E... end token that this defining construct specifies % so that it will exit this group. \def#1{\endgraf\endgroup\medbreak}% % \parindent=0in \advance\leftskip by \defbodyindent \exdentamount=\defbodyindent } % Common part of the \...x definitions. % \def\defxbodycommon{% % As with \parsebodycommon above, allow line break if we have multiple % x headers in a row. It's not a great place, though. \ifnum\lastpenalty=10000 \penalty1000 \fi % \begingroup\obeylines } % Process body of @defun, @deffn, @defmac, etc. % \def\defparsebody#1#2#3{% \parsebodycommon{#1}{#2}{#3}% \def#2{\defxbodycommon \activeparens \spacesplit#3}% \catcode\equalChar=\active \begingroup\obeylines\activeparens \spacesplit#3% } % #1, #2, #3 are the common arguments (see \parsebodycommon above). % #4, delimited by the space, is the class name. % \def\defmethparsebody#1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 {\defxbodycommon \activeparens \spacesplit{#3{##1}}}% \begingroup\obeylines\activeparens % The \empty here prevents misinterpretation of a construct such as % @deffn {whatever} {Enharmonic comma} % See comments at \deftpparsebody, although in our case we don't have % to remove the \empty afterwards, since it is empty. \spacesplit{#3{#4}}\empty } % Used for @deftypemethod and @deftypeivar. % #1, #2, #3 are the common arguments (see \defparsebody). % #4, delimited by a space, is the class name. % #5 is the method's return type. % \def\deftypemethparsebody#1#2#3#4 #5 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 ##2 {\defxbodycommon \activeparens \spacesplit{#3{##1}{##2}}}% \begingroup\obeylines\activeparens \spacesplit{#3{#4}{#5}}% } % Used for @deftypeop. The change from \deftypemethparsebody is an % extra argument at the beginning which is the `category', instead of it % being the hardwired string `Method' or `Instance Variable'. We have % to account for this both in the \...x definition and in parsing the % input at hand. Thus also need a control sequence (passed as #5) for % the \E... definition to assign the category name to. % \def\deftypeopparsebody#1#2#3#4#5 #6 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 ##2 ##3 {\def#4{##1}% \defxbodycommon \activeparens \spacesplit{#3{##2}{##3}}}% \begingroup\obeylines\activeparens \spacesplit{#3{#5}{#6}}% } % For @defop. \def\defopparsebody #1#2#3#4#5 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 ##2 {\def#4{##1}% \defxbodycommon \activeparens \spacesplit{#3{##2}}}% \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{% \parsebodycommon{#1}{#2}{#3}% \def#2{\defxbodycommon \spacesplit#3}% \catcode\equalChar=\active \begingroup\obeylines \spacesplit#3% } % @defopvar. \def\defopvarparsebody #1#2#3#4#5 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 ##2 {\def#4{##1}% \defxbodycommon \spacesplit{#3{##2}}}% \begingroup\obeylines \spacesplit{#3{#5}}% } \def\defvrparsebody#1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}% \begingroup\obeylines \spacesplit{#3{#4}}% } % This loses on `@deftp {Data Type} {struct termios}' -- it thinks the % type is just `struct', because we lose the braces in `{struct % termios}' when \spacesplit reads its undelimited argument. Sigh. % \let\deftpparsebody=\defvrparsebody % % So, to get around this, we put \empty in with the type name. That % way, TeX won't find exactly `{...}' as an undelimited argument, and % won't strip off the braces. % \def\deftpparsebody #1#2#3#4 {% \parsebodycommon{#1}{#2}{#3}% \def#2##1 {\defxbodycommon \spacesplit{#3{##1}}}% \begingroup\obeylines \spacesplit{\parsetpheaderline{#3{#4}}}\empty } % Fine, but then we have to eventually remove the \empty *and* the % braces (if any). That's what this does. % \def\removeemptybraces\empty#1\relax{#1} % After \spacesplit has done its work, this is called -- #1 is the final % thing to call, #2 the type name (which starts with \empty), and #3 % (which might be empty) the arguments. % \def\parsetpheaderline#1#2#3{% #1{\removeemptybraces#2\relax}{#3}% }% % Split up #2 (the rest of the input line) 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\spacesplitx{#1}#2 \relax\spacesplitx}% \long\gdef\spacesplitx#1#2 #3#4\spacesplitx{% \ifx\relax #3% #1{#2}{}% \else % #1{#2}{#3#4}% \fi}% } % Define @defun. % This is called to end the arguments processing for all the @def... commands. % \def\defargscommonending{% \interlinepenalty = 10000 \advance\rightskip by 0pt plus 1fil \endgraf \nobreak\vskip -\parskip \penalty 10002 % signal to \parsebodycommon. } % This expands the args and terminates the paragraph they comprise. % \def\defunargs#1{\functionparens \sl % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. % Set the font temporarily and use \font in case \setfont made \tensl a macro. {\tensl\hyphenchar\font=0}% #1% {\tensl\hyphenchar\font=45}% \ifnum\parencount=0 \else \errmessage{Unbalanced parentheses in @def}\fi% \defargscommonending } \def\deftypefunargs #1{% % Expand, preventing hyphenation at `-' chars. % Note that groups don't affect changes in \hyphenchar. % Use \boldbraxnoamp, not \functionparens, so that & is not special. \boldbraxnoamp \tclose{#1}% avoid \code because of side effects on active chars \defargscommonending } % 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\equalChar=\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}{\putwordDeffunc}% \defunargs {#2}\endgroup % \catcode\equalChar=\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 {\defheaderxcond#1\relax$.$#2}{\putwordDeftypefun}% \deftypefunargs {#3}\endgroup % \catcode\equalChar=\other % Turn off change made in \defparsebody } % @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) \def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} % \defheaderxcond#1\relax$.$ % puts #1 in @code, followed by a space, but does nothing if #1 is null. \def\defheaderxcond#1#2$.${\ifx#1\relax\else\code{#1#2} \fi} % #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 \normalparens % notably, turn off `&' magic, which prevents % at least some C++ text from working \defname {\defheaderxcond#2\relax$.$#3}{#1}% \deftypefunargs {#4}\endgroup % \catcode\equalChar=\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}{\putwordDefmac}% \defunargs {#2}\endgroup % \catcode\equalChar=\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}{\putwordDefspec}% \defunargs {#2}\endgroup % \catcode\equalChar=\other % Turn off change made in \defparsebody } % @defop CATEGORY CLASS OPERATION ARG... % \def\defop #1 {\def\defoptype{#1}% \defopparsebody\Edefop\defopx\defopheader\defoptype} % \def\defopheader#1#2#3{% \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% function index entry \begingroup \defname{#2}{\defoptype\ \putwordon\ #1}% \defunargs{#3}% \endgroup } % @deftypeop CATEGORY CLASS TYPE OPERATION ARG... % \def\deftypeop #1 {\def\deftypeopcategory{#1}% \deftypeopparsebody\Edeftypeop\deftypeopx\deftypeopheader \deftypeopcategory} % % #1 is the class name, #2 the data type, #3 the operation name, #4 the args. \def\deftypeopheader#1#2#3#4{% \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{\defheaderxcond#2\relax$.$#3} {\deftypeopcategory\ \putwordon\ \code{#1}}% \deftypefunargs{#4}% \endgroup } % @deftypemethod CLASS TYPE METHOD ARG... % \def\deftypemethod{% \deftypemethparsebody\Edeftypemethod\deftypemethodx\deftypemethodheader} % % #1 is the class name, #2 the data type, #3 the method name, #4 the args. \def\deftypemethodheader#1#2#3#4{% \dosubind{fn}{\code{#3}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{\defheaderxcond#2\relax$.$#3}{\putwordMethodon\ \code{#1}}% \deftypefunargs{#4}% \endgroup } % @deftypeivar CLASS TYPE VARNAME % \def\deftypeivar{% \deftypemethparsebody\Edeftypeivar\deftypeivarx\deftypeivarheader} % % #1 is the class name, #2 the data type, #3 the variable name. \def\deftypeivarheader#1#2#3{% \dosubind{vr}{\code{#3}}{\putwordof\ \code{#1}}% entry in variable index \begingroup \defname{\defheaderxcond#2\relax$.$#3} {\putwordInstanceVariableof\ \code{#1}}% \defvarargs{#3}% \endgroup } % @defmethod == @defop Method % \def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} % % #1 is the class name, #2 the method name, #3 the args. \def\defmethodheader#1#2#3{% \dosubind{fn}{\code{#2}}{\putwordon\ \code{#1}}% entry in function index \begingroup \defname{#2}{\putwordMethodon\ \code{#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}}{\putwordof\ \code{#1}}% variable index entry \begingroup \defname{#2}{\defcvtype\ \putwordof\ #1}% \defvarargs{#3}% \endgroup } % @defivar CLASS VARNAME == @defcv {Instance Variable} CLASS VARNAME % \def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} % \def\defivarheader#1#2#3{% \dosubind{vr}{\code{#2}}{\putwordof\ \code{#1}}% entry in var index \begingroup \defname{#2}{\putwordInstanceVariableof\ #1}% \defvarargs{#3}% \endgroup } % @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% \defargscommonending } % @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}{\putwordDefvar}% \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}{\putwordDefopt}% \defvarargs {#2}\endgroup % } % @deftypevar int foobar \def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} % #1 is the data type. #2 is the name, perhaps followed by text that % is actually part of the data type, which should not be put into the index. \def\deftypevarheader #1#2{% \dovarind#2 \relax% Make entry in variables index \begingroup\defname {\defheaderxcond#1\relax$.$#2}{\putwordDeftypevar}% \defargscommonending \endgroup} \def\dovarind#1 #2\relax{\doind{vr}{\code{#1}}} % @deftypevr {Global Flag} int enable \def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} \def\deftypevrheader #1#2#3{\dovarind#3 \relax% \begingroup\defname {\defheaderxcond#2\relax$.$#3}{#1} \defargscommonending \endgroup} % 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{\deftpparsebody\Edeftp\deftpx\deftpheader} \def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% \begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} % These definitions are used if you use @defunx (etc.) % anywhere other than immediately after a @defun or @defunx. % \def\defcvx#1 {\errmessage{@defcvx in invalid context}} \def\deffnx#1 {\errmessage{@deffnx in invalid context}} \def\defivarx#1 {\errmessage{@defivarx in invalid context}} \def\defmacx#1 {\errmessage{@defmacx in invalid context}} \def\defmethodx#1 {\errmessage{@defmethodx in invalid context}} \def\defoptx #1 {\errmessage{@defoptx in invalid context}} \def\defopx#1 {\errmessage{@defopx in invalid context}} \def\defspecx#1 {\errmessage{@defspecx in invalid context}} \def\deftpx#1 {\errmessage{@deftpx in invalid context}} \def\deftypefnx#1 {\errmessage{@deftypefnx in invalid context}} \def\deftypefunx#1 {\errmessage{@deftypefunx in invalid context}} \def\deftypeivarx#1 {\errmessage{@deftypeivarx in invalid context}} \def\deftypemethodx#1 {\errmessage{@deftypemethodx in invalid context}} \def\deftypeopx#1 {\errmessage{@deftypeopx in invalid context}} \def\deftypevarx#1 {\errmessage{@deftypevarx in invalid context}} \def\deftypevrx#1 {\errmessage{@deftypevrx in invalid context}} \def\defunx#1 {\errmessage{@defunx in invalid context}} \def\defvarx#1 {\errmessage{@defvarx in invalid context}} \def\defvrx#1 {\errmessage{@defvrx in invalid context}} \message{macros,} % @macro. % To do this right we need a feature of e-TeX, \scantokens, % which we arrange to emulate with a temporary file in ordinary TeX. \ifx\eTeXversion\undefined \newwrite\macscribble \def\scanmacro#1{% \begingroup \newlinechar`\^^M % Undo catcode changes of \startcontents and \doprintindex \catcode`\@=0 \catcode`\\=\other \escapechar=`\@ % Append \endinput to make sure that TeX does not see the ending newline. \toks0={#1\endinput}% \immediate\openout\macscribble=\jobname.tmp \immediate\write\macscribble{\the\toks0}% \immediate\closeout\macscribble \let\xeatspaces\eatspaces \input \jobname.tmp \endgroup } \else \def\scanmacro#1{% \begingroup \newlinechar`\^^M % Undo catcode changes of \startcontents and \doprintindex \catcode`\@=0 \catcode`\\=\other \escapechar=`\@ \let\xeatspaces\eatspaces\scantokens{#1\endinput}\endgroup} \fi \newcount\paramno % Count of parameters \newtoks\macname % Macro name \newif\ifrecursive % Is it recursive? \def\macrolist{} % List of all defined macros in the form % \do\macro1\do\macro2... % Utility routines. % Thisdoes \let #1 = #2, except with \csnames. \def\cslet#1#2{% \expandafter\expandafter \expandafter\let \expandafter\expandafter \csname#1\endcsname \csname#2\endcsname} % Trim leading and trailing spaces off a string. % Concepts from aro-bend problem 15 (see CTAN). {\catcode`\@=11 \gdef\eatspaces #1{\expandafter\trim@\expandafter{#1 }} \gdef\trim@ #1{\trim@@ @#1 @ #1 @ @@} \gdef\trim@@ #1@ #2@ #3@@{\trim@@@\empty #2 @} \def\unbrace#1{#1} \unbrace{\gdef\trim@@@ #1 } #2@{#1} } % Trim a single trailing ^^M off a string. {\catcode`\^^M=\other \catcode`\Q=3% \gdef\eatcr #1{\eatcra #1Q^^MQ}% \gdef\eatcra#1^^MQ{\eatcrb#1Q}% \gdef\eatcrb#1Q#2Q{#1}% } % Macro bodies are absorbed as an argument in a context where % all characters are catcode 10, 11 or 12, except \ which is active % (as in normal texinfo). It is necessary to change the definition of \. % It's necessary to have hard CRs when the macro is executed. This is % done by making ^^M (\endlinechar) catcode 12 when reading the macro % body, and then making it the \newlinechar in \scanmacro. \def\macrobodyctxt{% \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \catcode`\{=\other \catcode`\}=\other \catcode`\@=\other \catcode`\^^M=\other \usembodybackslash} \def\macroargctxt{% \catcode`\~=\other \catcode`\^=\other \catcode`\_=\other \catcode`\|=\other \catcode`\<=\other \catcode`\>=\other \catcode`\+=\other \catcode`\@=\other \catcode`\\=\other} % \mbodybackslash is the definition of \ in @macro bodies. % It maps \foo\ => \csname macarg.foo\endcsname => #N % where N is the macro parameter number. % We define \csname macarg.\endcsname to be \realbackslash, so % \\ in macro replacement text gets you a backslash. {\catcode`@=0 @catcode`@\=@active @gdef@usembodybackslash{@let\=@mbodybackslash} @gdef@mbodybackslash#1\{@csname macarg.#1@endcsname} } \expandafter\def\csname macarg.\endcsname{\realbackslash} \def\macro{\recursivefalse\parsearg\macroxxx} \def\rmacro{\recursivetrue\parsearg\macroxxx} \def\macroxxx#1{% \getargs{#1}% now \macname is the macname and \argl the arglist \ifx\argl\empty % no arguments \paramno=0% \else \expandafter\parsemargdef \argl;% \fi \if1\csname ismacro.\the\macname\endcsname \message{Warning: redefining \the\macname}% \else \expandafter\ifx\csname \the\macname\endcsname \relax \else \errmessage{Macro name \the\macname\space already defined}\fi \global\cslet{macsave.\the\macname}{\the\macname}% \global\expandafter\let\csname ismacro.\the\macname\endcsname=1% % Add the macroname to \macrolist \toks0 = \expandafter{\macrolist\do}% \xdef\macrolist{\the\toks0 \expandafter\noexpand\csname\the\macname\endcsname}% \fi \begingroup \macrobodyctxt \ifrecursive \expandafter\parsermacbody \else \expandafter\parsemacbody \fi} \def\unmacro{\parsearg\dounmacro} \def\dounmacro#1{% \if1\csname ismacro.#1\endcsname \global\cslet{#1}{macsave.#1}% \global\expandafter\let \csname ismacro.#1\endcsname=0% % Remove the macro name from \macrolist: \begingroup \expandafter\let\csname#1\endcsname \relax \let\do\unmacrodo \xdef\macrolist{\macrolist}% \endgroup \else \errmessage{Macro #1 not defined}% \fi } % Called by \do from \dounmacro on each macro. The idea is to omit any % macro definitions that have been changed to \relax. % \def\unmacrodo#1{% \ifx#1\relax % remove this \else \noexpand\do \noexpand #1% \fi } % This makes use of the obscure feature that if the last token of a % is #, then the preceding argument is delimited by % an opening brace, and that opening brace is not consumed. \def\getargs#1{\getargsxxx#1{}} \def\getargsxxx#1#{\getmacname #1 \relax\getmacargs} \def\getmacname #1 #2\relax{\macname={#1}} \def\getmacargs#1{\def\argl{#1}} % Parse the optional {params} list. Set up \paramno and \paramlist % so \defmacro knows what to do. Define \macarg.blah for each blah % in the params list, to be ##N where N is the position in that list. % That gets used by \mbodybackslash (above). % We need to get `macro parameter char #' into several definitions. % The technique used is stolen from LaTeX: let \hash be something % unexpandable, insert that wherever you need a #, and then redefine % it to # just before using the token list produced. % % The same technique is used to protect \eatspaces till just before % the macro is used. \def\parsemargdef#1;{\paramno=0\def\paramlist{}% \let\hash\relax\let\xeatspaces\relax\parsemargdefxxx#1,;,} \def\parsemargdefxxx#1,{% \if#1;\let\next=\relax \else \let\next=\parsemargdefxxx \advance\paramno by 1% \expandafter\edef\csname macarg.\eatspaces{#1}\endcsname {\xeatspaces{\hash\the\paramno}}% \edef\paramlist{\paramlist\hash\the\paramno,}% \fi\next} % These two commands read recursive and nonrecursive macro bodies. % (They're different since rec and nonrec macros end differently.) \long\def\parsemacbody#1@end macro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% \long\def\parsermacbody#1@end rmacro% {\xdef\temp{\eatcr{#1}}\endgroup\defmacro}% % This defines the macro itself. There are six cases: recursive and % nonrecursive macros of zero, one, and many arguments. % Much magic with \expandafter here. % \xdef is used so that macro definitions will survive the file % they're defined in; @include reads the file inside a group. \def\defmacro{% \let\hash=##% convert placeholders to macro parameter chars \ifrecursive \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\scanmacro{\temp}}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup\noexpand\scanmacro{\temp}}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{\egroup\noexpand\scanmacro{\temp}}% \fi \else \ifcase\paramno % 0 \expandafter\xdef\csname\the\macname\endcsname{% \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \or % 1 \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \noexpand\braceorline \expandafter\noexpand\csname\the\macname xxx\endcsname}% \expandafter\xdef\csname\the\macname xxx\endcsname##1{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \else % many \expandafter\xdef\csname\the\macname\endcsname{% \bgroup\noexpand\macroargctxt \expandafter\noexpand\csname\the\macname xx\endcsname}% \expandafter\xdef\csname\the\macname xx\endcsname##1{% \expandafter\noexpand\csname\the\macname xxx\endcsname ##1,}% \expandafter\expandafter \expandafter\xdef \expandafter\expandafter \csname\the\macname xxx\endcsname \paramlist{% \egroup \noexpand\norecurse{\the\macname}% \noexpand\scanmacro{\temp}\egroup}% \fi \fi} \def\norecurse#1{\bgroup\cslet{#1}{macsave.#1}} % \braceorline decides whether the next nonwhitespace character is a % {. If so it reads up to the closing }, if not, it reads the whole % line. Whatever was read is then fed to the next control sequence % as an argument (by \parsebrace or \parsearg) \def\braceorline#1{\let\next=#1\futurelet\nchar\braceorlinexxx} \def\braceorlinexxx{% \ifx\nchar\bgroup\else \expandafter\parsearg \fi \next} % We mant to disable all macros during \shipout so that they are not % expanded by \write. \def\turnoffmacros{\begingroup \def\do##1{\let\noexpand##1=\relax}% \edef\next{\macrolist}\expandafter\endgroup\next} % @alias. % We need some trickery to remove the optional spaces around the equal % sign. Just make them active and then expand them all to nothing. \def\alias{\begingroup\obeyspaces\parsearg\aliasxxx} \def\aliasxxx #1{\aliasyyy#1\relax} \def\aliasyyy #1=#2\relax{\ignoreactivespaces \edef\next{\global\let\expandafter\noexpand\csname#1\endcsname=% \expandafter\noexpand\csname#2\endcsname}% \expandafter\endgroup\next} \message{cross references,} % @xref etc. \newwrite\auxfile \newif\ifhavexrefs % True if xref values are known. \newif\ifwarnedxrefs % True if we warned once that they aren't known. % @inforef is relatively simple. \def\inforef #1{\inforefzzz #1,,,,**} \def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, node \samp{\ignorespaces#1{}}} % @node's job is to define \lastnode. \def\node{\ENVcheck\parsearg\nodezzz} \def\nodezzz#1{\nodexxx [#1,]} \def\nodexxx[#1,#2]{\gdef\lastnode{#1}} \let\nwnode=\node \let\lastnode=\relax % The sectioning commands (@chapter, etc.) call these. \def\donoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Ysectionnumberandtype}% \global\let\lastnode=\relax \fi } \def\unnumbnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}{Ynothing}% \global\let\lastnode=\relax \fi } \def\appendixnoderef{% \ifx\lastnode\relax\else \expandafter\expandafter\expandafter\setref{\lastnode}% {Yappendixletterandtype}% \global\let\lastnode=\relax \fi } % @anchor{NAME} -- define xref target at arbitrary point. % \newcount\savesfregister \gdef\savesf{\relax \ifhmode \savesfregister=\spacefactor \fi} \gdef\restoresf{\relax \ifhmode \spacefactor=\savesfregister \fi} \gdef\anchor#1{\savesf \setref{#1}{Ynothing}\restoresf \ignorespaces} % \setref{NAME}{SNT} defines a cross-reference point NAME (a node or an % anchor), namely NAME-title (the corresponding @chapter/etc. name), % NAME-pg (the page number), and NAME-snt (section number and type). % Called from \foonoderef. % % We have to set \indexdummies so commands such as @code in a section % title aren't expanded. It would be nicer not to expand the titles in % the first place, but there's so many layers that that is hard to do. % % Likewise, use \turnoffactive so that punctuation chars such as underscore % and backslash work in node names. % \def\setref#1#2{{% \atdummies \pdfmkdest{#1}% % \turnoffactive \dosetq{#1-title}{Ytitle}% \dosetq{#1-pg}{Ypagenumber}% \dosetq{#1-snt}{#2}% }} % @xref, @pxref, and @ref generate cross-references. 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{\putwordsee{} \xrefX[#1,,,,,,,]} \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces \def\printedmanual{\ignorespaces #5}% \def\printednodename{\ignorespaces #3}% \setbox1=\hbox{\printedmanual}% \setbox0=\hbox{\printednodename}% \ifdim \wd0 = 0pt % No printed node name was explicitly given. \expandafter\ifx\csname SETxref-automatic-section-title\endcsname\relax % Use the node name inside the square brackets. \def\printednodename{\ignorespaces #1}% \else % Use the actual chapter/section title appear inside % the square brackets. Use the real section title if we have it. \ifdim \wd1 > 0pt % It is in another manual, so we don't have it. \def\printednodename{\ignorespaces #1}% \else \ifhavexrefs % We know the real title if we have the xref values. \def\printednodename{\refx{#1-title}{}}% \else % Otherwise just copy the Info node name. \def\printednodename{\ignorespaces #1}% \fi% \fi \fi \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 give the text of the node name again, so it % is as if TeX is seeing it for the first time. \ifpdf \leavevmode \getfilename{#4}% {\turnoffactive \otherbackslash \ifnum\filenamelength>0 \startlink attr{/Border [0 0 0]}% goto file{\the\filename.pdf} name{#1}% \else \startlink attr{/Border [0 0 0]}% goto name{#1}% \fi }% \linkcolor \fi % \ifdim \wd1 > 0pt \putwordsection{} ``\printednodename'' \putwordin{} \cite{\printedmanual}% \else % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand % into the usual \leavevmode...\vrule stuff for purposes of % printing. So we \turnoffactive for the \refx-snt, back on for the % printing, back off for the \refx-pg. {\turnoffactive \otherbackslash % Only output a following space if the -snt ref is nonempty; for % @unnumbered and @anchor, it won't be. \setbox2 = \hbox{\ignorespaces \refx{#1-snt}{}}% \ifdim \wd2 > 0pt \refx{#1-snt}\space\fi }% % [mynode], [\printednodename],\space % page 3 \turnoffactive \otherbackslash \putwordpage\tie\refx{#1-pg}{}% \fi \endlink \endgroup} % \dosetq is called from \setref to do the actual \write (\iflinks). % \def\dosetq#1#2{% {\let\folio=0% \edef\next{\write\auxfile{\internalsetq{#1}{#2}}}% \iflinks \next \fi }% } % \internalsetq{foo}{page} expands into % CHARACTERS @xrdef{foo}{...expansion of \page...} \def\internalsetq#1#2{@xrdef{#1}{\csname #2\endcsname}} % Things to be expanded by \internalsetq. % \def\Ypagenumber{\folio} \def\Ytitle{\thissection} \def\Ynothing{} \def\Ysectionnumberandtype{% \ifnum\secno=0 \putwordChapter@tie \the\chapno \else \ifnum\subsecno=0 \putwordSection@tie \the\chapno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie \the\chapno.\the\secno.\the\subsecno \else \putwordSection@tie \the\chapno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } \def\Yappendixletterandtype{% \ifnum\secno=0 \putwordAppendix@tie @char\the\appendixno{}% \else \ifnum\subsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno \else \ifnum\subsubsecno=0 \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno \else \putwordSection@tie @char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno \fi\fi\fi } % 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 % Pre-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{% {% \indexnofonts \otherbackslash \expandafter\global\expandafter\let\expandafter\thisrefX \csname X#1\endcsname }% \ifx\thisrefX\relax % If not defined, say something at least. \angleleft un\-de\-fined\angleright \iflinks \ifhavexrefs \message{\linenumber Undefined cross reference `#1'.}% \else \ifwarnedxrefs\else \global\warnedxrefstrue \message{Cross reference values unknown; you must run TeX again.}% \fi \fi \fi \else % It's defined, so just use it. \thisrefX \fi #2% Output the suffix in any case. } % This is the macro invoked by entries in the aux file. % \def\xrdef#1{\expandafter\gdef\csname X#1\endcsname} % Read the last existing aux file, if any. No error if none exists. \def\readauxfile{\begingroup \catcode`\^^@=\other \catcode`\^^A=\other \catcode`\^^B=\other \catcode`\^^C=\other \catcode`\^^D=\other \catcode`\^^E=\other \catcode`\^^F=\other \catcode`\^^G=\other \catcode`\^^H=\other \catcode`\^^K=\other \catcode`\^^L=\other \catcode`\^^N=\other \catcode`\^^P=\other \catcode`\^^Q=\other \catcode`\^^R=\other \catcode`\^^S=\other \catcode`\^^T=\other \catcode`\^^U=\other \catcode`\^^V=\other \catcode`\^^W=\other \catcode`\^^X=\other \catcode`\^^Z=\other \catcode`\^^[=\other \catcode`\^^\=\other \catcode`\^^]=\other \catcode`\^^^=\other \catcode`\^^_=\other % It was suggested to set the catcode of ^ to 7, which would allow ^^e4 etc. % in xref tags, i.e., node names. But since ^^e4 notation isn't % supported in the main text, it doesn't seem desirable. Furthermore, % that is not enough: for node names that actually contain a ^ % character, we would end up writing a line like this: 'xrdef {'hat % b-title}{'hat b} and \xrdef does a \csname...\endcsname on the first % argument, and \hat is not an expandable control sequence. It could % all be worked out, but why? Either we support ^^ or we don't. % % The other change necessary for this was to define \auxhat: % \def\auxhat{\def^{'hat }}% extra space so ok if followed by letter % and then to call \auxhat in \setq. % \catcode`\^=\other % % Special characters. Should be turned off anyway, but... \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 % avoid \+ for paranoia even though we've turned it off % % Make the characters 128-255 be printing characters {% \count 1=128 \def\loop{% \catcode\count 1=\other \advance\count 1 by 1 \ifnum \count 1<256 \loop \fi }% }% % % 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`\\=\other % % @ is our escape character in .aux files. \catcode`\{=1 \catcode`\}=2 \catcode`\@=0 % \openin 1 \jobname.aux \ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue \global\warnedobstrue \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. (Generally, numeric constants should always be followed by a % space to prevent strange expansion errors.) \def\supereject{\par\penalty -20000\footnoteno =0 } % @footnotestyle is meaningful for info output only. \let\footnotestyle=\comment \let\ptexfootnote=\footnote {\catcode `\@=11 % % Auto-number footnotes. Otherwise like plain. \gdef\footnote{% \global\advance\footnoteno by \@ne \edef\thisfootno{$^{\the\footnoteno}$}% % % In case the footnote comes at the end of a sentence, preserve the % extra spacing after we do the footnote number. \let\@sf\empty \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi % % Remove inadvertent blank space before typesetting the footnote number. \unskip \thisfootno\@sf \dofootnote }% % Don't bother with the trickery in plain.tex to not require the % footnote text as a parameter. Our footnotes don't need to be so general. % % Oh yes, they do; otherwise, @ifset and anything else that uses % \parseargline fail inside footnotes because the tokens are fixed when % the footnote is read. --karl, 16nov96. % % The start of the footnote looks usually like this: \gdef\startfootins{\insert\footins\bgroup} % % ... but this macro is redefined inside @multitable. % \gdef\dofootnote{% \startfootins % We want to typeset this text as a normal paragraph, even if the % footnote reference occurs in (for example) a display environment. % So reset some parameters. \hsize=\pagewidth \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 \parindent\defaultparindent % \smallfonts \rm % % Because we use hanging indentation in footnotes, a @noindent appears % to exdent this text, so make it be a no-op. makeinfo does not use % hanging indentation so @noindent can still be needed within footnote % text after an @example or the like (not that this is good style). \let\noindent = \relax % % Hang the footnote text off the number. Use \everypar in case the % footnote extends for more than one paragraph. \everypar = {\hang}% \textindent{\thisfootno}% % % Don't crash into the line above the footnote text. Since this % expands into a box, it must come within the paragraph, lest it % provide a place where TeX can split the footnote. \footstrut \futurelet\next\fo@t } }%end \catcode `\@=11 % @| inserts a changebar to the left of the current line. It should % surround any changed text. This approach does *not* work if the % change spans more than two lines of output. To handle that, we would % have adopt a much more difficult approach (putting marks into the main % vertical list for the beginning and end of each change). % \def\|{% % \vadjust can only be used in horizontal mode. \leavevmode % % Append this vertical mode material after the current line in the output. \vadjust{% % We want to insert a rule with the height and depth of the current % leading; that is exactly what \strutbox is supposed to record. \vskip-\baselineskip % % \vadjust-items are inserted at the left edge of the type. So % the \llap here moves out into the left-hand margin. \llap{% % % For a thicker or thinner bar, change the `1pt'. \vrule height\baselineskip width1pt % % This is the space between the bar and the text. \hskip 12pt }% }% } % 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} % @image. We use the macros from epsf.tex to support this. % If epsf.tex is not installed and @image is used, we complain. % % Check for and read epsf.tex up front. If we read it only at @image % time, we might be inside a group, and then its definitions would get % undone and the next image would fail. \openin 1 = epsf.tex \ifeof 1 \else \closein 1 % Do not bother showing banner with epsf.tex v2.7k (available in % doc/epsf.tex and on ctan). \def\epsfannounce{\toks0 = }% \input epsf.tex \fi % % We will only complain once about lack of epsf.tex. \newif\ifwarnednoepsf \newhelp\noepsfhelp{epsf.tex must be installed for images to work. It is also included in the Texinfo distribution, or you can get it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% \ifx\epsfbox\undefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% \global\warnednoepsftrue \fi \else \imagexxx #1,,,,,\finish \fi } % % Arguments to @image: % #1 is (mandatory) image filename; we tack on .eps extension. % #2 is (optional) width, #3 is (optional) height. % #4 is (ignored optional) html alt text. % #5 is (ignored optional) extension. % #6 is just the usual extra ignored arg for parsing this stuff. \newif\ifimagevmode \def\imagexxx#1,#2,#3,#4,#5,#6\finish{\begingroup \catcode`\^^M = 5 % in case we're inside an example \normalturnoffactive % allow _ et al. in names % If the image is by itself, center it. \ifvmode \imagevmodetrue \nobreak\bigskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space % above and below. \nobreak\vskip\parskip \nobreak \line\bgroup\hss \fi % % Output the image. \ifpdf \dopdfimage{#1}{#2}{#3}% \else % \epsfbox itself resets \epsf?size at each figure. \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \epsfxsize=#2\relax \fi \setbox0 = \hbox{\ignorespaces #3}\ifdim\wd0 > 0pt \epsfysize=#3\relax \fi \epsfbox{#1.eps}% \fi % \ifimagevmode \hss \egroup \bigbreak \fi % space after the image \endgroup} \message{localization,} % and i18n. % @documentlanguage is usually given very early, just after % @setfilename. If done too late, it may not override everything % properly. Single argument is the language abbreviation. % It would be nice if we could set up a hyphenation file here. % \def\documentlanguage{\parsearg\dodocumentlanguage} \def\dodocumentlanguage#1{% \tex % read txi-??.tex file in plain TeX. % Read the file if it exists. \openin 1 txi-#1.tex \ifeof1 \errhelp = \nolanghelp \errmessage{Cannot read language file txi-#1.tex}% \let\temp = \relax \else \def\temp{\input txi-#1.tex }% \fi \temp \endgroup } \newhelp\nolanghelp{The given language definition file cannot be found or is empty. Maybe you need to install it? In the current directory should work if nowhere else does.} % @documentencoding should change something in TeX eventually, most % likely, but for now just recognize it. \let\documentencoding = \comment % Page size parameters. % \newdimen\defaultparindent \defaultparindent = 15pt \chapheadingskip = 15pt plus 4pt minus 2pt \secheadingskip = 12pt plus 3pt minus 2pt \subsecheadingskip = 9pt plus 2pt minus 2pt % Prevent underfull vbox error messages. \vbadness = 10000 % Don't be so finicky about underfull hboxes, either. \hbadness = 2000 % 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. We call this whenever the paper size is set. % \def\setemergencystretch{% \ifx\emergencystretch\thisisundefined % Allow us to assign to \emergencystretch anyway. \def\emergencystretch{\dimen0}% \else \emergencystretch = .15\hsize \fi } % Parameters in order: 1) textheight; 2) textwidth; 3) voffset; % 4) hoffset; 5) binding offset; 6) topskip; 7) physical page height; 8) % physical page width. % % We also call \setleading{\textleading}, so the caller should define % \textleading. The caller should also set \parskip. % \def\internalpagesizes#1#2#3#4#5#6#7#8{% \voffset = #3\relax \topskip = #6\relax \splittopskip = \topskip % \vsize = #1\relax \advance\vsize by \topskip \outervsize = \vsize \advance\outervsize by 2\topandbottommargin \pageheight = \vsize % \hsize = #2\relax \outerhsize = \hsize \advance\outerhsize by 0.5in \pagewidth = \hsize % \normaloffset = #4\relax \bindingoffset = #5\relax % \ifpdf \pdfpageheight #7\relax \pdfpagewidth #8\relax \fi % \setleading{\textleading} % \parindent = \defaultparindent \setemergencystretch } % @letterpaper (the default). \def\letterpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % If page is nothing but text, make it come out even. \internalpagesizes{46\baselineskip}{6in}% {\voffset}{.25in}% {\bindingoffset}{36pt}% {11in}{8.5in}% }} % Use @smallbook to reset parameters for 7x9.5 (or so) format. \def\smallbook{{\globaldefs = 1 \parskip = 2pt plus 1pt \textleading = 12pt % \internalpagesizes{7.5in}{5in}% {\voffset}{.25in}% {\bindingoffset}{16pt}% {9.25in}{7in}% % \lispnarrowing = 0.3in \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = .5cm }} % Use @afourpaper to print on European A4 paper. \def\afourpaper{{\globaldefs = 1 \parskip = 3pt plus 2pt minus 1pt \textleading = 13.2pt % % Double-side printing via postscript on Laserjet 4050 % prints double-sided nicely when \bindingoffset=10mm and \hoffset=-6mm. % To change the settings for a different printer or situation, adjust % \normaloffset until the front-side and back-side texts align. Then % do the same for \bindingoffset. You can set these for testing in % your texinfo source file like this: % @tex % \global\normaloffset = -6mm % \global\bindingoffset = 10mm % @end tex \internalpagesizes{51\baselineskip}{160mm} {\voffset}{\hoffset}% {\bindingoffset}{44pt}% {297mm}{210mm}% % \tolerance = 700 \hfuzz = 1pt \contentsrightmargin = 0pt \defbodyindent = 5mm }} % Use @afivepaper to print on European A5 paper. % From romildo@urano.iceb.ufop.br, 2 July 2000. % He also recommends making @example and @lisp be small. \def\afivepaper{{\globaldefs = 1 \parskip = 2pt plus 1pt minus 0.1pt \textleading = 12.5pt % \internalpagesizes{160mm}{120mm}% {\voffset}{\hoffset}% {\bindingoffset}{8pt}% {210mm}{148mm}% % \lispnarrowing = 0.2in \tolerance = 800 \hfuzz = 1.2pt \contentsrightmargin = 0pt \defbodyindent = 2mm \tableindent = 12mm }} % A specific text layout, 24x15cm overall, intended for A4 paper. \def\afourlatex{{\globaldefs = 1 \afourpaper \internalpagesizes{237mm}{150mm}% {\voffset}{4.6mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% % % Must explicitly reset to 0 because we call \afourpaper. \globaldefs = 0 }} % Use @afourwide to print on A4 paper in landscape format. \def\afourwide{{\globaldefs = 1 \afourpaper \internalpagesizes{241mm}{165mm}% {\voffset}{-2.95mm}% {\bindingoffset}{7mm}% {297mm}{210mm}% \globaldefs = 0 }} % @pagesizes TEXTHEIGHT[,TEXTWIDTH] % Perhaps we should allow setting the margins, \topskip, \parskip, % and/or leading, also. Or perhaps we should compute them somehow. % \def\pagesizes{\parsearg\pagesizesxxx} \def\pagesizesxxx#1{\pagesizesyyy #1,,\finish} \def\pagesizesyyy#1,#2,#3\finish{{% \setbox0 = \hbox{\ignorespaces #2}\ifdim\wd0 > 0pt \hsize=#2\relax \fi \globaldefs = 1 % \parskip = 3pt plus 2pt minus 1pt \setleading{\textleading}% % \dimen0 = #1 \advance\dimen0 by \voffset % \dimen2 = \hsize \advance\dimen2 by \normaloffset % \internalpagesizes{#1}{\hsize}% {\voffset}{\normaloffset}% {\bindingoffset}{44pt}% {\dimen0}{\dimen2}% }} % Set default to letter. % \letterpaper \message{and turning on texinfo input format.} % 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 \catcode`\$=\other \def\normaldoublequote{"} \def\normaltilde{~} \def\normalcaret{^} \def\normalunderscore{_} \def\normalverticalbar{|} \def\normalless{<} \def\normalgreater{>} \def\normalplus{+} \def\normaldollar{$}%$ font-lock fix % 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\font=0pt #1\else #2\fi} % Same as above, but check for italic font. Actually this also catches % non-italic slanted fonts since it is impossible to distinguish them from % italic fonts. But since this is only used by $ and it uses \sl anyway % this is not a problem. \def\ifusingit#1#2{\ifdim \fontdimen1\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\char34}} \let"=\activedoublequote \catcode`\~=\active \def~{{\tt\char126}} \chardef\hat=`\^ \catcode`\^=\active \def^{{\tt \hat}} \catcode`\_=\active \def_{\ifusingtt\normalunderscore\_} % Subroutine for the previous macro. \def\_{\leavevmode \kern.07em \vbox{\hrule width.3em height.1ex}\kern .07em } \catcode`\|=\active \def|{{\tt\char124}} \chardef \less=`\< \catcode`\<=\active \def<{{\tt \less}} \chardef \gtr=`\> \catcode`\>=\active \def>{{\tt \gtr}} \catcode`\+=\active \def+{{\tt \char 43}} \catcode`\$=\active \def${\ifusingit{{\sl\$}}\normaldollar}%$ font-lock fix % Set up an active definition for =, but don't enable it most of the time. {\catcode`\==\active \global\def={{\tt \char 61}}} \catcode`+=\active \catcode`\_=\active % If a .fmt file is being used, characters that might appear in a file % name cannot be active until we have parsed the command line. % So turn them off again, and have \everyjob (or @setfilename) turn them on. % \otherifyactive is called near the end of this file. \def\otherifyactive{\catcode`+=\other \catcode`\_=\other} \catcode`\@=0 % \rawbackslashxx outputs one backslash character in current font, % as in \char`\\. \global\chardef\rawbackslashxx=`\\ % \rawbackslash defines an active \ to do \rawbackslashxx. % \otherbackslash defines an active \ to be a literal `\' character with % catcode other. {\catcode`\\=\active @gdef@rawbackslash{@let\=@rawbackslashxx} @gdef@otherbackslash{@let\=@realbackslash} } % \realbackslash is an actual character `\' with catcode other. {\catcode`\\=\other @gdef@realbackslash{\}} % \normalbackslash outputs one backslash in fixed width font. \def\normalbackslash{{\tt\rawbackslashxx}} \catcode`\\=\active % Used sometimes to turn off (effectively) the active characters % even after parsing them. @def@turnoffactive{% @let"=@normaldoublequote @let\=@realbackslash @let~=@normaltilde @let^=@normalcaret @let_=@normalunderscore @let|=@normalverticalbar @let<=@normalless @let>=@normalgreater @let+=@normalplus @let$=@normaldollar %$ font-lock fix } % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of % the literal character `\'. (Thus, \ is not expandable when this is in % effect.) % @def@normalturnoffactive{@turnoffactive @let\=@normalbackslash} % Make _ and + \other characters, temporarily. % This is canceled by @fixbackslash. @otherifyactive % 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. % Also back turn on active characters that might appear in the input % file name, in case not using a pre-dumped format. % @gdef@fixbackslash{% @ifx\@eatinput @let\ = @normalbackslash @fi @catcode`+=@active @catcode`@_=@active } % Say @foo, not \foo, in error messages. @escapechar = `@@ % These look ok in all fonts, so just make them not special. @catcode`@& = @other @catcode`@# = @other @catcode`@% = @other @c Set initial fonts. @textfonts @rm @c Local variables: @c eval: (add-hook 'write-file-hooks 'time-stamp) @c page-delimiter: "^\\\\message" @c time-stamp-start: "def\\\\texinfoversion{" @c time-stamp-format: "%:y-%02m-%02d.%02H" @c time-stamp-end: "}" @c End: bhl-1.7.3/ChangeLog0100644000076400007640000003751110146222714013474 0ustar guerryguerry2004-11-15 Bastien Guerry * bhl.el: patched bhl.el fixed verbatim/comment/link conversion added bhl-latex-extra-preambles added bhl-latex-extra-body 2004-11-13 Bastien Guerry * bhl.el (Module) Added ==== and //// for larger fr Added bhl-tags-overlap (and modified menu). 2003-11-25 Bastien Guerry * bhl.el (Module): Checkdoc OK: changed bhl-is-a-local-wiki to bhl-is-a-local-wiki-flag. Added bhl-autoguess-style-flag (default to t) Added Interactive bhl-guess-style: C-c M-s (& menu) Fixed a bug concerning WikiNames conversion. Updated the manual. 2003-11-24 Bastien Guerry * bhl.el (Module): bhl2html now converts < and >. You can escape backslashes for bhl2latex conversion. That means: "\\" -> "$\backslash$" (just for latex) bhl-convert-para matches lines beginning with a `@'. bhl-check-existing-tags rewritten so that verbatim environnements are not skipped. 2003-07-25 Bastien Guerry * bhl.el (Module): Fixed a bug concerning minipage conversion into LaTeX. 2003-07-22 Bastien Guerry * bhl.el (Module): Fixed a bug concerning tag conversion. Fixed a bug concerning the title conversion (special chars). Fixed a bug concerning special chars conversion. 2003-07-19 Bastien Guerry * bhl.el (Module): Added url:blabla as an url. 2003-07-17 Bastien Guerry * bhl.el (Module): Added bhl-ignored-regexp and bhl-ignore-regexp-line. 2003-07-14 Bastien Guerry * bhl.el (Module): Downcased html tags Added bhl-is-a-local-wiki Added specification : #!title! #!xxx-title! #!latex-package! Added the quote environment 2003-04-29 Bastien Guerry * bhl.el (Module): Fixed bhl-indent-line. 2003-04-03 Bastien Guerry * bhl.el (Module): Fixed a bug concerning escaping chars in LaTeX (thx to Thomas G.) 2003-03-31 Bastien Guerry * bhl.el (Module): You can now escape underscore inside links and images. Added a mechanism for escaping chars when converting into LaTeX. `bhl-check-existing-tags' dont stop anymore at things like \this. 2003-03-27 Bastien Guerry * bhl.el (Module): Use my own bhl-replace-regexp-in-string (fixed XEmacs table conversion bug). Put (provide 'bhl) at the end of bhl.el. Fixed a bug concerning `bhl-show-toc'. 2003-03-25 Bastien Guerry * bhl.el (Module): Release of BHL 1.6 2003-03-21 Bastien Guerry * bhl.el (Module): Protected footnotes inside (sub)sections' title. Fixed a bug concerning the BHL menu for XEmacs (thx to Jacob Hamacher). Added bhl-insert-lol . 2003-03-20 Bastien Guerry * bhl.el (Module): Added insertion of the subtitle into TXT output. Fixed bugs concerning description lists (thx to J. Stauffer). Changed french quote from <<...>> to ... into LaTeX output. Added bhl-texi-toggle-accents. Added "footnote" to `bhl-verbatim-ignore'. 2003-03-18 Bastien Guerry * bhl.el (Module): Added documentation for bhl-url-regexp. Fixed a bug concerning bhl-check in SGML format. Added "lang", "encoding" and "texi-style" specifications. 2003-03-17 Bastien Guerry * bhl.el (Module): C-down-mouse-3 for the popup menu: avoid conflict with X keys. Fixed a bug concerning the insertion of ε (was ε). Removed the binding in the output buffer. Removed bhl-txt-tabs-are-spc (-> TAS: see properties list). Specification should be at the *beginning* of the line. Cleaned up some ugly code. 2003-03-14 Bastien Guerry * bhl.el (Module): Fixed some (invalid "\" in replacement) errors. Added `bhl-replace-tab-with-spc' and `bhl-txt-tabs-are-spc'. Use `defalias' instead of `defsubst' for XEmacs compat. Added `bhl-non-wiki-names-list' and `bhl-non-wiki-names-unhighlight'. Fixed a bug concerning the 'check' specification. 2003-03-13 Bastien Guerry * bhl.el (Module): bhl-sectioning-guess-style is not interactive anymore. Added hooks after global conversion and format-relative conversion. Fixed a bug in the LaTeX footnote conversion (thx to Mario Domgrgen). 2003-03-12 Bastien Guerry * bhl.el (Module): Get rid of the setplist calls. Fixed wrong (get 'html ...). Added bhl-hide-comment. Bhl mode now guesses automatically the style. Some message strings have been added. bhl-show-lol doesn't return an error while listing a buffer which does not include any link. The popup keymap doesn't make an error when no local-keymap is currently defined (thx to Mario Domgrgen). 2003-03-11 Bastien Guerry * bhl.el (Module): Added \' to bhl-xx-quotation-marks. Removed "ue" from deutsch special chars. Added (rear-nonsticky t) property to URL and WikiNames. 2003-03-10 Bastien Guerry * bhl.el (Module): Fixed stupid empty &optional in bhl2xxx. Fixed a bug concerning bhl-skip-toc. 2003-03-06 Bastien Guerry * bhl.el (Module): Moved bhl-sec-* to bhl-sectioning-*. Made bhl-sectioning-switch-style interactive. Added (face bold) in bhl-lol/toc-mode. Added some (custom-manual) entries. 2003-03-05 Bastien Guerry * bhl.el (Module): Added bhl-show-links (C-c C-/). Removed bhl-main-buffer. Fixed conflictual keymap [(mouse-2)]. 2003-03-04 Bastien Guerry * bhl.el (Module): Added html-style, latex-class and latex-options specifications. Rewritten bhl-parse-specifications. Renamed bhl-sectioning-style to bhl-default-sectioning-style. Renamed bhl-html-style to bhl-html-default-style. Added bhl-convert-toc property. Added bhl-verbatim-ignore and subsequent code inside the core conversion functions so that verbatim and comment regions are properly handled. Removed some unuseful save-excursion. Support for format-time-string in date specification. 2003-03-03 Bastien Guerry * bhl.el (Module): Added bhl-add-text-properties. Added bhl-guess-sectioning-style. Changed "equal" style to "equal-sign". Fixed a BUG concerning i18n conversion. Fixed the bug concerning bad conversion inside links, verbatim and comments. 2003-03-02 Bastien Guerry * bhl.el (Module): Clean up (eval (intern ...) Thx to D. Katz. Added bhl-cleanup-cell (no more whitespaces in cells). Changed alist keys from bhl-xxx to xxx. 2003-02-28 Bastien Guerry * bhl.el (Module): Updated bhl-submit-bug-report. Added bhl-latex-default-class and bhl-latex-default-class-options. Removed bhl-latex-class and bhl-latex-pt. Added recognizing of some headers (author, date). Added bhl-xxx-list-item-is-para. Added WikiNames handling (highlighting, browsing, following.) Removed bhl-goto-previous-url (no use?) Converted bhl-goto-next-url into bhl-goto-next-url-or-wiki. 2003-02-27 Bastien Guerry * bhl.el (Module): Removed umlaut from bhl-de-special-chars. 2003-02-26 Bastien Guerry * bhl.el (Module): A header cell is now indicated by @...@. 2003-02-25 Bastien Guerry * bhl.el (Module): Added custom variables for faces. Enhanced fontification (-> XEmacs). Removed bhl-uncomment-region (now in bhl-comment-region). Removed (require 'foonote) (-> XEmacs). Modified bhl-sec-regexp-list. Changed the matching of headers in tables (@). 2003-02-24 Bastien Guerry * bhl.el (Module): Fixed table headers conversion -- thx to D. Katz. Added bhl-mark-active (-> XEmacs). 2003-02-22 Bastien Guerry * bhl.el (Module): Get rid of the mode-line. Get rid of skeleton (-> XEmacs) Modified bhl-change-font. Added bhl-change-font-normal. Simplified the handling of plist and the parsing of specifications: fixed a BIG BAD BUG that prevented the customization of bhl2xxx. Added bhl-initialize-properties. 2003-02-21 Bastien Guerry * bhl.el (Module): Added bhl-match-string. Fixed the ref to free var caption. Minor documentation fixes. Changed bhl-generic-url-regexp "<". Removed the `copy-to-register'. Added a popup menu (down-mouse-2). Point set to min after conversion. Cursor now at the right place in bhl-show-toc. Synchro depth of toc inserted while in *toc*. Modified bhl-convert-para: too much looking-at. Fixed bhl-comment-region. 2003-02-20 Bastien Guerry * bhl.el (Module): Rewritten bhl2xxx-convert-table (faster). Fixed indentation for description lists. Removed bad fset in Emacs namespace. Removed all add-to-list (Emacs20 & XEmacs). Put bhl-add-to-conversion-list -- thx to Mario. Fixed a stupid bug of `bhl-convert-verbatim' - thx to Massimiliano. 2003-02-19 Bastien Guerry * bhl.el (Module): Removed the :help tags in the menu. Added bhl-list-regexp-list. Added bhl-list-syntax-alist. Enhanced list conversion (nesting & indentation). Change bhl-img-face. Rewritten bhl-convert-img. Added bhl-uncomment-region. 2003-02-18 Bastien Guerry * bhl.el (Module): Added bhl-comment-region. Added support for comment conversion. Added support for line specification. Updated the menu. Added bhl2xxx-default-plist. Added bhl-sec-turn-to-alpha/num. Added support for different sectioning styles Fully rewritten the way of TOC handling. Nice colors (DarkBhl). Added support for escape chars. Removed "propertize". Removed imenu-generic-expression. Removed bhl-table-ask-caption-flag Removed bhl-txt-center-flag. New key binding for bhl-insert-tab: M-TAB Renamed `bhl-tab' to `bhl-insert-tab'. Rewritten key bindings. Removed default conversion of footnote. Fixed replace-tag and replace-section. 2003-02-04 Bastien Guerry * bhl.el (Module): Added auto-indentation when editing lists. Added a bhl-tab-width variable. 2003-02-02 Bastien Guerry * bhl.el (Module): Changed the output of LaTeX labels. 2003-01-29 Bastien Guerry * bhl.el (Module): Changed the sections' labels for bhl2txt. 2003-01-26 Bastien Guerry * bhl.el (Module): Changed the fontified match-string of tags. Changed bhl-convert-para -> \&"' Fixed minors bugs concerning list conversion. bhl-check now handles \blabla tags. 2003-01-25 Bastien Guerry * bhl.el (Module): Enhanced bhl-convert-para (bug fixes). Handling some errors with footnotes. Fixed a bug concerning sections' numbering. The first "|" of table must be at the beginning of the line: so that you can insert "|" inside verbatim environment by adding a whitespace. Changed the replace-tag defun. 2003-01-22 Bastien Guerry * bhl-mode.el (Module): Added support for footnotes conversion. Added a check-no-tags function. Added a verbatim and minipage environment. Added a way to define the length of hr. Changed the highlighting functions. URLs are now clickable. Updated the menu. Changed the bhl-insert-img function. Changed the bhl-img-regexp. Splitted the bhl-url-regexp. Added bhl-html-title-tags. Added help-echo for customize. Improved bhl-replace-tag. Many other bugs fixes. 2003-01-15 Bastien Guerry * bhl.el (Module): makeinfo used by default (instead of texinfmt). Removed ifnotinfo in the bhl-en.texi. Splitted the bhl2xxx function. 2003-01-14 Bastien Guerry * bhl.el (Module): __word__ now means underline word. _*word*_ now means bold-italic word. ==word== now means truetype word. Added a verbatim environment (bhl-[intro|end]-verbatim) Added conversion of the abstract with bhl2sgml. Added support for browsing URL directly from the BHL buffer. Added TOC depth in the menu. Added bhl-txt-conversions-list. Reversed order of items in bhl-xxx-conversions-lists. Removed the tag. No tag is better :) Removed bhl-html-bg-color and -text-color. 2003-01-11 Bastien Guerry * bhl.el (Module): Added bhl-i18n-conventions in english/french/german. Added bhl-view-log and some warning messages. Added

    tag to list item in HTML output. Removed bhl-latex-use-url-flag, bhl-latex-maketitle-flag. Changed into . Enhanced bhl-show-version. Fixed a bug when converting definition lists. Fixed a minor bug concerning bold font-lock. Minor change in bhl-string-to-anchor. Minor changes in the mode-line-format. Updated the menu and the documentation. 2003-01-08 Bastien Guerry * bhl.el (Module): Added bhl2txt (strip font tags and URL/section syntax). Added special chars conversion (quote). Added LaTeX and TeX conversion. Support for french conventions (quote, ligature, punctuation). Added bhl-xxx-conversions-lists: allow the user to choose the conversion functions to perform in each format. Added bhl-submit-bug-report and bhl-doc-mode. Removed bhl-quick-help. Fixed defcustom bhl-xxx-conversions-list. Updated the menu. 2003-01-07 Bastien Guerry * bhl.el (Module): Fixed big bug with bhl2-*-convert-tables. Added bhl-version and bhl-show-version. Added bhl-convert-tex. 2003-01-06 Bastien Guerry * bhl.el (Module): Removed bhl-parse-*. Unified bhl2xxx. Other minor fixes. 2003-01-03 Bastien Guerry * bhl.el (Module): Added bhl-mode-hook. More convenient mode-line-format. Added imenu-generic-expression. Added "o" as list item marker. Changed [0-9] to [O-9]+\. as enumerate item marker [ZOPE]. Changed "=" to "--" as definition list marker [ZOPE]. Removed bhl2fancyhtml [no need]. Removed possibility to put the page into a table [no need]. Changed `bhl-html-justify-para' to `bhl-html-para-align'. Extracted `bhl-quick-help' from mode description. Fixed a minor bug concerning toc insert. 2003-01-02 Bastien Guerry * bhl.el (Module): Removed useless defcustom for BHL-faces. Added 'append flag into bhl-font-lock-keywords. 2002-12-30 Bastien Guerry * bhl.el (Module): Respect W3C conventions: i.e. no bad use of

    tag. Added summary for tables and alt for images. 2002-12-28 Bastien Guerry * bhl.el (Module): Better support for list conversion. Changed bhl-descrip-regexp (less blank lines). 2002-12-27 Bastien Guerry * bhl.el (Module): Added support of tables conversion. Added variables for tables conversion. Added support of image conversion (only in the HTML output). Added tag, conversion and change-font command. Changed the way filenames are created (dot mandatory). Changed URL regexp so that "http://" is not mandatory. Changed some key bindings to fit Emacs conventions. Fixed the bhl-change-font command: no auto-wrap. Fixed a minor inversion in bhl-latex-syntax-table. 2002-12-26 Bastien Guerry * bhl.el (Module): Fixed a bug concerning browsing the toc with the mouse. Changed the local keymap to fit with emacs conventions. 2002-12-24 Bastien Guerry * bhl.el (Module): Support for nested lists Replaced overline with bold-italic Fixed major bug concerning underline (==) Better TOC buffer (no need to mention the point location) Font change la html-mode Added functions for browsing the BHL file Added a function that inserts an URL Better SGML conversion Clean the doc strings inside the code No LaTeX options in the menu and mode-line 2002-12-19 Bastien Guerry * bhl/bhl.el (Module): First "serious" release. View toc in a window according to the size of toc. bhl-1.7.3/gpl.txt0100644000076400007640000004313110053644727013251 0ustar guerryguerry GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 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) 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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) year 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. bhl-1.7.3/bhl.texi0100644000076400007640000020425110146222030013346 0ustar guerryguerry\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename bhl.info @settitle BHL mode : Plain text - HTML - LaTeX - ... @setchapternewpage on @set AUTHOR Bastien Guerry @set MAIL_AUTHOR bastien1@-@@free.fr @set VERSION 1.7.3 @set UPDATED 14/11/2004 @set CREATED 16/11/2002 @set SITE http://@-www.@-nongnu.@-org/@-bhl/ @c @smallbook @c @afourpaper @c @afivepaper @c %**end of header @c @iftex @c @cropmarks @c @end iftex @syncodeindex vr cp @syncodeindex fn cp @syncodeindex pg cp @syncodeindex ky cp @dircategory Miscellaneous @direntry * BHL: (bhl.info). BHL mode: Plain text - HTML - LaTeX - ... @end direntry @footnotestyle separate @c @titlepage @c @title The @acronym{bhl} mode @c @subtitle Convert plain text to HTML/LaTeX/SGML @c @author Copyright @copyright{} 2003 @value{AUTHOR} - @value{UPDATED} @c Permission is granted to copy, distribute and/or modify this document @c under the terms of the GNU Free Documentation License, Version 1.2 or @c any later version published by the Free Software Foundation. @c @sp @c @end titlepage @titlepage @sp 10 @center @titlefont{The @acronym{bhl} mode} @sp 2 @center Convert plain text to HTML/La@TeX{}/Texinfo/SGML/TXT @sp 1 @center @value{AUTHOR} @sp 3 @center @value{UPDATED} @page @vskip 0pt plus 1filll This manual is for the @acronym{bhl} mode (version @value{VERSION}, @value{UPDATED}). @sp 1 Copyright @copyright{} 2003 Bastien Guerry. @sp 1 Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. @end titlepage @ifinfo @ignore Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation. @end ignore @end ifinfo @iftex @headings off @everyheading @emph{The @acronym{bhl} mode} @| @| @thispage @everyfooting @| @| Version @value{VERSION}, @today{} @end iftex @shortcontents @node top, Overview, (dir), (dir) @top BHL mode : Plain text - HTML - LaTeX - ... @cindex Plain @cindex HTML @cindex SGML @pindex LaTeX @pindex HeVeA @pindex latex2html @ifinfo @flushright Bastien Guerry Created @value{CREATED} Modified @value{UPDATED} @end flushright @end ifinfo This is the manual of @acronym{bhl} version @value{VERSION}. @acronym{bhl} is an Emacs mode that enables you to convert a plain text file into an HTML, SGML, LaTeX, Texinfo and TXT file. Since you can run @acronym{bhl} @emph{offline}, it's also a standalone format: writing a @acronym{bhl} file makes it ready for generic conversions. ``@acronym{bhl}'' is an acronym for: @b{B}rute (i.e. ``plain'') to @b{H}tml and @b{L}aTeX. I have been asked if there was an easy way to pronounce ``@acronym{bhl}''. Yes, there is. @code{Bhl-} is the indo-european root for ``blow'' (and derivative but less poetic verbs like ``blather''). So, just say ``blow''. @menu * Overview:: What is BHL? * Installing BHL:: How to install BHL quickly * The syntax:: The syntax of a BHL document * Properties of conversion:: Handling some properties * Browsing your document:: Show the toc and the lol * Commands and key bindings:: Complete list of available commands * Options:: Complete list of options * Example:: A full example * Index:: Index of variables, commands and concepts @end menu @node Overview, Installing BHL, top, top @chapter Overview @cindex StructuredText @cindex Emacs @cindex Zope @cindex Wiki @cindex Table of contents @cindex List @cindex Table @cindex Image @section What is BHL? @acronym{bhl} is a text formatting and publishing tool. It is an Emacs mode that provides two kinds of tools: tools for editing a plain text file as an implicitly structured document, and tools for converting this document into other formats: HTML, SGML, LaTeX, Texinfo and TXT. In order to be readable by @acronym{bhl}, a plain text file must fit some syntactic conventions. This conventions are neither completely universal nor specially odd. They are chosen among the most useful and the most convenient text formatting conventions. The purpose of this mode is to use the most @emph{invisible} and @emph{convenient} syntax. ``Invisible syntax'' means that the source file must be as readable as possible -- like any plain text file must be. ``Convenient syntax'' means that it must fit the users' habits. For example, @code{*word*} appears in bold; @code{_word_} appears in emphasis; lists and URLs follow @code{StructuredText} or @code{Wiki} conventions; the numbering of sections respects logic and intuition. (@xref{The syntax}.) In short: there is nothing you have to learn to write your documents with the @acronym{bhl} mode (just try, it's true). @acronym{bhl} is not @code{WYSIWYG} since you are only editing text. @acronym{bhl} is not @code{WYSIWYM} (like @code{LyX}), since what you mean is editing text. So, what is @acronym{bhl}? It is @code{WYSIWYS(IWYS)}: What You See Is What You See (Is What You See). Editing text is editing text. @section Why should I use BHL? @cindex Footnotes @cindex Happy @cindex Emacs @table @emph @item The Only One @acronym{bhl} is the only generic text converter which implement the conversion into the Texinfo format. @item Happy sectioning You can easily update the numbering of sections and (sub)subsections. You can easily choose/convert the style of sectioning. You can insert the table of content where you want. @xref{Sections}. @item Happy links @acronym{bhl} likes links: you can quickly jump to the next link, follow it (either an URL or a WikiName), browse through the complete list of your document's links and insert this list into your document. @xref{The list of links}. @item Happy specifications You can specify some conversion properties inside a document, so that @acronym{bhl} converts this document properly. @xref{Specifications}. @item Happy footnotes Footnotes won't stay aside. You can convert each of them, even if you are not using the classical numeric style. @end table @node Installing BHL, The syntax, Overview, top @chapter Installing BHL @cindex Installation @cindex Make @cindex Install @cindex Info @cindex HTML @cindex PDF @cindex ~/.emacs.el You have just downloaded @file{bhl.tar.gz} on @uref{http://@-www.@-nongnu.@-org/@-bhl}. Untar the archive like this: @example ~$ tar zxvf @file{bhl.tar.gz} @end example Go to the bhl-*/ directory and set up the @file{Makefile}. Once this is done, just compile and install like this: @example ~$ make ~$ make install @end example If you want to install @acronym{bhl} in your @code{/usr/local/} or @code{/usr/share/} paths, you need to have @code{superuser} (i.e. @code{root}) permissions. But don't worry: at the end of the install procedure, a message tells you if something has gone wrong. If you want to generate and install the @file{bhl.info} file: @example ~$ make info ~$ make install-info @end example If you want the printed manual (@code{PDF}): @example ~$ make pdf @end example If you want the HTML manual: @example ~$ make html @end example If you want to clean up the directory: @example ~$ make clean @end example You can add these lines to your @file{~/.emacs.el}: @lisp (autoload 'bhl-mode "bhl" "BHL Mode" t) (add-to-list 'auto-mode-alist '("\\.bhl$" . bhl-mode)) @end lisp The last line enables you to associate a new extension (i.e. @code{.bhl}) with the @acronym{bhl} editing mode, so that @acronym{bhl} will automatically be loaded when you open a @code{.bhl} ending file. @node The syntax, Properties of conversion, Installing BHL, top @chapter The syntax @cindex Conventions Ordinarily, a plain text file has no visible or invisible syntax. To be @acronym{bhl}-readable, a file has to respect some conventions. @menu * Title and paragraphs:: Things you cannot avoid * Sections:: Sectioning styles * Fonts and environments:: Beautifiers and Cie * Escaping characters:: To escape or not to escape * Handling links:: How BHL handles links * Handling lists:: How BHL handles lists * Handling tables:: How BHL handles tables * Handling images:: How BHL handles images @end menu @node Title and paragraphs, Sections, The syntax, The syntax @section Title and paragraphs @cindex Title @cindex Subtitle @cindex Paragraphs @cindex Indentation @cindex @code{#!subtitle!} The title is mandatory. @acronym{bhl} tries to read it in the very first lines of the buffer. The title is on a line that does not include any newline or tab character. The subtitle is not mandatory. It is currently included in the HTML, TXT and Texinfo output. You can include it as a specification, like this: @example #!subtitle!My subtile subtitle @end example For details on how to format and insert specifications, @xref{Specifications}. The paragraphs always begin at the beginning of the line. Don't indent paragraphs: restrict indentation to lists. @node Sections, Fonts and environments, Title and paragraphs, The syntax @section Sections @cindex Section @cindex Subsection @cindex Subsubsection @cindex Whitespace @kindex C-c C-t @kindex C-c M-t @cindex @code{num} @cindex @code{alpha} @cindex @code{aster} @cindex @code{equal-sign} @cindex num @cindex alpha @cindex aster @cindex equal-sign @cindex guess @cindex style @acronym{bhl} handles three levels of section: sections, subsections and subsubsections. @acronym{bhl} handles five different sectioning styles: @code{num}, @code{alpha}, @code{aster}, @code{equal-sign} and @code{user-defined}. The default style is set to numerical. Here is a table with examples of each sectioning style: @vtable @code @item num 1.A section@* 1.1.A subsection@* 1.1.1.A subsubsection@* @item alpha A.A section@* A.A.A subsection@* A.A.A.A subsubsection@* @item aster *A section@* **A subsection@* ***A subsubsection@* @item equal-sign =A section@* ==A subsection@* ===A subsubsection@* @end vtable You can choose the default style of sectioning by modifying @var{bhl-sectioning-default-style}. This is the default sectioning style for any newly created @acronym{bhl} file. When you find an already existant @acronym{bhl} file, @acronym{bhl} tries to guess its sectioning style, if you've set @var{bhl-autoguess-style-flag} to @code{t} -- which is its default value. At any time, you can ask @acronym{bhl} to guess the style with @command{bhl-guess-style}, which is bound to @key{C-c M-s} (and also available from the menu, as usual). For example, suppose you are using the alphabetical style in @code{foo.bhl} and your @var{bhl-sectioning-default-style} is set to @code{num}, then @acronym{bhl} will automatically turn the current style to @code{alpha}. If @acronym{bhl} is not able to recognize any style, it sets the sectioning style to the value of @var{bhl-sectioning-default-style}. Don't mix sectioning styles! If @acronym{bhl} finds a numerical section, it will consider that all the (sub)sections are numerical, which is actually rather stupid, but I've no time for this at the moment. You can switch from one style to another style from the menu or with @command{bhl-sectioning-switch-style}. This command reads a style from the minibuffer and converts the (sub)sections' prefix into the chosen style. If you choose to use your own style, you have to manually customize @var{bhl-my-sectioning-regexp-list}. @xref{Global options}. This variable includes a list of the three regular expressions that match respectively the sections, subsections and subsubsections. Please note that @command{bhl-udpate-toc} won't work anymore if you set @var{bhl-sectioning-default-style} to @code{my}. You can update the sections' prefix (numbers or letters) with @key{C-c M-t}, which is the default key binding for @command{bhl-update-toc}. @node Fonts and environments, Escaping characters, Sections, The syntax @section Fonts and environments @cindex Beautifiers @cindex Horizontal rule This section describes the use of font beautifiers, environments and horizontal rules. @menu * Font beautifiers:: Bold, emphasis, underline, truetype * Comments:: Inserting comments * Environments:: Verbatim and minipage * Horizontal rules:: and their alignment @end menu @node Font beautifiers, Comments, Fonts and environments, Fonts and environments @subsection Font beautifiers @cindex *[words]* @cindex _[words]_ @cindex ==[words]== @cindex _*[words]*_ @cindex __[words]__ @cindex Bold @cindex TrueType @cindex Italic @cindex Emphasis @cindex Underline Font beautifiers allow you to emphasize, underline, boldify and truetypify some words. In the SGML and Texinfo outputs, @emph{underline} means put in italic, just like @emph{emphasis}. In the HTML and LaTeX output, @emph{underline} means underline truly. If you want to put your text in bold-italic, use @code{_*this order*_} rather than @code{*_this order_*}. Note that bold-italic is not available in the Texinfo output. If you want to insert an underscore or an asterisk that has no syntactic meaning, put an escape character before: @code{\*} and @code{\_}. The same is possible with the comment character @code{#}. @xref{Comments}. You can choose a font beautifier for a specific region with the @command{bhl-change-font-} commands. @xref{Changing font}. @sp 1 Here are the tags to be used in your @acronym{bhl} file if you want to change the fonts: @table @samp @item *a word* put @samp{a word} in bold font. @item _a word_ put @samp{a word} in emphasis font. @item _*a word*_ put @samp{a word} in bold and italic font. @item __a word__ underline @samp{a word}. @item ==a word== put @samp{a word} in truetype font. @end table @node Comments, Environments, Font beautifiers, Fonts and environments @subsection Comments @kindex C-c ; @kindex C-u C-c ; The character for introducing new comments is @code{#}. You can insert comments wherever you want, but comments always end at the end of the current line. There is no ``ending-comment'' character. If you want to insert a @code{#} which should not introduce a new comment, use the escape sequence @code{\#}. You can comment the current region with @command{bhl-comment-region} @key{C-c ;} and uncommment it by adding a symbolic prefix to @command{bhl-comment-region} @key{C-u C-c ;}. You can make comments invisible with @command{bhl-hide-comment} and make them visible again with @command{C-u bhl-hide-comment}. @node Environments, Horizontal rules, Comments, Fonts and environments @subsection Environments @cindex Length @cindex Environment @vindex bhl-hr-face @vindex bhl-special-face @cindex Documentation @acronym{bhl} handles three environments: @code{quote}, @code{verbatim} and @code{minipage}. The first one quotes some part of text. The second one may be useful for inserting code into a documentation. The third one creates a minipage inside the main page, with or without borders. @subsubsection Quote environment @cindex Quote @cindex Quotation To quote some part, just add one single tab in the beginning of each line. Here is an example: @smallexample Put some words here. Put some words here. Put some words here. Put some words here. @end smallexample @subsubsection Verbatim environment @cindex Verbatim @findex bhl-convert-url @cindex TrueType @vindex bhl-verbatim-ignore Here is the syntax of the @code{verbatim} environment: @smallexample -- Put some words here. -- @end smallexample Attention: two dashes are the default delimiters for the @code{verbatim} environment, while four dashes are markers for horizontal rules. Remember that the highlighting of dashes indicates the syntaxic role they play when @var{bhl-special-face} differs from @var{bhl-hr-face} (which is the default case). @xref{Horizontal rules}. The @var{bhl-verbatim-ignore} variable contains a list of syntactic elements that have no meaning inside a verbatim environment. This means that those syntactic elements won't be converted, even if they are fontified. @xref{Global options}. @subsubsection Minipage environment @cindex Minipage @cindex @code{%%%} @findex bhl-insert-minipage @vindex bhl-texi-centered-minipage-tag @vindex bhl-sgml-minipage-tag Here an example of how to insert a @code{minipage}: @smallexample %%%[12cm] This minipage (12cm) will be centered without border. %%% <%%[10cm] This minipage (10cm) will be put on the left without border. %%% >-% This minipage will be put on the right with borders. %%% @end smallexample The basic indicator for the beginning and the end of a minipage environment is @code{%%%} at the beginning of a line. This indicates a centered minipage, without border and of the same width as the main page. By replacing the first @code{%} with a @code{<} or a @code{>}, you put the minipage respectively on the left or on the right. For example, @code{<%%%%} indicates a left aligned minipage which has the same width as the main page. By replacing the second @code{%} with a dash (@code{-}), you put solid borders on the minipage. For example, @code{<-%%%%%} indicates the beginning of a minipage that has the same width as the main page, put on the left with solid borders. The length can be put into square brackets like this: @code{%%%[8cm]}. It is optional. Avoid using relative lengths such as ``40%'': the @code{%} character is syntax-sensible in the LaTeX environment. Use only absolute lengths and common units. Minipages are properly converted only for the HTML, LaTeX and Texinfo outputs. For the Texinfo output, you can choose what a centered minipage looks like with @var{bhl-texi-centered-minipage-tag}. For the SGML output, you can choose what a minipage looks like with @var{bhl-sgml-minipage-tag}. @command{bhl2txt} does not convert minipages, it simply strips the @code{%%%} at the beginning of the line. You can insert a minipage with @command{bhl-insert-minipage}. @xref{Inserting}. @node Horizontal rules, , Environments, Fonts and environments @subsection Horizontal rules @cindex @code{----} A horizontal rule is represented by at less four dashes (@code{----} - Small), equal signs (@code{====} - Large) or slashes (@code{////} - X-Large) at the beginning of a line. The first character can be replaced by an indicator of alignment. Attention: horizontal rules are not converted in the SGML and Texinfo formats. @example ----[12cm] <---[12cm] >---[12cm] @end example The first line will be centered. The second line will be put on the left. The third line will be put on the right. The width of these lines is 12cm. The length is optional: you can simply insert @code{----}, @code{====} or @code{////}. You can insert a horizontal rule with @command{bhl-insert-hr}. @xref{Inserting}. @node Escaping characters, Handling links, Fonts and environments, The syntax @section Escaping characters You can escape four characters: asterisk (@code{*}), underscore (@code{_}), sharp @code{#} and backslash @code{\}. When escaped, these characters have no syntactic effect anymore. Escaping backslashes only makes sense for the @code{bhl2latex} conversion. When converting into LaTeX, @acronym{bhl} escapes some characters by itself. These characters are: @code{$ & % @{ @}}. Attention: the @code{bhl2latex} conversion does NOT @emph{automatically} convert backslashes. You've to insert something like @code{$\backslash$} by yourself or escape them like @code{\\}. When converting into Texinfo, @acronym{bhl} escapes @code{@@ @{ @}}. If you don't want that @acronym{bhl} escapes those characters, just escape them by yourself in the @acronym{bhl} file. @node Handling links, Handling lists, Escaping characters, The syntax @section Handling links @cindex http @cindex ftp @cindex file @cindex mailto @kindex C-c C-c h @kindex C-S-TAB @kindex C-TAB @kindex mouse-2 @findex browse-url @findex bhl-convert-url @findex bhl-goto-next-url-or-wiki @findex bhl-browse-url-function @vindex bhl-default-wikifiles-extension @vindex bhl-downcase-wikifiles-names-flag @vindex bhl-non-wiki-names-list @subsection What is a link? There are two kinds of links: URLs and WikiNames. An URL is... you know what it is. A WikiName is a mixed-case word like ``MyWikiName''. When the cursor is on a link, you can hit @key{RET} or @key{mouse-2} to follow it. Following an URL calls @command{bhl-browse-url-function}. Following a WikiName finds a new file whose name is the concatenation of the WikiName and the @code{.bhl} extension. You can downcase this resulting name by setting @var{bhl-downcase-wikifiles-names-flag} to non-@code{nil}. You can also change the default extension of WikiFiles names by setting @var{bhl-default-wikifiles-extension}. The list of mixed-case strings that shouldn't be considered as WikiNames is stored in @var{bhl-non-wiki-names-list}. You can see the list of links of your document with @command{bhl-show-lol}, which is bound to @key{C-c C-/}. You can insert the list of links of your document with @command{bhl-insert-lol}, which is bound to @key{C-c C-c l}. @xref{The list of links}. You can browse URLs and WikiNames with @command{bhl-goto-next-url-or-wiki} @key{C-TAB}. (@xref{Browsing the BHL file}.) @subsection Converting Links URLs are converted by the @command{bhl-convert-url} function and WikiNames are converted by the @command{bhl-convert-wiki-names} function. You can write your URL as it is (@code{http://site.org}), or put it into square brackets to define a label: @code{[[http://@-site.@-org][my@- site]]}. You can insert an URL with @command{bhl-insert-url}, @key{C-c C-c h}: @xref{Commands and key bindings}. Here is a list of some URLs and their conversions into the HTML format: @cartouche @table @code @item http://site.org http://site.org @item url:mypage.html mypage.html @item [[http://site.org][SITE]] SITE @item mailto:bb@@site.fr bb@@site.org @item [[mailto:bb@@site.fr][BB]] BB @end table @end cartouche Here is a list of some URLs and their conversions into the LaTeX format: @cartouche @table @code @item http://site.org \url@{http://site.org@} @item url:mypage.html \url@{mypage.html@} @item [[http://site.org][SITE] SITE (\url@{http://site.org@}) @item mailto:bb@@site.org \url@{bb@@site.org@} @item [[mailto:bb@@site.org][BB]] BB (\url@{bb@@site.org@}) @end table @end cartouche Here is a list of some URLs and their conversions into the Texinfo format: @cartouche @table @code @item http://site.org @@uref@{http://site.org@} @item url:mypage.html @@uref@{mypage.html@} @item [[http://site.org][SITE] @@uref@{http://site.org,SITE@} @item mailto:bb@@site.org @@uref@{bb@@site.org@} @item [[mailto:bb@@site.org][BB]] @@uref@{bb@@site.org,BB@} @end table @end cartouche Here is a list of some URLs and their conversions into the SGML format: @cartouche @table @code @item http://site.org @item url:mypage.html @item [[http://site.org][SITE] @item mailto:bb@@site.org @item [[mailto:bb@@site.org][BB]] @end table @end cartouche Here is a list of some URLs and their conversions into the TXT format: @cartouche @table @code @item http://site.org http://site.org @item url:mypage.html mypage.html @item [[http://site.org][SITE] http://site.org (SITE) @item mailto:bb@@fardeau.fr bb@@fardeau.fr@ @item [[mailto:bb@@fardeau.fr][BB]] bb@@fardeau.fr (BB) @end table @end cartouche In these examples, you can replace `http://' by `ftp://' or `file:///'. When using @code{[[...][...]]}, a prefix like `http://' is not mandatory. @findex bhl-convert-url @node Handling lists, Handling tables, Handling links, The syntax @section Handling lists @cindex List @kindex M-TAB @acronym{bhl} handles three kinds of lists: non-ordered lists, ordered lists and descriptive (or definition) lists. A @emph{non-ordered list item} is defined by: some @key{TAB} at the beginning of the line, a list separator among <@code{- * o}>, a whitespace. An @emph{ordered list item} is defined by: some @key{TAB} at the beginning of the line, a number, a dot, a whitespace. A @emph{definition list item} is defined by: some @key{TAB} at the beginning of the line, a term, a whitespace, two dashes, a whitespace. @key{TAB} inserts an indent-relative TAB, while @key{M-TAB} inserts a rigid TAB mesuring exactly three columns. Make sure that there is a whitespace after a @code{*}: no whitespace means that the next characters may use bold font. @acronym{bhl} handles also nested lists, but no definition list can be nested. To add a nested item, just add a TAB character relatively to the previous item. In each list, the first item indicates the kind: ordered, non-ordered or definition list. Here is a table of lists separators: @table @code @item [*,-,o] item of a non-ordered list @item [0-9]. item of an ordered list (enumerate) @item A term-- item of a definition list @end table Take a look at the examples on @uref{http://@-www.@-nongnu.@-org/@-bhl} for further details. @cindex Examples @node Handling tables, Handling images, Handling lists, The syntax @section Handling tables @cindex Table Here is an example of a table: @cartouche @example | @@Name@@ | @@First name@@ | @@Age@@ | | Jean | Luc-Henri | 123 | | Paul | Matthieu | 2 | @end example @end cartouche The character @code{|} has three different functions: it begins a new row, it seperates two cells, it ends a row. Whitespaces and tab characters are NOT allowed between the beginning of a new line and the first @code{|}. Optional @code{@@} around the cell content indicates that this cell is a header. Typically, you put headers on the very first row of the table. In the HTML output, a header cell is put into @code{} tags. In other LaTeX and SGML, the header line is separated from the rest of the table by an horizontal rule. More details about the table options: @xref{Converting tables}. @node Handling images, , Handling tables, The syntax @section Handling images @cindex Image @findex bhl-insert-url @findex bhl-insert-image @kindex C-c C-c i Here is an example of how to insert an image: @example [[image.jpg]] @end example You can search for a particular file and insert it as an image with @key{C-c C-c i}, wich is the default key binding for @command{bhl-insert-image}. Only @command{bhl2html} handles images. Other conversion functions like @command{bhl2sgml}, @command{bhl2texinfo} or @command{bhl2latex} put images into comment strings. @command{bhl2txt} erases images. @node Properties of conversion, Browsing your document, The syntax, top @chapter Properties of conversion @cindex CSS @cindex Properties @cindex Specification You may want to convert your @acronym{bhl} document without customizing anything. This is OK. But you surely want to control some properties of the different conversion functions. For example, you may decide that the HTML conversion includes the table of contents, whereas the LaTeX conversion doesn't. You may want to calculate the @code{\date@{...@}} command of the LaTeX output relatively to the current time. You may want to set up a different CSS style for a particular HTML output. Etc. This section tells you how to do this. @menu * Overview of properties:: * Specifications:: @end menu @node Overview of properties, Specifications, Properties of conversion, Properties of conversion @section Overview of properties @vindex bhl-html-conversions-list @vindex bhl-latex-conversions-list @vindex bhl-sgml-conversions-list @vindex bhl-txt-conversions-list @vindex bhl-texi-conversions-list @vindex bhl2html-properties-list @vindex bhl2latex-properties-list @vindex bhl2sgml-properties-list @vindex bhl2txt-properties-list @vindex bhl2texi-properties-list @findex bhl-initialize-properties @vindex bhl-after-conversion-hook The two important variables for the choice of conversions properties are @var{bhl-xxx-conversions-list} and @var{bhl2xxx-properties-list}, where @code{xxx} is the name of the conversion. @xref{Global options}. @var{bhl-xxx-conversions-list} includes the detailed list of conversions for each format. Normally you should not change this variable too often. @var{bhl2xxx-properties-list} allows you to set global options for the conversion. These global options deal with the checking of dubious tags, the insertion of the sections' prefix, the tables' captions, the i18n conventions, the insertion of the table of contents and the centering of sections/title (for the @command{bhl2txt} conversion.) You can change this variable by: @itemize @minus @item inserting a specification line inside your @acronym{bhl} document; @item selecting the options from the menu; @item modifying this variable with @command{M-x customize}. @end itemize This order is important: the options set inside a specification line will override the options set from the menu, which override those set in the default customization. These global options are set to their default value (i.e. their customized value) each time you run the @code{bhl-mode} command. They are also set to their default value after each conversion, except if you remove the @command{bhl-initialize-properties} function from the @code{bhl-after-conversion-hook} list. @node Specifications, , Overview of properties, Properties of conversion @section Specifications @cindex Specifications @cindex @code{#!title!} @cindex @code{#!html-title!} @cindex @code{#!latex-title!} @cindex @code{#!texi-title!} @cindex @code{#!sgml-title!} @cindex @code{#!author!} @cindex @code{#!date!} @cindex @code{#!lang!} @cindex @code{#!subtitle!} @cindex @code{#!encoding!} @cindex @code{#!latex!} @cindex @code{#!latex-class!} @cindex @code{#!latex-options!} @cindex @code{#!latex-packages!} @cindex @code{#!html!} @cindex @code{#!html-style!} @cindex @code{#!sgml!} @cindex @code{#!txt!} @cindex @code{#!texi!} @cindex @code{#!texi-style!} @cindex @code{(no)prefix} @cindex @code{(no)check} @cindex @code{(no)caption} @cindex @code{(no)i18n} @cindex @code{(no)toc} @cindex @code{(no)center} @cindex @code{(no)tas} @vindex bhl-html-content-type @vindex bhl-i18n-conventions @acronym{bhl} allows you to add some specification lines inside a document, so that @acronym{bhl} handles @emph{this} document adequately. Specifications concern mainly two kind of properties: the properties of the document's header and the conversion properties. Here are some examples of specification lines: @example #!html!prefix:check:caption:toc #!latex!noprefix:nocheck:nocaption:notoc #!date!It's %H:%M. @end example In this example, the command @command{bhl2html} will insert the sections' prefix, check for dubious tags, ask for a caption for each table and insert the table of contents (also known as @emph{toc}). The command @command{bhl2latex} WON'T insert the sections' prefix, check for dubious tags, ask for a caption for each table and insert the toc. The date will be set to the current time (hours:minutes). Quite simple, isn't it? A specification line is always a comment at the beginning of the line. It splits into two parts: a @emph{prefix}, which is enclosed into two exclamation marks, and the @emph{labels}, which are separated by a column. Each label can be turned off by adding @code{no-}: @code{notoc} is the exact opposite of @code{toc}. Here is a complete list of available specification prefix and their relevant labels. @table @code @item #!author! The name of the author for the current document. @item #!title! The title of the document. This specification overrides any other title (the first line of the buffer or any @code{#!xxx-title!} specification). @item #!xxx-title! The title of the document for the @code{xxx} conversion. @code{xxx} may be @code{html}, @code{sgml}, @code{texi} or @code{latex}. This specification is overriden by the @code{#!title!} specification, and overrides the first line of the buffer. @item #!subtitle! The subtitle of the document. The subtitle conversion is supported only for the HTML, Texinfo and TXT output. @item #!lang! The language of the document. This override the value of @var{bhl-i18n-conventions}. In the Texinfo output, it sets the value of @code{@@documentlanguage}. @item #!encoding! The encoding of the document. This information is relevant for the Texinfo and HTML conversion. In the Texinfo output, it sets the value of @code{@@documentencoding}. In the HTML output, it overrides the value of @var{bhl-html-content-type}. @item #!date! The date of the current document. Since the column has no special meaning here, you can use the Emacs time-formatting conventions. For example, @code{#!date!%H:%M} will set @code{date} to the current time (hours:minutes). @inforef{Time Conversion, , Elisp}. @item #!html! The prefix concerning @command{bhl2html} specifications. Here is a complete list of available labels: @table @code @item prefix Insert the prefix of (sub)sections. @item check Check for dubious HTML tags/comments before converting. @item caption Ask for a caption when converting a table. @item i18n Use i18n conventions. @item toc Insert the table of content in the HTML output. @end table @item #!html-style! The CSS file to refer to as the style for the HTML output. @item #!latex! The prefix concerning @command{bhl2latex} specifications. Here is a complete list of available labels: @table @code @item prefix Insert the prefix of (sub)sections. @item check Check for dubious LaTeX commands/comments before converting. @item caption Ask for a caption when converting a table. @item i18n Use i18n conventions. @item toc Insert the table of content in the LaTeX output. @end table @item !#latex-class! The class of the LaTeX output. @item #!latex-options! The options of the chosen class. You can insert as many options as you want, provided that you separate them with a column. @item #!latex-packages! Some LaTeX packages and their options. For example : @smallexample #!latex-packages!fontenc[T1]:[latin1]inputenc:babel[french] \usepackage[T1]@{fontenc@} \usepackage[latin1]@{inputenc@} \usepackage[french]@{babel@} @end smallexample The location of the square brackets doesn't matter. @item #!texi! The prefix concerning @command{bhl2texinfo} specifications. Here is a complete list of available labels: @table @code @item check Check for dubious Texinfo commands/comments before converting. @item i18n Use i18n conventions. @item toc Insert the table of content in the Texinfo output. @end table @item #!texi-style! The style of the frontpage in the Texinfo output. May be either @code{classical} or @code{centered}. @item #!sgml! The prefix of @command{bhl2sgml} specifications. Here is a complete list of available labels: @table @code @item check Check for dubious SGML tags/comments before converting. @item caption Ask for a caption when converting a table. @item i18n Use i18n conventions. @end table @item #!txt! The prefix of @command{bhl2txt} specifications. Here is a complete list of available labels: @table @code @item center Center the title and (sub)sections' titles. @item toc Insert the table of content in the TXT output. @item tas tabs are spaces: convert tabs to whitespaces in the TXT output. @end table @end table @node Browsing your document, Commands and key bindings, Properties of conversion, top @chapter Browsing your document @cindex List of links @cindex Table of contents @cindex @code{*lol*} @cindex @code{*toc*} @kindex C-c C-t @kindex C-c C-/ @findex bhl-show-toc @findex bhl-show-lol @findex bhl-toc-mode The @acronym{bhl} mode comes with two commands that allows you to browse your document: @command{bhl-show-toc} and @command{bhl-show-lol}. The latter is not a joke: it allows you to browse the list of links. The former allows you to browse the table of contents. These two commands create a new buffer turned into either @code{bhl-toc-mode} or @code{bhl-lol-mode}. @menu * The table of contents:: Show me the toc! * The list of links:: Show me the lol! @end menu @node The table of contents, The list of links, Browsing your document, Browsing your document @section The table of contents @cindex Table of contents @findex bhl-insert-toc @vindex bhl-toc-location @vindex bhl-default-toc-depth @kindex C-c C-t @kindex C-c M-t The @acronym{bhl} mode enables you to update the numbering of sections of your @acronym{bhl} file, to insert the table of contents into your @acronym{bhl} file, to browse the table of contents in a new buffer. Two variables are required to handle the table of contents: @var{bhl-toc-location} and @var{bhl-default-toc-depth}. The first one defines the location of the inserted toc. You can change its value via the menu or via @command{customize}. The second one defines the default toc depth. You can insert the toc with @command{bhl-insert-toc} @key{C-c C-c t}. A numeric argument defines the depth of this inserted toc. You can also insert the toc from the @code{*toc*} buffer with @key{i}. From this buffer, the toc depth is set to the depth of the currently displayed toc. When it converts the buffer, @acronym{bhl} first checks if there is a table of contents. If there is one, @acronym{bhl} inserts it in the output according to the current toc location of the buffer. @menu * Browse the table of contents:: in a new buffer * Insert the table of contents:: in the source file @end menu @node Browse the table of contents, Insert the table of contents, The table of contents, The table of contents @subsection Browse the table of contents @cindex Browse @kindex C-c C-t @kindex ? @kindex q @kindex n @kindex p @kindex < @kindex > @kindex i @kindex 1 @kindex 2 @kindex 3 You can get a new buffer, named @code{*toc*}, with a browsable table of contents. You can browse the toc via the menu or with the key binding @key{C-c C-t}. An optional numeric argument indicates the toc depth. @table @key @item ? Display a quick help for the @code{bhl-toc-mode}. @item q Quit the @code{*toc*} buffer. @item n Go to the next item. @item p Go to the previous item. @item > Go to the last item. @item < Go to the first item. @item i Insert the table of contents in your @acronym{bhl} file. @item 1 Set the toc depth to 1. @item 2 Set the toc depth to 2. @item 3 Set the toc depth to 3. @end table @node Insert the table of contents, , Browse the table of contents, The table of contents @subsection Insert the table of contents @kindex C-c C-c t @vindex bhl-toc-location @cindex Menu You can insert the table of contents of your @acronym{bhl} file into itself with @key{C-c C-c t}. If a toc has already been inserted, this command only updates the table of contents, leaving it to its current location. If a toc has not been inserted yet, this command inserts a new one according to the value of @var{bhl-toc-location}. An optional numeric argument indicates the toc depth. @node The list of links, , The table of contents, Browsing your document @section The list of links @findex bhl-show-lol @findex bhl-lol-mode @cindex @code{*lol*} @kindex C-c C-/ @kindex ? @kindex q @kindex n @kindex p @kindex < @kindex > @kindex i @kindex RET @kindex mouse-2 You can see the list of links with @command{bhl-show-lol}. The default key for this command is @key{C-c C-/}. A new buffer is created, named @code{*lol*} and turned into the @code{bhl-lol-mode}. While moving inside this buffer, your document's buffer is updated so that its point is set to the link you're currently pointing on. You can also visit the link you're pointing on with @key{RET} or @key{mouse-2}. Here is a list of the available commands inside the @code{bhl-lol-mode}: @table @key @item ? Display a quick help for the @code{bhl-lol-mode}. @item q Quit the @code{*lol*} buffer. @item n Go to the next item/link. @item p Go to the previous item/link. @item > Go to the last item/link. @item < Go to the first item/link. @item i Insert the list of links into your document. @end table @node Commands and key bindings, Options, Browsing your document, top @chapter Commands and key bindings @kindex C-c C-w @kindex C-c C-c C-w @kindex C-c C-l @kindex C-c C-s @kindex C-c C-d @kindex C-c C-o @cindex TOC @kindex C-c M-t @kindex C-c C-t @vindex bhl-toc-location @kindex C-c C-c t @kindex C-c C-f C-b @kindex C-c C-f C-e @kindex C-c C-f C-u @kindex C-c C-f C-_ @kindex C-c C-f C-n @cindex Style This section describes the main commands of the @acronym{bhl} mode. @menu * Conversion commands:: The five conversions * Inserting:: Insert URls, images and the toc * Browsing the BHL file:: Browse the source file * Changing font:: Change the font * Miscellaneous:: Rather clear, no? @end menu @node Conversion commands, Inserting, Commands and key bindings, Commands and key bindings @section Conversion commands @kindex C-c C-w @kindex C-c C-l @kindex C-c C-s @kindex C-c C-d @kindex C-c C-o @cindex Popup menu This conversion commands end with two hooks: a hook relative to each conversion format (@var{bhl-xxx-after-conversion-hook}) and a global hook (@var{bhl-after-conversion-hook}). You can also reach these commands from the popup menu @key{C-down-mouse-3}: press @key{control} and the right button of the mouse. @defun bhl2html Convert the current buffer into HTML and display the output in a new buffer. The default key binding is @key{C-c C-w}. @end defun @defun bhl2latex Convert the current buffer into LaTeX and display the output in a new buffer. The default key binding is @key{C-c C-l}. @end defun @defun bhl2texinfo Convert the current buffer into Texinfo and display the output in a new buffer. The default key binding is @key{C-c C-o}. @end defun @defun bhl2sgml Convert the current buffer into SGML (Linuxdoc) and display the output in a new buffer. The default key binding is @key{C-c C-s}. @end defun @defun bhl2txt Convert the current buffer into TXT and display the output in a new buffer. Strip the remaining tags and syntaxic elements. The default key binding is @key{C-c C-d}. @end defun @node Inserting, Browsing the BHL file, Conversion commands, Commands and key bindings @section Inserting @kindex C-c C-c h @kindex C-c C-c i @kindex C-c C-c r @kindex C-c C-c v @kindex C-c C-c t @kindex C-c C-c l @defun bhl-insert-url Read an URL and his name from the minibuffer and insert it. The default key binding is @key{C-c C-c h}. @end defun @defun bhl-insert-image Read the filename of an image from the minibuffer and insert it. The default key binding is @key{C-c C-c i}. @end defun @defun bhl-insert-minipage Insert a minipage. The default key binding is @key{C-c C-c m}. @end defun @defun bhl-insert-verbatim Insert a verbatim environment. The default key binding is @key{C-c C-c v}. @end defun @defun bhl-insert-hr Insert a horizontal rule. Ask for its alignment and width in the minibuffer. The default key binding is @key{C-c C-c r}. @end defun @defun bhl-insert-toc [depth] Insert the table of contents into the current buffer. The default key binding is @key{C-c C-c t}. This command is also available from the @code{*toc*} buffer in @command{bhl-toc-mode} with @key{i}. The optional argument (@code{depth}) indicates the toc depth. Without any argument, the toc depth's value is @var{bhl-default-toc-depth}. You can insert the table of contents in three different places: just after the title, just before the end, just at the point. The value of @var{bhl-toc-location} defines the toc location. @end defun @defun bhl-insert-lol Insert the list of links into the current buffer. The default key binding is @key{C-c C-c l}. This command is also available from the @code{*lol*} buffer in @command{bhl-lol-mode} with @key{i}. @end defun @node Browsing the BHL file, Changing font, Inserting, Commands and key bindings @section Browsing the BHL file @kindex C-c C-t @kindex C-c C-/ @kindex C-c C-n @kindex C-c C-p @kindex C-u C-c C-n @kindex C-u C-c C-p @kindex C-TAB @kindex C-S-TAB @cindex WikiName @cindex Popup menu @defun bhl-show-toc [depth] Get a new buffer named @code{*toc*} with the table of contents. The default key binding is @key{C-c C-t}. The optional argument (@code{depth}) indicates the toc depth. Without any argument, the toc depth's value is @var{bhl-default-toc-depth}. This command is also available from the popup menu. @end defun @defun bhl-show-lol Get a new buffer named @code{*lol*} with the list of links. A link may be an URL or a WikiName. The default key binding is @key{C-c C-/}. This command is also available from the popup menu. @end defun @defun bhl-goto-next-section Go to the next section. The default key binding is @key{C-c C-n}. With @key{C-u}, go to the next section or (sub)subsection. @end defun @defun bhl-goto-previous-section Go to the previous section. The default key binding is @key{C-c C-p}. With @key{C-u}, go to the previous section or (sub)subsection. @end defun @defun bhl-goto-next-url-or-wiki Go to the next URL or WikiName. The default key binding is @key{C-TAB}. @end defun @node Changing font, Miscellaneous, Browsing the BHL file, Commands and key bindings @section Changing font @vindex bhl-tt-face @kindex C-c C-f C-b @kindex C-c C-f C-e @kindex C-c C-f C-u @kindex C-c C-f C-t @kindex C-c C-f C-_ @kindex C-c C-f C-n @defun bhl-change-font-bold Place the cursor between two @code{*}. If a region is selected, put the region between two @code{*}. This overrides previous fontification. The default key binding is @key{C-c C-f C-b}. @end defun @defun bhl-change-font-emphasis Place the cursor between two @code{_}. If a region is selected, put the region between two @code{_}. This overrides previous fontification. The default key binding is @key{C-c C-f C-e}. @end defun @defun bhl-change-font-underline Place the cursor between two @code{__}. If a region is selected, put the region between two @code{__}. This overrides previous fontification. The default key binding is @key{C-c C-f C-u}. @end defun @defun bhl-change-font-truetype Place the cursor or a selected region between two @code{==}. If a region is selected, put the region between two @code{==}. This overrides previous fontification. The default key binding is @key{C-c C-f C-t}. @end defun @defun bhl-change-font-bolditalic Place the cursor between @code{_*} and @code{*_}. If a region is selected, put the region between @code{_*} and @code{*_}. This overrides previous fontification. The default key binding is @key{C-c C-f C-_}. @end defun @defun bhl-change-font-normal Strip any fontification of the selected region. No effect when no region is selected. The default key binding is @key{C-c C-f C-n}. @end defun @node Miscellaneous, , Changing font, Commands and key bindings @section Miscellaneous @cindex numerical @cindex alphabetical @cindex mail @cindex log @cindex bug @cindex version @kindex C-c ; @kindex C-u C-c ; @kindex C-c C-x m @kindex C-c C-o @kindex C-c C-t @kindex C-c C-v @cindex Popup menu @cindex Comment @defun bhl-sectioning-switch-style Read a sectioning style from the minibuffer and convert (sub)sections' prefix into this style. The available styles are @code{num}, @code{alpha}, @code{aster} and @code{equal-sign}. @end defun @defun bhl-comment-region Comment the current region. With a symbolic argument, uncomment the current region. The default key binding is @key{C-c ;}. @end defun @defun bhl-hide-comment Make the comments invisible. With a symbolic argument, make the comments visible again. @end defun @defun bhl-compose-mail Convert the current buffer into TXT format with @command{bhl2txt} and use the output in a mail draft. The default key binding is @key{C-c C-x m}. This command is also available from the popup menu. @end defun @defun bhl-view-log Display the log of the last conversion in a temporary buffer. @end defun @defun bhl-update-toc Update the sections', subsections' and subsubsections' numbering. The default key binding is @key{C-c M-t}. @end defun @defun bhl-submit-but-report Send a mail with a bug report. This is only available in GNU Emacs. @end defun @defun bhl-show-version Display the version number of the @acronym{bhl} mode. The default key binding is @key{C-c C-v}. @end defun @defun bhl-texi-toggle-accents Toggle accents in a Texinfo buffer. If you are using accents, it may be a good idea to add this function to @var{bhl-after-texi-conversion-hook}. @end defun @node Options, Example, Commands and key bindings, top @chapter Options You can change the value of each option via @command{M-x customize-group RET bhl RET} or via @command{Customize BHL} in the @acronym{bhl} menu. @menu * Global options:: First things to set up * BHL to HTML:: Options of the HTML conversion * BHL to LaTeX:: Options of the LaTeX conversion * BHL to Texinfo:: Options of the Texinfo conversion * BHL to SGML:: Options of the SGML conversion * BHL to TXT:: Options of the TXT conversion * Wiki options:: Options of BHL as a local Wiki * Options of the toc:: Location and depth * Converting tables:: Alignment and caption @end menu @node Global options, BHL to HTML, Options, Options @section Global options @findex browse-url @vindex bhl-xxx-conversions-list @findex footnote-mode @cindex Anglais @cindex Convention @cindex numerical @cindex alphabetical @defopt bhl-mode-hook Hook run while in @acronym{bhl} mode. If you are under GNU Emacs, it could be useful to add @code{footnote-mode}, since @acronym{bhl} converts footnotes. @end defopt @defopt bhl-after-conversion-hook Hook run at the very end of a conversion. The default value is @command{bhl-initialize-properties}. If you remove this function, the conversion properties of the @emph{last} converted buffer will be the default conversion properties for the @emph{next} converted buffer -- which may not be what tou really want. @end defopt @defopt bhl-autoguess-style-flag If non-nil, autoguess the sectioning style. When you find a file, @acronym{BHL} tries to guess its sectioning style and sets the value of `bhl-sectioning-default-style' to the value of the file's style. The default value of @var{bhl-autoguess-style-flag} is @code{nil}. @end defopt @defopt bhl-sectioning-default-style Define the style for the titles of sections, subsections and subsubsections. The five available styles are: numerical (@code{num}), alphabetical (@code{alpha}), asterisks (@code{aster}), equal-signs (@code{equal-signs}) and your own style (@code{my}). @xref{Sections}. If you want to use your own style, you have to define @var{bhl-my-sectioning-regexp-list}. In this case, @command{bhl-update-toc} is not available anymore. @end defopt @defopt bhl-my-sectioning-regexp-list A list of regular expressions that match the different levels of sectioning. They respectively match the prefix of a section's, subsection's and subsubsection's title. Since the titles of the sections are always put @emph{at the beginning of the line}, you don't have to insert a @code{^} in these regular expressions. The default value of @var{bhl-my-sectioning-regexp-list} is the value of @var{bhl-my-sectioning-regexp-list}, which corresponds to the numerical style (@code{num}).. @end defopt @defopt bhl-verbatim-ignore A list of syntactic elements that shouldn't be converted when found inside a verbatim environment. The default value of this variable is @code{(tag comment list description table url wikiname images special-char tex-label footnote quote)}. @end defopt @defopt bhl-ignored-regexps A list of regexps. Each line matching a regexp within this list is automatically killed before any conversion. @end defopt @defopt bhl-tags-overlap-flag Non-nil means that you can use tags on multiple lines. Maybe useful to turn this option off is you want to use tags on multiple lines inside a verbatim environment. @end defopt @defopt bhl-i18n-conventions The car of this variable is a language specification among @code{english}, @code{french} and @code{german}. @acronym{bhl} will follows conventions according to the chosen language. If the second element if t, @acronym{bhl} follows conventions concerning the punctuation, as defined in @var{bhl-xx-punctuation} (where @code{xx} is @code{en}, @code{fr} or @code{de}). If the third element if t, @acronym{bhl} follows conventions concerning the quotation marks, as defined in @var{bhl-xx-quotation-marks}. If the fourth element if t, @acronym{bhl} follows conventions concerning special characters, as defined in @var{bhl-xx-special-chars}. @end defopt @defopt bhl-browse-url-function A function for calling your favorite browser. The default value is @command{browse-url}. @end defopt @node BHL to HTML, BHL to LaTeX, Global options, Options @section BHL to HTML @cindex Doctype @cindex Properties @defopt bhl-after-html-conversion-hook Hook run after the HTML conversion. @end defopt @defopt bhl2html-properties-list The list of properties relevant for the @command{bhl2html} conversion. @xref{Properties of conversion}. Don't modifiy this variable manually. Use @code{M-x customize} instead. @end defopt @defopt bhl-html-conversions-list A list of conversions to perform with @command{bhl2html}. Each element of this list is boolean. Don't edit this option manually, use @command{M-x customize} instead. @end defopt @defopt bhl-html-meta-alist A list of META tags to be inserted in the header of HTML output. Each element is divided into two elements: the first one indicates the @emph{name} of the META tag, the second one indicates the @emph{content} of the META tag. @table @code @item '((``author'' . ``you'')) @code{} @end table @end defopt @defopt bhl-html-link-alist A list of @code{LINK} tags to be inserted in the header of HTML output. Each element is divided into two elements: the first one indicates the @emph{rel} of the @code{LINK} tag, the second one indicates the @code{href} of the @code{LINK} tag. @table @code @item '((``generator-home . ``http://www.nongnu.org/bhl)) @code{} @end table @end defopt @defopt bhl-html-doctype The document type description of the HTML output. The default value is: @code{}. @end defopt @defopt bhl-html-content-type The content type description of the HTML output. The default value is: @code{"}. @end defopt @defopt bhl-html-default-style The style to be inserted into the header (@code{...}) of the HTML output. @end defopt @defopt bhl-html-title-tags A list defining the opening and closing tags of the HTML title. @end defopt @defopt bhl-html-subtitle-tags A list defining the opening and closing tags of the HTML subtitle. @end defopt @defopt bhl-html-para-align How @acronym{bhl} aligns each paragraph of the HTML output. The default value is @code{none}. @end defopt @defopt bhl-html-img-align Image alignment. The default value is @code{center}. @end defopt @defopt bhl-html-list-item-is-para-flag Non-@code{nil} means that list items are paragraphs into the HTML output. @end defopt @node BHL to LaTeX, BHL to Texinfo, BHL to HTML, Options @section BHL to LaTeX @defopt bhl-after-latex-conversion-hook Hook run after the LaTeX conversion. @end defopt @defopt bhl2latex-properties-list The list of properties relevant for the @command{bhl2latex} conversion. @xref{Properties of conversion}. Don't modifiy this variable manually. Use @code{M-x customize} instead. @end defopt @defopt bhl-latex-conversions-list A list of conversions to perform with @command{bhl2latex}. Each element of this list is boolean. Don't edit this option manually, use @command{M-x customize} instead. @end defopt @defopt bhl-latex-packages-alist A list of packages to be included in the LaTeX header. Each element is divided into two elements: the first one indicates the @emph{name} of the packages, the second one indicates the @emph{options} of the package. @table @samp @item '((``inputenc'' . ``latin1'')) @code{\usepackage[latin1]@{inputenc@}}. @end table @end defopt @defopt bhl-latex-default-class The default class of document for the LaTeX output. The default value is @code{article}. @end defopt @defopt bhl-latex-default-class-options The default options passed to the @code{\documentclass@{...@}} command. The default value is @code{12pt}. @end defopt @defopt bhl-latex-extra-preambles A list of lines to be included in the LaTeX header. @end defopt @defopt bhl-latex-extra-body A list of lines to be included before the first section. @end defopt @defopt bhl-latex-default-class-options The default options passed to the @code{\documentclass@{...@}} command. The default value is @code{12pt}. @end defopt @node BHL to Texinfo, BHL to SGML, BHL to LaTeX, Options @section BHL to Texinfo @defopt bhl-texi-conversion-hook Hook run after the Texinfo conversion. The default value is @code{(texinfo-@-every-@-node-@-update bhl-@-texi-@-make-@-menu)}, so that the output file is ready for compilation. If you are using accents, you may add @code{bhl-texi-toggle-accents}. @end defopt @defopt bhl2texi-properties-list The list of properties relevant for the @command{bhl2texinfo} conversion. @xref{Properties of conversion}. Don't modifiy this variable manually. Use @code{M-x customize} instead. @end defopt @defopt bhl-texi-conversions-list A list of conversions to perform with @command{bhl2texinfo}. Each element of this list is boolean. Don't edit this option manually, use @command{M-x customize} instead. @end defopt @defopt bhl-texi-setchapternewpage-flag Set the @code{@@setchapternewpage} value. The default value is @code{on}. @end defopt @defopt bhl-texi-titlepage-style The style of the title page. The @code{classical} titlepage is the one mostly used by the @acronym{GNU} manuals. The @code{centered} titlepage centers the title and other informations on the front page. @end defopt @defopt bhl-texi-centered-minipage-tag The default tag used for the conversion of centered minipages. @xref{Environments}. @end defopt @defopt bhl-texi-table-tag The tag for the conversion of tables in the Texinfo output. The default value is @code{verbatim}. If you want to skip tables when converting into Texinfo format, you should set this to @code{ignore}. @end defopt @node BHL to SGML, BHL to TXT, BHL to Texinfo, Options @section BHL to SGML @defopt bhl-after-sgml-conversion-hook Hook run after the SGML conversion. @end defopt @defopt bhl2sgml-properties-list The list of properties relevant for the @command{bhl2hsgml} conversion. @xref{Properties of conversion}. Don't modifiy this variable manually. Use @code{M-x customize} instead. @end defopt @defopt bhl-sgml-conversions-list A list of conversions to perform with @command{bhl2sgml}. Each element of this list is boolean. Don't edit this option manually, use @command{M-x customize} instead. @end defopt @defopt bhl-sgml-list-item-is-para-flag Non-@code{nil} means that list items are paragraphs into the SGML output. @end defopt @defopt bhl-sgml-minipage-tag The default tag used for the conversion of minipages. @xref{Environments}. @end defopt @node BHL to TXT, Wiki options, BHL to SGML, Options @section BHL to TXT @defopt bhl-after-txt-conversion-hook Hook run after the TXT conversion. @end defopt @defopt bhl2txt-properties-list The list of properties relevant for the @command{bhl2txt} conversion. @xref{Properties of conversion}. Don't modifiy this variable manually. Use @code{M-x customize} instead. @end defopt @defopt bhl-txt-conversions-list A list of conversions to perform with @command{bhl2txt}. Each element of this list is boolean. Don't edit this option manually, use @command{M-x customize} instead. @end defopt @node Wiki options, Options of the toc, BHL to TXT, Options @section Wiki options @defopt bhl-is-a-local-wiki-flag If non-@code{nil}, this means that @acronym{bhl} is a local wiki. You can toggle this variable from the menu. @end defopt @defopt bhl-default-wikifiles-extension The default extension for the Wiki file names. The default value for this options is @code{.bhl}. For example, when following a WikiName named @code{MyWikiName}, a new file named @code{MyWikiName.bhl} will be found. @end defopt @defopt bhl-downcase-wikifiles-names-flag If non-@code{nil}, following a WikiName named @code{MyWikiName} will find a file named @code{mywikiname.bhl}, which is the downcased value of the WikiName. Otherwise, it will find a file named @code{MyWikiName.bhl}. @end defopt @defopt bhl-non-wiki-names-list A list of mixed-case strings that should not be considered as WikiNames. For example: ``OpenOffice''. @end defopt @node Options of the toc, Converting tables, Wiki options, Options @section Options of the toc @defopt bhl-default-toc-depth The default doc depth. The default value is three. @end defopt @defopt bhl-toc-location Indicates the toc location. This variable may have three different values: @code{top} (just after the title), @code{bottom} (just before the end) or @code{point} (at point). @end defopt @defopt bhl-intro-toc A string to insert before the table of contents in the source file. @end defopt @defopt bhl-end-toc A string to insert after the table of contents in the @acronym{bhl} files. @end defopt @node Converting tables, , Options of the toc, Options @section Converting tables @defopt bhl-table-location Where to put the table. The default value is @code{htbp}, i.e. @code{here top bottom page}. This variable does not concern the HTML output. @end defopt @defopt bhl-table-align The table alignment. The default value is @code{center}. @end defopt @defopt bhl-table-cell-align The cell alignment inside a table. The default value is @code{center}. @end defopt @node Example, Index, Options, top @chapter Example @smallexample Just ANother Example --- Table of contents 1. Fonts and environments 1.1. Using font beautifiers 1.2. Environments 2. Converting lists 2.1. Ordered and non-ordered lists 2.2. Description lists 2.3. Nested lists 3. Converting tables 4. Browsing your document 4.1. The table of content 4.2. The list of links 5. Contact --- End of the table of contents # This is the last example of a BHL file converted into HTML, LaTeX # and SGML formats. This example shows you the various syntaxic rules # that BHL handles. For further details, please refer to the manual # of the BHL mode. http://www.nongnu.org/bhl # These lines are comments. # You can comment a region with `bhl-comment-region' # The few next lines are specification lines. They # indicate the properties of the different conversions. #!author!Bastien Guerry #!date!It is %Hh%M on %d/%m/%Y. #!html!toc:nocaption:noprefix:noi18n #!sgml!caption #!latex!toc:caption:prefix:i18n #!latex-options!11pt:a4paper #!latex-packages!inputenc[latin1] This document is a small example of what BHL can do. For further details, please read the full documentation on http://www.nongnu.org/bhl. #!language!fr #!encoding!iso-8859-1 #!texi-style!centered 1. Fonts and environments 1.1. Using font beautifiers Here is a list of the *different* fonts beautifiers that you can use inside the BHL mode. Bold -- *one or two words.* Emphasis -- _one or two words._ Truetype -- ==one or two words.== Underline -- __one or two words.__ Bold italic -- _*one or two words*_. If want to insert an asterisk, you can use the escape character like \*this\* or like \_this\_. This is also available for \#comments. 1.2. Environments BHL handles two specific environments: verbatim and minipage. Verbatim: -- Here is a *part* of text that will be displayed in verbatim #a comment Please remark[1] that this environment has no syntactic rule, except you modify the variable bhl-verbatim-ignore. * list are ignored And so do... Item -- descriptions. And so do tables! | A | B | | C | D | And so do quote environments: blahblahblah blahblahblah Etc. -- A minipage: %%%[12cm] This minipage (12cm) is centered without border. %%% <%%[10cm] This minipage (10cm) is put on the left without border. %%% >-%[8cm] This minipage (8cm) is put on the right with border. %%% A horizontal rule: ----[3cm] Another horizontal rule, put on the right: >---[3cm] 2. Converting lists 2.1. Ordered and non-ordered lists *Ordered* lists begin with three *whitespaces*, a list separator (\*, - or o) and another whitespace. * Like this; * or like that. 2.2. Description lists Description lists are treated like other lists, except that they cannot be nested in other lists. A description item consists in tabs, a term to be defined, a whitespace, two dashes and another whitespace. Term -- a definition of the terme. Definition -- another definition. 2.3. Nested lists * Lists can be nested inside other lists. * You just need to add three whitespaces more. * These to items will be nested into two other items. sldkfj lskdjf lmmlkm 1. Three levels of nested lists are supported. 2. Four levels won't be very useful... * Blank lines are not mandatory between items. 3. Converting tables A WikiName. Here is a table: | @@dHL et lqskdj@@ | @@qsdqsdOolsqdf@@ | | Free softxware | bastien1@@free.fr | | With Emacs | Without Emacs | | bastien | Without Emacs | A table line begins and ends with a "|". Other "|" inside a line of the table separate two cells. Arobases around the content of a cell mean that this cell is a header of the table. 4. Browsing your document 4.1. The table of content Hhh. You can _browse_ the table of content, _insert_ it inside your document, and _update_ the numbering of sections. The default key binding for browsing the table of content is C-c C-t. You can also choose the style of sectioning and swith from one style to another. The style of this document is set to *num* (which is the default style) by the specification line above. 4.2. The list of links The default key binding for browsing the list of links is C-c C-/. This creates a new buffer with a list of URLs or wikinames that you can follow. 5. Contact Please feel free to submit bugs or ideas: [[mailto:bastien1@@free.fr][BHL contact]]. Footnotes: [1] A note. @end smallexample @node Index, , Example, top @chapter Index @printindex cp @unnumbered Thanks Thanks to Serge Basterot, Jeffrey Borlik, Christoph Conrad, Tim Cross, Mario Domgrgen, Thomas Gehrlein, Jacob Hamacher, Sylvain Holtzer, Dan P. Katz, Mario Lang, Massimiliano Mirra, Julie Neveux, John Stauffer, Thierry Stoehr and Marco Testi. @contents @bye bhl-1.7.3/Makefile0100644000076400007640000000617110053644727013371 0ustar guerryguerry### ### Makefile for the BHL mode ### ### Author: Bastien Guerry ### Revised: 23/07/2003 ### Created: 11/16/2002 ### URL: http://www.nongnu.org/bhl/ ### (0) Set the following variables as you like. ### (1) ~$ make ### (2) ~$ make info ### (3) ~$ make install ### (4) ~$ make install-info ### (4) ~$ make pdf ################################################################ ## ## EDIT THE FOLLOWINGS ## prefix=/usr/share infodir=$(prefix)/info ## ## Texinfo Manual ## manual = bhl.texi #English manual ## ## Compile engines ## EMACS = emacs #EMACS = xemacs #EMACS = mule ## ## A directory where bhl.el[c] will be installed. ## elispdir = $(prefix)/share/emacs/site-lisp/ #elispdir = $(prefix)/lib/$(EMACS)/site-lisp #elispdir = $(prefix)/lib/emacs ## ## A directory where bhl2* will be installed. ## bindir = $(prefix)/bin/ ## Conversion tools TEXI2PDF = texi2pdf TEXI2HTML = makeinfo --html --no-split #TEXI2HTML = texi2html ################################################################ ## ## DO NOT EDIT THE FOLLOWINGS ## CP = cp RM = rm -f MKDIR = mkdir -p TEMPFILE = tmp.el PWD = INSTALLINFO = `which install-info` INSTALLINFO_ARGS = bhl.info* $(infodir)/dir ################################################################ all: el info: infofile install: install-el install-scripts install-info: inst-info pdf: make-pdf html: make-html clean: ################################################################ el: bhl.el @echo "Compiling EL files of BHL ... " @echo "PLEASE IGNORE WARNINGS IF DISPLAYED. TAKE IT EASY!" $(EMACS) -batch -q -no-site-file --eval "(byte-compile-file \"bhl.el\")" @echo "Compiling EL files of BHL ... done." @echo "You can now install the BHL mode (make install)." install-el: bhl.elc -@if [ ! -d $(elispdir) ]; then \ $(MKDIR) $(elispdir); \ fi $(CP) bhl.el* $(elispdir) ################################################################ install-scripts: -@if [ ! -d $(bindir) ]; then \ $(MKDIR) $(bindir); \ fi $(CP) contrib/bhl2* $(bindir) ################################################################ infofile: # $(EMACS) -batch -q -no-site-file -l texinfmt \ # -f batch-texinfo-format $(manual) # Uncomment the two lines above and uncomment the next line # if you prefer to use makeinfo instead of texinfmt. makeinfo --no-split $(manual) @echo "You can now install the info file (make install-info)." inst-info: -@if [ ! -d $(infodir) ]; then \ $(MKDIR) $(infodir); \ fi; \ cp bhl.info* $(infodir) -@if [ -x "$(INSTALLINFO)" ]; then \ $(INSTALLINFO) $(INSTALLINFO_ARGS); \ else \ echo "Don't forget to edit $(infodir)/dir so that it includes the info pages for the BHL mode."; \ fi ################################################################ make-pdf: @echo "Creating PDF manual..." $(TEXI2PDF) $(manual) @echo "... done." ################################################################ make-html: @echo "Creating HTML manual..." $(TEXI2HTML) $(manual) @echo "... done." ################################################################ clean: $(RM) *cps *elc *fn *aux *cp *ky *log *pg *tp *toc *vr *~ $(TEMPFILE) ## ## End of Makefile ##