home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / HOWTOs / LINUXDOC < prev    next >
Text File  |  1999-11-04  |  25KB  |  859 lines

  1.   LinuxDoc+Emacs+Ispell-HOWTO
  2.   Author: Philippe MARTIN (feloy@wanadoo.fr)
  3.   Translator: SΘbastien Blondeel (Sebastien.Blondeel@lifl.fr)
  4.  
  5.   v0.4, 27 February 1998
  6.  
  7.   This document is aimed at writers and translators of Linux HOWTOs or
  8.   any other paper for the Linux Documentation Project. It gives them
  9.   hints at using tools including Emacs and Ispell.
  10.  
  11.   ______________________________________________________________________
  12.  
  13.   Table of Contents
  14.  
  15.  
  16.   1. Preamble
  17.  
  18.      1.1 Copyright
  19.      1.2 Credits
  20.      1.3 Comments
  21.      1.4 Versions
  22.  
  23.   2. Introduction
  24.  
  25.      2.1 SGML
  26.      2.2 The
  27.      2.3 (TT
  28.  
  29.   3. Your first document.
  30.  
  31.      3.1 From a text document
  32.  
  33.   4. Configuring
  34.  
  35.      4.1 Accented Characters
  36.         4.1.1 The displaying of 8-bit characters
  37.         4.1.2 The typing of 8-bit characters
  38.            4.1.2.1 The
  39.            4.1.2.2 The
  40.         4.1.3 The displaying of 8-bit SGML characters
  41.      4.2 SGML mode
  42.      4.3 PSGML mode
  43.      4.4 Miscellaneous
  44.         4.4.1 auto-fill mode
  45.  
  46.   5. Ispell
  47.  
  48.      5.1 Choosing your default dictionaries
  49.      5.2 Selecting special dictionaries for certain files
  50.      5.3 Spell-checking your document
  51.      5.4 Personal dictionary versus local file dictionary
  52.      5.5 Typing spell-checking
  53.  
  54.   6. Dirty Tricks
  55.  
  56.      6.1 Inserting a header automatically
  57.         6.1.1 by inserting a file
  58.         6.1.2 by running a routine
  59.  
  60.   7. An
  61.  
  62.  
  63.  
  64.   ______________________________________________________________________
  65.  
  66.  
  67.   1.
  68.  
  69.   Preamble
  70.  
  71.   1.1.
  72.  
  73.   Copyright
  74.  
  75.   Copyright Philippe Martin 1998
  76.   You may redistribute and/or modify this document as long as you comply
  77.   with the terms of the GNU General Public Licence, version 2 or later.
  78.  
  79.  
  80.   1.2.
  81.  
  82.   Credits
  83.  
  84.   Special thanks go to SΘbastien Blondeel, who is a nasty bugger and
  85.   asked me so much about Emacs setup. His clever questions have allowed
  86.   me to understand it better and pass the knowledge to you through this
  87.   document.
  88.  
  89.  
  90.   1.3.
  91.  
  92.   Comments
  93.  
  94.   Do not hesitate to tell me any thing you think will help make this
  95.   document better. I will examine your critics thoroughly.
  96.   Do not hesitate as well to ask me any questions related to topics
  97.   discussed here. I will be more than happy to answer them, as they may
  98.   help me further improve this document. (-- Translator note: If the
  99.   English is ugly, well then that goes to me!--)
  100.  
  101.  
  102.   1.4.
  103.  
  104.   Versions
  105.  
  106.   This paper is about the following versions:
  107.  
  108.   ╖  Sgml-tools version 0.99,
  109.  
  110.   ╖  Emacs version 19.34,
  111.  
  112.   ╖  Ispell version 3.1,
  113.  
  114.   ╖  All Emacs libraries referred to in this document are distributed
  115.      with the above Emacs version, apart from iso-sgml, which is
  116.      distributed with XEmacs, and psgml, which is a stand-alone library.
  117.  
  118.  
  119.  
  120.   2.
  121.  
  122.   Introduction
  123.  
  124.   2.1.
  125.  
  126.   SGML
  127.  
  128.   Standard Generalised Mark-up Language, or SGML, is a language to
  129.   define document types.
  130.  
  131.   For instance, one may define the document type recipe, with a first
  132.   part presenting the ingredients, a second part introducing the
  133.   accessories, a third part giving step by step instructions for baking
  134.   the cake, and a nice final picture to show the outcome of it all.
  135.  
  136.  
  137.   This is called a Document Type Definition.  It does not define what
  138.   the final product will look like, it only defines what it may contain.
  139.  
  140.  
  141.   To use the same example again, I'm sure that upon reading my idea of a
  142.   recipe, you recognised yours, or your favourite cook's. Nevertheless,
  143.   they actually look different: mine have a picture in the upper left
  144.   corner of the bathroom cupboard, and the ingredients list can be found
  145.   in the back garden, between the swimming pool and the barbecue. Yours?
  146.  
  147.  
  148.   Thanks to this standard definition, one can write a document, without
  149.   taking into account what it will look like in the end to the reader.
  150.  
  151.  
  152.   2.2.
  153.  
  154.   The LinuxDoc  Type Definition
  155.  
  156.   This type is used to write, as you might have guessed, documents
  157.   related to Linux.
  158.  
  159.   Such documents are generally built as follows: they start with a title
  160.   followed by the name of the author, and the version number and date.
  161.   Then comes the abstract (so you don't have to browse through it before
  162.   realizing it isn't what you were looking for after all), then the
  163.   contents which show the structure so that those in a rush can go
  164.   directly to the part they want to read.
  165.  
  166.   Then comes a list of chapters, sections, paragraphs. Among these, one
  167.   can insert bits of programs, change the font to emphasise a word or a
  168.   sentence, insert lists, refer to another part of the document, etc.
  169.  
  170.   To write such a document, you just need to specify at the right time
  171.   the title, the author, the date, and the document version, the
  172.   chapters and sections, say when a list is to be inserted, what its
  173.   elements are etc.
  174.  
  175.  
  176.   2.3.
  177.  
  178.   SGML-Tools
  179.  
  180.   SGML-Tools will turn the specification of a document into the final
  181.   result in the form you prefer. If you want it in your personal
  182.   library, you will choose PostScript. If you want to share it with the
  183.   world through the Web, it will be HTML. If you can't help it and must
  184.   read it under Windows, you can turn it into RTF to be able to read it
  185.   with any word processor. Or maybe use all three formats to accommodate
  186.   your changing moods.
  187.  
  188.   SGML-Tools are available via anonymous FTP at
  189.   ftp://ftp.lip6.fr/pub/sgml-tools/
  190.  
  191.  
  192.   3.
  193.  
  194.   Your first document.
  195.  
  196.  
  197.  
  198.  
  199.   3.1.
  200.  
  201.   From a text document
  202.  
  203.   If you want to turn a text document into SGML to port it to other
  204.   formats, this is the way to go:
  205.  
  206.  
  207.   1. Add the following lines at the very beginning:
  208.  
  209.  
  210.              <!doctype linuxdoc system>
  211.               <article>
  212.                <title>Title Goes Here</title>
  213.                <author>
  214.                 name of author, author's e-mail, etc.
  215.                </author>
  216.                <date>
  217.                 version and date
  218.                </date>
  219.  
  220.  
  221.  
  222.  
  223.  
  224.   2. If you describe briefly the contents of the document in the
  225.      beginning, surround that paragraph with the <abstract> and
  226.      </abstract> tags.
  227.  
  228.  
  229.   3. Then insert the <toc> tag, which stands for Table Of Contents.
  230.  
  231.   4. At the beginning of each new chapter, replace the line giving the
  232.      number and title of the chapter with:
  233.  
  234.  
  235.             <sect>The Title Of The Chapter
  236.  
  237.  
  238.  
  239.   and add the </sect> tag at the end of the chapter.
  240.  
  241.   Note : You don't have to put the chapter number, this is done
  242.   automatically.
  243.  
  244.  
  245.   5. Proceed in the same way for sections. You need to delete their
  246.      numbers and tag their titles with <sect1> and they end with
  247.      </sect1>.
  248.  
  249.   6. You can also define as many as 4 levels of nesting in the sections,
  250.      using <sectn> and </sectn> where n= 2, 3, or 4 in a similar way.
  251.  
  252.   7. In the beginning of each paragraph, insert the <p> tag.
  253.  
  254.   8. If you need to emphasise some parts, tag them with <it> and </it>
  255.      (italics), <bf> and </bf> (bold face), or <tt> and </tt>
  256.      (typewriter style).
  257.  
  258.   9. To insert a list like the following one:
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.              This is a four lines list:
  266.  
  267.               - first line goes here
  268.               - second line comes next
  269.               - yet another one
  270.               - that's it.
  271.  
  272.  
  273.  
  274.  
  275.   you must replace it with:
  276.  
  277.  
  278.           This is a four lines list:
  279.          <itemize>
  280.          <item>first line goes here
  281.          <item>second line come next
  282.          <item>yet another one
  283.          <item>that's it.
  284.          </itemize>
  285.  
  286.  
  287.  
  288.  
  289.   10.
  290.      When a whole block is a part of a program, or something else that
  291.      needs to stick out:
  292.  
  293.  
  294.             <verb>
  295.              10 REM Oh my God what's this?
  296.              20 REM I thought this had long disappeared!
  297.              30 PRINT "I am back to";
  298.              40 PRINT "save the world."
  299.              50 INPUT "From whom, do you reckon? ",M$
  300.              60 IF M$="Bill" THEN PRINT "Thou art wise.":GOTO PARADISE
  301.              70 ELSE PRINT "You ain't got a clue...":GOTO RICHMOND
  302.              </verb>
  303.  
  304.  
  305.  
  306.  
  307.   11.
  308.      Thus far, your SGML formating skills are fairly decent. If you want
  309.      to refine your document, you may have a look at the user's guide
  310.      for SGML-Tools, which gives more details about the LinuxDoc
  311.      document type.
  312.  
  313.   4.
  314.  
  315.   Configuring Emacs
  316.  
  317.  
  318.   4.1.
  319.  
  320.   Accented Characters
  321.  
  322.   If you want to write documents in French or in any other western
  323.   European language, you will need 8-bit characters. This is how to set
  324.   Emacs up to tell it to accept such characters.
  325.  
  326.  
  327.   4.1.1.
  328.  
  329.   The displaying of 8-bit characters
  330.  
  331.   To let Emacs display 8-bit characters, you will need the following
  332.   lines in your .emacs file:
  333.  
  334.          (standard-display-european 1)
  335.          (load-library "iso-syntax")
  336.  
  337.  
  338.  
  339.  
  340.   If you are using Emacs on a terminal which has no 8-bit support, you
  341.   can use the iso-ascii library ((load-library "iso-ascii")), which
  342.   tells Emacs to display such characters to its best approximation.
  343.  
  344.  
  345.   4.1.2.
  346.  
  347.   The typing of 8-bit characters
  348.  
  349.   If your keyboard allows you to enter accented characters, no problem.
  350.   If not here are some remedies:
  351.  
  352.  
  353.   4.1.2.1.
  354.  
  355.   The iso-acc  library
  356.  
  357.   The Emacs iso-acc library will let you type 8-bit characters from a
  358.   7-bit keyboard.
  359.  
  360.   To use it, insert the following in your .emacs file:
  361.  
  362.         (load-library "iso-acc")
  363.  
  364.  
  365.  
  366.  
  367.   Then, upon running Emacs and opening the file you need to edit, type
  368.   Meta-x iso-accents-mode.
  369.  
  370.   You can then enter the Θ of the French word cafΘ typing ' then e. More
  371.   generally, you will type an accented character typing the accent
  372.   first, then the letter to accent (upper or lower case). The following
  373.   are the accents you may use:
  374.  
  375.  
  376.  
  377.   ` : Grave
  378.  
  379.   ^ : Circumflex
  380.  
  381.   " : Dieresis
  382.  
  383.   ~ : Tilde, cedilla, and other particular cases (cf iso-acc.el).
  384.  
  385.   / : To bar a letter, etc.
  386.  
  387.   If you need one of these characters and not an accented letter, type a
  388.   space next to it. For instance, to type l'ΘlΘphant, type l ' <spc> ' e
  389.   l ' e ...
  390.  
  391.   You will find all the possible combinations in the iso-acc.el file.
  392.  
  393.  
  394.  
  395.  
  396.  
  397.   4.1.2.2.
  398.  
  399.   The<Meta> key
  400.  
  401.   Some terminals will let you type 8-bit characters with the <Meta> (or
  402.   <Alt>) key. For example, pressing <Meta>-i will get you the Θ
  403.   character.
  404.  
  405.   But Emacs reserved the <Meta> key for other uses, and I know of no
  406.   library which lets you use it for accented characters.
  407.  
  408.   This is a solution:
  409.  
  410.  
  411.         (global-set-key "\ei" '(lambda () (interactive) (insert ?\351)))
  412.                            _                                      ___
  413.  
  414.  
  415.  
  416.  
  417.   Such a line, if inserted in your .emacs file, will let you type Θ
  418.   using the <Meta>-i keystroke.  You can redefine in such a way the
  419.   combinations you need if you replace i with the right key and 351 with
  420.   the right code (the code being taken from the ISO-8859-1 character
  421.   set).
  422.  
  423.   Warning! Some local modes may redefine such key combinations.
  424.  
  425.  
  426.   4.1.3.  The displaying of 8-bit SGML characters
  427.  
  428.   Under SGML, you can type accented characters with macros. For example,
  429.   the Θ key is é. Generally, the applications that need to read
  430.   SGML can read 8-bit characters and there is no need to use these
  431.   macros. But some may not be able to do so. Given that there is a way
  432.   to solve this problem, it would be a waste to let these crash.
  433.  
  434.   The iso-sgml library will let you type accented characters under
  435.   Emacs, like always, but upon saving your file to the disk, it will
  436.   turn these 8-bit characters into their SGML equivalent.
  437.  
  438.   It is therefore easy, thanks to this library, to type and reread your
  439.   document under Emacs, and you can be sure a non 8-bit clean
  440.   application will accept you document.
  441.  
  442.   To use this library, you just need to add the following lines to your
  443.   .emacs file:
  444.  
  445.  
  446.         (setq sgml-mode-hook
  447.         '(lambda () "Defaults for SGML mode."
  448.          (load-library "iso-sgml")))
  449.  
  450.  
  451.  
  452.  
  453.  
  454.   4.2.
  455.  
  456.   SGML mode
  457.  
  458.   Upon loading a file with the .sgml extension, Emacs enters the sgml
  459.   mode automatically. If it doesn't, you can tell it to do so manually
  460.   by typing Meta-x sgml-mode, or automatically by adding the following
  461.   lines to your .emacs file:
  462.  
  463.         (setq auto-mode-alist
  464.         (append '(("\.sgml$"  . sgml-mode))
  465.                   auto-mode-alist))
  466.  
  467.  
  468.  
  469.  
  470.   This mode will let you choose how to insert 8-bit characters for
  471.   example. With Meta-x sgml-name-8bit-mode (or the menu item SGML/Toggle
  472.   8-bit insertion), you can choose to type 8-bit characters as is, or in
  473.   SGML form, i.e. in the form &...;.
  474.  
  475.   It will as well let you hide or show SGML tags, with Meta-x sgml-tags-
  476.   invisible (or the menu item SGML/Toggle Tag Visibility).
  477.  
  478.  
  479.  
  480.   4.3.
  481.  
  482.   PSGML mode
  483.  
  484.   PSGML mode helps a lot to edit SGML documents with Emacs.
  485.  
  486.   The psgml-linuxdoc documentation explains how to install this mode and
  487.   use it with LinuxDoc.
  488.  
  489.  
  490.   4.4.
  491.  
  492.   Miscellaneous
  493.  
  494.  
  495.   4.4.1.
  496.  
  497.   auto-fill mode
  498.  
  499.   In the normal mode, when you type a paragraph and get to the end of
  500.   the line, you must use the <Return> key yourself to get to the next
  501.   line, or else your line goes on through the whole paragraph.  When you
  502.   use <Return> to get to the next line, you get a paragraph with ragged
  503.   right margins.
  504.  
  505.   If you let some lines go beyond a reasonable width, you won't be able
  506.   to see them with some editors.
  507.  
  508.   The auto-fill mode automates this boring task: when you go further
  509.   than a certain column (the 70th by default), you are automatically
  510.   taken to the next line.
  511.  
  512.   This is how to use this mode, and set the width of your lines to 80:
  513.  
  514.  
  515.          (setq sgml-mode-hook
  516.                '(lambda () "Defaults for SGML mode."
  517.                    (auto-fill-mode)
  518.                    (setq fill-column 80)))
  519.  
  520.  
  521.  
  522.  
  523.  
  524.   5.
  525.  
  526.   Ispell
  527.  
  528.  
  529.   If you want to spell-check your document from within Emacs, you may
  530.   use the Ispell package and its Emacs mode.
  531.  
  532.  
  533.   5.1.
  534.  
  535.   Choosing your default dictionaries
  536.  
  537.   You can set up Emacs so that upon loading a file, it chooses
  538.   automatically which dictionaries to use (you can use several). The
  539.   first one, certainly the most important, is the main dictionary,
  540.   distributed with Ispell. You can choose among several languages. The
  541.   second one is your personal dictionary, where Ispell will insert words
  542.   it couldn't find in the main dictionary but you told it to remember.
  543.  
  544.   If you wish to use as a default dictionary the French dictionary that
  545.   comes with Ispell, and if you wish to use the file .ispell-dico-perso
  546.   in your home directory as a personal dictionary, insert the following
  547.   lines in your .emacs file:
  548.  
  549.  
  550.          (setq sgml-mode-hook
  551.          '(lambda () "Defauts for SGML mode."
  552.          (setq ispell-personal-dictionary "~/.ispell-dico-perso")
  553.          (ispell-change-dictionary "francais")
  554.          ))
  555.  
  556.  
  557.  
  558.  
  559.  
  560.   5.2.  Selecting special dictionaries for certain files
  561.  
  562.   You may have a little problem if you do not spell-check documents in
  563.   the same language at all times. If you translate documents, it is very
  564.   likely that you swap languages (and dictionaries) very often.
  565.  
  566.  
  567.   I don't know of any Lisp way of selecting, either automatically, or
  568.   with a single mouse click, the main and personal dictionaries
  569.   associated to the language currently being used. (If you do, please
  570.   tell me!)
  571.  
  572.  
  573.   However, it is possible to indicate, at the end of the file, which
  574.   dictionaries you want to use for the current file (and only this one).
  575.   It suffices to add them as commentaries, so that Ispell can read them
  576.   upon launching a spell-check:
  577.  
  578.  
  579.         <!-- Local IspellDict: english -->
  580.         <!-- Local IspellPersDict: ~/emacs/.ispell-english -->
  581.  
  582.  
  583.  
  584.  
  585.   If you have previously defined, in your .emacs file, that your default
  586.   dictionaries are the French dictionaries, then you can add these lines
  587.   in the end of any file written in English.
  588.  
  589.  
  590.   5.3.
  591.  
  592.   Spell-checking your document
  593.  
  594.  
  595.   To spell-check the whole of your document, use, from anywhere in the
  596.   document the Meta-x ispell-buffer command. You may as well only run
  597.   the checking on a region in your document:
  598.  
  599.  
  600.   ╖  Mark the beginning of the region with Ctrl-Spc (mark-set-command),
  601.  
  602.   ╖  Go to the end of the region to check,
  603.  
  604.   ╖  type Meta-x ispell-region.
  605.  
  606.   Emacs then runs Ispell. Upon meeting an unknown word, this one shows
  607.   you said word (usually highlighted) and prompts you for a key:
  608.  
  609.  
  610.   ╖  spc accepts the word, this time only,
  611.  
  612.   ╖  i accepts the word and inserts it in your personal dictionary,
  613.  
  614.   ╖  a accepts the word for this session,
  615.  
  616.   ╖  A accepts the word for this file, and inserts it in the local file
  617.      dictionary
  618.  
  619.   ╖  r allows you to correct the word by hand
  620.  
  621.   ╖  R allows you to correct all the occurrences of the misspelled word,
  622.  
  623.   ╖  x stops the checking, and puts the cursor back in place,
  624.  
  625.   ╖  X stops the checking and leaves the cursor where it is, letting you
  626.      correct your file; you will be able to continue the spell-checking
  627.      later if you type Meta-x ispell-continue,
  628.  
  629.   ╖  ? gives you online help.
  630.  
  631.   If ispell finds one or several words close to the unknown one, it will
  632.   show them in a little window, each one of them preceded by a digit.
  633.   Just type this digit to replace the misspelled word with the
  634.   corresponding word.
  635.  
  636.  
  637.   5.4.
  638.  
  639.   Personal dictionary versus local file dictionary
  640.  
  641.   The i key will let you insert a word in your personal dictionary,
  642.   whereas A will let you insert a word in the local file dictionary.
  643.  
  644.  
  645.   The local file dictionary is a sequence of words inserted at the end
  646.   of the file, as comments, reread by Ispell each time it is run on the
  647.   file. This way, you can accept some words, acceptable in this file,
  648.   but not necessarily acceptable in other files.
  649.  
  650.  
  651.   As far as I am concerned, I think it is better that the personal
  652.   dictionary be reserved for words the main dictionary doesn't know but
  653.   which belong to the language (like hyphenated words), plus some common
  654.   words like proper nouns or others (like Linux), if they don't look too
  655.   much like a real word of the main dictionary; adding too many words in
  656.   the personal dictionary, such as first names, may be dangerous,
  657.   because they may look like a word of the language (one can imagine
  658.   Ispell being mystified on the following: `When the going gets tof, the
  659.   tof get going (-- Tof is a French abbreviation for the first name
  660.   Christophe.--)
  661.   5.5.
  662.  
  663.   Typing spell-checking
  664.  
  665.   Ispell can spell-check your file while you're typing. You need to use
  666.   ispell-minor-mode for this. To start it or stop it, type Meta-x
  667.   ispell-minor-mode. Ispell will beep you each time you type a word it
  668.   doesn't know.
  669.  
  670.  
  671.   If those beeps hassle you (or your roommate is taking a nap), you can
  672.   replace those annoying beeps with a flash on the screen, with the
  673.   command Meta-x set-variable RET visible-bell RET t RET. You can add
  674.   the following line in your .emacs and silence Emacs forever:
  675.  
  676.  
  677.          (setq visible-bell t)
  678.  
  679.  
  680.  
  681.  
  682.  
  683.   6.
  684.  
  685.   Dirty Tricks
  686.  
  687.   6.1.
  688.  
  689.   Inserting a header automatically
  690.  
  691.   Emacs allows you to hook some actions to any event (opening of a file,
  692.   saving, running a new mode, etc).
  693.  
  694.  
  695.   The autoinsert library uses this feature: when you open a new file
  696.   under Emacs, this library inserts, according to the type of the file,
  697.   a standard header.
  698.  
  699.  
  700.   In our case, this standard header could well be the part declaring the
  701.   document type (LinuxDoc), the title, the author, and the date.
  702.  
  703.  
  704.   I will describe here two ways to insert such a header. You could
  705.   insert a template file containing the information to insert, or you
  706.   could run an elisp routine.
  707.  
  708.  
  709.   6.1.1.
  710.  
  711.   by inserting a file
  712.  
  713.   You must first tell Emacs to run the auto-insert when opening a file,
  714.   then to read the autoinsert library which declares the auto-insert-
  715.   alist list which we need to change. This list defines the header to
  716.   insert for each file type. By default, the file to insert must be in
  717.   the ~/insert/ directory, but it is possible to redefine the auto-
  718.   insert-directory variable if you want to put it somewhere else.
  719.  
  720.  
  721.   Add the following lines to your .emacs file to insert the
  722.   ~/emacs/sgml-insert.sgml file each time you open a new SGML file:
  723.  
  724.  
  725.  
  726.  
  727.         (add-hook 'find-file-hooks 'auto-insert)
  728.         (load-library "autoinsert")
  729.         (setq auto-insert-directory "~/emacs/")
  730.         (setq auto-insert-alist
  731.               (append '((sgml-mode .  "sgml-insert.sgml"))
  732.                       auto-insert-alist))
  733.  
  734.  
  735.  
  736.  
  737.   You can then write in the ~/emacs/sgml-insert.sgml file your
  738.   customised header, then re-run Emacs and open some foobar.sgml file.
  739.   Emacs should ask you to confirm the automatic insertion, and if you
  740.   answer yes, insert your header.
  741.  
  742.  
  743.   6.1.2.
  744.  
  745.   by running a routine
  746.  
  747.   This works like before, but instead of setting the auto-insert-alist
  748.   to a file to insert, you need to set it to a function to execute. This
  749.   is how to proceed, taking for granted you want to write this function
  750.   in a file named ~/emacs/sgml-header.el.  (there's no need to burden
  751.   your .emacs file with such a function, as it may turn out to be quite
  752.   long):
  753.  
  754.  
  755.         (add-hook 'find-file-hooks 'auto-insert)
  756.         (load-library "autoinsert")
  757.         (add-to-list 'load-path "~/emacs")
  758.         (load-library "sgml-header")
  759.         (setq auto-insert-alist
  760.               (append '(((sgml-mode .  "SGML Mode") . insert-sgml-header))
  761.                       auto-insert-alist))
  762.  
  763.  
  764.  
  765.  
  766.   You will find in ``appendix'' an example of insert-sgml-header
  767.   function.
  768.  
  769.  
  770.  
  771.   G.
  772.  
  773.   An insert-sgml-header  function
  774.  
  775.   This function will let the user insert a customised header for a Linux
  776.   Documentation Project document in a file. It can be called
  777.   automatically when one opens a new file, or explicitly, by the user.
  778.  
  779.  
  780.   This function prompts the user, through the mini-buffer, for some
  781.   pieces of information, some of which are necessary, some of which are
  782.   not.
  783.  
  784.   First comes the title. If none is given, the function returns
  785.   immediately, and inserts nothing. Then comes the date, the author, his
  786.   e-mail and home page (these last two are optional).
  787.  
  788.   Then comes a request for the name of the translator. If there is none,
  789.   just type Return, and no further prompting about a hypothetical
  790.   translator will be done. If there is one, you are asked for his e-mail
  791.   and home page (optional as well).
  792.  
  793.   This function then prints your request to the current buffer,
  794.   including of course all the information you typed in a set up form,
  795.   and including as well the tags which will serve for the abstract and
  796.   the first chapter. It finally puts the cursor in the place where the
  797.   abstract needs to be typed.
  798.  
  799.  
  800.   (defun insert-sgml-header ()
  801.     "Inserts the header for a LinuxDoc document"
  802.     (interactive)
  803.     (let (title author email home translator email-translator home-translator date
  804.                 starting-point)
  805.       (setq title (read-from-minibuffer "Title: "))
  806.       (if (> (length title) 0)
  807.           (progn
  808.             (setq date (read-from-minibuffer "Date: ")
  809.                   author (read-from-minibuffer "Author: ")
  810.                   email (read-from-minibuffer "Author e-mail: ")
  811.                   home (read-from-minibuffer "Author home page: http://")
  812.                   translator (read-from-minibuffer "Translator: "))
  813.             (insert "<!doctype linuxdoc system>\n<article>\n<title>")
  814.             (insert title)
  815.             (insert "</title>\n<author>\nAuthor: ") (insert author) (insert "<newline>\n")
  816.             (if (> (length email) 0)
  817.                 (progn
  818.                   (insert "<htmlurl url=\"mailto:")
  819.                   (insert email) (insert "\" name=\"") (insert email)
  820.                   (insert "\"><newline>\n")))
  821.             (if (> (length home) 0)
  822.                 (progn
  823.                   (insert "<htmlurl url=\"http://")
  824.                   (insert home) (insert "\" name=\"") (insert home)
  825.                   (insert "\">\n<newline>")))
  826.             (if (> (length translator) 0)
  827.                 (progn
  828.                   (setq email-translator (read-from-minibuffer "Translator e-mail: ")
  829.                         home-translator (read-from-minibuffer "Translator home page: http://"))
  830.                   (insert "Translator : ")
  831.                   (insert translator)
  832.                   (insert "<newline>\n")
  833.                   (if (> (length email-translator) 0)
  834.                       (progn
  835.                         (insert "<htmlurl url=\"mailto:")
  836.                         (insert email-translator) (insert "\" name=\"")
  837.                         (insert email-translator)
  838.                         (insert "\"><newline>\n")))
  839.                   (if (> (length home-translator) 0)
  840.                       (progn
  841.                         (insert "<htmlurl url=\"http://")
  842.                         (insert home-translator) (insert "\" name=\"")
  843.                         (insert home-translator)
  844.                         (insert "\"><newline>\n")))))
  845.             (insert "</author>\n<date>\n")
  846.             (insert date)
  847.             (insert "\n</date>\n\n<abstract>\n")
  848.             (setq point-beginning (point))
  849.             (insert "\n</abstract>\n<toc>\n\n<sect>\n<p>\n\n\n</sect>\n\n</article>\n")
  850.             (goto-char point-beginning)
  851.             ))))
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.