mirror of https://github.com/tLDP/LDP
717 lines
26 KiB
Plaintext
717 lines
26 KiB
Plaintext
|
<!doctype linuxdoc system>
|
||
|
<article>
|
||
|
<title>LinuxDoc+Emacs+Ispell-HOWTO</title>
|
||
|
<author>
|
||
|
Author: Philippe MARTIN
|
||
|
(<htmlurl url="mailto:feloy@wanadoo.fr" name="feloy@wanadoo.fr">) &nl;
|
||
|
Translator: Sébastien Blondeel
|
||
|
(<htmlurl url="mailto:Sebastien.Blondeel@lifl.fr"
|
||
|
name="Sebastien.Blondeel@lifl.fr">)
|
||
|
</author>
|
||
|
<date>v0.4, 27 February 1998
|
||
|
|
||
|
<abstract>
|
||
|
This document is aimed at writers and translators of Linux HOWTOs or
|
||
|
any other paper for the Linux Documentation Project. It gives them hints at
|
||
|
using tools including Emacs and Ispell.
|
||
|
</abstract>
|
||
|
<toc>
|
||
|
|
||
|
<sect>Preamble
|
||
|
<sect1>Copyright
|
||
|
<p>
|
||
|
Copyright Philippe Martin 1998&nl;
|
||
|
You may redistribute and/or modify this document as long as you
|
||
|
comply with the terms of the GNU General Public Licence, version 2 or
|
||
|
later.
|
||
|
|
||
|
<sect1>Credits
|
||
|
<p>
|
||
|
Special thanks go to Sébastien Blondeel, who is a nasty bugger and
|
||
|
asked me so much about Emacs setup. His clever questions have allowed me to
|
||
|
understand it better and pass the knowledge to you through this
|
||
|
document.
|
||
|
|
||
|
<sect1>Comments
|
||
|
<p>
|
||
|
Do not hesitate to tell me any thing you think will help make this
|
||
|
document better. I will examine your critics thoroughly.&nl;
|
||
|
Do not hesitate as well to ask me any questions related to topics discussed
|
||
|
here. I will be more than happy to answer them, as they may help me
|
||
|
further improve this document.
|
||
|
<footnote>
|
||
|
Translator note: If the English is ugly, well then that goes to me!
|
||
|
</footnote>
|
||
|
|
||
|
<sect1>Versions
|
||
|
<p>
|
||
|
This paper is about the following versions:
|
||
|
<itemize>
|
||
|
<item>Sgml-tools version 0.99,
|
||
|
<item>Emacs version 19.34,
|
||
|
<item>Ispell version 3.1,
|
||
|
<item>All Emacs libraries referred to in this document are distributed
|
||
|
with the above Emacs version, apart from <tt/iso-sgml/, which is
|
||
|
distributed with XEmacs, and <tt/psgml/, which is a stand-alone library.
|
||
|
</itemize>
|
||
|
|
||
|
|
||
|
<sect>Introduction
|
||
|
<sect1>SGML
|
||
|
<p>
|
||
|
<it>Standard Generalised Mark-up Language</it>, or
|
||
|
<bf>SGML</bf>, is a language to define document types.
|
||
|
<p>
|
||
|
For instance, one may define the document type <it>recipe</it>, with a
|
||
|
first part presenting the ingredients, a second part introducing the
|
||
|
accessories, a third part giving step by step instructions for baking
|
||
|
the cake, and a nice final picture to show the outcome of it all.
|
||
|
<p>
|
||
|
This is called a <it>Document Type Definition</it>.
|
||
|
It does not define what the final product will look like, it only defines
|
||
|
what it may contain.
|
||
|
<p>
|
||
|
To use the same example again, I'm sure that upon reading my idea
|
||
|
of a recipe, you recognised yours, or your favourite cook's. Nevertheless,
|
||
|
they actually look different: mine have a picture in the upper left corner of
|
||
|
the bathroom cupboard, and the ingredients list can be found in the back
|
||
|
garden, between the swimming pool and the barbecue. Yours?
|
||
|
<p>
|
||
|
Thanks to this standard definition, one can write a document,
|
||
|
without taking into account what it will look like in the end to
|
||
|
the reader.
|
||
|
|
||
|
</sect1>
|
||
|
|
||
|
<sect1>The <tt>LinuxDoc</tt> Type Definition
|
||
|
<p>
|
||
|
This type is used to write, as you might have guessed,
|
||
|
documents related to Linux.
|
||
|
<p>
|
||
|
Such documents are generally built as follows: they start with a title
|
||
|
followed by the name of the author, and the version number and
|
||
|
date. Then comes the abstract (so you don't have to browse through it
|
||
|
before realizing it isn't what you were looking for after all),
|
||
|
then the contents which show the
|
||
|
structure so that those in a rush can go directly to the part they
|
||
|
want to read.
|
||
|
<p>
|
||
|
Then comes a list of chapters, sections, paragraphs. Among these, one
|
||
|
can insert bits of programs, change the font to emphasise a word or a
|
||
|
sentence, insert lists, refer to another part of the document, etc.
|
||
|
<p>
|
||
|
To write such a document, you just need to specify at the right time
|
||
|
the title, the author, the date, and the document version, the chapters
|
||
|
and sections, say when a list is to be inserted, what its elements are
|
||
|
etc.
|
||
|
|
||
|
</sect1>
|
||
|
|
||
|
<sect1><tt>SGML-Tools</tt>
|
||
|
<p>
|
||
|
<bf>SGML-Tools</bf> will turn the specification of a document into
|
||
|
the final result in the form you prefer. If you want it in your personal
|
||
|
library, you will choose <it>PostScript</it>. If you want to share it with
|
||
|
the world through the Web, it will be <it>HTML</it>. If you can't help it
|
||
|
and must read it under Windows, you can turn it into <it>RTF</it> to be
|
||
|
able to read it with any word processor. Or maybe use all three formats
|
||
|
to accommodate your changing moods.
|
||
|
|
||
|
SGML-Tools are available via anonymous FTP at <htmlurl
|
||
|
url="ftp://ftp.lip6.fr/pub/sgml-tools/" name
|
||
|
="ftp://ftp.lip6.fr/pub/sgml-tools/">
|
||
|
|
||
|
</sect1>
|
||
|
|
||
|
<sect>Your first document.
|
||
|
<p>
|
||
|
<sect1>From a text document
|
||
|
<p>
|
||
|
If you want to turn a text document into SGML to port it to other
|
||
|
formats, this is the way to go:
|
||
|
|
||
|
<enum>
|
||
|
<item>
|
||
|
Add the following lines at the very beginning:
|
||
|
|
||
|
<verb>
|
||
|
<!doctype linuxdoc system>
|
||
|
<article>
|
||
|
<title>Title Goes Here&etago;title>
|
||
|
<author>
|
||
|
name of author, author's e-mail, etc.
|
||
|
&etago;author>
|
||
|
<date>
|
||
|
version and date
|
||
|
&etago;date>
|
||
|
</verb>
|
||
|
|
||
|
<item>
|
||
|
If you describe briefly the contents of the document in the
|
||
|
beginning, surround that paragraph with the
|
||
|
<tt><abstract></tt> and <tt>&etago;abstract></tt> tags.
|
||
|
|
||
|
<item>
|
||
|
Then insert the <tt><toc></tt> tag, which stands for <em>Table
|
||
|
Of Contents</em>.
|
||
|
|
||
|
<item>
|
||
|
At the beginning of each new chapter, replace the line giving the
|
||
|
number and title of the chapter with:
|
||
|
|
||
|
<verb>
|
||
|
<sect>The Title Of The Chapter
|
||
|
</verb>
|
||
|
and add the <tt>&etago;sect></tt> tag at the end of the
|
||
|
chapter.&nl;
|
||
|
<p>
|
||
|
<bf>Note :</bf> You don't have to put the chapter number, this
|
||
|
is done automatically.
|
||
|
|
||
|
<item>
|
||
|
Proceed in the same way for sections. You need to
|
||
|
delete their numbers and tag their titles with <tt><sect1></tt>
|
||
|
and they end with <tt>&etago;sect1></tt>.
|
||
|
|
||
|
<item>
|
||
|
You can also define as many as 4 levels of nesting in the sections,
|
||
|
using <tt><sectn></tt> and <tt>&etago;sectn></tt> where
|
||
|
<tt>n=</tt> 2, 3, or 4 in a similar way.
|
||
|
|
||
|
<item>
|
||
|
In the beginning of each paragraph, insert the <tt><p></tt>
|
||
|
tag.
|
||
|
|
||
|
<item>
|
||
|
If you need to emphasise some parts, tag them with
|
||
|
<tt><it></tt> and <tt>&etago;it></tt>
|
||
|
(<it>italics</it>), <tt><bf></tt> and <tt>&etago;bf></tt>
|
||
|
(<bf>bold face</bf>), or <tt><tt></tt> and <tt>&etago;tt></tt>
|
||
|
(<tt>typewriter style</tt>).
|
||
|
|
||
|
<item>
|
||
|
To insert a list like the following one:
|
||
|
|
||
|
<verb>
|
||
|
This is a four lines list:
|
||
|
|
||
|
- first line goes here
|
||
|
- second line comes next
|
||
|
- yet another one
|
||
|
- that's it.
|
||
|
</verb>
|
||
|
|
||
|
you must replace it with:
|
||
|
|
||
|
<verb>
|
||
|
This is a four lines list:
|
||
|
<itemize>
|
||
|
<item>first line goes here
|
||
|
<item>second line come next
|
||
|
<item>yet another one
|
||
|
<item>that's it.
|
||
|
&etago;itemize>
|
||
|
</verb>
|
||
|
|
||
|
<item>
|
||
|
When a whole block is a part of a program, or something else that
|
||
|
needs to stick out:
|
||
|
|
||
|
<verb>
|
||
|
<verb>
|
||
|
10 REM Oh my God what's this?
|
||
|
20 REM I thought this had long disappeared!
|
||
|
30 PRINT "I am back to";
|
||
|
40 PRINT "save the world."
|
||
|
50 INPUT "From whom, do you reckon? ",M$
|
||
|
60 IF M$="Bill" THEN PRINT "Thou art wise.":GOTO PARADISE
|
||
|
70 ELSE PRINT "You ain't got a clue...":GOTO RICHMOND
|
||
|
&etago;verb>
|
||
|
</verb>
|
||
|
|
||
|
<item>
|
||
|
Thus far, your SGML formating skills are fairly decent. If you want to
|
||
|
refine your document, you may have a look at the user's guide for
|
||
|
<bf>SGML-Tools</bf>, which gives more details about the
|
||
|
<bf>LinuxDoc</bf> document type.
|
||
|
|
||
|
</enum>
|
||
|
</sect1>
|
||
|
</sect>
|
||
|
|
||
|
<sect>Configuring <tt>Emacs</tt>
|
||
|
<p>
|
||
|
<sect1>Accented Characters
|
||
|
<p>
|
||
|
If you want to write documents in French or in any other western
|
||
|
European language, you will need 8-bit characters. This is how to set Emacs
|
||
|
up to tell it to accept such characters.
|
||
|
|
||
|
<sect2>The displaying of 8-bit characters
|
||
|
<p>
|
||
|
To let Emacs display 8-bit characters, you will need the following
|
||
|
lines in your <tt>.emacs</tt> file:
|
||
|
<verb>
|
||
|
(standard-display-european 1)
|
||
|
(load-library "iso-syntax")
|
||
|
</verb>
|
||
|
|
||
|
If you are using Emacs on a terminal which has no 8-bit support, you
|
||
|
can use the <tt>iso-ascii</tt> library (<tt>(load-library "iso-ascii")</tt>),
|
||
|
which tells Emacs to display such characters to its best approximation.
|
||
|
|
||
|
<sect2>The typing of 8-bit characters
|
||
|
<p>
|
||
|
If your keyboard allows you to enter accented characters, no
|
||
|
problem. If not here are some remedies:
|
||
|
|
||
|
<sect3>The <tt>iso-acc</tt> library
|
||
|
<p>
|
||
|
The Emacs <tt>iso-acc</tt> library will let you type 8-bit
|
||
|
characters from a 7-bit keyboard.
|
||
|
<p>
|
||
|
To use it, insert the following in your <tt>.emacs</tt> file:
|
||
|
<verb>
|
||
|
(load-library "iso-acc")
|
||
|
</verb>
|
||
|
<p>
|
||
|
Then, upon running Emacs and opening the file you need to edit, type
|
||
|
<tt>Meta-x iso-accents-mode</tt>.
|
||
|
<p>
|
||
|
You can then enter the <bf>é</bf> of the French word <em>café</em>
|
||
|
typing <bf>'</bf> then <tt>e</tt>. More generally, you will type an
|
||
|
accented character typing the accent first, then the letter to accent
|
||
|
(upper or lower case). The following are the accents you may use:
|
||
|
|
||
|
<list>
|
||
|
<item><tt>'</tt>~: Acute
|
||
|
<item><tt>`</tt>~: Grave
|
||
|
<item><tt>^</tt>~: Circumflex
|
||
|
<item><tt>"</tt>~: Dieresis
|
||
|
<item><tt>˜</tt>~: Tilde, cedilla, and other particular
|
||
|
cases (cf iso-acc.el).
|
||
|
<item><tt>/</tt>~: To bar a letter, etc.
|
||
|
</list>
|
||
|
|
||
|
If you need one of these characters and not an accented letter, type
|
||
|
a space next to it. For instance, to type
|
||
|
<it>l'éléphant</it>, type <tt>l ' <cparam/spc/ ' e l ' e ...</tt>
|
||
|
<p>
|
||
|
You will find all the possible combinations in the
|
||
|
<tt>iso-acc.el</tt> file.
|
||
|
|
||
|
<sect3>The <cparam/Meta/ key
|
||
|
<p>
|
||
|
Some terminals will let you type 8-bit characters with the
|
||
|
<cparam/Meta/ (or <cparam/Alt/) key. For example, pressing
|
||
|
<bf><cparam/Meta/-i</bf> will get you the <bf>é</bf> character.
|
||
|
<p>
|
||
|
But Emacs reserved the <cparam/Meta/ key for other uses, and I know
|
||
|
of no library which lets you use it for accented characters.
|
||
|
<p>
|
||
|
This is a solution:
|
||
|
|
||
|
<verb>
|
||
|
(global-set-key "\ei" '(lambda () (interactive) (insert ?\351)))
|
||
|
_ ___
|
||
|
</verb>
|
||
|
|
||
|
Such a line, if inserted in your
|
||
|
<tt>.emacs</tt> file, will let you type
|
||
|
<bf>é</bf> using the <bf><cparam/Meta/-i</bf> keystroke.
|
||
|
You can redefine in such a way the combinations you need
|
||
|
if you replace <bf>i</bf> with the right key and
|
||
|
<bf>351</bf> with the right code (the code being taken from the
|
||
|
ISO-8859-1 character set).
|
||
|
<p>
|
||
|
<bf>Warning!</bf> Some local modes may redefine such key
|
||
|
combinations.
|
||
|
|
||
|
<sect2>The displaying of 8-bit SGML characters
|
||
|
<p>
|
||
|
Under SGML, you can type accented characters with macros. For
|
||
|
example, the <bf/é/ key is <bf/&eacute;/. Generally, the applications
|
||
|
that need to read SGML can read 8-bit characters and there is no need to
|
||
|
use these macros. But some may not be able to do so. Given that there is a
|
||
|
way to solve this problem, it would be a waste to let these crash.
|
||
|
<p>
|
||
|
The <tt>iso-sgml</tt> library will let you type accented characters
|
||
|
under Emacs, like always, but upon saving your file to the disk, it will
|
||
|
turn these 8-bit characters into their SGML equivalent.
|
||
|
<p>
|
||
|
It is therefore easy, thanks to this library, to type and reread
|
||
|
your document under Emacs, and you can be sure a non 8-bit clean
|
||
|
application will accept you document.
|
||
|
<p>
|
||
|
To use this library, you just need to add the following lines to your
|
||
|
<tt>.emacs</tt> file:
|
||
|
|
||
|
<verb>
|
||
|
(setq sgml-mode-hook
|
||
|
'(lambda () "Defaults for SGML mode."
|
||
|
(load-library "iso-sgml")))
|
||
|
</verb>
|
||
|
|
||
|
<sect1>SGML mode
|
||
|
<p>
|
||
|
Upon loading a file with the <bf>.sgml</bf> extension,
|
||
|
Emacs enters the <bf>sgml mode</bf> automatically. If it doesn't, you
|
||
|
can tell it to do so manually by typing <tt>Meta-x sgml-mode</tt>, or
|
||
|
automatically by adding the following lines to your <tt>.emacs</tt> file:
|
||
|
|
||
|
<verb>
|
||
|
(setq auto-mode-alist
|
||
|
(append '(("\.sgml$" . sgml-mode))
|
||
|
auto-mode-alist))
|
||
|
</verb>
|
||
|
|
||
|
This mode will let you choose how to insert 8-bit characters for
|
||
|
example. With <tt>Meta-x sgml-name-8bit-mode</tt> (or the menu item
|
||
|
<it>SGML/Toggle 8-bit insertion</it>), you can choose to type 8-bit
|
||
|
characters as is, or in SGML form, i.e. in the form <bf>&...;</bf>.
|
||
|
|
||
|
It will as well let you hide or show SGML tags, with <tt>Meta-x
|
||
|
sgml-tags-invisible</tt> (or the menu item <it>SGML/Toggle Tag
|
||
|
Visibility</it>).
|
||
|
|
||
|
|
||
|
<sect1>PSGML mode
|
||
|
<p>
|
||
|
PSGML mode helps a lot to edit SGML documents with Emacs.
|
||
|
<p>
|
||
|
The <htmlurl name="psgml-linuxdoc"
|
||
|
url="http://www.linux-france.com/article/psgml-linuxdoc">
|
||
|
documentation explains how to install this mode and use it with
|
||
|
<it>LinuxDoc</it>.
|
||
|
|
||
|
<sect1>Miscellaneous
|
||
|
<p>
|
||
|
<sect2>auto-fill mode
|
||
|
<p>
|
||
|
In the normal mode, when you type a paragraph and get to the end of
|
||
|
the line, you must use the
|
||
|
<cparam/Return/ key yourself to get to the next line, or else your line
|
||
|
goes on through the whole paragraph. When you use
|
||
|
<cparam/Return/ to get to the next line, you get a paragraph
|
||
|
with ragged right margins.
|
||
|
<p>
|
||
|
If you let some lines go beyond a
|
||
|
reasonable width, you won't be able to see them with some editors.
|
||
|
<p>
|
||
|
The <bf>auto-fill</bf> mode automates this boring task: when you go
|
||
|
further than a certain column (the 70th by default), you are automatically
|
||
|
taken to the next line.
|
||
|
<p>
|
||
|
This is how to use this mode, and set the width of your lines to 80:
|
||
|
|
||
|
<verb>
|
||
|
(setq sgml-mode-hook
|
||
|
'(lambda () "Defaults for SGML mode."
|
||
|
(auto-fill-mode)
|
||
|
(setq fill-column 80)))
|
||
|
</verb>
|
||
|
|
||
|
<sect>Ispell
|
||
|
<p>
|
||
|
If you want to spell-check your document from within Emacs, you may
|
||
|
use the <bf>Ispell</bf> package and its Emacs mode.
|
||
|
|
||
|
<sect1>Choosing your default dictionaries
|
||
|
<p>
|
||
|
You can set up Emacs so that upon loading a file, it chooses
|
||
|
automatically which dictionaries to use (you can use several). The first
|
||
|
one, certainly the most important, is the main dictionary, distributed
|
||
|
with Ispell. You can choose among several languages. The second one is
|
||
|
your personal dictionary, where Ispell will insert words it couldn't
|
||
|
find in the main dictionary but you told it to remember.
|
||
|
|
||
|
If you wish to use as a default dictionary the French dictionary
|
||
|
that comes with Ispell, and if you wish to use the file
|
||
|
<tt>.ispell-dico-perso</tt> in your home directory as a personal
|
||
|
dictionary, insert the following lines in your <tt>.emacs</tt> file:
|
||
|
|
||
|
<verb>
|
||
|
(setq sgml-mode-hook
|
||
|
'(lambda () "Defauts for SGML mode."
|
||
|
(setq ispell-personal-dictionary "~/.ispell-dico-perso")
|
||
|
(ispell-change-dictionary "francais")
|
||
|
))
|
||
|
</verb>
|
||
|
|
||
|
<sect1>Selecting special dictionaries for certain files
|
||
|
<p>
|
||
|
You may have a little problem if you do not spell-check documents in
|
||
|
the same language at all times. If you translate documents, it is very
|
||
|
likely that you swap languages (and dictionaries) very often.
|
||
|
|
||
|
<p>
|
||
|
I don't know of any Lisp way of selecting, either automatically, or
|
||
|
with a single mouse click, the main and personal dictionaries associated
|
||
|
to the language currently being used. (If you do, please tell me!)
|
||
|
|
||
|
<p>
|
||
|
However, it is possible to indicate, at the end of the file, which
|
||
|
dictionaries you want to use for the current file (and only this one).
|
||
|
It suffices to add them as commentaries, so that Ispell can read them
|
||
|
upon launching a spell-check:
|
||
|
|
||
|
<verb>
|
||
|
<!-- Local IspellDict: english -->
|
||
|
<!-- Local IspellPersDict: ~/emacs/.ispell-english -->
|
||
|
</verb>
|
||
|
|
||
|
If you have previously defined, in your <tt/.emacs/ file, that
|
||
|
your default dictionaries are the French dictionaries, then you can add
|
||
|
these lines in the end of any file written in English.
|
||
|
|
||
|
<sect1>Spell-checking your document
|
||
|
<p>
|
||
|
To spell-check the whole of your document, use, from anywhere in
|
||
|
the document the <tt>Meta-x ispell-buffer</tt> command. You may as well
|
||
|
only run the checking on a region in your document:
|
||
|
|
||
|
<itemize>
|
||
|
<item> Mark the beginning of the region with <tt>Ctrl-Spc</tt>
|
||
|
(mark-set-command),
|
||
|
<item> Go to the end of the region to check,
|
||
|
<item> type <tt>Meta-x ispell-region</tt>.
|
||
|
</itemize>
|
||
|
|
||
|
Emacs then runs Ispell. Upon meeting an unknown word, this one
|
||
|
shows you said word (usually highlighted) and prompts you for a key:
|
||
|
|
||
|
<itemize>
|
||
|
<item><bf>spc </bf>accepts the word, this time only,
|
||
|
<item><bf>i </bf>accepts the word and inserts it in your personal
|
||
|
dictionary,
|
||
|
<item><bf>a </bf>accepts the word for this session,
|
||
|
<item><bf>A </bf>accepts the word for this file, and inserts it
|
||
|
in the local file dictionary
|
||
|
<item><bf>r </bf>allows you to correct the word by hand
|
||
|
<item><bf>R </bf>allows you to correct all the occurrences of the
|
||
|
misspelled word,
|
||
|
<item><bf>x </bf>stops the checking, and puts the cursor back in
|
||
|
place,
|
||
|
<item><bf>X </bf>stops the checking and leaves the cursor where
|
||
|
it is, letting you correct your file; you will be able to continue the
|
||
|
spell-checking later if you type <tt>Meta-x ispell-continue</tt>,
|
||
|
<item><bf>? </bf>gives you online help.
|
||
|
</itemize>
|
||
|
|
||
|
If ispell finds one or several words close to the unknown one, it
|
||
|
will show them in a little window, each one of them preceded by a digit.
|
||
|
Just type this digit to replace the misspelled word with the corresponding
|
||
|
word.
|
||
|
|
||
|
<sect1>Personal dictionary versus local file dictionary
|
||
|
<p>
|
||
|
The <bf>i</bf> key will let you insert a word in your personal
|
||
|
dictionary, whereas <bf>A</bf> will let you insert a word in the local
|
||
|
file dictionary.
|
||
|
|
||
|
<p>
|
||
|
The local file dictionary is a sequence of words inserted at the
|
||
|
end of the file, as comments, reread by Ispell each time it is run on
|
||
|
the file. This way, you can accept some words, acceptable in this file,
|
||
|
but not necessarily acceptable in other files.
|
||
|
|
||
|
<p>
|
||
|
As far as I am concerned, I think it is better that the personal
|
||
|
dictionary be reserved for words the main dictionary doesn't know but
|
||
|
which belong to the language (like hyphenated words), plus some common
|
||
|
words like proper nouns or others (like <it>Linux</it>), if they don't
|
||
|
look too much like a real word of the main dictionary; adding too many
|
||
|
words in the personal dictionary, such as first names, may be dangerous,
|
||
|
because they may look like a word of the language (one can imagine
|
||
|
Ispell being mystified on the following:
|
||
|
`<it>When the going gets tof, the tof get going</it><footnote>
|
||
|
<em>Tof</em> is a French abbreviation for the first name
|
||
|
<em>Christophe</em>.</footnote>'!).
|
||
|
|
||
|
<sect1>Typing spell-checking
|
||
|
<p>
|
||
|
Ispell can spell-check your file while you're typing. You need to
|
||
|
use <bf>ispell-minor-mode</bf> for this. To start it or stop it, type
|
||
|
<tt>Meta-x ispell-minor-mode</tt>. Ispell will <em>beep</em> you each
|
||
|
time you type a word it doesn't know.
|
||
|
|
||
|
<p>
|
||
|
If those <em>beeps</em> hassle you (or your roommate
|
||
|
is taking a nap), you can replace those annoying <em>beeps</em>
|
||
|
with a flash on the screen, with
|
||
|
the command <tt>Meta-x set-variable RET visible-bell RET t RET</tt>. You
|
||
|
can add the following line in your <tt>.emacs</tt> and silence Emacs
|
||
|
forever:
|
||
|
|
||
|
<verb>
|
||
|
(setq visible-bell t)
|
||
|
</verb>
|
||
|
|
||
|
<sect>Dirty Tricks
|
||
|
<sect1>Inserting a header automatically
|
||
|
<p>
|
||
|
Emacs allows you to <em>hook</em> some actions to any event
|
||
|
(opening of a file, saving, running a new mode, etc).
|
||
|
|
||
|
<p>
|
||
|
The <bf>autoinsert</bf> library uses this feature: when you open a
|
||
|
new file under Emacs, this library inserts, according to the type of the
|
||
|
file, a <em>standard</em> header.
|
||
|
|
||
|
<p>
|
||
|
In our case, this <em>standard</em>
|
||
|
header could well be the part declaring
|
||
|
the document type (LinuxDoc), the title, the author, and the date.
|
||
|
|
||
|
<p>
|
||
|
I will describe here two ways to insert such a header. You could
|
||
|
insert a template file containing the information to insert, or you could run
|
||
|
an <bf>elisp</bf> routine.
|
||
|
|
||
|
<sect2>by inserting a file
|
||
|
<p>
|
||
|
You must first tell Emacs to run the <tt>auto-insert</tt> when
|
||
|
opening a file, then to read the <bf>autoinsert</bf> library which
|
||
|
declares the <tt>auto-insert-alist</tt> list which we need to change. This
|
||
|
list defines the header to insert for each file type. By default, the
|
||
|
file to insert must be in the <tt>~/insert/</tt> directory, but it is
|
||
|
possible to redefine the <tt>auto-insert-directory</tt> variable
|
||
|
if you want to put it somewhere else.
|
||
|
|
||
|
<p>
|
||
|
Add the following lines to your <tt>.emacs</tt> file to insert the
|
||
|
<tt>~/emacs/sgml-insert.sgml</tt> file each time you open a new SGML
|
||
|
file:
|
||
|
|
||
|
<verb>
|
||
|
(add-hook 'find-file-hooks 'auto-insert)
|
||
|
(load-library "autoinsert")
|
||
|
(setq auto-insert-directory "~/emacs/")
|
||
|
(setq auto-insert-alist
|
||
|
(append '((sgml-mode . "sgml-insert.sgml"))
|
||
|
auto-insert-alist))
|
||
|
</verb>
|
||
|
|
||
|
You can then write in the <tt>~/emacs/sgml-insert.sgml</tt> file
|
||
|
your customised header, then re-run Emacs and open some
|
||
|
<tt>foobar.sgml</tt> file. Emacs should ask you to confirm the automatic
|
||
|
insertion, and if you answer yes, insert your header.
|
||
|
|
||
|
<sect2>by running a routine
|
||
|
<p>
|
||
|
This works like before, but instead of setting the
|
||
|
<tt>auto-insert-alist</tt> to a file to insert, you need to set it to a
|
||
|
function to execute. This is how to proceed, taking for granted you want
|
||
|
to write this function in a file named <tt>~/emacs/sgml-header.el</tt>.
|
||
|
(there's no need to burden your <tt>.emacs</tt> file with such a
|
||
|
function, as it may turn out to be quite long):
|
||
|
|
||
|
<verb>
|
||
|
(add-hook 'find-file-hooks 'auto-insert)
|
||
|
(load-library "autoinsert")
|
||
|
(add-to-list 'load-path "~/emacs")
|
||
|
(load-library "sgml-header")
|
||
|
(setq auto-insert-alist
|
||
|
(append '(((sgml-mode . "SGML Mode") . insert-sgml-header))
|
||
|
auto-insert-alist))
|
||
|
</verb>
|
||
|
|
||
|
You will find in <ref id="insert-sgml-header" name="appendix"> an
|
||
|
example of <tt>insert-sgml-header</tt> function.
|
||
|
|
||
|
|
||
|
<appendix>
|
||
|
|
||
|
<sect>An <tt>insert-sgml-header</tt> function <label id="insert-sgml-header">
|
||
|
<p>
|
||
|
This function will let the user insert a customised header for a
|
||
|
Linux Documentation Project document in a file. It can be called
|
||
|
automatically when one opens a new file, or explicitly, by the user.
|
||
|
|
||
|
<p>
|
||
|
This function prompts the user, through the <em>mini-buffer</em>,
|
||
|
for some pieces of information, some of which are necessary, some of which are
|
||
|
not.
|
||
|
|
||
|
First comes the title. If none is given, the function returns
|
||
|
immediately, and inserts nothing. Then comes the date, the author, his
|
||
|
e-mail and home page (these last two are optional).
|
||
|
|
||
|
Then comes a request for the name of the translator. If there is
|
||
|
none, just type <em>Return</em>, and no further prompting about a
|
||
|
hypothetical translator will be done. If there is one, you are asked for
|
||
|
his e-mail and home page (optional as well).
|
||
|
|
||
|
This function then prints your request to the current buffer,
|
||
|
including of course all the information you typed in a set up form, and
|
||
|
including as well the tags which will serve for the abstract and the
|
||
|
first chapter. It finally puts the cursor
|
||
|
in the place where the abstract needs to be typed.
|
||
|
|
||
|
<verb>
|
||
|
(defun insert-sgml-header ()
|
||
|
"Inserts the header for a LinuxDoc document"
|
||
|
(interactive)
|
||
|
(let (title author email home translator email-translator home-translator date
|
||
|
starting-point)
|
||
|
(setq title (read-from-minibuffer "Title: "))
|
||
|
(if (> (length title) 0)
|
||
|
(progn
|
||
|
(setq date (read-from-minibuffer "Date: ")
|
||
|
author (read-from-minibuffer "Author: ")
|
||
|
email (read-from-minibuffer "Author e-mail: ")
|
||
|
home (read-from-minibuffer "Author home page: http://")
|
||
|
translator (read-from-minibuffer "Translator: "))
|
||
|
(insert "<!doctype linuxdoc system>\n<article>\n<title>")
|
||
|
(insert title)
|
||
|
(insert "&etago;title>\n<author>\nAuthor: ") (insert author) (insert "&nl;\n")
|
||
|
(if (> (length email) 0)
|
||
|
(progn
|
||
|
(insert "<htmlurl url=\"mailto:")
|
||
|
(insert email) (insert "\" name=\"") (insert email)
|
||
|
(insert "\">&nl;\n")))
|
||
|
(if (> (length home) 0)
|
||
|
(progn
|
||
|
(insert "<htmlurl url=\"http://")
|
||
|
(insert home) (insert "\" name=\"") (insert home)
|
||
|
(insert "\">\n&nl;")))
|
||
|
(if (> (length translator) 0)
|
||
|
(progn
|
||
|
(setq email-translator (read-from-minibuffer "Translator e-mail: ")
|
||
|
home-translator (read-from-minibuffer "Translator home page: http://"))
|
||
|
(insert "Translator : ")
|
||
|
(insert translator)
|
||
|
(insert "&nl;\n")
|
||
|
(if (> (length email-translator) 0)
|
||
|
(progn
|
||
|
(insert "<htmlurl url=\"mailto:")
|
||
|
(insert email-translator) (insert "\" name=\"")
|
||
|
(insert email-translator)
|
||
|
(insert "\">&nl;\n")))
|
||
|
(if (> (length home-translator) 0)
|
||
|
(progn
|
||
|
(insert "<htmlurl url=\"http://")
|
||
|
(insert home-translator) (insert "\" name=\"")
|
||
|
(insert home-translator)
|
||
|
(insert "\">&nl;\n")))))
|
||
|
(insert "&etago;author>\n<date>\n")
|
||
|
(insert date)
|
||
|
(insert "\n&etago;date>\n\n<abstract>\n")
|
||
|
(setq point-beginning (point))
|
||
|
(insert "\n&etago;abstract>\n<toc>\n\n<sect>\n<p>\n\n\n&etago;sect>\n\n&etago;article>\n")
|
||
|
(goto-char point-beginning)
|
||
|
))))
|
||
|
</verb>
|
||
|
</article>
|
||
|
|
||
|
<!-- Local IspellDict: english -->
|
||
|
<!-- Local IspellPersDict: ~/emacs/.ispell-english -->
|
||
|
<!-- Local IspellDict: english
|
||
|
-->
|
||
|
<!-- Local IspellPersDict: ~/emacs/.ispell-english
|
||
|
-->
|
||
|
<!-- LocalWords: bastien HOWTOs rushy HTML Dieresis phant eacute sgml caf
|
||
|
-->
|
||
|
<!-- LocalWords: tof Christophe autoinsert elisp Blondeel spc XEmacs
|
||
|
-->
|