Html helper mode is not part of Emacs by default. You can download it from its homepage at http://www.nongnu.org/baol-hth . Download the file into a directory such as ~/elisp , move to that directory, and then type:
% tar xvzf html-helper-mode.tar.gz
The system unpacks the tar file for you. (Of course, if you are installing on Windows, you can simply use WinZip to decompress and unpack the file.) The tar file contains several components, including:
• html-helper-mode.el— the Lisp file for HTML helper mode
• hhm-changelog— changes that have been made
• hhm-config.el— a Lisp file that allows Emacs customization to work [47]
8.3.2.1 Starting HTML helper mode
Before you can start HTML helper mode, you have to load it into Emacs. (For a complete discussion of this topic, see "Building Your Own Lisp Library" in Chapter 11; we describe it briefly here.) Begin by typing M-x load-file Enter. Emacs asks which file to load and you enter ~/elisp/html-helper-mode.eland press Enter, adjusting the path to reflect the location where you installed html-helper-mode.el . You enter the mode by typing M-x html-helper-mode Enter. HTML helper
appears on the mode line.
Making HTML helper mode part of your startup is easier. Put the following lines in your .emacs file:
(setq load-path (cons "~/elisp " load-path))
(autoload 'html-helper-mode "html-helper-mode" "Yay HTML" t)
In the first line, insert the complete path for the directory in which html-helper-mode.el is located in quotation marks, replacing ~/elisp to the correct value for your system. The second line tells Emacs to load HTML helper mode automatically when you start Emacs.
If you want to use HTML helper mode for editing HTML files by default, add this line to .emacs as well:
(setq auto-mode-alist (cons '("\\.html?$" . html-helper-mode) auto-mode-alist))
If you edit other types of files with HTML helper mode, you may want to add lines to include all the types of files you edit. Adding more lines is the easiest way. For example, to make HTML helper mode the default for PHP files, add this line to .emacs :
(setq auto-mode-alist (cons '("\\.php$" . html-helper-mode) auto-mode-alist))
8.3.2.2 A brief tour of HTML helper mode
The main reason people like HTML helper mode is that it provides easy menu access to a wide variety of options. Realizing that having a crowded menu with many submenus could overwhelm new users, the authors created an option called Turn on Novice Menu. Selecting this option from the HTML menu provides a barebones menu, as shown in Figure 8-1. Novice HTML writers can use these options to create a basic HTML document without worrying about what forms, JSPs, PHP, and the like mean.
Figure 8-1. HTML helper mode's Novice menu (Mac OS X)
Selecting Turn on Expert Menu from the HTML menu returns the larger menu with its numerous submenus, as shown in Figure 8-2.
Figure 8-2. HTML helper mode's Expert menu (Mac OS X)
8.3.2.3 Inserting an HTML template
HTML helper mode inserts a template for you every time you create a new HTML file.
Type: C-x C-f new.html

HTML helper mode inserts a template with all the basic elements needed for a valid HTML document (Windows).
The template contains all the basic HTML elements. The entire document is surrounded by
tags. Then the head and the body are separated. Following an
tag that tells the browser to insert a horizontal line, called a horizontal rule, the tag leaves a place for the author to put in his or her email address. In these days of spam, it's unlikely you'll want to do that. (You can leave the tag blank or delete it.)
If you do want to include an email address, enter a line like this in your .emacs file (substituting your own email address, of course):
(setq html-helper-address-string
"Charles Dickens")
Type: C-x C-f newfile.html

Emacs inserts the HTML template, including the address.
Normally you begin filling out the template by entering title and a level-one header (these are often the same). You can then begin writing paragraphs of text. Before you start typing, press M-Enter. Emacs inserts
and positions the cursor between them. You can see from the ending paragraph tag that HTML helper mode is working toward XHTML compliance.
Type: M-Enter

Emacs positions the cursor between
and
so you can start insert text.
8.3.2.4 Putting tags around a region
When editing HTML files, you often spend a lot of time marking up existing text. If you preface any of the tag commands with C-u, Emacs inserts the tags around a region rather than putting them at the cursor position. [48]To demonstrate, we'll start a new HTML file and insert text from our dickens file.
Type: C-x C-f ataleoftwocities.html

Emacs inserts the HTML template.
Move the cursor past the
pair and type C-x C-i dickens.

Emacs inserts the dickens text file, to which we can add HTML tags.
If you were really doing this properly, you'd type something like "A Tale of Two Cities, Chapter 1 Chapter 1. Emacs Basics Some of you out there are probably dying to get your hands on the keyboard and start typing. We won't try to stop you; turn to the section called "Starting Emacs" and you can go ahead. But do read the beginning of this chapter later when you're ready for a break. Emacs is much easier to learn if you understand some of the basic concepts involved, which we discuss in the following introduction.
as the title and the first-level header. But for now, you just want to see how to mark up a region of existing text. Begin by marking the Dickens paragraph as a region and type C-u M-Enter.
Type: M-h C-u M-Enter.

Emacs inserts opening and closing paragraph tags.
HTML helper mode supports completion. You type the beginning of a tag and press M-Tab(for tempo-complete-tag). [49]If there's more than one possibility, a window of possible completions appears. Let's say you are working on a bulleted list.
Type:

Читать дальше