annotate lisp/textmodes/sgml-mode.el @ 44244:31f1fc31fd45

(sgml-lexical-context): Return (text . START) instead of nil when point is outside of any tag. (sgml-beginning-of-tag): Adjust to the change. (sgml-calculate-indent): Use the new info returned by sgml-lexical-context. Try to handle unclosed tags.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 29 Mar 2002 22:20:15 +0000
parents 600b7e53cf18
children 1d7ee8515c45
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1 ;;; sgml-mode.el --- SGML- and HTML-editing modes
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
2
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
3 ;; Copyright (C) 1992,95,96,98,2001,2002 Free Software Foundation, Inc.
844
bf829a2d63b4 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 828
diff changeset
4
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
5 ;; Author: James Clark <jjc@jclark.com>
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
6 ;; Maintainer: FSF
23869
8d2bb5d1416a Update comment.
Karl Heuer <kwzh@gnu.org>
parents: 23726
diff changeset
7 ;; Adapted-By: ESR, Daniel Pfeiffer <occitan@esperanto.org>,
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
8 ;; F.Potorti@cnuce.cnr.it
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
9 ;; Keywords: wp, hypermedia, comm, languages
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
10
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
11 ;; This file is part of GNU Emacs.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
12
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
12244
ac7375e60931 Update GPL to version 2.
Karl Heuer <kwzh@gnu.org>
parents: 3366
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
16 ;; any later version.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
17
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
21 ;; GNU General Public License for more details.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
22
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14168
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14168
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 14168
diff changeset
26 ;; Boston, MA 02111-1307, USA.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
27
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
28 ;;; Commentary:
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
29
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
30 ;; Configurable major mode for editing document in the SGML standard general
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
31 ;; markup language. As an example contains a mode for editing the derived
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
32 ;; HTML hypertext markup language.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
33
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
34 ;;; Code:
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
35
25175
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
36 (eval-when-compile
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
37 (require 'skeleton)
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
38 (require 'outline))
23726
ca83df619ee6 Require skeleton when compiling.
Dave Love <fx@gnu.org>
parents: 23652
diff changeset
39
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
40 (defgroup sgml nil
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
41 "SGML editing mode"
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
42 :group 'languages)
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
43
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
44 (defcustom sgml-basic-offset 2
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
45 "*Specifies the basic indentation level for `sgml-indent-line'."
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
46 :type 'integer
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
47 :group 'sgml)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
48
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
49 (defcustom sgml-transformation 'identity
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
50 "*Default value for `skeleton-transformation' (which see) in SGML mode."
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
51 :type 'function
17530
9fb83ef40566 (sgml-transformation): Fix previous change.
Richard M. Stallman <rms@gnu.org>
parents: 17500
diff changeset
52 :group 'sgml)
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
53
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
54 (put 'sgml-transformation 'variable-interactive
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
55 "aTransformation function: ")
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
56
25175
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
57 (defcustom sgml-mode-hook nil
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
58 "Hook run by command `sgml-mode'.
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
59 `text-mode-hook' is run first."
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
60 :group 'sgml
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
61 :type 'hook)
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
62
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
63 ;; As long as Emacs' syntax can't be complemented with predicates to context
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
64 ;; sensitively confirm the syntax of characters, we have to live with this
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
65 ;; kludgy kind of tradeoff.
16404
0cdf66e69ad8 (sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents: 15867
diff changeset
66 (defvar sgml-specials '(?\")
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
67 "List of characters that have a special meaning for SGML mode.
43589
57e4f81f3346 (sgml-specials, sgml-quick-keys): Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 40624
diff changeset
68 This list is used when first loading the `sgml-mode' library.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
69 The supported characters and potential disadvantages are:
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
70
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
71 ?\\\" Makes \" in text start a string.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
72 ?' Makes ' in text start a string.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
73 ?- Makes -- in text start a comment.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
74
22319
18b5b2445726 (sgml-font-lock-keywords-1): Add -. as
Dave Love <fx@gnu.org>
parents: 22222
diff changeset
75 When only one of ?\\\" or ?' are included, \"'\" or '\"', as can be found in
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
76 DTDs, start a string. To partially avoid this problem this also makes these
16404
0cdf66e69ad8 (sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents: 15867
diff changeset
77 self insert as named entities depending on `sgml-quick-keys'.
0cdf66e69ad8 (sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents: 15867
diff changeset
78
0cdf66e69ad8 (sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents: 15867
diff changeset
79 Including ?- has the problem of affecting dashes that have nothing to do
0cdf66e69ad8 (sgml-specials): Delete `-' from the list.
Richard M. Stallman <rms@gnu.org>
parents: 15867
diff changeset
80 with comments, so we normally turn it off.")
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
81
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
82 (defvar sgml-quick-keys nil
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
83 "Use <, >, &, SPC and `sgml-specials' keys \"electrically\" when non-nil.
43589
57e4f81f3346 (sgml-specials, sgml-quick-keys): Doc fixes.
Pavel Janík <Pavel@Janik.cz>
parents: 40624
diff changeset
84 This takes effect when first loading the `sgml-mode' library.")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
85
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
86
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
87 (defvar sgml-mode-map
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
88 (let ((map (make-keymap)) ;`sparse' doesn't allow binding to charsets.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
89 (menu-map (make-sparse-keymap "SGML")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
90 (define-key map "\C-c\C-i" 'sgml-tags-invisible)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
91 (define-key map "/" 'sgml-slash)
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
92 (define-key map "\C-c\C-n" 'sgml-name-char)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
93 (define-key map "\C-c\C-t" 'sgml-tag)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
94 (define-key map "\C-c\C-a" 'sgml-attributes)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
95 (define-key map "\C-c\C-b" 'sgml-skip-tag-backward)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
96 (define-key map [?\C-c left] 'sgml-skip-tag-backward)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
97 (define-key map "\C-c\C-f" 'sgml-skip-tag-forward)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
98 (define-key map [?\C-c right] 'sgml-skip-tag-forward)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
99 (define-key map "\C-c\C-d" 'sgml-delete-tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
100 (define-key map "\C-c\^?" 'sgml-delete-tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
101 (define-key map "\C-c?" 'sgml-tag-help)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
102 (define-key map "\C-c8" 'sgml-name-8bit-mode)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
103 (define-key map "\C-c\C-v" 'sgml-validate)
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
104 (when sgml-quick-keys
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
105 (define-key map "&" 'sgml-name-char)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
106 (define-key map "<" 'sgml-tag)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
107 (define-key map " " 'sgml-auto-attributes)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
108 (define-key map ">" 'sgml-maybe-end-tag)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
109 (when (memq ?\" sgml-specials)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
110 (define-key map "\"" 'sgml-name-self))
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
111 (when (memq ?' sgml-specials)
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
112 (define-key map "'" 'sgml-name-self)))
38108
f535923264bd (sgml-mode-map): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38068
diff changeset
113 (define-key map (vector (make-char 'latin-iso8859-1))
f535923264bd (sgml-mode-map): Fix thinko.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 38068
diff changeset
114 'sgml-maybe-name-self)
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
115 (let ((c 127)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
116 (map (nth 1 map)))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
117 (while (< (setq c (1+ c)) 256)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
118 (aset map c 'sgml-maybe-name-self)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
119 (define-key map [menu-bar sgml] (cons "SGML" menu-map))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
120 (define-key menu-map [sgml-validate] '("Validate" . sgml-validate))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
121 (define-key menu-map [sgml-name-8bit-mode]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
122 '("Toggle 8 Bit Insertion" . sgml-name-8bit-mode))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
123 (define-key menu-map [sgml-tags-invisible]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
124 '("Toggle Tag Visibility" . sgml-tags-invisible))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
125 (define-key menu-map [sgml-tag-help]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
126 '("Describe Tag" . sgml-tag-help))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
127 (define-key menu-map [sgml-delete-tag]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
128 '("Delete Tag" . sgml-delete-tag))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
129 (define-key menu-map [sgml-skip-tag-forward]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
130 '("Forward Tag" . sgml-skip-tag-forward))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
131 (define-key menu-map [sgml-skip-tag-backward]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
132 '("Backward Tag" . sgml-skip-tag-backward))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
133 (define-key menu-map [sgml-attributes]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
134 '("Insert Attributes" . sgml-attributes))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
135 (define-key menu-map [sgml-tag] '("Insert Tag" . sgml-tag))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
136 map)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
137 "Keymap for SGML mode. See also `sgml-specials'.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
138
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
139
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
140 (defun sgml-make-syntax-table (specials)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
141 (let ((table (make-syntax-table text-mode-syntax-table)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
142 (modify-syntax-entry ?< "(>" table)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
143 (modify-syntax-entry ?> ")<" table)
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
144 (modify-syntax-entry ?: "_" table)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
145 (modify-syntax-entry ?_ "_" table)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
146 (modify-syntax-entry ?. "_" table)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
147 (if (memq ?- specials)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
148 (modify-syntax-entry ?- "_ 1234" table))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
149 (if (memq ?\" specials)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
150 (modify-syntax-entry ?\" "\"\"" table))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
151 (if (memq ?' specials)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
152 (modify-syntax-entry ?\' "\"'" table))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
153 table))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
154
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
155 (defvar sgml-mode-syntax-table (sgml-make-syntax-table sgml-specials)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
156 "Syntax table used in SGML mode. See also `sgml-specials'.")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
157
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
158 (defconst sgml-tag-syntax-table
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
159 (let ((table (sgml-make-syntax-table '(?- ?\" ?\'))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
160 (dolist (char '(?\( ?\) ?\{ ?\} ?\[ ?\] ?$ ?% ?& ?* ?+ ?/))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
161 (modify-syntax-entry char "." table))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
162 table)
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
163 "Syntax table used to parse SGML tags.")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
164
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
165
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
166 (defcustom sgml-name-8bit-mode nil
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
167 "*When non-nil, insert non-ASCII characters as named entities."
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
168 :type 'boolean
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
169 :group 'sgml)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
170
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
171 (defvar sgml-char-names
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
172 [nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
173 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
174 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
175 nil nil nil nil nil nil nil nil
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
176 "nbsp" "excl" "quot" "num" "dollar" "percnt" "amp" "apos"
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
177 "lpar" "rpar" "ast" "plus" "comma" "hyphen" "period" "sol"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
178 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
179 nil nil "colon" "semi" "lt" "eq" "gt" "quest"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
180 "commat" nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
181 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
182 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
183 nil nil nil "lsqb" nil "rsqb" "uarr" "lowbar"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
184 "lsquo" nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
185 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
186 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
187 nil nil nil "lcub" "verbar" "rcub" "tilde" nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
188 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
189 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
190 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
191 nil nil nil nil nil nil nil nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
192 "nbsp" "iexcl" "cent" "pound" "curren" "yen" "brvbar" "sect"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
193 "uml" "copy" "ordf" "laquo" "not" "shy" "reg" "macr"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
194 "ring" "plusmn" "sup2" "sup3" "acute" "micro" "para" "middot"
26250
194bcc8d17db * textmodes/sgml-mode.el (sgml-char-names): Change "half" to
Gerd Moellmann <gerd@gnu.org>
parents: 25175
diff changeset
195 "cedil" "sup1" "ordm" "raquo" "frac14" "frac12" "frac34" "iquest"
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
196 "Agrave" "Aacute" "Acirc" "Atilde" "Auml" "Aring" "AElig" "Ccedil"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
197 "Egrave" "Eacute" "Ecirc" "Euml" "Igrave" "Iacute" "Icirc" "Iuml"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
198 "ETH" "Ntilde" "Ograve" "Oacute" "Ocirc" "Otilde" "Ouml" nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
199 "Oslash" "Ugrave" "Uacute" "Ucirc" "Uuml" "Yacute" "THORN" "szlig"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
200 "agrave" "aacute" "acirc" "atilde" "auml" "aring" "aelig" "ccedil"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
201 "egrave" "eacute" "ecirc" "euml" "igrave" "iacute" "icirc" "iuml"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
202 "eth" "ntilde" "ograve" "oacute" "ocirc" "otilde" "ouml" "divide"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
203 "oslash" "ugrave" "uacute" "ucirc" "uuml" "yacute" "thorn" "yuml"]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
204 "Vector of symbolic character names without `&' and `;'.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
205
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
206 (put 'sgml-table 'char-table-extra-slots 0)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
207
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
208 (defvar sgml-char-names-table
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
209 (let ((table (make-char-table 'sgml-table))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
210 (i 32)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
211 elt)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
212 (while (< i 256)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
213 (setq elt (aref sgml-char-names i))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
214 (if elt (aset table (make-char 'latin-iso8859-1 i) elt))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
215 (setq i (1+ i)))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
216 table)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
217 "A table for mapping non-ASCII characters into SGML entity names.
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
218 Currently, only Latin-1 characters are supported.")
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
219
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
220
25052
d2a4359531e0 (sgml-validate-command): Use nsgmls.
Dave Love <fx@gnu.org>
parents: 24463
diff changeset
221 ;; nsgmls is a free SGML parser in the SP suite available from
d2a4359531e0 (sgml-validate-command): Use nsgmls.
Dave Love <fx@gnu.org>
parents: 24463
diff changeset
222 ;; ftp.jclark.com and otherwise packaged for GNU systems.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
223 ;; Its error messages can be parsed by next-error.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
224 ;; The -s option suppresses output.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
225
25052
d2a4359531e0 (sgml-validate-command): Use nsgmls.
Dave Love <fx@gnu.org>
parents: 24463
diff changeset
226 (defcustom sgml-validate-command "nsgmls -s" ; replaced old `sgmls'
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
227 "*The command to validate an SGML document.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
228 The file name of current buffer file name will be appended to this,
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
229 separated by a space."
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
230 :type 'string
25175
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
231 :version "21.1"
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
232 :group 'sgml)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
233
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
234 (defvar sgml-saved-validate-command nil
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
235 "The command last used to validate in this buffer.")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
236
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
237
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
238 ;; I doubt that null end tags are used much for large elements,
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
239 ;; so use a small distance here.
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
240 (defcustom sgml-slash-distance 1000
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
241 "*If non-nil, is the maximum distance to search for matching `/'."
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
242 :type '(choice (const nil) integer)
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
243 :group 'sgml)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
244
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
245 (defconst sgml-name-re "[_:[:alpha:]][-_.:[:alnum:]]*")
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
246 (defconst sgml-tag-name-re (concat "<\\([!/?]?" sgml-name-re "\\)"))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
247 (defconst sgml-attrs-re "\\(?:[^\"'/><]\\|\"[^\"]*\"\\|'[^']*'\\)*")
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
248 (defconst sgml-start-tag-regex (concat "<" sgml-name-re sgml-attrs-re)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
249 "Regular expression that matches a non-empty start tag.
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
250 Any terminating `>' or `/' is not matched.")
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
251
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
252
21780
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
253 ;; internal
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
254 (defconst sgml-font-lock-keywords-1
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
255 `((,(concat "<\\([!?]" sgml-name-re "\\)") 1 font-lock-keyword-face)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
256 (,(concat "<\\(/?" sgml-name-re"\\)") 1 font-lock-function-name-face)
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
257 ;; FIXME: this doesn't cover the variables using a default value.
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
258 (,(concat "\\(" sgml-name-re "\\)=[\"']") 1 font-lock-variable-name-face)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
259 (,(concat "[&%]" sgml-name-re ";?") . font-lock-variable-name-face)))
21780
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
260
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
261 (defconst sgml-font-lock-keywords-2
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
262 (append
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
263 sgml-font-lock-keywords-1
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
264 '((eval
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
265 . (cons (concat "<"
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
266 (regexp-opt (mapcar 'car sgml-tag-face-alist) t)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
267 "\\([ \t][^>]*\\)?>\\([^<]+\\)</\\1>")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
268 '(3 (cdr (assoc (downcase (match-string 1))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
269 sgml-tag-face-alist))))))))
21780
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
270
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
271 ;; for font-lock, but must be defvar'ed after
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
272 ;; sgml-font-lock-keywords-1 and sgml-font-lock-keywords-2 above
5dc3fe7cd300 (sgml-font-lock-keywords-1): Copy initialization from sgml-font-lock-keywords.
Richard M. Stallman <rms@gnu.org>
parents: 20922
diff changeset
273 (defvar sgml-font-lock-keywords sgml-font-lock-keywords-1
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
274 "*Rules for highlighting SGML code. See also `sgml-tag-face-alist'.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
275
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
276 (defvar sgml-font-lock-syntactic-keywords
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
277 ;; Use the `b' style of comments to avoid interference with the -- ... --
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
278 ;; comments recognized when `sgml-specials' includes ?-.
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
279 ;; FIXME: beware of <!--> blabla <!--> !!
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
280 '(("\\(<\\)!--" (1 "< b"))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
281 ("--[ \t\n]*\\(>\\)" (1 "> b")))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
282 "Syntactic keywords for `sgml-mode'.")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
283
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
284 ;; internal
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
285 (defvar sgml-face-tag-alist ()
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
286 "Alist of face and tag name for facemenu.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
287
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
288 (defvar sgml-tag-face-alist ()
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
289 "Tag names and face or list of faces to fontify with when invisible.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
290 When `font-lock-maximum-decoration' is 1 this is always used for fontifying.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
291 When more these are fontified together with `sgml-font-lock-keywords'.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
292
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
293
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
294 (defvar sgml-display-text ()
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
295 "Tag names as lowercase symbols, and display string when invisible.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
296
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
297 ;; internal
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
298 (defvar sgml-tags-invisible nil)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
299
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
300
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
301 (defcustom sgml-tag-alist
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
302 '(("![" ("ignore" t) ("include" t))
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
303 ("!attlist")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
304 ("!doctype")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
305 ("!element")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
306 ("!entity"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
307 "*Alist of tag names for completing read and insertion rules.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
308 This alist is made up as
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
309
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
310 ((\"tag\" . TAGRULE)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
311 ...)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
312
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
313 TAGRULE is a list of optionally `t' (no endtag) or `\\n' (separate endtag by
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
314 newlines) or a skeleton with `nil', `t' or `\\n' in place of the interactor
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
315 followed by an ATTRIBUTERULE (for an always present attribute) or an
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
316 attribute alist.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
317
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
318 The attribute alist is made up as
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
319
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
320 ((\"attribute\" . ATTRIBUTERULE)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
321 ...)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
322
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
323 ATTRIBUTERULE is a list of optionally `t' (no value when no input) followed by
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
324 an optional alist of possible values."
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
325 :type '(repeat (cons (string :tag "Tag Name")
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
326 (repeat :tag "Tag Rule" sexp)))
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
327 :group 'sgml)
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
328
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
329 (defcustom sgml-tag-help
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
330 '(("!" . "Empty declaration for comment")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
331 ("![" . "Embed declarations with parser directive")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
332 ("!attlist" . "Tag attributes declaration")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
333 ("!doctype" . "Document type (DTD) declaration")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
334 ("!element" . "Tag declaration")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
335 ("!entity" . "Entity (macro) declaration"))
17432
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
336 "*Alist of tag name and short description."
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
337 :type '(repeat (cons (string :tag "Tag Name")
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
338 (string :tag "Description")))
5d2e0051fe39 Add defgroup; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 17309
diff changeset
339 :group 'sgml)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
340
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
341 (defcustom sgml-xml-mode nil
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
342 "*When non-nil, tag insertion functions will be XML-compliant.
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
343 If this variable is customized, the custom value is used always.
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
344 Otherwise, it is set to be buffer-local when the file has
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
345 a DOCTYPE or an XML declaration."
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
346 :type 'boolean
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
347 :version "21.2"
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
348 :group 'sgml)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
349
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
350 (defvar sgml-empty-tags nil
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
351 "List of tags whose !ELEMENT definition says EMPTY.")
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
352
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
353 (defvar sgml-unclosed-tags nil
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
354 "List of tags whose !ELEMENT definition says the end-tag is optional.")
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
355
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
356 (defun sgml-xml-guess ()
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
357 "Guess whether the current buffer is XML."
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
358 (save-excursion
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
359 (goto-char (point-min))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
360 (when (or (string= "xml" (file-name-extension (or buffer-file-name "")))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
361 (looking-at "\\s-*<\\?xml")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
362 (when (re-search-forward
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
363 (eval-when-compile
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
364 (mapconcat 'identity
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
365 '("<!DOCTYPE" "\\(\\w+\\)" "\\(\\w+\\)"
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
366 "\"\\([^\"]+\\)\"" "\"\\([^\"]+\\)\"")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
367 "\\s-+"))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
368 nil t)
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
369 (string-match "X\\(HT\\)?ML" (match-string 3))))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
370 (set (make-local-variable 'sgml-xml-mode) t))))
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
371
23726
ca83df619ee6 Require skeleton when compiling.
Dave Love <fx@gnu.org>
parents: 23652
diff changeset
372 (defvar v2) ; free for skeleton
ca83df619ee6 Require skeleton when compiling.
Dave Love <fx@gnu.org>
parents: 23652
diff changeset
373
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
374 (defun sgml-mode-facemenu-add-face-function (face end)
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
375 (if (setq face (cdr (assq face sgml-face-tag-alist)))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
376 (progn
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
377 (setq face (funcall skeleton-transformation face))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
378 (setq facemenu-end-add-face (concat "</" face ">"))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
379 (concat "<" face ">"))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
380 (error "Face not configured for %s mode" mode-name)))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
381
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
382
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
383 ;;;###autoload
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
384 (define-derived-mode sgml-mode text-mode "SGML"
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
385 "Major mode for editing SGML documents.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
386 Makes > match <.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
387 Keys <, &, SPC within <>, \" and ' can be electric depending on
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
388 `sgml-quick-keys'.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
389
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
390 An argument of N to a tag-inserting command means to wrap it around
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
391 the next N words. In Transient Mark mode, when the mark is active,
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
392 N defaults to -1, which means to wrap it around the current region.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
393
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
394 If you like upcased tags, put (setq sgml-transformation 'upcase) in
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
395 your `.emacs' file.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
396
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
397 Use \\[sgml-validate] to validate your document with an SGML parser.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
398
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
399 Do \\[describe-variable] sgml- SPC to see available variables.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
400 Do \\[describe-key] on the following bindings to discover what they do.
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
401 \\{sgml-mode-map}"
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
402 (make-local-variable 'sgml-saved-validate-command)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
403 (make-local-variable 'facemenu-end-add-face)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
404 ;;(make-local-variable 'facemenu-remove-face-function)
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
405 ;; A start or end tag by itself on a line separates a paragraph.
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
406 ;; This is desirable because SGML discards a newline that appears
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
407 ;; immediately after a start tag or immediately before an end tag.
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
408 (set (make-local-variable 'paragraph-start) (concat "[ \t]*$\\|\
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
409 \[ \t]*</?\\(" sgml-name-re sgml-attrs-re "\\)?>"))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
410 (set (make-local-variable 'paragraph-separate)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
411 (concat paragraph-start "$"))
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
412 (set (make-local-variable 'adaptive-fill-regexp) "[ \t]*")
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
413 (set (make-local-variable 'comment-start) "<!-- ")
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
414 (set (make-local-variable 'comment-end) " -->")
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
415 (set (make-local-variable 'comment-indent-function) 'sgml-comment-indent)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
416 (set (make-local-variable 'skeleton-further-elements)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
417 '((completion-ignore-case t)))
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
418 (set (make-local-variable 'skeleton-end-hook)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
419 (lambda ()
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
420 (or (eolp)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
421 (not (or (eq v2 '\n) (eq (car-safe v2) '\n)))
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
422 (newline-and-indent))))
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
423 (set (make-local-variable 'font-lock-defaults)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
424 '((sgml-font-lock-keywords
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
425 sgml-font-lock-keywords-1
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
426 sgml-font-lock-keywords-2)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
427 nil t nil nil
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
428 (font-lock-syntactic-keywords
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
429 . sgml-font-lock-syntactic-keywords)))
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
430 (set (make-local-variable 'facemenu-add-face-function)
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
431 'sgml-mode-facemenu-add-face-function)
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
432 (sgml-xml-guess)
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
433 (if sgml-xml-mode
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
434 (setq mode-name "XML")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
435 (set (make-local-variable 'skeleton-transformation) sgml-transformation))
36609
8e1755c3dd2b (sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27683
diff changeset
436 ;; This will allow existing comments within declarations to be
8e1755c3dd2b (sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27683
diff changeset
437 ;; recognized.
8e1755c3dd2b (sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27683
diff changeset
438 (set (make-local-variable 'comment-start-skip) "\\(?:<!\\)?--[ \t]*")
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
439 (set (make-local-variable 'comment-end-skip) "[ \t]*--\\([ \t\n]*>\\)?")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
440 ;; This definition probably is not useful in derived modes.
40377
ea7ef845ccf3 renamed `html-xhtml' to `sgml-xml' and generalized accordingly
Sam Steingold <sds@gnu.org>
parents: 40350
diff changeset
441 (set (make-local-variable 'imenu-generic-expression)
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
442 (concat "<!\\(element\\|entity\\)[ \t\n]+%?[ \t\n]*\\("
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
443 sgml-name-re "\\)")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
444
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
445
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
446 (defun sgml-comment-indent ()
36609
8e1755c3dd2b (sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27683
diff changeset
447 (if (looking-at "--") comment-column 0))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
448
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
449
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
450
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
451 (defun sgml-slash (arg)
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
452 "Insert `/' and display any previous matching `/'.
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
453 Two `/'s are treated as matching if the first `/' ends a net-enabling
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
454 start tag, and the second `/' is the corresponding null end tag."
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
455 (interactive "p")
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
456 (insert-char ?/ arg)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
457 (if (> arg 0)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
458 (let ((oldpos (point))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
459 (blinkpos)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
460 (level 0))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
461 (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
462 (save-restriction
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
463 (if sgml-slash-distance
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
464 (narrow-to-region (max (point-min)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
465 (- (point) sgml-slash-distance))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
466 oldpos))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
467 (if (and (re-search-backward sgml-start-tag-regex (point-min) t)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
468 (eq (match-end 0) (1- oldpos)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
469 ()
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
470 (goto-char (1- oldpos))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
471 (while (and (not blinkpos)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
472 (search-backward "/" (point-min) t))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
473 (let ((tagend (save-excursion
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
474 (if (re-search-backward sgml-start-tag-regex
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
475 (point-min) t)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
476 (match-end 0)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
477 nil))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
478 (if (eq tagend (point))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
479 (if (eq level 0)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
480 (setq blinkpos (point))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
481 (setq level (1- level)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
482 (setq level (1+ level)))))))
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
483 (when blinkpos
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
484 (goto-char blinkpos)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
485 (if (pos-visible-in-window-p)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
486 (sit-for 1)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
487 (message "Matches %s"
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
488 (buffer-substring (line-beginning-position)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
489 (1+ blinkpos)))))))))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
490
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
491
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
492 ;; Why doesn't this use the iso-cvt table or, preferably, generate the
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
493 ;; inverse of the extensive table in the SGML Quail input method? -- fx
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
494 ;; I guess that's moot since it only works with Latin-1 anyhow.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
495 (defun sgml-name-char (&optional char)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
496 "Insert a symbolic character name according to `sgml-char-names'.
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
497 Non-ASCII chars may be inserted either with the meta key, as in M-SPC for
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
498 no-break space or M-- for a soft hyphen; or via an input method or
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
499 encoded keyboard operation."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
500 (interactive "*")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
501 (insert ?&)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
502 (or char
17500
e8d7c7e2acab (sgml-name-char): Ask user with a prompt.
Richard M. Stallman <rms@gnu.org>
parents: 17491
diff changeset
503 (setq char (read-quoted-char "Enter char or octal number")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
504 (delete-backward-char 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
505 (insert char)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
506 (undo-boundary)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
507 (delete-backward-char 1)
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
508 (cond
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
509 ((< char 256)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
510 (insert ?&
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
511 (or (aref sgml-char-names char)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
512 (format "#%d" char))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
513 ?\;))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
514 ((aref sgml-char-names-table char)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
515 (insert ?& (aref sgml-char-names-table char) ?\;))
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
516 ((let ((c (encode-char char 'ucs)))
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
517 (when c
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
518 (insert (format "&#%d;" c))
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
519 t)))
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
520 (t ; should be an error? -- fx
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
521 (insert char))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
522
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
523 (defun sgml-name-self ()
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
524 "Insert a symbolic character name according to `sgml-char-names'."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
525 (interactive "*")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
526 (sgml-name-char last-command-char))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
527
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
528 (defun sgml-maybe-name-self ()
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
529 "Insert a symbolic character name according to `sgml-char-names'."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
530 (interactive "*")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
531 (if sgml-name-8bit-mode
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
532 (let ((mc last-command-char))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
533 (if (< mc 256)
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
534 (setq mc (unibyte-char-to-multibyte mc)))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
535 (or mc (setq mc last-command-char))
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
536 (sgml-name-char mc))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
537 (self-insert-command 1)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
538
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
539 (defun sgml-name-8bit-mode ()
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
540 "Toggle whether to insert named entities instead of non-ASCII characters.
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
541 This only works for Latin-1 input."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
542 (interactive)
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
543 (setq sgml-name-8bit-mode (not sgml-name-8bit-mode))
40176
744190a4880c (sgml-mode-map): Bind 8-bit codes above 127 to sgml-maybe-name-self.
Eli Zaretskii <eliz@gnu.org>
parents: 39616
diff changeset
544 (message "sgml name entity mode is now %s"
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
545 (if sgml-name-8bit-mode "ON" "OFF")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
546
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
547 ;; When an element of a skeleton is a string "str", it is passed
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
548 ;; through skeleton-transformation and inserted. If "str" is to be
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
549 ;; inserted literally, one should obtain it as the return value of a
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
550 ;; function, e.g. (identity "str").
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
551
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
552 (define-skeleton sgml-tag
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
553 "Prompt for a tag and insert it, optionally with attributes.
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
554 Completion and configuration are done according to `sgml-tag-alist'.
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
555 If you like tags and attributes in uppercase do \\[set-variable]
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
556 skeleton-transformation RET upcase RET, or put this in your `.emacs':
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
557 (setq sgml-transformation 'upcase)"
37252
5db39c2eba1e Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36609
diff changeset
558 (funcall skeleton-transformation
5db39c2eba1e Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36609
diff changeset
559 (completing-read "Tag: " sgml-tag-alist))
36609
8e1755c3dd2b (sgml-mode-common): Correct value of
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 27683
diff changeset
560 ?< str |
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
561 (("") -1 '(undo-boundary) (identity "&lt;")) | ; see comment above
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
562 `(("") '(setq v2 (sgml-attributes ,str t)) ?>
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
563 (cond
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
564 ((string= "![" ,str)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
565 (backward-char)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
566 '(("") " [ " _ " ]]"))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
567 ((and (eq v2 t) sgml-xml-mode (member ,str sgml-empty-tags))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
568 '(("") -1 "/>"))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
569 ((or (and (eq v2 t) (not sgml-xml-mode)) (string-match "^[/!?]" ,str))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
570 nil)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
571 ((symbolp v2)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
572 ;; Make sure we don't fall into an infinite loop.
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
573 ;; For xhtml's `tr' tag, we should maybe use \n instead.
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
574 (if (eq v2 t) (setq v2 nil))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
575 ;; We use `identity' to prevent skeleton from passing
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
576 ;; `str' through skeleton-transformation a second time.
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
577 '(("") v2 _ v2 "</" (identity ',str) ?>))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
578 ((eq (car v2) t)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
579 (cons '("") (cdr v2)))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
580 (t
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
581 (append '(("") (car v2))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
582 (cdr v2)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
583 '(resume: (car v2) _ "</" (identity ',str) ?>))))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
584
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
585 (autoload 'skeleton-read "skeleton")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
586
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
587 (defun sgml-attributes (tag &optional quiet)
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
588 "When at top level of a tag, interactively insert attributes.
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
589
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
590 Completion and configuration of TAG are done according to `sgml-tag-alist'.
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
591 If QUIET, do not print a message when there are no attributes for TAG."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
592 (interactive (list (save-excursion (sgml-beginning-of-tag t))))
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
593 (or (stringp tag) (error "Wrong context for adding attribute"))
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
594 (if tag
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
595 (let ((completion-ignore-case t)
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
596 (alist (cdr (assoc (downcase tag) sgml-tag-alist)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
597 car attribute i)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
598 (if (or (symbolp (car alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
599 (symbolp (car (car alist))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
600 (setq car (car alist)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
601 alist (cdr alist)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
602 (or quiet
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
603 (message "No attributes configured."))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
604 (if (stringp (car alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
605 (progn
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
606 (insert (if (eq (preceding-char) ? ) "" ? )
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
607 (funcall skeleton-transformation (car alist)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
608 (sgml-value alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
609 (setq i (length alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
610 (while (> i 0)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
611 (insert ? )
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
612 (insert (funcall skeleton-transformation
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
613 (setq attribute
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
614 (skeleton-read '(completing-read
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
615 "Attribute: "
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
616 alist)))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
617 (if (string= "" attribute)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
618 (setq i 0)
20922
3ae81bc17b19 (sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents: 20394
diff changeset
619 (sgml-value (assoc (downcase attribute) alist))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
620 (setq i (1- i))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
621 (if (eq (preceding-char) ? )
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
622 (delete-backward-char 1)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
623 car)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
624
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
625 (defun sgml-auto-attributes (arg)
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
626 "Self insert the character typed; at top level of tag, prompt for attributes.
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
627 With prefix argument, only self insert."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
628 (interactive "*P")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
629 (let ((point (point))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
630 tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
631 (if (or arg
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
632 (not sgml-tag-alist) ; no message when nothing configured
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
633 (symbolp (setq tag (save-excursion (sgml-beginning-of-tag t))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
634 (eq (aref tag 0) ?/))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
635 (self-insert-command (prefix-numeric-value arg))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
636 (sgml-attributes tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
637 (setq last-command-char ? )
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
638 (or (> (point) point)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
639 (self-insert-command 1)))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
640
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
641
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
642 (defun sgml-tag-help (&optional tag)
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
643 "Display description of tag TAG. If TAG is omitted, use the tag at point."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
644 (interactive)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
645 (or tag
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
646 (save-excursion
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
647 (if (eq (following-char) ?<)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
648 (forward-char))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
649 (setq tag (sgml-beginning-of-tag))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
650 (or (stringp tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
651 (error "No tag selected"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
652 (setq tag (downcase tag))
14328
5d0e329a44d8 (sgml-tag-help): Pass proper format string to message.
Karl Heuer <kwzh@gnu.org>
parents: 14270
diff changeset
653 (message "%s"
20922
3ae81bc17b19 (sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents: 20394
diff changeset
654 (or (cdr (assoc (downcase tag) sgml-tag-help))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
655 (and (eq (aref tag 0) ?/)
20922
3ae81bc17b19 (sgml-mode-common): Downcase key for
Dave Love <fx@gnu.org>
parents: 20394
diff changeset
656 (cdr (assoc (downcase (substring tag 1)) sgml-tag-help)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
657 "No description available")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
658
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
659
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
660 (defun sgml-maybe-end-tag (&optional arg)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
661 "Name self unless in position to end a tag or a prefix ARG is given."
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
662 (interactive "P")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
663 (if (or arg (eq (car (sgml-lexical-context)) 'tag))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
664 (self-insert-command (prefix-numeric-value arg))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
665 (sgml-name-self)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
666
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
667 (defun sgml-skip-tag-backward (arg)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
668 "Skip to beginning of tag or matching opening tag if present.
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
669 With prefix argument ARG, repeat this ARG times."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
670 (interactive "p")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
671 (while (>= arg 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
672 (search-backward "<" nil t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
673 (if (looking-at "</\\([^ \n\t>]+\\)")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
674 ;; end tag, skip any nested pairs
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
675 (let ((case-fold-search t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
676 (re (concat "</?" (regexp-quote (match-string 1)))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
677 (while (and (re-search-backward re nil t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
678 (eq (char-after (1+ (point))) ?/))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
679 (forward-char 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
680 (sgml-skip-tag-backward 1))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
681 (setq arg (1- arg))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
682
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
683 (defun sgml-skip-tag-forward (arg &optional return)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
684 "Skip to end of tag or matching closing tag if present.
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
685 With prefix argument ARG, repeat this ARG times.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
686 Return t iff after a closing tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
687 (interactive "p")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
688 (setq return t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
689 (while (>= arg 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
690 (skip-chars-forward "^<>")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
691 (if (eq (following-char) ?>)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
692 (up-list -1))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
693 (if (looking-at "<\\([^/ \n\t>]+\\)")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
694 ;; start tag, skip any nested same pairs _and_ closing tag
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
695 (let ((case-fold-search t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
696 (re (concat "</?" (regexp-quote (match-string 1))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
697 point close)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
698 (forward-list 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
699 (setq point (point))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
700 (while (and (re-search-forward re nil t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
701 (not (setq close
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
702 (eq (char-after (1+ (match-beginning 0))) ?/)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
703 (not (up-list -1))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
704 (sgml-skip-tag-forward 1))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
705 (setq close nil))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
706 (if close
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
707 (up-list 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
708 (goto-char point)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
709 (setq return)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
710 (forward-list 1))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
711 (setq arg (1- arg)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
712 return)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
713
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
714 (defun sgml-delete-tag (arg)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
715 "Delete tag on or after cursor, and matching closing or opening tag.
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
716 With prefix argument ARG, repeat this ARG times."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
717 (interactive "p")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
718 (while (>= arg 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
719 (save-excursion
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
720 (let* (close open)
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
721 (if (looking-at "[ \t\n]*<")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
722 ;; just before tag
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
723 (if (eq (char-after (match-end 0)) ?/)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
724 ;; closing tag
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
725 (progn
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
726 (setq close (point))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
727 (goto-char (match-end 0))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
728 ;; on tag?
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
729 (or (save-excursion (setq close (sgml-beginning-of-tag)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
730 close (and (stringp close)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
731 (eq (aref close 0) ?/)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
732 (point))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
733 ;; not on closing tag
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
734 (let ((point (point)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
735 (sgml-skip-tag-backward 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
736 (if (or (not (eq (following-char) ?<))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
737 (save-excursion
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
738 (forward-list 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
739 (<= (point) point)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
740 (error "Not on or before tag")))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
741 (if close
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
742 (progn
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
743 (sgml-skip-tag-backward 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
744 (setq open (point))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
745 (goto-char close)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
746 (kill-sexp 1))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
747 (setq open (point))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
748 (sgml-skip-tag-forward 1)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
749 (backward-list)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
750 (forward-char)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
751 (if (eq (aref (sgml-beginning-of-tag) 0) ?/)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
752 (kill-sexp 1)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
753 (goto-char open)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
754 (kill-sexp 1)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
755 (setq arg (1- arg))))
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
756
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
757 ;; Put read-only last to enable setting this even when read-only enabled.
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
758 (or (get 'sgml-tag 'invisible)
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
759 (setplist 'sgml-tag
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
760 (append '(invisible t
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
761 intangible t
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
762 point-entered sgml-point-entered
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
763 rear-nonsticky t
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
764 read-only t)
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
765 (symbol-plist 'sgml-tag))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
766
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
767 (defun sgml-tags-invisible (arg)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
768 "Toggle visibility of existing tags."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
769 (interactive "P")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
770 (let ((modified (buffer-modified-p))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
771 (inhibit-read-only t)
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
772 (inhibit-modification-hooks t)
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
773 ;; Avoid spurious the `file-locked' checks.
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
774 (buffer-file-name nil)
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
775 ;; This is needed in case font lock gets called,
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
776 ;; since it moves point and might call sgml-point-entered.
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
777 ;; How could it get called? -stef
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
778 (inhibit-point-motion-hooks t)
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
779 string)
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
780 (unwind-protect
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
781 (save-excursion
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
782 (goto-char (point-min))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
783 (if (set (make-local-variable 'sgml-tags-invisible)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
784 (if arg
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
785 (>= (prefix-numeric-value arg) 0)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
786 (not sgml-tags-invisible)))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
787 (while (re-search-forward sgml-tag-name-re nil t)
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
788 (setq string
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
789 (cdr (assq (intern-soft (downcase (match-string 1)))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
790 sgml-display-text)))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
791 (goto-char (match-beginning 0))
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
792 (and (stringp string)
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
793 (not (overlays-at (point)))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
794 (let ((ol (make-overlay (point) (match-beginning 1))))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
795 (overlay-put ol 'before-string string)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
796 (overlay-put ol 'sgml-tag t)))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
797 (put-text-property (point)
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
798 (progn (forward-list) (point))
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
799 'category 'sgml-tag))
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
800 (let ((pos (point-min)))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
801 (while (< (setq pos (next-overlay-change pos)) (point-max))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
802 (dolist (ol (overlays-at pos))
40393
591afd36f0b3 (sgml-tags-invisible): Typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40392
diff changeset
803 (if (overlay-get ol 'sgml-tag)
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
804 (delete-overlay ol)))))
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
805 (remove-text-properties (point-min) (point-max) '(category nil))))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
806 (restore-buffer-modified-p modified))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
807 (run-hooks 'sgml-tags-invisible-hook)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
808 (message "")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
809
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
810 (defun sgml-point-entered (x y)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
811 ;; Show preceding or following hidden tag, depending of cursor direction.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
812 (let ((inhibit-point-motion-hooks t))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
813 (save-excursion
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
814 (message "Invisible tag: %s"
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
815 ;; Strip properties, otherwise, the text is invisible.
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
816 (buffer-substring-no-properties
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
817 (point)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
818 (if (or (and (> x y)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
819 (not (eq (following-char) ?<)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
820 (and (< x y)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
821 (eq (preceding-char) ?>)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
822 (backward-list)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
823 (forward-list)))))))
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
824
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
825 (autoload 'compile-internal "compile")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
826
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
827 (defun sgml-validate (command)
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
828 "Validate an SGML document.
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
829 Runs COMMAND, a shell command, in a separate process asynchronously
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
830 with output going to the buffer `*compilation*'.
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
831 You can then use the command \\[next-error] to find the next error message
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
832 and move to the line in the SGML document that caused it."
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
833 (interactive
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
834 (list (read-string "Validate command: "
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
835 (or sgml-saved-validate-command
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
836 (concat sgml-validate-command
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
837 " "
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
838 (let ((name (buffer-file-name)))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
839 (and name
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
840 (file-name-nondirectory name))))))))
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
841 (setq sgml-saved-validate-command command)
23970
d1d08f461c9c (sgml-validate): Ask whether to save only
Richard M. Stallman <rms@gnu.org>
parents: 23869
diff changeset
842 (save-some-buffers (not compilation-ask-about-save) nil)
3121
8cf203c42bee (sgml-validate): compile1 renamed to compile-internal.
Richard M. Stallman <rms@gnu.org>
parents: 2315
diff changeset
843 (compile-internal command "No more errors"))
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
844
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
845
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
846 (defun sgml-lexical-context (&optional limit)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
847 "Return the lexical context at point as (TYPE . START).
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
848 START is the location of the start of the lexical element.
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
849 TYPE is one of `string', `comment', `tag', or `text'.
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
850
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
851 If non-nil LIMIT is a nearby position before point outside of any tag."
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
852 ;; As usual, it's difficult to get a reliable answer without parsing the
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
853 ;; whole buffer. We'll assume that a tag at indentation is outside of
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
854 ;; any string or tag or comment or ...
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
855 (save-excursion
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
856 (let ((pos (point))
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
857 (state nil)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
858 textstart)
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
859 (if limit (goto-char limit)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
860 ;; Hopefully this regexp will match something that's not inside
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
861 ;; a tag and also hopefully the match is nearby.
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
862 (re-search-backward "^[ \t]*<[_:[:alpha:]/%!?#]" nil 'move))
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
863 (setq textstart (point))
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
864 (with-syntax-table sgml-tag-syntax-table
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
865 (while (< (point) pos)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
866 ;; When entering this loop we're inside text.
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
867 (setq textstart (point))
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
868 (skip-chars-forward "^<" pos)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
869 ;; We skipped text and reached a tag. Parse it.
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
870 ;; FIXME: Handle net-enabling start-tags and <![CDATA[ ...]]>.
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
871 (setq state (parse-partial-sexp (point) pos 0)))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
872 (cond
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
873 ((nth 3 state) (cons 'string (nth 8 state)))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
874 ((nth 4 state) (cons 'comment (nth 8 state)))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
875 ((and state (> (nth 0 state) 0)) (cons 'tag (nth 1 state)))
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
876 (t (cons 'text textstart)))))))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
877
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
878 (defun sgml-beginning-of-tag (&optional top-level)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
879 "Skip to beginning of tag and return its name.
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
880 If this can't be done, return nil."
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
881 (let ((context (sgml-lexical-context)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
882 (if (eq (car context) 'tag)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
883 (progn
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
884 (goto-char (cdr context))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
885 (when (looking-at sgml-tag-name-re)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
886 (match-string-no-properties 1)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
887 (if top-level nil
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
888 (when (not (eq (car context) 'text))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
889 (goto-char (cdr context))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
890 (sgml-beginning-of-tag t))))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
891
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
892 (defun sgml-value (alist)
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
893 "Interactively insert value taken from attributerule ALIST.
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
894 See `sgml-tag-alist' for info about attribute rules."
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
895 (setq alist (cdr alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
896 (if (stringp (car alist))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
897 (insert "=\"" (car alist) ?\")
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
898 (if (and (eq (car alist) t) (not sgml-xml-mode))
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
899 (when (cdr alist)
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
900 (insert "=\"")
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
901 (setq alist (skeleton-read '(completing-read "Value: " (cdr alist))))
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
902 (if (string< "" alist)
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
903 (insert alist ?\")
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
904 (delete-backward-char 2)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
905 (insert "=\"")
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
906 (when alist
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
907 (insert (skeleton-read '(completing-read "Value: " alist))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
908 (insert ?\"))))
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
909
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
910 (defun sgml-quote (start end &optional unquotep)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
911 "Quote SGML text in region.
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
912 With prefix argument, unquote the region."
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
913 (interactive "r\np")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
914 (if (< start end)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
915 (goto-char start)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
916 (goto-char end)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
917 (setq end start))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
918 (if unquotep
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
919 (while (re-search-forward "&\\(amp\\|\\(l\\|\\(g\\)\\)t\\)[;\n]" end t)
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
920 (replace-match (if (match-end 3) ">" (if (match-end 2) "<" "&"))))
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
921 (while (re-search-forward "[&<>]" end t)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
922 (replace-match (cdr (assq (char-before) '((?& . "&amp;")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
923 (?< . "&lt;")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
924 (?> . "&gt;"))))))))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
925
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
926
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
927 (defun sgml-calculate-indent ()
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
928 "Calculate the column to which this line should be indented."
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
929 (let ((lcon (sgml-lexical-context)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
930 ;; Indent comment-start markers inside <!-- just like comment-end markers.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
931 (if (and (eq (car lcon) 'tag)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
932 (looking-at "--")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
933 (save-excursion (goto-char (cdr lcon)) (looking-at "<!--")))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
934 (setq lcon (cons 'comment (+ (cdr lcon) 2))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
935
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
936 (case (car lcon)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
937 (string
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
938 ;; Go back to previous non-empty line.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
939 (while (and (> (point) (cdr lcon))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
940 (zerop (forward-line -1))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
941 (looking-at "[ \t]*$")))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
942 (if (> (point) (cdr lcon))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
943 ;; Previous line is inside the string.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
944 (current-indentation)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
945 (goto-char (cdr lcon))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
946 (1+ (current-column))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
947
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
948 (comment
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
949 (let ((mark (looking-at "--")))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
950 ;; Go back to previous non-empty line.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
951 (while (and (> (point) (cdr lcon))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
952 (zerop (forward-line -1))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
953 (or (looking-at "[ \t]*$")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
954 (if mark (not (looking-at "[ \t]*--"))))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
955 (if (> (point) (cdr lcon))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
956 ;; Previous line is inside the comment.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
957 (skip-chars-forward " \t")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
958 (goto-char (cdr lcon)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
959 (when (and (not mark) (looking-at "--"))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
960 (forward-char 2) (skip-chars-forward " \t"))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
961 (current-column)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
962
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
963 (tag
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
964 (goto-char (1+ (cdr lcon)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
965 (skip-chars-forward "^ \t\n") ;Skip tag name.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
966 (skip-chars-forward " \t")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
967 (if (not (eolp))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
968 (current-column)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
969 ;; This is the first attribute: indent.
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
970 (goto-char (1+ (cdr lcon)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
971 (+ (current-column) sgml-basic-offset)))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
972
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
973 (t ;; text
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
974 (while (looking-at "</")
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
975 (forward-sexp 1)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
976 (skip-chars-forward " \t"))
44244
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
977 (let* ((here (point))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
978 (unclosed (and ;; (not sgml-xml-mode)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
979 (looking-at sgml-tag-name-re)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
980 (member-ignore-case (match-string 1)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
981 sgml-unclosed-tags)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
982 (match-string 1)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
983 (context
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
984 ;; If possible, align on the previous non-empty text line.
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
985 ;; Otherwise, do a more serious parsing to find the
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
986 ;; tag(s) relative to which we should be indenting.
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
987 (if (and (not unclosed) (skip-chars-backward " \t")
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
988 (< (skip-chars-backward " \t\n") 0)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
989 (back-to-indentation)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
990 (> (point) (cdr lcon)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
991 nil
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
992 (goto-char here)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
993 (nreverse (xml-lite-get-context (if unclosed nil 'empty)))))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
994 (there (point)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
995 ;; Ignore previous unclosed start-tag in context.
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
996 (while (and context unclosed
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
997 (eq t (compare-strings
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
998 (xml-lite-tag-name (car context)) nil nil
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
999 unclosed nil nil t)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1000 (setq context (cdr context)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1001 ;; Indent to reflect nesting.
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1002 (if (and context
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1003 (goto-char (xml-lite-tag-end (car context)))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1004 (skip-chars-forward " \t\n")
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1005 (< (point) here) (xml-lite-at-indentation-p))
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1006 (current-column)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1007 (goto-char there)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1008 (+ (current-column)
31f1fc31fd45 (sgml-lexical-context): Return (text . START)
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44241
diff changeset
1009 (* sgml-basic-offset (length context)))))))))
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1010
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1011 (defun sgml-indent-line ()
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1012 "Indent the current line as SGML."
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1013 (interactive)
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1014 (let* ((savep (point))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1015 (indent-col
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1016 (save-excursion
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1017 (back-to-indentation)
44200
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1018 (if (>= (point) savep) (setq savep nil))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1019 (sgml-calculate-indent))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1020 (if savep
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1021 (save-excursion (indent-line-to indent-col))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1022 (indent-line-to indent-col))))
3ea526b58b9e (sgml-make-syntax-table): New fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43979
diff changeset
1023
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1024 (defun sgml-parse-dtd ()
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1025 "Simplistic parse of the current buffer as a DTD.
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1026 Currently just returns (EMPTY-TAGS UNCLOSED-TAGS)."
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1027 (goto-char (point-min))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1028 (let ((empty nil)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1029 (unclosed nil))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1030 (while (re-search-forward "<!ELEMENT[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+[-O][ \t\n]+\\([-O]\\)[ \t\n]+\\([^ \t\n]+\\)" nil t)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1031 (cond
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1032 ((string= (match-string 3) "EMPTY")
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1033 (push (match-string-no-properties 1) empty))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1034 ((string= (match-string 2) "O")
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1035 (push (match-string-no-properties 1) unclosed))))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1036 (setq empty (sort (mapcar 'downcase empty) 'string<))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1037 (setq unclosed (sort (mapcar 'downcase unclosed) 'string<))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1038 (list empty unclosed)))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1039
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1040 ;;; HTML mode
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1041
25175
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1042 (defcustom html-mode-hook nil
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1043 "Hook run by command `html-mode'.
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1044 `text-mode-hook' and `sgml-mode-hook' are run first."
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1045 :group 'sgml
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1046 :type 'hook
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1047 :options '(html-autoview-mode))
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1048
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1049 (defvar html-quick-keys sgml-quick-keys
14377
2e6bd1a2712a Whitespace fix.
Richard M. Stallman <rms@gnu.org>
parents: 14328
diff changeset
1050 "Use C-c X combinations for quick insertion of frequent tags when non-nil.
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1051 This defaults to `sgml-quick-keys'.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1052 This takes effect when first loading the library.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1053
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1054 (defvar html-mode-map
37252
5db39c2eba1e Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36609
diff changeset
1055 (let ((map (make-sparse-keymap))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1056 (menu-map (make-sparse-keymap "HTML")))
37252
5db39c2eba1e Add unknown maintainer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 36609
diff changeset
1057 (set-keymap-parent map sgml-mode-map)
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1058 (define-key map "\C-c6" 'html-headline-6)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1059 (define-key map "\C-c5" 'html-headline-5)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1060 (define-key map "\C-c4" 'html-headline-4)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1061 (define-key map "\C-c3" 'html-headline-3)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1062 (define-key map "\C-c2" 'html-headline-2)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1063 (define-key map "\C-c1" 'html-headline-1)
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1064 (define-key map "\C-c\r" 'html-paragraph)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1065 (define-key map "\C-c\n" 'html-line)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1066 (define-key map "\C-c\C-c-" 'html-horizontal-rule)
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1067 (define-key map "\C-c\C-co" 'html-ordered-list)
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1068 (define-key map "\C-c\C-cu" 'html-unordered-list)
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1069 (define-key map "\C-c\C-cr" 'html-radio-buttons)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1070 (define-key map "\C-c\C-cc" 'html-checkboxes)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1071 (define-key map "\C-c\C-cl" 'html-list-item)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1072 (define-key map "\C-c\C-ch" 'html-href-anchor)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1073 (define-key map "\C-c\C-cn" 'html-name-anchor)
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1074 (define-key map "\C-c\C-ci" 'html-image)
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1075 (when html-quick-keys
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1076 (define-key map "\C-c-" 'html-horizontal-rule)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1077 (define-key map "\C-co" 'html-ordered-list)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1078 (define-key map "\C-cu" 'html-unordered-list)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1079 (define-key map "\C-cr" 'html-radio-buttons)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1080 (define-key map "\C-cc" 'html-checkboxes)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1081 (define-key map "\C-cl" 'html-list-item)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1082 (define-key map "\C-ch" 'html-href-anchor)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1083 (define-key map "\C-cn" 'html-name-anchor)
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1084 (define-key map "\C-ci" 'html-image))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1085 (define-key map "\C-c\C-s" 'html-autoview-mode)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1086 (define-key map "\C-c\C-v" 'browse-url-of-buffer)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1087 (define-key map [menu-bar html] (cons "HTML" menu-map))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1088 (define-key menu-map [html-autoview-mode]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1089 '("Toggle Autoviewing" . html-autoview-mode))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1090 (define-key menu-map [browse-url-of-buffer]
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1091 '("View Buffer Contents" . browse-url-of-buffer))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1092 (define-key menu-map [nil] '("--"))
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1093 ;;(define-key menu-map "6" '("Heading 6" . html-headline-6))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1094 ;;(define-key menu-map "5" '("Heading 5" . html-headline-5))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1095 ;;(define-key menu-map "4" '("Heading 4" . html-headline-4))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1096 (define-key menu-map "3" '("Heading 3" . html-headline-3))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1097 (define-key menu-map "2" '("Heading 2" . html-headline-2))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1098 (define-key menu-map "1" '("Heading 1" . html-headline-1))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1099 (define-key menu-map "l" '("Radio Buttons" . html-radio-buttons))
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1100 (define-key menu-map "c" '("Checkboxes" . html-checkboxes))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1101 (define-key menu-map "l" '("List Item" . html-list-item))
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1102 (define-key menu-map "u" '("Unordered List" . html-unordered-list))
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1103 (define-key menu-map "o" '("Ordered List" . html-ordered-list))
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1104 (define-key menu-map "-" '("Horizontal Rule" . html-horizontal-rule))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1105 (define-key menu-map "\n" '("Line Break" . html-line))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1106 (define-key menu-map "\r" '("Paragraph" . html-paragraph))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1107 (define-key menu-map "i" '("Image" . html-image))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1108 (define-key menu-map "h" '("Href Anchor" . html-href-anchor))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1109 (define-key menu-map "n" '("Name Anchor" . html-name-anchor))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1110 map)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1111 "Keymap for commands for use in HTML mode.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1112
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1113
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1114 (defvar html-face-tag-alist
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1115 '((bold . "b")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1116 (italic . "i")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1117 (underline . "u")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1118 (modeline . "rev"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1119 "Value of `sgml-face-tag-alist' for HTML mode.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1120
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1121 (defvar html-tag-face-alist
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1122 '(("b" . bold)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1123 ("big" . bold)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1124 ("blink" . highlight)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1125 ("cite" . italic)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1126 ("em" . italic)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1127 ("h1" bold underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1128 ("h2" bold-italic underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1129 ("h3" italic underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1130 ("h4" . underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1131 ("h5" . underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1132 ("h6" . underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1133 ("i" . italic)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1134 ("rev" . modeline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1135 ("s" . underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1136 ("small" . default)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1137 ("strong" . bold)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1138 ("title" bold underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1139 ("tt" . default)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1140 ("u" . underline)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1141 ("var" . italic))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1142 "Value of `sgml-tag-face-alist' for HTML mode.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1143
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1144
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1145 (defvar html-display-text
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1146 '((img . "[/]")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1147 (hr . "----------")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1148 (li . "o "))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1149 "Value of `sgml-display-text' for HTML mode.")
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1150
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1151
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1152 ;; should code exactly HTML 3 here when that is finished
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1153 (defvar html-tag-alist
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1154 (let* ((1-7 '(("1") ("2") ("3") ("4") ("5") ("6") ("7")))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1155 (1-9 `(,@1-7 ("8") ("9")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1156 (align '(("align" ("left") ("center") ("right"))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1157 (valign '(("top") ("middle") ("bottom") ("baseline")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1158 (rel '(("next") ("previous") ("parent") ("subdocument") ("made")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1159 (href '("href" ("ftp:") ("file:") ("finger:") ("gopher:") ("http:")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1160 ("mailto:") ("news:") ("rlogin:") ("telnet:") ("tn3270:")
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1161 ("wais:") ("/cgi-bin/")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1162 (name '("name"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1163 (link `(,href
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1164 ("rel" ,@rel)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1165 ("rev" ,@rel)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1166 ("title")))
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1167 (list '((nil \n ("List item: " "<li>" str
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1168 (if sgml-xml-mode "</li>") \n))))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1169 (cell `(t
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1170 ,@align
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1171 ("valign" ,@valign)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1172 ("colspan" ,@1-9)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1173 ("rowspan" ,@1-9)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1174 ("nowrap" t))))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1175 ;; put ,-expressions first, else byte-compile chokes (as of V19.29)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1176 ;; and like this it's more efficient anyway
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1177 `(("a" ,name ,@link)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1178 ("base" t ,@href)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1179 ("dir" ,@list)
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1180 ("font" nil "size" ("-1") ("+1") ("-2") ("+2") ,@1-7)
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
1181 ("form" (\n _ \n "<input type=\"submit\" value=\"\""
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1182 (if sgml-xml-mode "/>" ">"))
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1183 ("action" ,@(cdr href)) ("method" ("get") ("post")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1184 ("h1" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1185 ("h2" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1186 ("h3" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1187 ("h4" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1188 ("h5" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1189 ("h6" ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1190 ("hr" t ("size" ,@1-9) ("width") ("noshade" t) ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1191 ("img" t ("align" ,@valign ("texttop") ("absmiddle") ("absbottom"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1192 ("src") ("alt") ("width" "1") ("height" "1")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1193 ("border" "1") ("vspace" "1") ("hspace" "1") ("ismap" t))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1194 ("input" t ("size" ,@1-9) ("maxlength" ,@1-9) ("checked" t) ,name
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1195 ("type" ("text") ("password") ("checkbox") ("radio")
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1196 ("submit") ("reset"))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1197 ("value"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1198 ("link" t ,@link)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1199 ("menu" ,@list)
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1200 ("ol" ,@list ("type" ("A") ("a") ("I") ("i") ("1")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1201 ("p" t ,@align)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1202 ("select" (nil \n
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1203 ("Text: "
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1204 "<option>" str (if sgml-xml-mode "</option>") \n))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1205 ,name ("size" ,@1-9) ("multiple" t))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1206 ("table" (nil \n
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1207 ((completing-read "Cell kind: " '(("td") ("th"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1208 nil t "t")
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
1209 "<tr><" str ?> _
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1210 (if sgml-xml-mode (concat "<" str "></tr>")) \n))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1211 ("border" t ,@1-9) ("width" "10") ("cellpadding"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1212 ("td" ,@cell)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1213 ("textarea" ,name ("rows" ,@1-9) ("cols" ,@1-9))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1214 ("th" ,@cell)
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1215 ("ul" ,@list ("type" ("disc") ("circle") ("square")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1216
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1217 ,@sgml-tag-alist
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1218
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1219 ("abbrev")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1220 ("acronym")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1221 ("address")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1222 ("array" (nil \n
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1223 ("Item: " "<item>" str (if sgml-xml-mode "</item>") \n))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1224 "align")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1225 ("au")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1226 ("b")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1227 ("big")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1228 ("blink")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1229 ("blockquote" \n)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1230 ("body" \n ("background" ".gif") ("bgcolor" "#") ("text" "#")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1231 ("link" "#") ("alink" "#") ("vlink" "#"))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1232 ("box" (nil _ "<over>" _ (if sgml-xml-mode "</over>")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1233 ("br" t ("clear" ("left") ("right")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1234 ("caption" ("valign" ("top") ("bottom")))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1235 ("center" \n)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1236 ("cite")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1237 ("code" \n)
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1238 ("dd" ,(not sgml-xml-mode))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1239 ("del")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1240 ("dfn")
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1241 ("div")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1242 ("dl" (nil \n
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1243 ( "Term: "
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1244 "<dt>" str (if sgml-xml-mode "</dt>")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1245 "<dd>" _ (if sgml-xml-mode "</dd>") \n)))
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1246 ("dt" (t _ (if sgml-xml-mode "</dt>")
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1247 "<dd>" (if sgml-xml-mode "</dd>") \n))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1248 ("em")
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1249 ;("fn" "id" "fn") ; ???
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1250 ("head" \n)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1251 ("html" (\n
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1252 "<head>\n"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1253 "<title>" (setq str (read-input "Title: ")) "</title>\n"
24413
e2c5b1571392 (html-tag-alist): Add /head and /body to the "html" template.
Richard M. Stallman <rms@gnu.org>
parents: 23970
diff changeset
1254 "</head>\n"
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1255 "<body>\n<h1>" str "</h1>\n" _
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1256 "\n<address>\n<a href=\"mailto:"
14518
5b2bc060c90d (html-tag-alist): within the <ADDRESS> tag
Richard M. Stallman <rms@gnu.org>
parents: 14377
diff changeset
1257 user-mail-address
24413
e2c5b1571392 (html-tag-alist): Add /head and /body to the "html" template.
Richard M. Stallman <rms@gnu.org>
parents: 23970
diff changeset
1258 "\">" (user-full-name) "</a>\n</address>\n"
e2c5b1571392 (html-tag-alist): Add /head and /body to the "html" template.
Richard M. Stallman <rms@gnu.org>
parents: 23970
diff changeset
1259 "</body>"
e2c5b1571392 (html-tag-alist): Add /head and /body to the "html" template.
Richard M. Stallman <rms@gnu.org>
parents: 23970
diff changeset
1260 ))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1261 ("i")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1262 ("ins")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1263 ("isindex" t ("action") ("prompt"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1264 ("kbd")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1265 ("lang")
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1266 ("li" ,(not sgml-xml-mode))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1267 ("math" \n)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1268 ("nobr")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1269 ("option" t ("value") ("label") ("selected" t))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1270 ("over" t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1271 ("person")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1272 ("pre" \n)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1273 ("q")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1274 ("rev")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1275 ("s")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1276 ("samp")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1277 ("small")
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1278 ("span" nil
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1279 ("class"
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1280 ("builtin")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1281 ("comment")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1282 ("constant")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1283 ("function-name")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1284 ("keyword")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1285 ("string")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1286 ("type")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1287 ("variable-name")
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1288 ("warning")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1289 ("strong")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1290 ("sub")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1291 ("sup")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1292 ("title")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1293 ("tr" t)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1294 ("tt")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1295 ("u")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1296 ("var")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1297 ("wbr" t)))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1298 "*Value of `sgml-tag-alist' for HTML mode.")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1299
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1300 (defvar html-tag-help
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1301 `(,@sgml-tag-help
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1302 ("a" . "Anchor of point or link elsewhere")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1303 ("abbrev" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1304 ("acronym" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1305 ("address" . "Formatted mail address")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1306 ("array" . "Math array")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1307 ("au" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1308 ("b" . "Bold face")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1309 ("base" . "Base address for URLs")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1310 ("big" . "Font size")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1311 ("blink" . "Blinking text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1312 ("blockquote" . "Indented quotation")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1313 ("body" . "Document body")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1314 ("box" . "Math fraction")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1315 ("br" . "Line break")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1316 ("caption" . "Table caption")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1317 ("center" . "Centered text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1318 ("changed" . "Change bars")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1319 ("cite" . "Citation of a document")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1320 ("code" . "Formatted source code")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1321 ("dd" . "Definition of term")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1322 ("del" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1323 ("dfn" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1324 ("dir" . "Directory list (obsolete)")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1325 ("dl" . "Definition list")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1326 ("dt" . "Term to be definined")
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1327 ("em" . "Emphasised")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1328 ("embed" . "Embedded data in foreign format")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1329 ("fig" . "Figure")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1330 ("figa" . "Figure anchor")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1331 ("figd" . "Figure description")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1332 ("figt" . "Figure text")
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1333 ;("fn" . "?") ; ???
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1334 ("font" . "Font size")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1335 ("form" . "Form with input fields")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1336 ("group" . "Document grouping")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1337 ("h1" . "Most important section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1338 ("h2" . "Important section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1339 ("h3" . "Section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1340 ("h4" . "Minor section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1341 ("h5" . "Unimportant section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1342 ("h6" . "Least important section headline")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1343 ("head" . "Document header")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1344 ("hr" . "Horizontal rule")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1345 ("html" . "HTML Document")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1346 ("i" . "Italic face")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1347 ("img" . "Graphic image")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1348 ("input" . "Form input field")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1349 ("ins" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1350 ("isindex" . "Input field for index search")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1351 ("kbd" . "Keybard example face")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1352 ("lang" . "Natural language")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1353 ("li" . "List item")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1354 ("link" . "Link relationship")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1355 ("math" . "Math formula")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1356 ("menu" . "Menu list (obsolete)")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1357 ("mh" . "Form mail header")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1358 ("nextid" . "Allocate new id")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1359 ("nobr" . "Text without line break")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1360 ("ol" . "Ordered list")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1361 ("option" . "Selection list item")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1362 ("over" . "Math fraction rule")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1363 ("p" . "Paragraph start")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1364 ("panel" . "Floating panel")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1365 ("person" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1366 ("pre" . "Preformatted fixed width text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1367 ("q" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1368 ("rev" . "Reverse video")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1369 ("s" . "?")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1370 ("samp" . "Sample text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1371 ("select" . "Selection list")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1372 ("small" . "Font size")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1373 ("sp" . "Nobreak space")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1374 ("strong" . "Standout text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1375 ("sub" . "Subscript")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1376 ("sup" . "Superscript")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1377 ("table" . "Table with rows and columns")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1378 ("tb" . "Table vertical break")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1379 ("td" . "Table data cell")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1380 ("textarea" . "Form multiline edit area")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1381 ("th" . "Table header cell")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1382 ("title" . "Document title")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1383 ("tr" . "Table row separator")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1384 ("tt" . "Typewriter face")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1385 ("u" . "Underlined text")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1386 ("ul" . "Unordered list")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1387 ("var" . "Math variable face")
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1388 ("wbr" . "Enable <br> within <nobr>"))
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1389 "*Value of `sgml-tag-help' for HTML mode.")
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1390
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1391 ;;;###autoload
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1392 (define-derived-mode html-mode sgml-mode "HTML"
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1393 "Major mode based on SGML mode for editing HTML documents.
23652
42bf6553a2e9 (html-mode): Doc fix.
Andreas Schwab <schwab@suse.de>
parents: 22772
diff changeset
1394 This allows inserting skeleton constructs used in hypertext documents with
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1395 completion. See below for an introduction to HTML. Use
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1396 \\[browse-url-of-buffer] to see how this comes out. See also `sgml-mode' on
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1397 which this is based.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1398
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1399 Do \\[describe-variable] html- SPC and \\[describe-variable] sgml- SPC to see available variables.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1400
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1401 To write fairly well formatted pages you only need to know few things. Most
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1402 browsers have a function to read the source code of the page being seen, so
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1403 you can imitate various tricks. Here's a very short HTML primer which you
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1404 can also view with a browser to see what happens:
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1405
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1406 <title>A Title Describing Contents</title> should be on every page. Pages can
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1407 have <h1>Very Major Headlines</h1> through <h6>Very Minor Headlines</h6>
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1408 <hr> Parts can be separated with horizontal rules.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1409
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1410 <p>Paragraphs only need an opening tag. Line breaks and multiple spaces are
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1411 ignored unless the text is <pre>preformatted.</pre> Text can be marked as
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1412 <b>bold</b>, <i>italic</i> or <u>underlined</u> using the normal M-g or
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1413 Edit/Text Properties/Face commands.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1414
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1415 Pages can have <a name=\"SOMENAME\">named points</a> and can link other points
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1416 to them with <a href=\"#SOMENAME\">see also somename</a>. In the same way <a
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1417 href=\"URL\">see also URL</a> where URL is a filename relative to current
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
1418 directory, or absolute as in `http://www.cs.indiana.edu/elisp/w3/docs.html'.
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1419
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1420 Images in many formats can be inlined with <img src=\"URL\">.
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1421
17551
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
1422 If you mainly create your own documents, `sgml-specials' might be
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
1423 interesting. But note that some HTML 2 browsers can't handle `&apos;'.
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
1424 To work around that, do:
2738b57e4704 Many doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 17545
diff changeset
1425 (eval-after-load \"sgml-mode\" '(aset sgml-char-names ?' nil))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1426
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1427 \\{html-mode-map}"
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1428 (set (make-local-variable 'sgml-display-text) html-display-text)
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1429 (set (make-local-variable 'sgml-tag-face-alist) html-tag-face-alist)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1430 (make-local-variable 'sgml-tag-alist)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1431 (make-local-variable 'sgml-face-tag-alist)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1432 (make-local-variable 'sgml-tag-help)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1433 (make-local-variable 'outline-regexp)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1434 (make-local-variable 'outline-heading-end-regexp)
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1435 (make-local-variable 'outline-level)
16914
4b79df16b939 (html-mode): Locally set sentence-end.
Richard M. Stallman <rms@gnu.org>
parents: 16404
diff changeset
1436 (make-local-variable 'sentence-end)
4b79df16b939 (html-mode): Locally set sentence-end.
Richard M. Stallman <rms@gnu.org>
parents: 16404
diff changeset
1437 (setq sentence-end
24463
9ef31386cb47 (html-mode): Use sentence-end-double-space when setting sentence-end.
Dave Love <fx@gnu.org>
parents: 24413
diff changeset
1438 (if sentence-end-double-space
9ef31386cb47 (html-mode): Use sentence-end-double-space when setting sentence-end.
Dave Love <fx@gnu.org>
parents: 24413
diff changeset
1439 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\| $\\|\t\\| \\)[ \t\n]*"
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1440 "[.?!][]\"')}]*\\(<[^>]*>\\)*\\($\\|[ \t]\\)[ \t\n]*"))
22772
3dc5c3a4f1f8 (sgml-mode): Call kill-local-variables
Richard M. Stallman <rms@gnu.org>
parents: 22629
diff changeset
1441 (setq sgml-tag-alist html-tag-alist
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1442 sgml-face-tag-alist html-face-tag-alist
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1443 sgml-tag-help html-tag-help
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1444 outline-regexp "^.*<[Hh][1-6]\\>"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1445 outline-heading-end-regexp "</[Hh][1-6]>"
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1446 outline-level (lambda ()
43692
568974ab1796 Change maintainer to FSF.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43589
diff changeset
1447 (char-before (match-end 0))))
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1448 (setq imenu-create-index-function 'html-imenu-index)
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1449 (when sgml-xml-mode (setq mode-name "XHTML"))
40392
e4b72489cdc4 (sgml-empty-tags): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40377
diff changeset
1450 (set (make-local-variable 'sgml-empty-tags)
44241
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1451 ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd',
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1452 ;; plus manual addition of "wbr".
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1453 '("area" "base" "basefont" "br" "col" "frame" "hr" "img" "input"
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1454 "isindex" "link" "meta" "param" "wbr"))
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1455 (set (make-local-variable 'sgml-unclosed-tags)
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1456 ;; From HTML-4.01's loose.dtd, parsed with `sgml-parse-dtd'.
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1457 '("body" "colgroup" "dd" "dt" "head" "html" "li" "option"
600b7e53cf18 (sgml-basic-offset): New var.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 44200
diff changeset
1458 "p" "tbody" "td" "tfoot" "th" "thead" "tr"))
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1459 ;; It's for the user to decide if it defeats it or not -stef
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1460 ;; (make-local-variable 'imenu-sort-function)
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1461 ;; (setq imenu-sort-function nil) ; sorting the menu defeats the purpose
40320
66ba1d523634 (sgml-font-lock-keywords-1): Ignore comments.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 40176
diff changeset
1462 )
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1463
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1464 (defvar html-imenu-regexp
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1465 "\\s-*<h\\([1-9]\\)[^\n<>]*>\\(<[^\n<>]*>\\)*\\s-*\\([^\n<>]*\\)"
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1466 "*A regular expression matching a head line to be added to the menu.
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1467 The first `match-string' should be a number from 1-9.
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1468 The second `match-string' matches extra tags and is ignored.
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1469 The third `match-string' will be the used in the menu.")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1470
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1471 (defun html-imenu-index ()
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1472 "Return an table of contents for an HTML buffer for use with Imenu."
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1473 (let (toc-index)
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1474 (save-excursion
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1475 (goto-char (point-min))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1476 (while (re-search-forward html-imenu-regexp nil t)
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1477 (setq toc-index
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1478 (cons (cons (concat (make-string
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1479 (* 2 (1- (string-to-number (match-string 1))))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1480 ?\ )
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1481 (match-string 3))
40343
25129ef47b45 some code simplifications: when instead of if+progn;
Sam Steingold <sds@gnu.org>
parents: 40320
diff changeset
1482 (line-beginning-position))
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1483 toc-index))))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1484 (nreverse toc-index)))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1485
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1486 (defun html-autoview-mode (&optional arg)
25175
d780a1dc11f2 Require outline when compiling.
Dave Love <fx@gnu.org>
parents: 25052
diff changeset
1487 "Toggle automatic viewing via `browse-url-of-buffer' upon saving buffer.
22629
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1488 With positive prefix ARG always turns viewing on, with negative ARG always off.
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1489 Can be used as a value for `html-mode-hook'."
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1490 (interactive "P")
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1491 (if (setq arg (if arg
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1492 (< (prefix-numeric-value arg) 0)
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1493 (and (boundp 'after-save-hook)
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1494 (memq 'browse-url-of-buffer after-save-hook))))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1495 (setq after-save-hook (delq 'browse-url-of-buffer after-save-hook))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1496 (add-hook 'after-save-hook 'browse-url-of-buffer nil t))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1497 (message "Autoviewing turned %s."
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1498 (if arg "off" "on")))
5d51b13e0d1f (html-imenu-regexp): New defvar.
Richard M. Stallman <rms@gnu.org>
parents: 22319
diff changeset
1499
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1500 (define-skeleton html-href-anchor
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1501 "HTML anchor tag with href attribute."
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1502 "URL: "
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1503 '(setq input "http:")
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1504 "<a href=\"" str "\">" _ "</a>")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1505
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1506 (define-skeleton html-name-anchor
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1507 "HTML anchor tag with name attribute."
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1508 "Name: "
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1509 "<a name=\"" str "\">" _ "</a>")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1510
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1511 (define-skeleton html-headline-1
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1512 "HTML level 1 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1513 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1514 "<h1>" _ "</h1>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1515
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1516 (define-skeleton html-headline-2
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1517 "HTML level 2 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1518 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1519 "<h2>" _ "</h2>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1520
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1521 (define-skeleton html-headline-3
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1522 "HTML level 3 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1523 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1524 "<h3>" _ "</h3>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1525
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1526 (define-skeleton html-headline-4
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1527 "HTML level 4 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1528 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1529 "<h4>" _ "</h4>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1530
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1531 (define-skeleton html-headline-5
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1532 "HTML level 5 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1533 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1534 "<h5>" _ "</h5>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1535
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1536 (define-skeleton html-headline-6
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1537 "HTML level 6 headline tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1538 nil
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1539 "<h6>" _ "</h6>")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1540
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1541 (define-skeleton html-horizontal-rule
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1542 "HTML horizontal rule tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1543 nil
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1544 (if sgml-xml-mode "<hr/>" "<hr>") \n)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1545
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1546 (define-skeleton html-image
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1547 "HTML image tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1548 nil
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1549 "<img src=\"" _ "\""
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1550 (if sgml-xml-mode "/>" ">"))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1551
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1552 (define-skeleton html-line
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1553 "HTML line break tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1554 nil
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1555 (if sgml-xml-mode "<br/>" "<br>") \n)
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1556
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1557 (define-skeleton html-ordered-list
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1558 "HTML ordered list tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1559 nil
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1560 "<ol>" \n
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1561 "<li>" _ (if sgml-xml-mode "</li>") \n
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1562 "</ol>")
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1563
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1564 (define-skeleton html-unordered-list
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1565 "HTML unordered list tags."
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1566 nil
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1567 "<ul>" \n
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1568 "<li>" _ (if sgml-xml-mode "</li>") \n
15437
43b1f8a3af53 (html-list): Definition deleted.
Richard M. Stallman <rms@gnu.org>
parents: 14518
diff changeset
1569 "</ul>")
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1570
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1571 (define-skeleton html-list-item
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1572 "HTML list item tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1573 nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1574 (if (bolp) nil '\n)
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1575 "<li>" _ (if sgml-xml-mode "</li>"))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1576
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1577 (define-skeleton html-paragraph
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1578 "HTML paragraph tag."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1579 nil
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1580 (if (bolp) nil ?\n)
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1581 \n "<p>" _ (if sgml-xml-mode "</p>"))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1582
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1583 (define-skeleton html-checkboxes
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1584 "Group of connected checkbox inputs."
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1585 nil
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1586 '(setq v1 nil
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1587 v2 nil)
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1588 ("Value: "
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1589 "<input type=\"" (identity "checkbox") ; see comment above about identity
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1590 "\" name=\"" (or v1 (setq v1 (skeleton-read "Name: ")))
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1591 "\" value=\"" str ?\"
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1592 (when (y-or-n-p "Set \"checked\" attribute? ")
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1593 (funcall skeleton-transformation " checked"))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1594 (if sgml-xml-mode "/>" ">")
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1595 (skeleton-read "Text: " (capitalize str))
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1596 (or v2 (setq v2 (if (y-or-n-p "Newline after text? ")
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1597 (funcall skeleton-transformation
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1598 (if sgml-xml-mode "<br/>" "<br>"))
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1599 "")))
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1600 \n))
14270
15c3d6255a1c (sgml-quick-keys): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 14169
diff changeset
1601
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1602 (define-skeleton html-radio-buttons
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1603 "Group of connected radio button inputs."
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1604 nil
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1605 '(setq v1 nil
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1606 v2 (cons nil nil))
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1607 ("Value: "
17545
c67787f92aea (sgml-value): Use 'identity as default value.
Richard M. Stallman <rms@gnu.org>
parents: 17530
diff changeset
1608 "<input type=\"" (identity "radio") ; see comment above about identity
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1609 "\" name=\"" (or (car v2) (setcar v2 (skeleton-read "Name: ")))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1610 "\" value=\"" str ?\"
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1611 (when (and (not v1) (setq v1 (y-or-n-p "Set \"checked\" attribute? ")))
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1612 (funcall skeleton-transformation " checked"))
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1613 (if sgml-xml-mode "/>" ">")
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1614 (skeleton-read "Text: " (capitalize str))
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1615 (or (cdr v2) (setcdr v2 (if (y-or-n-p "Newline after text? ")
39616
13a1b8cf5135 added `html-xhtml' for XHTML input
Sam Steingold <sds@gnu.org>
parents: 38431
diff changeset
1616 (funcall skeleton-transformation
43979
6dff5806cdcd (sgml-xml-mode): Renamed from sgml-xml.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 43692
diff changeset
1617 (if sgml-xml-mode "<br/>" "<br>"))
17491
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1618 "")))
4c6505ca34a7 (sgml-value): Don't perform the skeleton-transformation
Richard M. Stallman <rms@gnu.org>
parents: 17433
diff changeset
1619 \n))
14159
93175ed23e01 Also load for .sgm and .dtd files.
Richard M. Stallman <rms@gnu.org>
parents: 12244
diff changeset
1620
38068
e3bd229672c1 Move `provide' to the end. Update copyright.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 37252
diff changeset
1621 (provide 'sgml-mode)
38431
853c3674f20a Fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 38108
diff changeset
1622
809
8a0066235d56 Initial revision
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
diff changeset
1623 ;;; sgml-mode.el ends here