LDP/LDP/guide/docbook/LDP-Author-Guide/tools-emacs.xml

177 lines
5.2 KiB
XML

<!--
<!DOCTYPE book PUBLIC '-//OASIS//DTD DocBook XML V4.2//EN'>
-->
<section id="psgml">
<title>Emacs (PSGML)</title>
<indexterm> <primary>psgml</primary> </indexterm>
<indexterm> <primary>Emacs</primary> </indexterm>
<indexterm> <primary>Editors</primary>
<secondary>Emacs</secondary> </indexterm>
<indexterm> <primary>Editors</primary>
<secondary>psgml</secondary> </indexterm>
<para>
<ulink url="http://www.lysator.liu.se/~lenst/about_psgml/">
http://www.lysator.liu.se/~lenst/about_psgml/
</ulink>
</para>
<para><application>Emacs</application> has an SGML
writing mode called <application>psgml</application> that is a
major mode designed for editing SGML and XML documents. It
provides:
</para>
<itemizedlist>
<listitem><para>
<quote>syntax highlighting</quote> or <quote>pretty
printing</quote> features that make the tags stand out
</para></listitem>
<listitem><para>
a way to insert tags other than typing them by hand
</para></listitem>
<listitem><para>
and the ability to validate your document while writing
</para></listitem>
</itemizedlist>
<para>
For users of Emacs, it's a great way to go.
PSGML works with DocBook, LinuxDoc and other DTDs equally well.
</para>
<section id="emacs-psgml-install">
<title>Verifying PSGML is Installed</title>
<para>
If you have installed a recent distribution, you may
already have PSGML installed for use with Emacs. To check,
start Emacs and look for the PSGML documentation (<keycombo
moreinfo="none"><keycap moreinfo="none">C</keycap><keycap
moreinfo="none">h</keycap></keycombo><keycap
moreinfo="none">i</keycap><keycap
moreinfo="none">m</keycap><keycap
moreinfo="none">psgml</keycap>).
</para>
<tip><title>Dependencies</title><para>
If you don't have PSGML installed now might be a good
time to upgrade Emacs. The rest of these instructions
will assume you have PSGML installed.
</para></tip>
</section>
<section id="emacs-config">
<title>Configuring Emacs for Use With PSGML</title>
<para>
If you want GNU Emacs to enter PSGML mode when you open
an <filename class="extension">.xml</filename> file, it
will need to be able to find the DocBook DTD files.
If your distribution already had PSGML set up for use
with GNU Emacs, you probably won't need to do anything.
</para>
<note><title>Tuning Emacs</title>
<para>
For more information on how to configure Emacs, check out
<xref linkend="ref-software-edit" />.
</para>
</note>
<para>
Once you've configured your system to use PSGML you will
need to override Emacs' default <emphasis>sgml-mode</emphasis> with the
<emphasis>psgml-mode</emphasis>. This can be done by configuring your
<filename>.emacs</filename> file. After you've edited the
configuration file you will need to restart Emacs.
</para>
</section>
<section id="emacs-new-file">
<title>Creating New DocBook XML Files</title>
<para>
There are a number of steps to creating a new DocBook XML
file in Emacs.
</para>
<itemizedlist>
<listitem><para>
Create a new file with an
<filename class="extension">xml</filename>
extension.
</para></listitem>
<listitem><para>
On the first line of the file enter the doctype for the
version of DocBook that you would like to use.
If you're not sure what a doctype is all about, check <xref
linkend="dtd" />
</para></listitem>
<listitem><para>
Enter
<keycombo moreinfo="none">
<keycap moreinfo="none">C</keycap>
<keycap moreinfo="none">c</keycap>
</keycombo>
<keycombo moreinfo="none">
<keycap moreinfo="none">C</keycap>
<keycap moreinfo="none">p</keycap>
</keycombo>.
If Emacs manages to parse your DTD, you will
see <computeroutput>Parsing prolog...done</computeroutput>
in the minibuffer.
</para></listitem>
<listitem><para>
Enter
<keycombo moreinfo="none">
<keycap moreinfo="none">C</keycap>
<keycap moreinfo="none">c</keycap>
</keycombo>
<keycombo moreinfo="none">
<keycap moreinfo="none">C</keycap>
<keycap moreinfo="none">e</keycap>
</keycombo>
<keycombo moreinfo="none"><keycap moreinfo="none">Enter</keycap></keycombo>
to auto-magically insert the parent element for your
document. (New authors are typically writing
<sgmltag>article</sgmltag>s.)
</para></listitem>
<listitem><para>
If things are working correctly, you should see new tags
for the parent element for your document right after the
document type declaration. In other words you should now
see two extra tags:
<sgmltag class="starttag">article</sgmltag>
and
<sgmltag class="endtag">article</sgmltag>
in your document.
</para></listitem>
</itemizedlist>
</section>
<section id="emacs-spell">
<title>Spell Checking in Emacs</title>
<para>
Emacs can be configured to use <application>aspell</application>
by adding the following to your <filename>~/.emacs</filename> file.
Thanks to <ulink url="http://www.ertius.org">Rob Weir</ulink> for
this configuration information.
</para>
<programlisting>
;; Use aspell
(setq-default ispell-program-name &quot;aspell&quot;)
;;Setup some dictionary languages
(setq ispell-dictionary &quot;british&quot;)
(setq flyspell-default-dictionary &quot;british&quot;)
</programlisting>
</section>
</section>