Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 17: Editing LaTeX/HTML Files |  | Previous HourNext Hour
Sections in this Hour: |  |

## Writing HTML with XEmacs

Much of the information in the previous GNU Emacs section also applies to XEmacs.

The maintainers of XEmacs have chosen to use psgml as the native XEmacs HTML mode. This is a complex package, originally written by Lennart Staflin and James Clark and subsequently adapted for XEmacs by Ben Wing, Bill Perry, and Steve Bauer. Parts of Nelson Minar's html-helper-mode have been incorporated into the HTML-specific portions of the code in the XEmacs version. You can access this mode at the following Web site: http://www.santafe.edu/~nelson/tools/

### Using psgml-HTML

psgml's HTML mode is not as easy to use as the GNU Emacs HTML mode, but many more tags are supported. There are more menus (five in all), but the menus won't make much sense without first reading the Info help documentation (C-h-i summons the Info index). The basic tag-insertion functions aren't immediately evident, but clicking with the right mouse button shows a cascading menu of context-sensitive tag items. By context-sensitive, I mean that the only tags shown in the menu are those which are appropriate to the cursor position in the file. For example, if your cursor is below the second </head> tag the menu consists of a single item, Body, because that is the only appropriate tag for that place in the file.

But let's ignore the mouse menus for the time being. Learning the keybindings for the tags is more important, especially in this particular mode. In this mode, the equivalent tag keybindings aren't shown on the menus. The psgml Info file doesn't list them; most of this documentation is concerned with esoteric commands and functions used with other sorts of SGML files. Any time you're faced with an Emacs mode and need some quick information, typing C-h-m helps. If an HTML file is being edited, a window appears with a brief summary of psgml's HTML mode, followed by two full pages of keybindings. Information concerning other active modes (such as font -lock-mode and text -mode) also appears; just scroll down to the section beginning with HTML Mode.

This is a good opportunity to practice cutting and pasting. Type C-space at the beginning of the HTML mode section and scroll down to the end of the buffer (type M-> to get there quickly). When your cursor is at the end of the last line, type M-w, which copies the region you have marked with the two previous commands.

Now type C-x C-f. You are prompted for a filename in the minibuffer; type in a nonexistent mnemonic filename, perhaps something such as html-keys.txt. After the new empty buffer appears, type C-y and watch the HTML-mode section of the mode-help buffer appear in your buffer. I recommend printing out this file, because it is a great help in learning the keybindings for this particular HTML mode.

It is often useful to be able to tag a marked region or selection. This feature makes it possible to write a file in untagged normal text and go back through the file afterward and tag regions, effectively transforming a text file into an HTML file. Tagging marked selections is also handy when importing blocks of text from a text file into an HTML file.

Try it out by first marking an area of text, first using C-space to mark one end. Move the cursor to the other end of the region and type C-u followed by a keybinding for any of the HTML tags. For example, if an area of text is selected, typing C-u C-z q surrounds the area with the <blockquote> tags, which causes the area to be indented in from the rest of the text when a browser displays the file.

Sams Teach Yourself Emacs in 24 Hours |  | ContentsIndex
Hour 17: Editing LaTeX/HTML Files |  | Previous HourNext Hour
Sections in this Hour: |  |

© Copyright Macmillan USA. All rights reserved.