annotate lisp/modes/sgml-mode.el @ 213:78f53ef88e17 r20-4b5

Import from CVS: tag r20-4b5
author cvs
date Mon, 13 Aug 2007 10:06:47 +0200
parents 85ec50267440
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1 ;;; sgml-mode.el --- SGML- and HTML-editing modes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
2
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
4
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
5 ;; Author: James Clark <jjc@clark.com>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
6 ;; Adapted-By: ESR; Daniel.Pfeiffer@Informatik.START.dbp.de
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
7 ;; Keywords: wp, hypermedia, comm, languages
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
8
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
10
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
14 ;; any later version.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
15
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
19 ;; GNU General Public License for more details.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
20
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
25
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
26 ;;; Commentary:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
27
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
28 ;; Configurable major mode for editing document in the SGML standard general
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
29 ;; markup language. As an example contains a mode for editing the derived
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
30 ;; HTML hypertext markup language.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
31
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
32 ;;; Code:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
33
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
34 ;; As long as Emacs' syntax can't be complemented with predicates to context
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
35 ;; sensitively confirm the syntax of characters, we have to live with this
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
36 ;; kludgy kind of tradeoff.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
37 (defvar sgml-specials '(?\")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
38 "List of characters that have a special meaning for sgml-mode.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
39 This list is used when first loading the sgml-mode library.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
40 The supported characters and potential disadvantages are:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
41
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
42 ?\\\" Makes \" in text start a string.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
43 ?' Makes ' in text start a string.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
44 ?- Makes -- in text start a comment.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
45
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
46 When only one of ?\\\" or ?' are included, \"'\" or '\"' as it can be found in
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
47 DTDs, start a string. To partially avoid this problem this also makes these
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
48 self insert as named entities depending on `sgml-quick-keys'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
49
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
50 Including ?- has the problem of affecting dashes that have nothing to do
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
51 with comments, so we normally turn it off.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
52
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
53 (defvar sgml-quick-keys nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
54 "Use <, >, &, SPC and `sgml-specials' keys ``electrically'' when non-nil.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
55 This takes effect when first loading the library.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
56
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
57
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
58 (defvar sgml-mode-map
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
59 (let (;;(map (list 'keymap (make-vector 256 nil)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
60 (map (make-keymap))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
61 (menu-map (make-sparse-keymap "SGML")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
62 (define-key map "\t" 'indent-relative-maybe)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
63 (define-key map "\C-c\C-i" 'sgml-tags-invisible)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
64 (define-key map "/" 'sgml-slash)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
65 (define-key map "\C-c\C-n" 'sgml-name-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
66 (define-key map "\C-c\C-t" 'sgml-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
67 (define-key map "\C-c\C-a" 'sgml-attributes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
68 (define-key map "\C-c\C-b" 'sgml-skip-tag-backward)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
69 (define-key map [?\C-c left] 'sgml-skip-tag-backward)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
70 (define-key map "\C-c\C-f" 'sgml-skip-tag-forward)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
71 (define-key map [?\C-c right] 'sgml-skip-tag-forward)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
72 (define-key map "\C-c\C-d" 'sgml-delete-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
73 (define-key map "\C-c\^?" 'sgml-delete-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
74 (define-key map "\C-c?" 'sgml-tag-help)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
75 (define-key map "\C-c8" 'sgml-name-8bit-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
76 (define-key map "\C-c\C-v" 'sgml-validate)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
77 (if sgml-quick-keys
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
78 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
79 (define-key map "&" 'sgml-name-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
80 (define-key map "<" 'sgml-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
81 (define-key map " " 'sgml-auto-attributes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
82 (define-key map ">" 'sgml-maybe-end-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
83 (if (memq ?\" sgml-specials)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
84 (define-key map "\"" 'sgml-name-self))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
85 (if (memq ?' sgml-specials)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
86 (define-key map "'" 'sgml-name-self))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
87 (let ((c 127)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
88 ;; (map (nth 1 map))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
89 )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
90 (while (< (setq c (1+ c)) 256)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
91 ;; (aset map c 'sgml-maybe-name-self)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
92 (define-key map (int-char c) 'sgml-maybe-name-self)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
93 (define-key map [menu-bar sgml] (cons "SGML" menu-map))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
94 (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
95 (define-key menu-map [sgml-name-8bit-mode]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
96 '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
97 (define-key menu-map [sgml-tags-invisible]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
98 '("Toggle Tag Visibility" . sgml-tags-invisible))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
99 (define-key menu-map [sgml-tag-help]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
100 '("Describe Tag" . sgml-tag-help))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
101 (define-key menu-map [sgml-delete-tag]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
102 '("Delete Tag" . sgml-delete-tag))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
103 (define-key menu-map [sgml-skip-tag-forward]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
104 '("Forward Tag" . sgml-skip-tag-forward))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
105 (define-key menu-map [sgml-skip-tag-backward]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
106 '("Backward Tag" . sgml-skip-tag-backward))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
107 (define-key menu-map [sgml-attributes]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
108 '("Insert Attributes" . sgml-attributes))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
109 (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
110 map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
111 "Keymap for SGML mode. See also `sgml-specials'.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
112
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
113
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
114 (defvar sgml-mode-syntax-table
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
115 (let ((table (copy-syntax-table text-mode-syntax-table)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
116 (modify-syntax-entry ?< "(>" table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
117 (modify-syntax-entry ?> ")<" table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
118 (if (memq ?- sgml-specials)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
119 (modify-syntax-entry ?- "_ 1234" table))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
120 (if (memq ?\" sgml-specials)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
121 (modify-syntax-entry ?\" "\"\"" table))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
122 (if (memq ?' sgml-specials)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
123 (modify-syntax-entry ?\' "\"'" table))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
124 table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
125 "Syntax table used in SGML mode. See also `sgml-specials'.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
126
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
127
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
128 (defvar sgml-name-8bit-mode nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
129 "*When non-`nil' insert 8 bit characters with their names.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
130
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
131 (defvar sgml-char-names
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
132 [nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
133 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
134 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
135 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
136 "ensp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
137 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
138 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
139 nil nil "colon" "semi" "lt" "eq" "gt" "quest"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
140 "commat" nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
141 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
142 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
143 nil nil nil "lsqb" nil "rsqb" "uarr" "lowbar"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
144 "lsquo" nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
145 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
146 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
147 nil nil nil "lcub" "verbar" "rcub" "tilde" nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
148 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
149 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
150 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
151 nil nil nil nil nil nil nil nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
152 "nbsp" "iexcl" "cent" "pound" "curren" "yen" "brvbar" "sect"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
153 "uml" "copy" "ordf" "laquo" "not" "shy" "reg" "macr"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
154 "ring" "plusmn" "sup2" "sup3" "acute" "micro" "para" "middot"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
155 "cedil" "sup1" "ordm" "raquo" "frac14" "half" "frac34" "iquest"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
156 "Agrave" "Aacute" "Acirc" "Atilde" "Auml" "Aring" "AElig" "Ccedil"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
157 "Egrave" "Eacute" "Ecirc" "Euml" "Igrave" "Iacute" "Icirc" "Iuml"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
158 "ETH" "Ntilde" "Ograve" "Oacute" "Ocirc" "Otilde" "Ouml" nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
159 "Oslash" "Ugrave" "Uacute" "Ucirc" "Uuml" "Yacute" "THORN" "szlig"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
160 "agrave" "aacute" "acirc" "atilde" "auml" "aring" "aelig" "ccedil"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
161 "egrave" "eacute" "ecirc" "euml" "igrave" "iacute" "icirc" "iuml"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
162 "eth" "ntilde" "ograve" "oacute" "ocirc" "otilde" "ouml" "divide"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
163 "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
164 "Vector of symbolic character names without `&' and `;'.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
165
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
166
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
167 ;; sgmls is a free SGML parser available from
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
168 ;; ftp.uu.net:pub/text-processing/sgml
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
169 ;; Its error messages can be parsed by next-error.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
170 ;; The -s option suppresses output.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
171
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
172 (defvar sgml-validate-command "sgmls -s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
173 "*The command to validate an SGML document.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
174 The file name of current buffer file name will be appended to this,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
175 separated by a space.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
176
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
177 (defvar sgml-saved-validate-command nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
178 "The command last used to validate in this buffer.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
179
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
180
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
181 ;;; I doubt that null end tags are used much for large elements,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
182 ;;; so use a small distance here.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
183 (defconst sgml-slash-distance 1000
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
184 "*If non-nil, is the maximum distance to search for matching /.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
185
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
186 (defconst sgml-start-tag-regex
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
187 "<[A-Za-z]\\([-.A-Za-z0-9= \n\t]\\|\"[^\"]*\"\\|'[^']*'\\)*"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
188 "Regular expression that matches a non-empty start tag.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
189 Any terminating > or / is not matched.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
190
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
191
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
192 (defvar sgml-font-lock-keywords
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
193 '(("<\\([!?][a-z0-9]+\\)" 1 font-lock-keyword-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
194 ("<\\(/?[a-z0-9]+\\)" 1 font-lock-function-name-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
195 ("[&%][-.A-Za-z0-9]+;?" . font-lock-variable-name-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
196 ("<!--[^<>]*-->" . font-lock-comment-face))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
197 "*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
198
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
199 ;; internal
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
200 (defvar sgml-font-lock-keywords-1 ())
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
201
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
202 (defvar sgml-face-tag-alist ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
203 "Alist of face and tag name for facemenu.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
204
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
205 (defvar sgml-tag-face-alist ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
206 "Tag names and face or list of faces to fontify with when invisible.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
207 When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
208 When more these are fontified together with `sgml-font-lock-keywords'.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
209
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
210
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
211 (defvar sgml-display-text ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
212 "Tag names as lowercase symbols, and display string when invisible.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
213
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
214 ;; internal
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
215 (defvar sgml-tags-invisible nil)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
216
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
217
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
218 (defvar sgml-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
219 '(("![" ("ignore" t) ("include" t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
220 ("!attlist")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
221 ("!doctype")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
222 ("!element")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
223 ("!entity"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
224 "*Alist of tag names for completing read and insertion rules.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
225 This alist is made up as
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
226
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
227 ((\"tag\" . TAGRULE)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
228 ...)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
229
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
230 TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
231 newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
232 followed by an ATTRIBUTERULE (for an always present attribute) or an
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
233 attribute alist.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
234
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
235 The attribute alist is made up as
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
236
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
237 ((\"attribute\" . ATTRIBUTERULE)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
238 ...)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
239
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
240 ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
241 an optional alist of possible values.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
242
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
243 (defvar sgml-tag-help
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
244 '(("!" . "Empty declaration for comment")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
245 ("![" . "Embed declarations with parser directive")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
246 ("!attlist" . "Tag attributes declaration")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
247 ("!doctype" . "Document type (DTD) declaration")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
248 ("!element" . "Tag declaration")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
249 ("!entity" . "Entity (macro) declaration"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
250 "*Alist of tag name and short description.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
251
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
252
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
253 ;; put read-only last to enable setting this even when read-only enabled
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
254 (or (get 'sgml-tag 'invisible)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
255 (setplist 'sgml-tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
256 (append '(invisible t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
257 rear-nonsticky t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
258 point-entered sgml-point-entered
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
259 read-only t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
260 (symbol-plist 'sgml-tag))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
261
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
262
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
263
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
264 (defun sgml-mode-common (sgml-tag-face-alist sgml-display-text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
265 "Common code for setting up `sgml-mode' and derived modes.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
266 SGML-TAG-FACE-ALIST is used for calculating `sgml-font-lock-keywords-1'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
267 SGML-DISPLAY-TEXT sets up alternate text for when tags are invisible (see
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
268 varables of same name)."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
269 (kill-all-local-variables)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
270 (setq local-abbrev-table text-mode-abbrev-table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
271 (set-syntax-table sgml-mode-syntax-table)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
272 (make-local-variable 'indent-line-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
273 (make-local-variable 'paragraph-start)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
274 (make-local-variable 'paragraph-separate)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
275 (make-local-variable 'sgml-saved-validate-command)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
276 (make-local-variable 'comment-start)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
277 (make-local-variable 'comment-end)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
278 (make-local-variable 'comment-indent-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
279 (make-local-variable 'comment-start-skip)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
280 (make-local-variable 'comment-indent-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
281 (make-local-variable 'sgml-tags-invisible)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
282 (make-local-variable 'skeleton-transformation)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
283 (make-local-variable 'skeleton-further-elements)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
284 (make-local-variable 'skeleton-end-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
285 (make-local-variable 'font-lock-defaults)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
286 (make-local-variable 'sgml-font-lock-keywords-1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
287 (make-local-variable 'facemenu-add-face-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
288 (make-local-variable 'facemenu-end-add-face)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
289 ;;(make-local-variable 'facemenu-remove-face-function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
290 (and sgml-tag-face-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
291 (not (assq 1 sgml-tag-face-alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
292 (nconc sgml-tag-face-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
293 `((1 (,(concat "<\\("
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
294 (mapconcat 'car sgml-tag-face-alist "\\|")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
295 "\\)\\([ \t].+\\)?>\\(.+\\)</\\1>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
296 3 (cdr (assoc (match-string 1) ',sgml-tag-face-alist)))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
297 (setq indent-line-function 'indent-relative-maybe
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
298 ;; A start or end tag by itself on a line separates a paragraph.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
299 ;; This is desirable because SGML discards a newline that appears
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
300 ;; immediately after a start tag or immediately before an end tag.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
301 paragraph-start "^[ \t\n]\\|\
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
302 \\(</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$\\)"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
303 paragraph-separate "^[ \t\n]*$\\|\
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
304 ^</?\\([A-Za-z]\\([-.A-Za-z0-9= \t\n]\\|\"[^\"]*\"\\|'[^']*'\\)*\\)?>$"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
305 comment-start "<!-- "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
306 comment-end " -->"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
307 comment-indent-function 'sgml-comment-indent
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
308 ;; This will allow existing comments within declarations to be
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
309 ;; recognized.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
310 comment-start-skip "--[ \t]*"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
311 skeleton-transformation 'identity
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
312 skeleton-further-elements '((completion-ignore-case t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
313 skeleton-end-hook (lambda ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
314 (or (eolp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
315 (not (or (eq v2 '\n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
316 (eq (car-safe v2) '\n)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
317 (newline-and-indent)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
318 sgml-font-lock-keywords-1 (cdr (assq 1 sgml-tag-face-alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
319 font-lock-defaults '((sgml-font-lock-keywords
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
320 sgml-font-lock-keywords-1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
321 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
322 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
323 facemenu-add-face-function
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
324 (lambda (face end)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
325 (if (setq face (cdr (assq face sgml-face-tag-alist)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
326 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
327 (setq facemenu-end-add-face (concat "</" face ">"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
328 (concat "<" face ">"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
329 (error "Face not configured for %s mode." mode-name))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
330 (while sgml-display-text
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
331 (put (car (car sgml-display-text)) 'before-string
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
332 (cdr (car sgml-display-text)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
333 (setq sgml-display-text (cdr sgml-display-text)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
334 (run-hooks 'text-mode-hook 'sgml-mode-hook))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
335
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
336 ;; Conflicts with psgml, don't autoload
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
337 ;; ;;;###autoload
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
338 (defun sgml-mode (&optional function)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
339 "Major mode for editing SGML documents.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
340 Makes > match <. Makes / blink matching /.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
341 Keys <, &, SPC within <>, \" and ' can be electric depending on
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
342 `sgml-quick-keys'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
343
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
344 Do \\[describe-variable] sgml- SPC to see available variables.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
345
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
346 Use \\[sgml-validate] to validate your document with an SGML parser.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
347 \\{sgml-mode-map}"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
348 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
349 (sgml-mode-common sgml-tag-face-alist sgml-display-text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
350 (use-local-map sgml-mode-map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
351 (setq mode-name "SGML"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
352 major-mode 'sgml-mode))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
353
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
354
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
355
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
356 (defun sgml-comment-indent ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
357 (if (and (looking-at "--")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
358 (not (and (eq (preceding-char) ?!)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
359 (eq (char-after (- (point) 2)) ?<))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
360 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
361 (skip-chars-backward " \t")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
362 (max comment-column (1+ (current-column))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
363 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
364
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
365
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
366
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
367 (defun sgml-slash (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
368 "Insert / and display any previous matching /.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
369 Two /s are treated as matching if the first / ends a net-enabling
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
370 start tag, and the second / is the corresponding null end tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
371 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
372 (insert-char ?/ arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
373 (if (> arg 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
374 (let ((oldpos (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
375 (blinkpos)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
376 (level 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
377 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
378 (save-restriction
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
379 (if sgml-slash-distance
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
380 (narrow-to-region (max (point-min)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
381 (- (point) sgml-slash-distance))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
382 oldpos))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
383 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
384 (eq (match-end 0) (1- oldpos)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
385 ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
386 (goto-char (1- oldpos))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
387 (while (and (not blinkpos)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
388 (search-backward "/" (point-min) t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
389 (let ((tagend (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
390 (if (re-search-backward sgml-start-tag-regex
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
391 (point-min) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
392 (match-end 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
393 nil))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
394 (if (eq tagend (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
395 (if (eq level 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
396 (setq blinkpos (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
397 (setq level (1- level)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
398 (setq level (1+ level)))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
399 (if blinkpos
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
400 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
401 (goto-char blinkpos)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
402 (if (pos-visible-in-window-p)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
403 (sit-for 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
404 (message "Matches %s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
405 (buffer-substring (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
406 (beginning-of-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
407 (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
408 (1+ blinkpos))))))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
409
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
410
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
411 (defun sgml-name-char (&optional char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
412 "Insert a symbolic character name according to `sgml-char-names'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
413 8 bit chars may be inserted with the meta key as in M-SPC for no break space,
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
414 or M-- for a soft hyphen."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
415 (interactive "*")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
416 (insert ?&)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
417 (or char
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
418 (setq char (read-quoted-char)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
419 (delete-backward-char 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
420 (insert char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
421 (undo-boundary)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
422 (delete-backward-char 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
423 (insert ?&
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
424 (or (aref sgml-char-names char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
425 (format "#%d" char))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
426 ?\;))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
427
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
428
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
429 (defun sgml-name-self ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
430 "Insert a symbolic character name according to `sgml-char-names'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
431 (interactive "*")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
432 (sgml-name-char last-command-char))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
433
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
434
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
435 (defun sgml-maybe-name-self ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
436 "Insert a symbolic character name according to `sgml-char-names'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
437 (interactive "*")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
438 (if sgml-name-8bit-mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
439 (sgml-name-char last-command-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
440 (self-insert-command 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
441
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
442
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
443 (defun sgml-name-8bit-mode ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
444 "Toggle insertion of 8 bit characters."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
445 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
446 (setq sgml-name-8bit-mode (not sgml-name-8bit-mode)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
447
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
448
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
449
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
450 (define-skeleton sgml-tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
451 "Insert a tag you are prompted for, optionally with attributes.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
452 Completion and configuration is according to `sgml-tag-alist'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
453 If you like tags and attributes in uppercase set `skeleton-transformation'
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
454 to `upcase'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
455 (funcall skeleton-transformation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
456 (completing-read "Tag: " sgml-tag-alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
457 ?< (setq v1 (eval str)) |
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
458 (("") -1 '(undo-boundary) "&lt;") |
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
459 (("") '(setq v2 (sgml-attributes v1 t)) ?>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
460 (if (string= "![" v1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
461 (prog1 '(("") " [ " _ " ]]")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
462 (backward-char))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
463 (if (or (eq v2 t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
464 (string-match "^[/!?]" v1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
465 ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
466 (if (symbolp v2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
467 '(("") v2 _ v2 "</" v1 ?>)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
468 (if (eq (car v2) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
469 (cons '("") (cdr v2))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
470 (append '(("") (car v2))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
471 (cdr v2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
472 '(resume: (car v2) _ "</" v1 ?>))))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
473
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
474 (autoload 'skeleton-read "skeleton")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
475
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
476 (defun sgml-attributes (alist &optional quiet)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
477 "When at toplevel of a tag, interactively insert attributes."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
478 (interactive (list (save-excursion (sgml-beginning-of-tag t))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
479 (or (stringp alist) (error "Wrong context for adding attribute"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
480 (if alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
481 (let ((completion-ignore-case t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
482 car attribute i)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
483 (setq alist (cdr (assoc (downcase alist) sgml-tag-alist)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
484 (if (or (symbolp (car alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
485 (symbolp (car (car alist))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
486 (setq car (car alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
487 alist (cdr alist)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
488 (or quiet
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
489 (message "No attributes configured."))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
490 (if (stringp (car alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
491 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
492 (insert (if (eq (preceding-char) ? ) "" ? ) (car alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
493 (sgml-value alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
494 (setq i (length alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
495 (while (> i 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
496 (insert ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
497 (insert (funcall skeleton-transformation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
498 (setq attribute
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
499 (skeleton-read '(completing-read
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
500 "[Attribute]: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
501 alist)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
502 (if (string= "" attribute)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
503 (setq i 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
504 (sgml-value (assoc attribute alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
505 (setq i (1- i))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
506 (if (eq (preceding-char) ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
507 (delete-backward-char 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
508 car)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
509
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
510 (defun sgml-auto-attributes (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
511 "Self insert, except, when at top level of tag, prompt for attributes.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
512 With prefix ARG only self insert."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
513 (interactive "*P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
514 (let ((point (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
515 tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
516 (if (or arg
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
517 (not sgml-tag-alist) ; no message when nothing configured
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
518 (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
519 (eq (aref tag 0) ?/))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
520 (self-insert-command (prefix-numeric-value arg))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
521 (sgml-attributes tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
522 (setq last-command-char ? )
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
523 (or (> (point) point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
524 (self-insert-command 1)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
525
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
526
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
527 (defun sgml-tag-help (&optional tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
528 "Display description of optional TAG or tag at point."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
529 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
530 (or tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
531 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
532 (if (eq (following-char) ?<)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
533 (forward-char))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
534 (setq tag (sgml-beginning-of-tag))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
535 (or (stringp tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
536 (error "No tag selected"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
537 (setq tag (downcase tag))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
538 (message "%s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
539 (or (cdr (assoc tag sgml-tag-help))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
540 (and (eq (aref tag 0) ?/)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
541 (cdr (assoc (substring tag 1) sgml-tag-help)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
542 "No description available")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
543
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
544
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
545 (defun sgml-maybe-end-tag ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
546 "Name self unless in position to end a tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
547 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
548 (or (condition-case nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
549 (save-excursion (up-list -1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
550 (error
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
551 (sgml-name-self)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
552 t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
553 (condition-case nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
554 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
555 (save-excursion (up-list 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
556 (sgml-name-self))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
557 (error (self-insert-command 1)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
558
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
559
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
560 (defun sgml-skip-tag-backward (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
561 "Skip to beginning of tag or matching opening tag if present.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
562 With prefix ARG, repeat that many times."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
563 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
564 (while (>= arg 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
565 (search-backward "<" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
566 (if (looking-at "</\\([^ \n\t>]+\\)")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
567 ;; end tag, skip any nested pairs
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
568 (let ((case-fold-search t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
569 (re (concat "</?" (regexp-quote (match-string 1)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
570 (while (and (re-search-backward re nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
571 (eq (char-after (1+ (point))) ?/))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
572 (forward-char 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
573 (sgml-skip-tag-backward 1))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
574 (setq arg (1- arg))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
575
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
576 (defun sgml-skip-tag-forward (arg &optional return)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
577 "Skip to end of tag or matching closing tag if present.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
578 With prefix ARG, repeat that many times.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
579 Return t iff after a closing tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
580 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
581 (setq return t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
582 (while (>= arg 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
583 (skip-chars-forward "^<>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
584 (if (eq (following-char) ?>)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
585 (up-list -1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
586 (if (looking-at "<\\([^/ \n\t>]+\\)")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
587 ;; start tag, skip any nested same pairs _and_ closing tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
588 (let ((case-fold-search t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
589 (re (concat "</?" (regexp-quote (match-string 1))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
590 point close)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
591 (forward-list 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
592 (setq point (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
593 (while (and (re-search-forward re nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
594 (not (setq close
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
595 (eq (char-after (1+ (match-beginning 0))) ?/)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
596 (not (up-list -1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
597 (sgml-skip-tag-forward 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
598 (setq close nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
599 (if close
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
600 (up-list 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
601 (goto-char point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
602 (setq return)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
603 (forward-list 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
604 (setq arg (1- arg)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
605 return)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
606
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
607 (defun sgml-delete-tag (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
608 "Delete tag on or after cursor, and matching closing or opening tag.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
609 With prefix ARG, repeat that many times."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
610 (interactive "p")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
611 (while (>= arg 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
612 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
613 (let* (close open)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
614 (if (looking-at "[ \t\n]*<")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
615 ;; just before tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
616 (if (eq (char-after (match-end 0)) ?/)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
617 ;; closing tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
618 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
619 (setq close (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
620 (goto-char (match-end 0))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
621 ;; on tag?
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
622 (or (save-excursion (setq close (sgml-beginning-of-tag)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
623 close (and (stringp close)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
624 (eq (aref close 0) ?/)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
625 (point))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
626 ;; not on closing tag
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
627 (let ((point (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
628 (sgml-skip-tag-backward 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
629 (if (or (not (eq (following-char) ?<))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
630 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
631 (forward-list 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
632 (<= (point) point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
633 (error "Not on or before tag")))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
634 (if close
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
635 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
636 (sgml-skip-tag-backward 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
637 (setq open (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
638 (goto-char close)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
639 (kill-sexp 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
640 (setq open (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
641 (sgml-skip-tag-forward 1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
642 (backward-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
643 (forward-char)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
644 (if (eq (aref (sgml-beginning-of-tag) 0) ?/)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
645 (kill-sexp 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
646 (goto-char open)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
647 (kill-sexp 1)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
648 (setq arg (1- arg))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
649
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
650
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
651
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
652 (defun sgml-tags-invisible (arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
653 "Toggle visibility of existing tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
654 (interactive "P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
655 (let ((modified (buffer-modified-p))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
656 (inhibit-read-only t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
657 (point (point-min))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
658 symbol)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
659 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
660 (goto-char point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
661 (if (setq sgml-tags-invisible
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
662 (if arg
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
663 (>= (prefix-numeric-value arg) 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
664 (not sgml-tags-invisible)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
665 (while (re-search-forward "<\\([!/?A-Za-z][-A-Za-z0-9]*\\)"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
666 nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
667 (setq symbol (intern-soft (downcase (match-string 1))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
668 (goto-char (match-beginning 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
669 (and (get symbol 'before-string)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
670 (not (overlays-at (point)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
671 (overlay-put (make-overlay (point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
672 (match-beginning 1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
673 'category symbol))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
674 (put-text-property (setq point (point)) (forward-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
675 'intangible (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
676 (put-text-property point (point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
677 'category 'sgml-tag))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
678 (while (< (setq point (next-overlay-change point)) (point-max))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
679 (delete-overlay (car (overlays-at point))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
680 (remove-text-properties (point-min) (point-max)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
681 '(category sgml-tag intangible t))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
682 (set-buffer-modified-p modified)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
683 (run-hooks 'sgml-tags-invisible-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
684 (message "")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
685
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
686 (defun sgml-point-entered (x y)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
687 ;; Show preceding or following hidden tag, depending of cursor direction.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
688 (let ((inhibit-point-motion-hooks t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
689 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
690 (message "Invisible tag: %s"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
691 (buffer-substring
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
692 (point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
693 (if (or (and (> x y)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
694 (not (eq (following-char) ?<)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
695 (and (< x y)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
696 (eq (preceding-char) ?>)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
697 (backward-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
698 (forward-list)))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
699
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
700
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
701 (autoload 'compile-internal "compile")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
702
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
703 (defun sgml-validate (command)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
704 "Validate an SGML document.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
705 Runs COMMAND, a shell command, in a separate process asynchronously
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
706 with output going to the buffer *compilation*.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
707 You can then use the command \\[next-error] to find the next error message
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
708 and move to the line in the SGML document that caused it."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
709 (interactive
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
710 (list (read-string "Validate command: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
711 (or sgml-saved-validate-command
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
712 (concat sgml-validate-command
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
713 " "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
714 (let ((name (buffer-file-name)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
715 (and name
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
716 (file-name-nondirectory name))))))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
717 (setq sgml-saved-validate-command command)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
718 (if (or (not compilation-ask-about-save)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
719 (y-or-n-p (message "Save buffer %s? " (buffer-name))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
720 (save-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
721 (compile-internal command "No more errors"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
722
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
723
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
724 (defun sgml-beginning-of-tag (&optional top-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
725 "Skip to beginning of tag and return its name.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
726 Else `t'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
727 (or (if top-level
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
728 (condition-case nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
729 (up-list -1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
730 (error t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
731 (>= (point)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
732 (if (search-backward "<" nil t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
733 (save-excursion
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
734 (forward-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
735 (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
736 0)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
737 (if (looking-at "<[!?/]?[[A-Za-z][A-Za-z0-9]*")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
738 (buffer-substring-no-properties
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
739 (1+ (point))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
740 (match-end 0))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
741 t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
742
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
743 (defun sgml-value (alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
744 (setq alist (cdr alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
745 (if (stringp (car alist))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
746 (insert "=\"" (car alist) ?\")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
747 (if (eq (car alist) t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
748 (if (cdr alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
749 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
750 (insert "=\"")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
751 (setq alist (skeleton-read '(completing-read
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
752 "[Value]: " (cdr alist))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
753 (if (string< "" alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
754 (insert (funcall skeleton-transformation alist) ?\")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
755 (delete-backward-char 2))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
756 (insert "=\"")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
757 (if alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
758 (insert (funcall skeleton-transformation
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
759 (skeleton-read '(completing-read "Value: " alist)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
760 (insert ?\"))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
761
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
762 (provide 'sgml-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
763
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
764 (defvar html-quick-keys sgml-quick-keys
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
765 "Use C-c X combinations for quick insertion of frequent tags when non-nil.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
766 This defaults to `sgml-quick-keys'.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
767 This takes effect when first loading the library.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
768
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
769 (defvar html-mode-map
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
770 (let (; (map (nconc (make-sparse-keymap) sgml-mode-map))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
771 (map (copy-keymap sgml-mode-map))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
772 (menu-map (make-sparse-keymap "HTML")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
773 (define-key map "\C-c6" 'html-headline-6)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
774 (define-key map "\C-c5" 'html-headline-5)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
775 (define-key map "\C-c4" 'html-headline-4)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
776 (define-key map "\C-c3" 'html-headline-3)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
777 (define-key map "\C-c2" 'html-headline-2)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
778 (define-key map "\C-c1" 'html-headline-1)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
779 (define-key map "\C-c\r" 'html-paragraph)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
780 (define-key map "\C-c\n" 'html-line)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
781 (define-key map "\C-c\C-c-" 'html-horizontal-rule)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
782 (define-key map "\C-c\C-co" 'html-ordered-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
783 (define-key map "\C-c\C-cu" 'html-unordered-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
784 (define-key map "\C-c\C-cr" 'html-radio-buttons)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
785 (define-key map "\C-c\C-cc" 'html-checkboxes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
786 (define-key map "\C-c\C-cl" 'html-list-item)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
787 (define-key map "\C-c\C-ch" 'html-href-anchor)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
788 (define-key map "\C-c\C-cn" 'html-name-anchor)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
789 (define-key map "\C-c\C-ci" 'html-image)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
790 (if html-quick-keys
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
791 (progn
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
792 (define-key map "\C-c-" 'html-horizontal-rule)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
793 (define-key map "\C-co" 'html-ordered-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
794 (define-key map "\C-cu" 'html-unordered-list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
795 (define-key map "\C-cr" 'html-radio-buttons)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
796 (define-key map "\C-cc" 'html-checkboxes)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
797 (define-key map "\C-cl" 'html-list-item)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
798 (define-key map "\C-ch" 'html-href-anchor)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
799 (define-key map "\C-cn" 'html-name-anchor)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
800 (define-key map "\C-ci" 'html-image)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
801 (define-key map "\C-c\C-s" 'html-autoview-mode)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
802 (define-key map "\C-c\C-v" 'browse-url-of-buffer)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
803 (define-key map [menu-bar html] (cons "HTML" menu-map))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
804 (define-key menu-map [html-autoview-mode]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
805 '("Toggle Autoviewing" . html-autoview-mode))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
806 (define-key menu-map [browse-url-of-buffer]
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
807 '("View Buffer Contents" . browse-url-of-buffer))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
808 (define-key menu-map [nil] '("--"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
809 ;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
810 ;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
811 ;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
812 (define-key menu-map "3" '("Heading 3" . html-headline-3))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
813 (define-key menu-map "2" '("Heading 2" . html-headline-2))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
814 (define-key menu-map "1" '("Heading 1" . html-headline-1))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
815 (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
816 (define-key menu-map "c" '("Checkboxes" . html-checkboxes))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
817 (define-key menu-map "l" '("List Item" . html-list-item))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
818 (define-key menu-map "u" '("Unordered List" . html-unordered-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
819 (define-key menu-map "o" '("Ordered List" . html-ordered-list))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
820 (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
821 (define-key menu-map "\n" '("Line Break" . html-line))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
822 (define-key menu-map "\r" '("Paragraph" . html-paragraph))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
823 (define-key menu-map "i" '("Image" . html-image))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
824 (define-key menu-map "h" '("Href Anchor" . html-href-anchor))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
825 (define-key menu-map "n" '("Name Anchor" . html-name-anchor))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
826 map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
827 "Keymap for commands for use in HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
828
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
829
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
830 (defvar html-face-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
831 '((bold . "b")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
832 (italic . "i")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
833 (underline . "u")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
834 (modeline . "rev"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
835 "Value of `sgml-face-tag-alist' for HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
836
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
837 (defvar html-tag-face-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
838 '(("b" . bold)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
839 ("big" . bold)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
840 ("blink" . highlight)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
841 ("cite" . italic)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
842 ("em" . italic)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
843 ("h1" bold underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
844 ("h2" bold-italic underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
845 ("h3" italic underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
846 ("h4" . underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
847 ("h5" . underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
848 ("h6" . underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
849 ("i" . italic)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
850 ("rev" . modeline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
851 ("s" . underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
852 ("small" . default)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
853 ("strong" . bold)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
854 ("title" bold underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
855 ("tt" . default)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
856 ("u" . underline)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
857 ("var" . italic))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
858 "Value of `sgml-tag-face-alist' for HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
859
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
860
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
861 (defvar html-display-text
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
862 '((img . "[/]")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
863 (hr . "----------")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
864 (li . "o "))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
865 "Value of `sgml-display-text' for HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
866
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
867
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
868 ; should code exactly HTML 3 here when that is finished
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
869 (defvar html-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
870 (let* ((1-9 '(("8") ("9")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
871 ("1") ("2") ("3") ("4") ("5") ("6") ("7")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
872 (align '(("align" ("left") ("center") ("right"))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
873 (valign '(("top") ("middle") ("bottom") ("baseline")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
874 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
875 (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
876 ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
877 ("wais:") ("/cgi-bin/")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
878 (name '("name"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
879 (link `(,href
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
880 ("rel" ,@rel)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
881 ("rev" ,@rel)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
882 ("title")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
883 (list '((nil \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
884 ( "List item: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
885 "<li>" str \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
886 ("type" ("A") ("a") ("I") ("i") ("1"))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
887 (cell `(t
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
888 ,align
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
889 ("valign" ,@valign)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
890 ("colspan" ,@1-9)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
891 ("rowspan" ,@1-9)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
892 ("nowrap" t))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
893 ;; put ,-expressions first, else byte-compile chokes (as of V19.29)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
894 ;; and like this it's more efficient anyway
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
895 `(("a" ,name ,@link)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
896 ("base" t ,@href)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
897 ("dir" ,@list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
898 ("font" ("size" ("-1") ("+1") ("-2") ("+2") ,@(cdr (cdr 1-9))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
899 ("form" (\n _ \n "<input type=\"submit\" value=\"\">")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
900 ("action" ,@(cdr href)) ("method" ("get") ("post")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
901 ("h1" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
902 ("h2" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
903 ("h3" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
904 ("h4" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
905 ("h5" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
906 ("h6" ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
907 ("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
908 ("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
909 ("src") ("alt") ("width" "1") ("height" "1")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
910 ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
911 ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
912 ("type" ("text") ("password") ("checkbox") ("radio")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
913 ("submit") ("reset"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
914 ("value"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
915 ("link" t ,@link)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
916 ("menu" ,@list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
917 ("ol" ,@list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
918 ("p" t ,@align)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
919 ("select" (nil \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
920 ("Text: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
921 "<option>" str \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
922 ,name ("size" ,@1-9) ("multiple" t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
923 ("table" (nil \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
924 ((completing-read "Cell kind: " '(("td") ("th"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
925 nil t "t")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
926 "<tr><" str ?> _ \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
927 ("border" t ,@1-9) ("width" "10") ("cellpadding"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
928 ("td" ,@cell)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
929 ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
930 ("th" ,@cell)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
931 ("ul" ,@list)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
932
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
933 ,@sgml-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
934
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
935 ("abbrev")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
936 ("acronym")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
937 ("address")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
938 ("array" (nil \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
939 ("Item: " "<item>" str \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
940 "align")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
941 ("au")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
942 ("b")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
943 ("big")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
944 ("blink")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
945 ("blockquote" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
946 ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
947 ("link" "#") ("alink" "#") ("vlink" "#"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
948 ("box" (nil _ "<over>" _))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
949 ("br" t ("clear" ("left") ("right")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
950 ("caption" ("valign" ("top") ("bottom")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
951 ("center" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
952 ("cite")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
953 ("code" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
954 ("dd" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
955 ("del")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
956 ("dfn")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
957 ("dl" (nil \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
958 ( "Term: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
959 "<dt>" str "<dd>" _ \n)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
960 ("dt" (t _ "<dd>"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
961 ("em")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
962 ("fn" "id" "fn")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
963 ("head" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
964 ("html" (\n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
965 "<head>\n"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
966 "<title>" (setq str (read-input "Title: ")) "</title>\n"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
967 "<body>\n<h1>" str "</h1>\n" _
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
968 "\n<address>\n<a href=\"mailto:"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
969 user-mail-address
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
970 "\">" (user-full-name) "</a>\n</address>"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
971 ("i")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
972 ("ins")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
973 ("isindex" t ("action") ("prompt"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
974 ("kbd")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
975 ("lang")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
976 ("li" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
977 ("math" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
978 ("nobr")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
979 ("option" t ("value") ("label") ("selected" t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
980 ("over" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
981 ("person")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
982 ("pre" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
983 ("q")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
984 ("rev")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
985 ("s")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
986 ("samp")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
987 ("small")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
988 ("strong")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
989 ("sub")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
990 ("sup")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
991 ("title")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
992 ("tr" t)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
993 ("tt")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
994 ("u")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
995 ("var")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
996 ("wbr" t)))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
997 "*Value of `sgml-tag-alist' for HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
998
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
999 (defvar html-tag-help
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1000 `(,@sgml-tag-help
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1001 ("a" . "Anchor of point or link elsewhere")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1002 ("abbrev" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1003 ("acronym" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1004 ("address" . "Formatted mail address")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1005 ("array" . "Math array")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1006 ("au" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1007 ("b" . "Bold face")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1008 ("base" . "Base address for URLs")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1009 ("big" . "Font size")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1010 ("blink" . "Blinking text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1011 ("blockquote" . "Indented quotation")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1012 ("body" . "Document body")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1013 ("box" . "Math fraction")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1014 ("br" . "Line break")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1015 ("caption" . "Table caption")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1016 ("center" . "Centered text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1017 ("changed" . "Change bars")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1018 ("cite" . "Citation of a document")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1019 ("code" . "Formatted source code")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1020 ("dd" . "Definition of term")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1021 ("del" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1022 ("dfn" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1023 ("dir" . "Directory list (obsolete)")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1024 ("dl" . "Definition list")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1025 ("dt" . "Term to be definined")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1026 ("em" . "Emphasised")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1027 ("embed" . "Embedded data in foreign format")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1028 ("fig" . "Figure")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1029 ("figa" . "Figure anchor")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1030 ("figd" . "Figure description")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1031 ("figt" . "Figure text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1032 ("fn" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1033 ("font" . "Font size")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1034 ("form" . "Form with input fields")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1035 ("group" . "Document grouping")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1036 ("h1" . "Most important section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1037 ("h2" . "Important section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1038 ("h3" . "Section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1039 ("h4" . "Minor section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1040 ("h5" . "Unimportant section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1041 ("h6" . "Least important section headline")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1042 ("head" . "Document header")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1043 ("hr" . "Horizontal rule")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1044 ("html" . "HTML Document")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1045 ("i" . "Italic face")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1046 ("img" . "Graphic image")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1047 ("input" . "Form input field")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1048 ("ins" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1049 ("isindex" . "Input field for index search")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1050 ("kbd" . "Keybard example face")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1051 ("lang" . "Natural language")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1052 ("li" . "List item")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1053 ("link" . "Link relationship")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1054 ("math" . "Math formula")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1055 ("menu" . "Menu list (obsolete)")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1056 ("mh" . "Form mail header")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1057 ("nextid" . "Allocate new id")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1058 ("nobr" . "Text without line break")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1059 ("ol" . "Ordered list")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1060 ("option" . "Selection list item")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1061 ("over" . "Math fraction rule")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1062 ("p" . "Paragraph start")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1063 ("panel" . "Floating panel")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1064 ("person" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1065 ("pre" . "Preformatted fixed width text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1066 ("q" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1067 ("rev" . "Reverse video")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1068 ("s" . "?")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1069 ("samp" . "Sample text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1070 ("select" . "Selection list")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1071 ("small" . "Font size")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1072 ("sp" . "Nobreak space")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1073 ("strong" . "Standout text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1074 ("sub" . "Subscript")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1075 ("sup" . "Superscript")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1076 ("table" . "Table with rows and columns")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1077 ("tb" . "Table vertical break")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1078 ("td" . "Table data cell")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1079 ("textarea" . "Form multiline edit area")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1080 ("th" . "Table header cell")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1081 ("title" . "Document title")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1082 ("tr" . "Table row separator")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1083 ("tt" . "Typewriter face")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1084 ("u" . "Underlined text")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1085 ("ul" . "Unordered list")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1086 ("var" . "Math variable face")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1087 ("wbr" . "Enable <br> within <nobr>"))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1088 "*Value of `sgml-tag-help' for HTML mode.")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1089
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1090
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1091 ;; Conflicts with psgml, don't autoload
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1092 ;; ;;;###autoload
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1093 (defun html-mode ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1094 "Major mode based on SGML mode for editing HTML documents.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1095 This allows inserting skeleton costructs used in hypertext documents with
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1096 completion. See below for an introduction to HTML. Use
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1097 \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1098 which this is based.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1099
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1100 Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1101
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1102 To write fairly well formatted pages you only need to know few things. Most
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1103 browsers have a function to read the source code of the page being seen, so
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1104 you can imitate various tricks. Here's a very short HTML primer which you
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1105 can also view with a browser to see what happens:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1106
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1107 <title>A Title Describing Contents</title> should be on every page. Pages can
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1108 have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6>
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1109 <hr> Parts can be separated with horizontal rules.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1110
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1111 <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1112 ignored unless the text is <pre>preformatted.</pre> Text can be marked as
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1113 <b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-g or
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1114 Edit/Text Properties/Face commands.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1115
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1116 Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1117 to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1118 href=\"URL\">see also URL</a> where URL is a filename relative to current
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1119 directory or something like http://www.cs.indiana.edu/elisp/w3/docs.html.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1120
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1121 Images in many formats can be inlined with <img src=\"URL\">.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1122
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1123 If you mainly create your own documents, `sgml-specials' might be interesting.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1124 But note that some HTML 2 browsers can't handle &apos;. To work around that
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1125 do:
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1126
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1127 \(eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1128 \\{html-mode-map}"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1129 (interactive)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1130 (sgml-mode-common html-tag-face-alist html-display-text)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1131 (use-local-map html-mode-map)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1132 (make-local-variable 'sgml-tag-alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1133 (make-local-variable 'sgml-face-tag-alist)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1134 (make-local-variable 'sgml-tag-help)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1135 (make-local-variable 'outline-regexp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1136 (make-local-variable 'outline-heading-end-regexp)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1137 (make-local-variable 'outline-level)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1138 (make-local-variable 'sentence-end)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1139 (setq sentence-end
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1140 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\| \\)[ \t\n]*")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1141 (setq mode-name "HTML"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1142 major-mode 'html-mode
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1143 sgml-tag-alist html-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1144 sgml-face-tag-alist html-face-tag-alist
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1145 sgml-tag-help html-tag-help
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1146 outline-regexp "^.*<[Hh][1-6]\\>"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1147 outline-heading-end-regexp "</[Hh][1-6]>"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1148 outline-level (lambda ()
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1149 (char-after (1- (match-end 0)))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1150 (run-hooks 'html-mode-hook))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1151
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1152
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1153 (define-skeleton html-href-anchor
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1154 "HTML anchor tag with href attribute."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1155 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1156 "<a href=\"http:" _ "\"></a>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1157
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1158 (define-skeleton html-name-anchor
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1159 "HTML anchor tag with name attribute."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1160 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1161 "<a name=\"" _ "\"></a>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1162
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1163 (define-skeleton html-headline-1
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1164 "HTML level 1 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1165 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1166 "<h1>" _ "</h1>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1167
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1168 (define-skeleton html-headline-2
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1169 "HTML level 2 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1170 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1171 "<h2>" _ "</h2>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1172
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1173 (define-skeleton html-headline-3
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1174 "HTML level 3 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1175 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1176 "<h3>" _ "</h3>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1177
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1178 (define-skeleton html-headline-4
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1179 "HTML level 4 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1180 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1181 "<h4>" _ "</h4>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1182
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1183 (define-skeleton html-headline-5
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1184 "HTML level 5 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1185 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1186 "<h5>" _ "</h5>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1187
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1188 (define-skeleton html-headline-6
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1189 "HTML level 6 headline tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1190 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1191 "<h6>" _ "</h6>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1192
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1193 (define-skeleton html-horizontal-rule
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1194 "HTML horizontal rule tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1195 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1196 "<hr>" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1197
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1198 (define-skeleton html-image
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1199 "HTML image tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1200 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1201 "<img src=\"http:" _ "\">")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1202
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1203 (define-skeleton html-line
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1204 "HTML line break tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1205 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1206 "<br>" \n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1207
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1208 (define-skeleton html-ordered-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1209 "HTML ordered list tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1210 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1211 ?< "ol>" \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1212 "<li>" _ \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1213 "</ol>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1214
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1215 (define-skeleton html-unordered-list
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1216 "HTML unordered list tags."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1217 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1218 ?< "ul>" \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1219 "<li>" _ \n
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1220 "</ul>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1221
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1222 (define-skeleton html-list-item
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1223 "HTML list item tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1224 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1225 (if (bolp) nil '\n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1226 "<li>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1227
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1228 (define-skeleton html-paragraph
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1229 "HTML paragraph tag."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1230 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1231 (if (bolp) nil ?\n)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1232 \n "<p>")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1233
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1234 (define-skeleton html-checkboxes
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1235 "Group of connected checkbox inputs."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1236 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1237 '(setq v1 (eval str)) ; allow passing name as argument
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1238 ("Value & Text: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1239 "<input type=\"checkbox\" name=\""
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1240 (or v1 (setq v1 (skeleton-read "Name: ")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1241 "\" value=\"" str ?\"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1242 (if v2 "" " checked") ?> str
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1243 (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1244
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1245 (define-skeleton html-radio-buttons
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1246 "Group of connected radio button inputs."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1247 nil
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1248 '(setq v1 (eval str)) ; allow passing name as argument
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1249 ("Value & Text: "
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1250 "<input type=\"radio\" name=\""
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1251 (or v1 (setq v1 (skeleton-read "Name: ")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1252 "\" value=\"" str ?\"
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1253 (if v2 "" " checked") ?> str
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1254 (or v2 (setq v2 (if (y-or-n-p "Newline? ") "<br>" ""))) \n))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1255
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1256
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1257 (defun html-autoview-mode (&optional arg)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1258 "Toggle automatic viewing via `html-viewer' upon saving buffer.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1259 With positive prefix ARG always turns viewing on, with negative ARG always off.
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1260 Can be used as a value for `html-mode-hook'."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1261 (interactive "P")
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1262 (if (setq arg (if arg
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1263 (< (prefix-numeric-value arg) 0)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1264 (and (boundp 'after-save-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1265 (memq 'browse-url-of-buffer after-save-hook))))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1266 (setq after-save-hook (delq 'browse-url-of-buffer after-save-hook))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1267 (make-local-hook 'after-save-hook)
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1268 (add-hook 'after-save-hook 'browse-url-of-buffer nil t))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1269 (message "Autoviewing turned %s."
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1270 (if arg "off" "on")))
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1271
85ec50267440 Import from CVS: tag r20-3b10
cvs
parents:
diff changeset
1272 ;;; sgml-mode.el ends here