annotate lisp/hm--html-menus/html-mode.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; html-mode --- Major mode for editing HTML hypertext documents for the WWW
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; Derived from Marc Andreesen's Revision 2.3.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; Keywords: hypermedia languages help docs wp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; HTML mode, based on text mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Copyright (C) 1985 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Copyright (C) 1992, 1993 National Center for Supercomputing Applications.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; NCSA modifications by Marc Andreessen (marca@ncsa.uiuc.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; Changed by Heiko Münkel, 6 Jan 1994, 10 Jan 1994, 15 Mar 1994, 03 Jan 1995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; 12 May 1995, 25 May 1995, 29 Jul 1995, 3 Feb 1996
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; This program is free software; you can redistribute it and/or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; modify it under the terms of the GNU General Public License as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; published by the Free Software Foundation; either version 1, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;; -------------------------------- CONTENTS --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; html-mode: Major mode for editing HTML hypertext documents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; Revision: 2.2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; Changes from 2.1 (beta)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; - Changed previewer for the new Mosaic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; - Changed lemacs to xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; Changes from 2.0 (beta):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; - Ripped out numeric anchor name stuff altogether (all names should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;; meaningful, not just numbers).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; - Fixed problem with unquoted names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; - Fixed font-lock support (yeah! thanks lamour@engin.umich.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; ------------------------------ INSTRUCTIONS ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; Put the following code in your .emacs file:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; (autoload 'html-mode "html-mode" "HTML major mode." t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; (or (assoc "\\.html$" auto-mode-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; (setq auto-mode-alist (cons '("\\.html$" . html-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; auto-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; Emacs will detect the ``.html'' suffix and activate html-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; appropriately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; You are assumed to be at least somewhat familiar with the HTML
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; format. If you aren't, read about it first (see below).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;; Here are key sequences and corresponding commands:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; NORMAL COMMANDS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; C-c a html-add-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; Open an address element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; C-c b html-add-blockquote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; C-c C-b html-add-bold
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; Open a bold element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; C-c c html-add-code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; Open a 'code' (fixed-font) element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; C-c C-c html-add-citation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; C-c d html-add-description-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ;; Open a definition list. The initial entry is created for you.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; To create subsequent entries, use 'C-c e'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; C-c e html-add-description-entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; Add a new definition entry in a definition list. You are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; assumed to be inside a definition list (specifically, at the end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;; of another definition entry).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; C-c C-e html-add-emphasized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; Open an emphasized element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; C-c C-f html-add-fixed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; C-c g html-add-img
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; Add an IMG element (inlined image or graphic). Note that the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; IMG tag is currently an extension to HTML supported only by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; NCSA Mosaic browser (to my knowledge). You will be prompted for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; the URL of the image you wish to inline into the document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; C-c h html-add-header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; Add a header. You are prompted for size (1 is biggest, 2 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 ;; next biggest; bottom limit is 6) and header contents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; C-c i html-add-list-or-menu-item
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; Add a new list or menu item in a list or menu. You are assumed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; to be inside a list or menu (specifically, at the end of another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; item).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; C-c C-i html-add-italic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; Open an italic element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; C-c C-k html-add-keyboard
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; C-c l html-add-normal-link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; Add a link. You will be prompted for the link (any string;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 ;; e.g., http://foo.bar/argh/blagh). The cursor will be left where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;; you can type the text that will represent the link in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;; document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; C-c C-l html-add-listing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; C-c m html-add-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; Open a menu. The initial item is created for you. To create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; additional items, use 'C-c i'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ;; C-c C-m html-add-sample
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; C-c n html-add-numbered-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; C-c p html-add-paragraph-separator
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; Use this command at the end of each paragraph.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; C-c C-p html-add-preformatted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 ;; C-c r html-add-normal-reference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 ;; C-c s html-add-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 ;; Open a list. The initial item is created for you. To create
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; additional items, use 'C-c i'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; C-c C-s html-add-strong
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 ;; C-c t html-add-title
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 ;; Add a title to the document. You will be prompted for the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 ;; contents of the title. If a title already exists at the very
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ;; top of the document, the existing contents will be replaced.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; C-c C-v html-add-variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 ;; C-c x html-add-plaintext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 ;; Add plaintext. The cursor will be positioned where you can type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; plaintext (or insert another file, or whatever).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 ;; C-c z html-preview-document
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 ;; Fork off a Mosaic process to preview the current document.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 ;; After you do this once, subsequent invocations of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 ;; html-preview-document will cause the same Mosaic process to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; used; this magic is accomplished through Mosaic's ability to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 ;; remote-controlled via Unix signals. This feature is only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 ;; available when running XEmacs v19 (it will maybe work with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ;; GNU Emacs v19; I'm not sure).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; COMMANDS THAT OPERATE ON THE CURRENT REGION:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 ;; C-c C-r l html-add-normal-link-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 ;; Add a link that will be represented by the current region. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 ;; will be prompted for the link (any string, as with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 ;; html-add-normal-link).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; C-c C-r r html-add-reference-to-region
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; Add a reference (a link that does not reference anything) that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 ;; will be represented by the current region. You will be prompted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 ;; for the name of the link.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 ;; SPECIAL COMMANDS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 ;; <, >, &
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 ;; These are overridden to output &lt;, &gt;, and &amp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 ;; respectively. The real characters <, >, and & can be entered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 ;; into the text either by typing 'C-c' before typing the character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 ;; or by using the Emacs quoted-insert (C-q) command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 ;; C-c <, C-c >, C-c &
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 ;; See '<, >, &' above.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 ;; ---------------------------- ADDITIONAL NOTES ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 ;; If you are running Epoch or XEmacs, highlighting will be used
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; to deemphasize HTML message elements as they are created. You can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; turn this off; see the variables 'html-use-highlighting' and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 ;; 'html-use-font-lock'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 ;; HREF and NAME arguments in anchors should always be quoted. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 ;; some existing HTML documents, they are not. html-mode will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 ;; automatically quotify all such unquoted arguments when it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 ;; encounters them. The following variables affect this behavior.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; html-quotify-hrefs-on-find (variable, default t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; If this is non-nil, all HREF arguments will be quotified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 ;; automatically when a HTML document is loaded into Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; (actually when html-mode is entered).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 ;; -------------------------------- GOTCHAS ---------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 ;; HTML documents can be tricky. html-mode is not smart enough to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 ;; enforce correctness or sanity, so you have to do that yourself.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 ;; ------------------------- WHAT HTML-MODE IS NOT --------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 ;; html-mode is not a mode for *browsing* HTML documents. In
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 ;; particular, html-mode provides no hypertext or World Wide Web
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 ;; capabilities.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 ;; The World Wide Web browser we (naturally) recommend is NCSA
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 ;; Mosaic, which can be found at ftp.ncsa.uiuc.edu in /Mosaic.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 ;; See file://moose.cs.indiana.edu/pub/elisp/w3 for w3.el, which is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 ;; an Elisp World Wide Web browser written by William Perry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 ;; ------------------------------ WHAT HTML IS ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 ;; HTML (HyperText Markup Language) is a format for hypertext
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 ;; documents, particularly in the World Wide Web system. For more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;; information on HTML, telnet to info.cern.ch or pick up a copy of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;; NCSA Mosaic for the X Window System via ftp to ftp.ncsa.uiuc.edu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; in /Mosaic; information is available online through the software
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; products distributed at those sites.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; ---------------------------- ACKNOWLEDGEMENTS ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;; Some code herein provided by:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;; Dan Connolly <connolly@pixel.convex.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;; LCD Archive Entry:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;; html-mode|Marc Andreessen|marca@ncsa.uiuc.edu|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;; Major mode for editing HTML hypertext files.|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;; Date: sometime in 1993|Revision: 2.1 (beta)|~/modes/html-mode.el.Z|
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 ;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; XEmacs change -- we require hm--html-menu here so that we do not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 ;; have to manually add an autoload for html-mode. If we didn't do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 ;; this the autoload for html-mode would have to be changed to load
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 ;; hm--html-menu even though it is defined in this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (require 'hm--html-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 ;;; ---------------------------- emacs variations ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (defvar html-running-xemacs (if (or (string-match "XEmacs" emacs-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (string-match "Lucid" emacs-version) )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 "Non-nil if running XEmacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (defvar html-running-epoch (boundp 'epoch::version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 "Non-nil if running Epoch.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (defvar html-running-emacs-19 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (not html-running-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (string= (substring emacs-version 0 2) "19"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 "Non-nil if running Emacs 19")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 ;;; ------------------------------- variables --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (defvar html-quotify-hrefs-on-find t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 "*If non-nil, all HREF's (and NAME's) in a file will be automatically
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 quotified when the file is loaded. This is useful for converting ancient
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 HTML documents to SGML-compatible syntax, which mandates quoted HREF's.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 This should always be T.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (defvar html-use-highlighting html-running-epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 "*Flag to use highlighting for HTML directives in Epoch or XEmacs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 if non-NIL, highlighting will be used. Default is T if you are running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 Epoch; nil otherwise (for XEmacs, font-lock is better; see
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 html-use-font-lock instead).")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (defvar html-use-font-lock (or html-running-xemacs html-running-emacs-19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 "*Flag to use font-lock for HTML directives in XEmacs. If non-NIL,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 font-lock will be used. Default is T if you are running with XEmacs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 NIL otherwise. This doesn't currently seem to work. Bummer. Ten points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 to the first person who tells me why not.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 (defvar html-deemphasize-color "grey80"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 "*Color for de-highlighting HTML directives in Epoch or XEmacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defvar html-emphasize-color "yellow"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 "*Color for highlighting HTML something-or-others in Epoch or XEmacs.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (defvar html-document-previewer "xmosaic"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 "*Program to be used to preview HTML documents. Program is assumed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 to accept a single argument, a filename containing a file to view; program
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 is also assumed to follow the Mosaic convention of handling SIGUSR1 as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 a remote-control mechanism.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (defvar html-document-previewer-args "-ngh"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 "*Arguments to be given to the program named by html-document-previewer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 NIL if none should be given.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (defvar html-sigusr1-signal-value 16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 "*Value for the SIGUSR1 signal on your system. See, usually,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 /usr/include/sys/signal.h.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;;; --------------------------------- setup ----------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (defvar html-mode-syntax-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 "Syntax table used while in html mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (defvar html-mode-abbrev-table nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 "Abbrev table used while in html mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (define-abbrev-table 'html-mode-abbrev-table ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (if html-mode-syntax-table
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 (setq html-mode-syntax-table (make-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (modify-syntax-entry ?\" ". " html-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (modify-syntax-entry ?\\ ". " html-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (modify-syntax-entry ?' "w " html-mode-syntax-table))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (defvar html-mode-map nil "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (if html-mode-map
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (setq html-mode-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (define-key html-mode-map "\t" 'tab-to-tab-stop)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (define-key html-mode-map "\C-ca" 'html-add-address)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (define-key html-mode-map "\C-cb" 'html-add-blockquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (define-key html-mode-map "\C-cc" 'html-add-code)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (define-key html-mode-map "\C-cd" 'html-add-description-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (define-key html-mode-map "\C-ce" 'html-add-description-entry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (define-key html-mode-map "\C-cg" 'html-add-img)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (define-key html-mode-map "\C-ch" 'html-add-header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (define-key html-mode-map "\C-ci" 'html-add-list-or-menu-item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (define-key html-mode-map "\C-cl" 'html-add-normal-link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (define-key html-mode-map "\C-cm" 'html-add-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (define-key html-mode-map "\C-cn" 'html-add-numbered-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (define-key html-mode-map "\C-cp" 'html-add-paragraph-separator)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (define-key html-mode-map "\C-cr" 'html-add-normal-reference)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (define-key html-mode-map "\C-cs" 'html-add-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (define-key html-mode-map "\C-ct" 'html-add-title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (define-key html-mode-map "\C-cx" 'html-add-plaintext)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; html-preview-document currently requires the primitive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; signal-process, which is only in v19 (is it in gnu 19? dunno).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (and html-running-xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (define-key html-mode-map "\C-cz" 'html-preview-document))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (define-key html-mode-map "\C-c\C-b" 'html-add-bold)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (define-key html-mode-map "\C-c\C-c" 'html-add-citation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (define-key html-mode-map "\C-c\C-e" 'html-add-emphasized)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (define-key html-mode-map "\C-c\C-f" 'html-add-fixed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (define-key html-mode-map "\C-c\C-i" 'html-add-italic)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (define-key html-mode-map "\C-c\C-k" 'html-add-keyboard)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (define-key html-mode-map "\C-c\C-l" 'html-add-listing)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (define-key html-mode-map "\C-c\C-m" 'html-add-sample)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (define-key html-mode-map "\C-c\C-p" 'html-add-preformatted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (define-key html-mode-map "\C-c\C-s" 'html-add-strong)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (define-key html-mode-map "\C-c\C-v" 'html-add-variable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (define-key html-mode-map "<" 'html-less-than)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (define-key html-mode-map ">" 'html-greater-than)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (define-key html-mode-map "&" 'html-ampersand)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (define-key html-mode-map "\C-c<" 'html-real-less-than)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (define-key html-mode-map "\C-c>" 'html-real-greater-than)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (define-key html-mode-map "\C-c&" 'html-real-ampersand)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (define-key html-mode-map "\C-c\C-rl" 'html-add-normal-link-to-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (define-key html-mode-map "\C-c\C-rr" 'html-add-reference-to-region)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 ;;; ------------------------------ highlighting ------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (if (and html-running-epoch html-use-highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (defvar html-deemphasize-style (make-style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (set-style-foreground html-deemphasize-style html-deemphasize-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (defvar html-emphasize-style (make-style))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (set-style-foreground html-emphasize-style html-emphasize-color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if (and html-running-xemacs html-use-highlighting)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defvar html-deemphasize-style (make-face 'html-deemphasize-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (set-face-foreground html-deemphasize-style html-deemphasize-color)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (defvar html-emphasize-style (make-face 'html-emphasize-face))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (set-face-foreground html-emphasize-style html-emphasize-color)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if html-use-highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (if html-running-xemacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun html-add-zone (start end style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 "Add a XEmacs extent from START to END with STYLE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (let ((extent (make-extent start end)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (set-extent-face extent style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (set-extent-data extent 'html-mode))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if html-running-epoch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (defun html-add-zone (start end style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 "Add an Epoch zone from START to END with STYLE."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (let ((zone (add-zone start end style)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (epoch::set-zone-data zone 'html-mode))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (defun html-maybe-deemphasize-region (start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 "Maybe deemphasize a region of text. Region is from START to END."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (and (or html-running-epoch html-running-xemacs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 html-use-highlighting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (html-add-zone start end html-deemphasize-style)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;;; ------------------------ command support routines ------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (defun html-add-link (link-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 "Add a link. Single argument LINK-OBJECT is value of HREF in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 new anchor. Mark is set after anchor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (insert "<A")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (insert " HREF=\"" link-object "\">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (insert "</A>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (forward-char -4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (html-maybe-deemphasize-region (1+ (point)) (+ (point) 4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (defun html-add-reference (ref-object)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Add a reference. Single argument REF-OBJECT is value of NAME in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 new anchor. Mark is set after anchor."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (insert "<A")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (insert " NAME=\"" ref-object "\">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (insert "</A>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (forward-char -4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (html-maybe-deemphasize-region (1+ (point)) (+ (point) 4))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (defun html-add-list-internal (type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 "Set up a given type of list by opening the list start/end pair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 and creating an initial element. Single argument TYPE is a string,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 assumed to be a valid HTML list type (e.g. \"UL\" or \"OL\").
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 Mark is set after list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (insert "<" type ">\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (insert "<LI> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 ;; Point goes right there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (insert "</" type ">\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 ;; Reuse start to set mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (setq start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (push-mark start t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (defun html-open-area (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 "Open an area for entering text such as PRE, XMP, or LISTING."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (insert "<" tag ">\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (insert "</" tag ">\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 ;; Reuse start to set mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (setq start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (push-mark start t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun html-open-field (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (insert "<" tag ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (insert "</" tag ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (html-maybe-deemphasize-region (1+ start) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (goto-char start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ;;; -------------------------------- commands --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; C-c a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (defun html-add-address ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 "Add an address."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (html-open-field "ADDRESS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 ;; C-c b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (defun html-add-blockquote ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (html-open-area "BLOCKQUOTE"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 ;; C-c C-b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defun html-add-bold ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (html-open-field "B"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; C-c c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (defun html-add-code ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (html-open-field "CODE"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ;; C-c C-c
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (defun html-add-citation ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (html-open-field "CITE"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 ;; C-c d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (defun html-add-description-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 "Add a definition list. Blah blah."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (insert "<DL>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (insert "<DT> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;; Point goes right there.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (insert "\n<DD> \n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (insert "</DL>\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 ;; Reuse start to set mark.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (setq start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (push-mark start t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;; C-c e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun html-add-description-entry ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 "Add a definition entry. Assume we're at the end of a previous
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (insert "\n<DT> ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (insert "\n<DD> "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ;; C-c C-e
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (defun html-add-emphasized ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (html-open-field "EM"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;; C-c C-f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun html-add-fixed ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (html-open-field "TT"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 ;; C-c g
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (defun html-add-img (href)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 "Add an img."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (interactive "sImage URL: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (insert "<IMG SRC=\"" href "\">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (html-maybe-deemphasize-region (1+ start) (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; C-c h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (defun html-add-header (size header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 "Add a header."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (interactive "sSize (1-6; 1 biggest): \nsHeader: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (insert "<H" size ">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (html-maybe-deemphasize-region start (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (insert header)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq start (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (insert "</H" size ">\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (html-maybe-deemphasize-region (1+ start) (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 ;; C-c i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (defun html-add-list-or-menu-item ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 "Add a list or menu item. Assume we're at the end of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 last item."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (insert "\n<LI> ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 ;; C-c C-i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun html-add-italic ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (html-open-field "I"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 ;; C-c C-k
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (defun html-add-keyboard ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (html-open-field "KBD"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; C-c l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (defun html-add-normal-link (link)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 "Make a link"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (interactive "sLink to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (html-add-link link))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;; C-c C-l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun html-add-listing ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (html-open-area "LISTING"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; C-c m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun html-add-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "Add a menu."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 (html-add-list-internal "MENU"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 ;; C-c C-m
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (defun html-add-sample ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (html-open-field "SAMP"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 ;; C-c n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (defun html-add-numbered-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 "Add a numbered list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (html-add-list-internal "OL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 ;; C-c p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (defun html-add-paragraph-separator ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 "Add a paragraph separator."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (let ((start (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (insert " <P>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 (html-maybe-deemphasize-region (+ start 1) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 ;; C-c C-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (defun html-add-preformatted ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (html-open-area "PRE"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 ;; C-c r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 (defun html-add-normal-reference (reference)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 "Add a reference (named anchor)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 (interactive "sReference name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (html-add-reference reference))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 ;; C-c s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (defun html-add-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 "Add a list."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (html-add-list-internal "UL"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 ;; C-c C-s
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (defun html-add-strong ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (html-open-field "STRONG"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 ;; C-c t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun html-add-title (title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "Add or modify a title."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (interactive "sTitle: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (if (and (looking-at "<TITLE>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (forward-char 7)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (re-search-forward "[^<]*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (save-excursion (end-of-line) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 ;; Plop the new title in its place.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (replace-match title t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (insert "<TITLE>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (html-maybe-deemphasize-region (point-min) (1- (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (insert title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (insert "</TITLE>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (html-maybe-deemphasize-region (- (point) 7) (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 ;; C-c C-v
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (defun html-add-variable ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (html-open-field "VAR"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;; C-c x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defun html-add-plaintext ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "Add plaintext."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (html-open-area "XMP"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 ;;; ---------------------------- region commands -----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ;; C-c C-r l
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (defun html-add-normal-link-to-region (link start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 "Make a link that applies to the current region. Again,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 no completion."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (interactive "sLink to: \nr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (insert "<A")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (insert " HREF=\"" link "\">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (html-maybe-deemphasize-region start (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (insert "</A>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (html-maybe-deemphasize-region (- (point) 3) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 ;; C-c C-r r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (defun html-add-reference-to-region (name start end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 "Add a reference point (a link with no reference of its own) to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 the current region."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (interactive "sName: \nr")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (or (string= name "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (goto-char end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 (insert "<A NAME=\"" name "\">")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (html-maybe-deemphasize-region start (1- (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (insert "</A>")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (html-maybe-deemphasize-region (- (point) 3) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ;;; ---------------------------- special commands ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (defun html-less-than ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (insert "&lt;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (defun html-greater-than ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (insert "&gt;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (defun html-ampersand ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (insert "&amp;"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (defun html-real-less-than ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (insert "<"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (defun html-real-greater-than ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (insert ">"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (defun html-real-ampersand ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (insert "&"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 ;;; --------------------------- Mosaic previewing ----------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 ;; OK, we work like this: We have a variable html-previewer-process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 ;; When we start, it's nil. First time html-preview-document is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 ;; called, we write the current document into a tmp file and call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 ;; Mosaic on it. Second time html-preview-document is called, we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 ;; write the current document into a tmp file, write out a tmp config
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; file, and send Mosaic SIGUSR1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; This feature REQUIRES the Lisp command signal-process, which seems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; to be a XEmacs v19 feature. It might be in GNU Emacs v19 too;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;; I dunno.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (defvar html-previewer-process nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 "Variable used to track live viewer process.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (defun html-write-buffer-to-tmp-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 "Write the current buffer to a temp file and return the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 of the tmp file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 (let ((filename (concat "/tmp/" (make-temp-name "html") ".html")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (write-region (point-min) (point-max) filename nil 'foo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (defun html-preview-document ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 "Preview the current buffer's HTML document by spawning off a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 previewing process (assumed to be Mosaic, basically) and controlling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 it with signals as long as it's alive."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (let ((tmp-file (html-write-buffer-to-tmp-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 ;; If html-previewer-process is nil, we start a process.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 ;; OR if the process status is not equal to 'run.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (if (or (eq html-previewer-process nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (not (eq (process-status html-previewer-process) 'run)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (message "Starting previewer...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (setq html-previewer-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (if html-document-previewer-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (start-process "html-previewer" "html-previewer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 html-document-previewer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 html-document-previewer-args
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (start-process "html-previewer" "html-previewer"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 html-document-previewer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 tmp-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 ;; We've got a running previewer; use it via SIGUSR1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (let ((config-file (format "/tmp/Mosaic.%d"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (process-id html-previewer-process))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (set-buffer (generate-new-buffer "*html-preview-tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (insert "goto\nfile:" tmp-file "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 (write-region (point-min) (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 config-file nil 'foo)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 ;; This is a v19 routine only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 (signal-process (process-id html-previewer-process)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 html-sigusr1-signal-value)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 (delete-file config-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 (delete-file tmp-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 (kill-buffer (current-buffer)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 ;;; --------------------------------------------------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 (defun html-replace-string-in-buffer (start end newstring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (goto-char start)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 (delete-char (1+ (- end start)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 (insert newstring)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 ;;; --------------------------- html-quotify-hrefs ---------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (defun html-quotify-hrefs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 "Insert quotes around all HREF and NAME attribute value literals.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 This remedies the problem with old HTML files that can't be processed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 by SGML parsers. That is, changes <A HREF=foo> to <A HREF=\"foo\">."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (re-search-forward
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 "<[aA][ \t\n]+\\([nN][aA][mM][eE]=[a-zA-Z0-9]+[ \t\n]+\\)?[hH][rR][eE][fF]="
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 ((null (looking-at "\""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (insert "\"")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (re-search-forward "[ \t\n>]" (point-max) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (forward-char -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (insert "\""))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;;; ------------------------------- html-mode --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (defun html-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 "Major mode for editing HTML hypertext documents. Special commands:\\{html-mode-map}
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 Turning on html-mode calls the value of the variable html-mode-hook,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 if that value is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 More extensive documentation is available in the file 'html-mode.el'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 The latest (possibly unstable) version of this file will always be available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 on anonymous FTP server ftp.ncsa.uiuc.edu in /Mosaic/elisp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (kill-all-local-variables)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (if hm--html-use-old-keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (use-local-map html-mode-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (use-local-map hm--html-mode-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (setq mode-name "HTML")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (setq major-mode 'html-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (setq local-abbrev-table html-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 (set-syntax-table html-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 (run-hooks 'html-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (and html-use-font-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (html-fontify)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;;; ------------------------------- our hooks --------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (defun html-html-mode-hook ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 "Hook called from html-mode-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 Run htlm-quotify-hrefs if html-quotify-hrefs-on-find is non-nil."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ;; Quotify existing HREF's if html-quotify-hrefs-on-find is non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 (and html-quotify-hrefs-on-find (html-quotify-hrefs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;;; ------------------------------- hook setup -------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ;; Author: Daniel LaLiberte (liberte@cs.uiuc.edu).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (defun html-postpend-unique-hook (hook-var hook-function)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 "Postpend HOOK-VAR with HOOK-FUNCTION, if it is not already an element.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 hook-var's value may be a single function or a list of functions."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 (if (boundp hook-var)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (let ((value (symbol-value hook-var)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (if (and (listp value) (not (eq (car value) 'lambda)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (and (not (memq hook-function value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (set hook-var (append value (list hook-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (and (not (eq hook-function value))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (set hook-var (append value (list hook-function))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (set hook-var (list hook-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (html-postpend-unique-hook 'html-mode-hook 'html-html-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;;; -------------------------- xemacs menubar setup ---------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (if (or html-running-xemacs html-running-emacs-19)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (defvar html-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 '("HTML Mode"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 ["Open Address" html-add-address t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 ["Open Blockquote" html-add-blockquote t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 ["Open Header" html-add-header t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ["Open Hyperlink" html-add-normal-link t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ["Open Listing" html-add-listing t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 ["Open Plaintext" html-add-plaintext t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 ["Open Preformatted" html-add-preformatted t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 ["Open Reference" html-add-normal-reference t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ["Open Title" html-add-title t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 ["Open Bold" html-add-bold t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 ["Open Citation" html-add-citation t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 ["Open Code" html-add-code t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 ["Open Emphasized" html-add-emphasized t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 ["Open Fixed" html-add-fixed t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ["Open Keyboard" html-add-keyboard t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ["Open Sample" html-add-sample t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ["Open Strong" html-add-strong t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 ["Open Variable" html-add-variable t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ["Add Inlined Image" html-add-img t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ["End Paragraph" html-add-paragraph-separator t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 ["Preview Document" html-preview-document t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 ("Definition List ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 ["Open Definition List" html-add-description-list t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 ["Add Definition Entry" html-add-description-entry t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ("Other Lists ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 ["Open Unnumbered List" html-add-list t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ["Open Numbered List" html-add-numbered-list t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 ["Open Menu" html-add-menu t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 ["Add List Or Menu Item" html-add-list-or-menu-item t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 ("Operations On Region ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 ["Add Hyperlink To Region" html-add-normal-link-to-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 ["Add Reference To Region" html-add-reference-to-region t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 ("Reserved Characters ..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ["Less Than (<)" html-real-less-than t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 ["Greater Than (>)" html-real-greater-than t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ["Ampersand (&)" html-real-ampersand t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 ; (defun html-menu (e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 ; (interactive "e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 ; (mouse-set-point e)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 ; (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 ; (popup-menu html-menu))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 ; (define-key html-mode-map 'button3 'html-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 ; (defun html-install-menubar ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 ; (if (and current-menubar (not (assoc "HTML" current-menubar)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 ; (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 ; (set-buffer-menubar (copy-sequence current-menubar))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 ; (add-menu nil "HTML" (cdr html-menu)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 ; (html-postpend-unique-hook 'html-mode-hook 'html-install-menubar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (defvar html-font-lock-keywords
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 '("\\(<[^>]*>\\)+" . font-lock-comment-face)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 '("[Hh][Rr][Ee][Ff]=\"\\([^\"]*\\)\"" 1 font-lock-string-face t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 '("[Ss][Rr][Cc]=\"\\([^\"]*\\)\"" 1 font-lock-string-face t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 "Patterns to highlight in HTML buffers.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 (defun html-fontify ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (font-lock-mode 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 (make-local-variable 'font-lock-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (setq font-lock-keywords html-font-lock-keywords)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 ; The following line was needed in older versions of font-lock.el
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ; (font-lock-hack-keywords (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 (message "Hey boss, we been through html-fontify."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 ;;; ------------------------------ final setup -------------------------------
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (or (rassq 'html-mode auto-mode-alist) ;jwz
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (setq auto-mode-alist (cons '("\\.html\\'" . html-mode) auto-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (provide 'html-mode)