# Emacs (PSGML)

http://www.lysator.liu.se/~lenst/about_psgml/

Emacs has an SGML writing mode called psgml that is a major mode designed for editing SGML and XML documents. It provides:

- syntax highlighting or pretty printing features that make the tags stand out

- a way to insert tags other than typing them by hand

- and the ability to validate your document while writing

For users of Emacs, it's a great way to go. PSGML works with DocBook, LinuxDoc and other DTDs equally well.

## Verifying PSGML is Installed

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 (Ch impsgml).

### Dependencies

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.

## Configuring Emacs for Use With PSGML

If you want GNU Emacs to enter PSGML mode when you open an `.xml` 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.

### Tuning Emacs

For more information on how to configure Emacs, check out .

Once you've configured your system to use PSGML you will need to override Emacs' default sgml-mode with the psgml-mode. This can be done by configuring your `.emacs` file. After you've edited the configuration file you will need to restart Emacs.

## Creating New DocBook XML Files

There are a number of steps to creating a new DocBook XML file in Emacs.

- Create a new file with an `xml` extension.

- 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

- Enter C c C p .

  If Emacs manages to parse your DTD, you will see `Parsing prolog...done` in the minibuffer.

- Enter C c C e Enter

  to auto-magically insert the parent element for your document. (New authors are typically writing `article`s.)

- 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: `article` and `article` in your document.

## Spell Checking in Emacs

Emacs can be configured to use aspell by adding the following to your `~/.emacs` file. Thanks to Rob Weir for this configuration information.

    ;; Use aspell
    (setq-default ispell-program-name "aspell")
    ;;Setup some dictionary languages
    (setq ispell-dictionary "british")
    (setq flyspell-default-dictionary "british")